From d1ebe1f777664437e5bb0d8f2a9a0c7c470b299b Mon Sep 17 00:00:00 2001 From: DCloud__JSON Date: Tue, 13 Jun 2023 17:29:42 +0800 Subject: [PATCH] 1.1.5 --- changelog.md | 2 ++ package.json | 2 +- pages/chat/chat.vue | 26 ++++++++++--------- .../cloudfunctions/uni-ai-chat/index.obj.js | 9 ++++--- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/changelog.md b/changelog.md index 27c32a2..9ae866d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,5 @@ +## 1.1.5(2023-06-13) +- 修复 提供给AI做出总结的内容,多包含了最后一次提问的内容 ## 1.1.4(2023-06-13) - 更新 当内容长度超过800再执行总结 ## 1.1.3(2023-06-12) diff --git a/package.json b/package.json index 878b65a..50483f4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "id": "uni-ai-chat", "name": "uni-ai-chat", - "version": "1.1.4", + "version": "1.1.5", "description": "基于uni-ai的聊天示例项目,支持流式、支持前文总结,云端一体", "main": "main.js", "scripts": { diff --git a/pages/chat/chat.vue b/pages/chat/chat.vue index dc7e1f6..7882c45 100644 --- a/pages/chat/chat.vue +++ b/pages/chat/chat.vue @@ -9,17 +9,19 @@ @retriesSendMsg="retriesSendMsg" @changeAnswer="changeAnswer" :show-cursor="index == msgLength - 1 && msgLength%2 === 0 && sseIndex" :isLastMsg="index == visibleMsgLength - 1" @removeMsg="removeMsg"> - - 消息发送失败 - - - - uni-ai正在思考中... - - 如需提速,请开通 - - + ▣ 停止响应 @@ -552,7 +554,7 @@ let messages = [] // 复制一份,消息列表数据 - let msgs = Array.from(msgList).filter(i => i.isDelete !== true) + let msgs = JSON.parse(JSON.stringify(msgList)).filter(i => i.isDelete !== true) // 带总结的消息 index let findIndex = [...msgs].reverse().findIndex(item => item.summarize) // console.log('findIndex', findIndex) diff --git a/uniCloud-aliyun/cloudfunctions/uni-ai-chat/index.obj.js b/uniCloud-aliyun/cloudfunctions/uni-ai-chat/index.obj.js index 10723cf..7caf0ea 100644 --- a/uniCloud-aliyun/cloudfunctions/uni-ai-chat/index.obj.js +++ b/uniCloud-aliyun/cloudfunctions/uni-ai-chat/index.obj.js @@ -225,10 +225,11 @@ module.exports = { chatCompletionOptions.model = llmModel } - // 判断是否需要总结,如果需要就开始总结 - // 计算消息总长度,判断是否需要总结 - let needSummarize = messages.map(i => i.content).join('').length > 800, + // console.log('messages',messages); + let lastTimeMessages = messages.slice(0,-1) + // console.log('lastTimeMessages',lastTimeMessages); + let needSummarize = lastTimeMessages.map(i => i.content).join('').length > 800, // 总结的内容默认为 false 表示没有内容或者暂未拿到 summarizeData = false, //成功拿到总结内容的回调函数列表 @@ -237,7 +238,7 @@ module.exports = { console.log('needSummarize',needSummarize); if (needSummarize) { // 获取总结 - let replySummarize = getSummarize(messages) + let replySummarize = getSummarize(lastTimeMessages) .then((replySummarize)=>{ // console.log('replySummarize1',replySummarize); summarizeData = replySummarize -- GitLab