Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-ai-chat
提交
5dad5d56
U
uni-ai-chat
项目概览
DCloud
/
uni-ai-chat
通知
893
Star
11
Fork
8
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
2
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-ai-chat
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
2
Issue
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
5dad5d56
编写于
6月 07, 2023
作者:
DCloud_JSON
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1.0.22
修复 解决Vue3版本的微信小程序端 textarea的blur事件,会触发“清空会话”事件的问题
上级
02819006
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
11 deletion
+30
-11
changelog.md
changelog.md
+2
-0
package.json
package.json
+1
-1
pages/chat/chat.vue
pages/chat/chat.vue
+23
-10
uniCloud-aliyun/cloudfunctions/uni-ai-chat/index.obj.js
uniCloud-aliyun/cloudfunctions/uni-ai-chat/index.obj.js
+4
-0
未找到文件。
changelog.md
浏览文件 @
5dad5d56
## 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端 发送消息,会失去焦点的问题
...
...
package.json
浏览文件 @
5dad5d56
{
{
"id"
:
"uni-ai-chat"
,
"id"
:
"uni-ai-chat"
,
"name"
:
"uni-ai-chat"
,
"name"
:
"uni-ai-chat"
,
"version"
:
"1.0.2
1
"
,
"version"
:
"1.0.2
2
"
,
"description"
:
"基于uni-ai的聊天示例项目,支持流式、支持前文总结,云端一体"
,
"description"
:
"基于uni-ai的聊天示例项目,支持流式、支持前文总结,云端一体"
,
"main"
:
"main.js"
,
"main"
:
"main.js"
,
"scripts"
:
{
"scripts"
:
{
...
...
pages/chat/chat.vue
浏览文件 @
5dad5d56
<
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=
"clear
AllMsg
"
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
:
"
确认要清空聊天记录?
"
,
...
...
uniCloud-aliyun/cloudfunctions/uni-ai-chat/index.obj.js
浏览文件 @
5dad5d56
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录