提交 d1ebe1f7 编写于 作者: DCloud_JSON's avatar DCloud_JSON

1.1.5

上级 4876c8ea
## 1.1.5(2023-06-13)
- 修复 提供给AI做出总结的内容,多包含了最后一次提问的内容
## 1.1.4(2023-06-13)
- 更新 当内容长度超过800再执行总结
## 1.1.3(2023-06-12)
......
{
"id": "uni-ai-chat",
"name": "uni-ai-chat",
"version": "1.1.4",
"version": "1.1.5",
"description": "基于uni-ai的聊天示例项目,支持流式、支持前文总结,云端一体",
"main": "main.js",
"scripts": {
......
......@@ -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-msg>
<view v-if="lastMsgState == -100" class="retries-box">
<text>消息发送失败</text>
<uni-icons @click="retriesSendMsg" color="#d22" type="refresh-filled" class="retries-icon"></uni-icons>
</view>
<view class="tip-ai-ing" v-else-if="msgLength && msgLength%2 !== 0">
<text>uni-ai正在思考中...</text>
<view v-if="NODE_ENV == 'development' && !enableStream">
如需提速,请开通<uni-link class="uni-link" href="https://uniapp.dcloud.net.cn/uniCloud/uni-ai-chat.html"
text="[流式响应]"></uni-link>
</view>
</view>
<template v-if="msgLength%2 !== 0">
<view v-if="lastMsgState == -100" class="retries-box">
<text>消息发送失败</text>
<uni-icons @click="retriesSendMsg" color="#d22" type="refresh-filled" class="retries-icon"></uni-icons>
</view>
<view class="tip-ai-ing" v-else-if="msgLength">
<text>uni-ai正在思考中...</text>
<view v-if="NODE_ENV == 'development' && !enableStream">
如需提速,请开通<uni-link class="uni-link" href="https://uniapp.dcloud.net.cn/uniCloud/uni-ai-chat.html"
text="[流式响应]"></uni-link>
</view>
</view>
</template>
<view @click="closeSseChannel" class="stop-responding" v-if="enableStream && sseIndex"> ▣ 停止响应</view>
<view id="last-msg-item" style="height: 1px;"></view>
</scroll-view>
......@@ -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)
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册