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

1.0.22

修复 解决Vue3版本的微信小程序端 textarea的blur事件,会触发“清空会话”事件的问题
上级 afee7ca2
## 1.0.22(2023-06-07)
- 修复 解决Vue3版本的微信小程序端 textarea的blur事件,会触发“清空会话”事件的问题
## 1.0.21(2023-06-06) ## 1.0.21(2023-06-06)
- 修复 用户输入的内容,会被markdown解析,导致显示错误的问题 - 修复 用户输入的内容,会被markdown解析,导致显示错误的问题
- 修复 web-pc端 发送消息,会失去焦点的问题 - 修复 web-pc端 发送消息,会失去焦点的问题
......
{ {
"id": "uni-ai-chat", "id": "uni-ai-chat",
"name": "uni-ai-chat", "name": "uni-ai-chat",
"version": "1.0.21", "version": "1.0.22",
"description": "基于uni-ai的聊天示例项目,支持流式、支持前文总结,云端一体", "description": "基于uni-ai的聊天示例项目,支持流式、支持前文总结,云端一体",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {
......
<template> <template>
<view class="page"> <view class="page">
<view class="container"> <view class="container">
<view v-if="isWidescreen" class="header">uni-ai-chat</view> <!-- #ifdef H5 -->
<view v-if="isWidescreen" class="header">uni-ai-chat</view>
<!-- #endif -->
<text class="noData" v-if="msgLength === 0">没有对话记录</text> <text class="noData" v-if="msgLength === 0">没有对话记录</text>
<scroll-view :scroll-into-view="scrollIntoView" scroll-y="true" class="msg-list" :enable-flex="true"> <scroll-view :scroll-into-view="scrollIntoView" scroll-y="true" class="msg-list" :enable-flex="true">
<uni-ai-msg ref="msg" v-for="(msgIndex,index) in msgLength" :key="index" :msgIndex="index" @retriesSendMsg="retriesSendMsg" @changeAnswer="changeAnswer" <uni-ai-msg ref="msg" v-for="(msgIndex,index) in msgLength" :key="index" :msgIndex="index" @retriesSendMsg="retriesSendMsg" @changeAnswer="changeAnswer"
...@@ -17,19 +19,20 @@ ...@@ -17,19 +19,20 @@
<view id="last-msg-item" style="height: 1px;"></view> <view id="last-msg-item" style="height: 1px;"></view>
</scroll-view> </scroll-view>
<view class="foot-box"> <view class="foot-box">
<view class="pc-menu" v-if="isWidescreen"> <!-- #ifdef H5 -->
<view class="pc-trash pc-menu-item" @click="clear" title="删除"> <view class="pc-menu" v-if="isWidescreen">
<view class="pc-trash pc-menu-item" @click="clearAllMsg" title="删除">
<image src="@/static/remove.png" mode="heightFix"></image> <image src="@/static/remove.png" mode="heightFix"></image>
</view> </view>
<view class="settings pc-menu-item" @click="setLLMmodel" title="设置"> <view class="settings pc-menu-item" @click="setLLMmodel" title="设置">
<uni-icons color="#555" size="20px" type="settings"></uni-icons> <uni-icons color="#555" size="20px" type="settings"></uni-icons>
</view> </view>
</view> </view>
<!-- #endif -->
<view class="foot-box-content"> <view class="foot-box-content">
<view v-if="!isWidescreen" class="menu"> <view v-if="!isWidescreen" class="menu">
<uni-icons class="menu-item" @click="clear" type="trash" size="24" color="#888"></uni-icons> <uni-icons class="menu-item" @click="clearAllMsg" type="trash" size="24" color="#888"></uni-icons>
<uni-icons class="menu-item" @click="setLLMmodel" color="#555" size="20px" type="settings"></uni-icons> <uni-icons class="menu-item" @click="setLLMmodel" color="#555" size="20px" type="settings"></uni-icons>
</view> </view>
<view class="textarea-box" @click="focus = true"> <view class="textarea-box" @click="focus = true">
...@@ -38,7 +41,9 @@ ...@@ -38,7 +41,9 @@
placeholder-class="input-placeholder"></textarea> placeholder-class="input-placeholder"></textarea>
</view> </view>
<view class="send-btn-box" :title="(msgLength && msgLength%2 !== 0) ? 'ai正在回复中不能发送':''"> <view class="send-btn-box" :title="(msgLength && msgLength%2 !== 0) ? 'ai正在回复中不能发送':''">
<text v-if="isWidescreen" class="send-btn-tip">↵ 发送 / shift + ↵ 换行</text> <!-- #ifdef H5 -->
<text v-if="isWidescreen" class="send-btn-tip">↵ 发送 / shift + ↵ 换行</text>
<!-- #endif -->
<button @click="beforeSendMsg" :disabled="inputBoxDisabled || !content" class="send" <button @click="beforeSendMsg" :disabled="inputBoxDisabled || !content" class="send"
type="primary">发送</button> type="primary">发送</button>
</view> </view>
...@@ -675,7 +680,15 @@ ...@@ -675,7 +680,15 @@
}) })
}, },
// 清空消息列表 // 清空消息列表
clear() { clearAllMsg(e) {
// #ifdef MP-WEIXIN && VUE3
console.log('clearAllMsg',e);
if(e && e.type == "blur"){
console.log('补丁:解决Vue3版本的微信小程序端 textarea的blur事件,会触发“清空会话”事件的问题');
return false
}
// #endif
// 弹出确认清空聊天记录的提示框 // 弹出确认清空聊天记录的提示框
uni.showModal({ uni.showModal({
title: "确认要清空聊天记录?", title: "确认要清空聊天记录?",
......
...@@ -221,6 +221,9 @@ module.exports = { ...@@ -221,6 +221,9 @@ module.exports = {
let {llm,chatCompletionOptions} = config let {llm,chatCompletionOptions} = config
// 如果客户端传了llmModel 就覆盖配置的model // 如果客户端传了llmModel 就覆盖配置的model
if(llmModel){ if(llmModel){
if(llmModel.includes('gpt-') && (llm && llm.provider != "openai")){
throw new Error('错误:LLM的provider不是openai,但model却选了'+llmModel+';请参考文档:https://uniapp.dcloud.net.cn/uniCloud/uni-ai.html#chat-completion 中model参数的说明')
}
chatCompletionOptions.model = llmModel chatCompletionOptions.model = llmModel
} }
return await chatCompletion({ return await chatCompletion({
...@@ -240,6 +243,7 @@ module.exports = { ...@@ -240,6 +243,7 @@ module.exports = {
// 语言模型 // 语言模型
llm llm
}) { }) {
// console.log({llm,chatCompletionOptions});
// 获取语言模型管理器 // 获取语言模型管理器
const llmManager = uniCloud.ai.getLLMManager(llm) const llmManager = uniCloud.ai.getLLMManager(llm)
// 调用chatCompletion方法,传入参数 // 调用chatCompletion方法,传入参数
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册