From 2713e2a2408b4cd251290f053875763f522bc9bc Mon Sep 17 00:00:00 2001 From: DCloud__JSON Date: Wed, 10 May 2023 21:59:05 +0800 Subject: [PATCH] =?UTF-8?q?1.0.4=20=E4=BF=AE=E5=A4=8D=20uni-ai=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E6=9C=8D=E5=8A=A1=E5=95=86=EF=BC=8C=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E5=88=B0=E5=86=85=E5=AE=B9=E6=B6=89=E5=8F=8A=E8=BF=9D=E8=A7=84?= =?UTF-8?q?=E5=90=8E=20=E5=86=85=E5=AE=B9=E4=BC=9A=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E4=B8=80=E9=83=A8=E5=88=86=E6=88=96=E5=8D=A1=E4=BD=8F=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=88HBuilderX3.8.2=E8=B5=B7=E6=88=96?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E4=BA=91=E7=AB=AF=E4=BA=91=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.0.4(2023-05-10) - 修复 uni-ai默认服务商,检测到内容涉及违规后 内容会返回一部分或卡住的问题(HBuilderX3.8.2起或连接云端云函数支持) - 修复 web-pc端当回车键敲得较快时 发送的内容不正确的问题 --- changelog.md | 3 +++ pages/chat/chat.vue | 7 +++++-- .../cloudfunctions/uni-ai-chat/index.obj.js | 11 ++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/changelog.md b/changelog.md index bb1b29d..dbf167d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ +## 1.0.4(2023-05-10) +- 修复 uni-ai默认服务商,检测到内容涉及违规后 内容会返回一部分或卡住的问题(HBuilderX3.8.2起或连接云端云函数支持) +- 修复 web-pc端当回车键敲得较快时 发送的内容不正确的问题 ## 1.0.3(2023-05-09) - 新增 提供了商业化能力,与uni-ai对话消耗积分。积分可通过看[激励视频广告](https://uniapp.dcloud.net.cn/component/ad-rewarded-video.html)获得。 - 优化 根据配置的llm服务商以及是否开启流式响应,自动处理是否逐字返回 diff --git a/pages/chat/chat.vue b/pages/chat/chat.vue index 8999722..0db3b11 100644 --- a/pages/chat/chat.vue +++ b/pages/chat/chat.vue @@ -160,7 +160,9 @@ adjunctKeydown = true; } if (e.keyCode == 13 && !adjunctKeydown) { - this.beforeSendMsg(); + setTimeout(()=> { + this.beforeSendMsg(); + }, 100); } }; textareaDom.onkeyup = e => { @@ -397,8 +399,9 @@ sseChannel }) .then(res => { + console.log(111,res); this.updateLastMsg({state:100}) - if (!sseChannel) { + if (res.data) { // console.log(res, res.reply); // 判断长度,防止请求未返回时,历史对话已被清空。引起对话顺序错误 导致 对话输入框卡住 if(!skip_callback){ diff --git a/uniCloud-aliyun/cloudfunctions/uni-ai-chat/index.obj.js b/uniCloud-aliyun/cloudfunctions/uni-ai-chat/index.obj.js index 8e7eb72..1c49590 100644 --- a/uniCloud-aliyun/cloudfunctions/uni-ai-chat/index.obj.js +++ b/uniCloud-aliyun/cloudfunctions/uni-ai-chat/index.obj.js @@ -106,10 +106,7 @@ module.exports = { async _after(error, result) { console.log('_after',{error,result}); if(error){ - if(error.errCode && error.errMsg) { - // 符合响应体规范的错误,直接返回 - return error - }else if(error == "uni-sec-check:illegalData" ) { + if(error.errCode == "60004" || error == "uni-sec-check:illegalData" ) { return { "data": { "reply": "内容涉及敏感", @@ -117,7 +114,11 @@ module.exports = { }, "errCode": 0 } - }else if(error == 'insufficientScore'){ + }else if(error.errCode && error.errMsg) { + // 符合响应体规范的错误,直接返回 + return error + } + else if(error == 'insufficientScore'){ let reply = "积分不足,请看完激励视频广告后再试" let {sseChannel} = this.getParams()[0]||{} if(sseChannel){ -- GitLab