From 3060f957e3e8d258a7c840adc7edb4700262ecc0 Mon Sep 17 00:00:00 2001 From: DCloud__JSON Date: Mon, 15 May 2023 12:08:27 +0800 Subject: [PATCH] =?UTF-8?q?1.0.7=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=B5=81=E5=BC=8F?= =?UTF-8?q?=E5=93=8D=E5=BA=94=E6=A8=A1=E5=BC=8F=EF=BC=8C=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=83=85=E5=86=B5=E4=B8=8B=EF=BC=9AAI=E5=9B=9E=E5=A4=8D?= =?UTF-8?q?=E7=9A=84=E5=86=85=E5=AE=B9=E5=8C=85=E5=90=AB=E7=9A=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=20=E6=B2=A1=E6=9C=89=E4=BB=A5=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E9=A3=8E=E6=A0=BC=E6=98=BE=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 2 ++ package.json | 2 +- uniCloud-aliyun/cloudfunctions/uni-ai-chat/index.obj.js | 7 +++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 4860ea1..b57a727 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,5 @@ +## 1.0.7(2023-05-15) +- 修复 uni-ai默认服务商,流式响应模式,部分情况下:AI回复的内容包含的代码 没有以代码风格显示的问题 ## 1.0.6(2023-05-12) - 修复 流式响应模式,AI回答内容在开头不涉及敏感,后续内容涉及敏感的场景 卡住会话的问题 ## 1.0.5(2023-05-11) diff --git a/package.json b/package.json index 3331ac7..d9a60c0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "id": "uni-ai-chat", "name": "uni-ai-chat", - "version": "1.0.6", + "version": "1.0.7", "description": "基于uni-ai的聊天示例项目,支持流式、支持前文总结,云端一体", "main": "main.js", "scripts": { diff --git a/uniCloud-aliyun/cloudfunctions/uni-ai-chat/index.obj.js b/uniCloud-aliyun/cloudfunctions/uni-ai-chat/index.obj.js index 200ed26..c1f6839 100644 --- a/uniCloud-aliyun/cloudfunctions/uni-ai-chat/index.obj.js +++ b/uniCloud-aliyun/cloudfunctions/uni-ai-chat/index.obj.js @@ -248,7 +248,7 @@ module.exports = { // 如果存在sseChannel if (sseChannel) { - let reply = "" + let reply = "" return new Promise((resolve, reject) => { // 反序列化sseChannel const channel = uniCloud.deserializeSSEChannel(sseChannel) @@ -263,8 +263,11 @@ module.exports = { }else{ // 按行返回 res.on('line', async (line) => { - await channel.write(reply? ("\n\n " + line) : line) + if(reply.length){ + line = " \n\n " + line + } reply += line + await channel.write(line) // console.log('---line----', line) }) } -- GitLab