From d2b5c56c9e16063d630a6c2cce4e4e246373f808 Mon Sep 17 00:00:00 2001 From: DCloud__JSON Date: Wed, 14 Jun 2023 20:27:19 +0800 Subject: [PATCH] 1.2.0 --- changelog.md | 3 + common/unicloud-co-task.js | 1 - components/llm-config/llm-config.vue | 4 +- components/uni-ai-msg/uni-ai-msg.vue | 75 +- package.json | 2 +- pages/chat/chat.vue | 284 +++--- pages/chat/msgList.js | 1 - .../reward-video-callback/index.js | 2 +- .../cloudfunctions/uni-ai-chat/index.obj.js | 811 ++++++++---------- .../uni-config-center/uni-ai-chat/config.json | 4 +- 10 files changed, 516 insertions(+), 671 deletions(-) delete mode 100644 pages/chat/msgList.js diff --git a/changelog.md b/changelog.md index 9ae866d..672960e 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ +## 1.2.0(2023-06-14) +- 【重要】支持通过 uni-ai 计费网关发起调用 [详情参考](https://uniapp.dcloud.net.cn/uniCloud/uni-ai.html#api) +- 更新 大语言模型provider的值默认为:azure ## 1.1.5(2023-06-13) - 修复 提供给AI做出总结的内容,多包含了最后一次提问的内容 ## 1.1.4(2023-06-13) diff --git a/common/unicloud-co-task.js b/common/unicloud-co-task.js index 417102d..e0bf059 100644 --- a/common/unicloud-co-task.js +++ b/common/unicloud-co-task.js @@ -11,7 +11,6 @@ class Task { complete } } - invoke(callbackName, ...args) { if (this.status !== 0) { // console.log('此任务已被终止'); diff --git a/components/llm-config/llm-config.vue b/components/llm-config/llm-config.vue index c880148..1cd7d94 100644 --- a/components/llm-config/llm-config.vue +++ b/components/llm-config/llm-config.vue @@ -55,11 +55,9 @@ currentModel:'' }; }, - mounted() { - this.currentModel = uni.getStorageSync('uni-ai-chat-llmModel') - }, methods: { open(callback){ + this.currentModel = uni.getStorageSync('uni-ai-chat-llmModel') confirmCallback = callback this.$refs.popup.open('center') }, diff --git a/components/uni-ai-msg/uni-ai-msg.vue b/components/uni-ai-msg/uni-ai-msg.vue index 3556426..bead518 100644 --- a/components/uni-ai-msg/uni-ai-msg.vue +++ b/components/uni-ai-msg/uni-ai-msg.vue @@ -39,10 +39,6 @@ - @@ -56,10 +52,6 @@ adpid } = config - import { - msgList - } from '@/pages/chat/msgList.js'; - // 引入markdown-it库 import MarkdownIt from '@/lib/markdown-it.min.js'; @@ -126,18 +118,13 @@ }) export default { - name: "msg", + name: "uni-ai-msg", data() { return { // 悬浮的复制按钮的左边距 left: "-100px", // 悬浮的复制按钮的上边距 top: "-100px", - msg: { - content: "", - isDelete:false - }, - msgIndexList: 0, adpid, showMoreMenu:false }; @@ -145,7 +132,6 @@ mounted() { }, created() { - this.msg = msgList[this.msgIndex] }, props: { // 是否显示鼠标闪烁的效果 @@ -155,24 +141,30 @@ return false } }, - msgIndex: { - type: Number, - default () { - return false - } - }, isLastMsg: { type: Boolean, default () { return false } - } + }, + msg: { + type: Object, + default () { + return { + content: "", + isDelete:false + } + } + }, }, computed: { msgContent() { return this.msg.content }, - nodes() { + nodes() { + if(!this.msgContent){ + return //处理特殊情况,比如网络异常导致的响应的 content 的值为空 + } let htmlString = '' // 修改转换结果的htmlString值 用于正确给界面增加鼠标闪烁的效果 // 判断markdown中代码块标识符的数量是否为偶数 @@ -200,27 +192,6 @@ } }, methods: { - // 根据消息状态返回对应的图标 - msgStateIcon(msg) { - switch (msg.state) { - case 0: - // 发送中 - return '' - break; - case -100: - // 发送失败 - return 'refresh-filled' - break; - case -200: - // 禁止发送(内容不合法) - return 'info-filled' - break; - default: - // 默认不返回任何图标 - return false - break; - } - }, trOnclick(e){ console.log(e); let {attrs} = e.detail.node @@ -262,8 +233,11 @@ }, // 删除消息 removeMsg(){ - this.$emit('removeMsg',this.msgIndex) + this.$emit('removeMsg') this.showMoreMenu = false + }, + onAdClose(e){ + this.$emit('onAdClose',e) } } } @@ -292,14 +266,6 @@ padding: 0 15px; padding-bottom: 15px; } - - .msgStateIcon { - position: relative; - top: -5px; - right: 1px; - align-self: center; - } - .avatar { width: 40px; height: 40px; @@ -332,7 +298,8 @@ word-break: break-all; user-select: text; cursor: text; - /* #endif */ + /* #endif */ + flex-direction: column; } .menu-box { diff --git a/package.json b/package.json index 50483f4..1b5b8b7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "id": "uni-ai-chat", "name": "uni-ai-chat", - "version": "1.1.5", + "version": "1.2.0", "description": "基于uni-ai的聊天示例项目,支持流式、支持前文总结,云端一体", "main": "main.js", "scripts": { diff --git a/pages/chat/chat.vue b/pages/chat/chat.vue index 7882c45..5f70070 100644 --- a/pages/chat/chat.vue +++ b/pages/chat/chat.vue @@ -3,18 +3,18 @@ uni-ai-chat - 没有对话记录 + 没有对话记录 - -