Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
saas-dml
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
saas-dml
Commits
4c4b2222
提交
4c4b2222
authored
5月 24, 2024
作者:
lhh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
7724b7a1
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
58 行增加
和
23 行删除
+58
-23
AIChat.vue
src/modules/material/all/components/AIChat.vue
+4
-1
ChuangKitDesign.vue
src/modules/material/all/components/ChuangKitDesign.vue
+2
-2
useChat.ts
src/modules/material/all/composables/useChat.ts
+52
-20
没有找到文件。
src/modules/material/all/components/AIChat.vue
浏览文件 @
4c4b2222
...
...
@@ -109,7 +109,6 @@ async function handleSendType(type, content) {
content
=
`我是
${
userName
}
,请帮我总结以下内容:
${
content
.
replace
(
'请帮我创作一个'
,
''
)}
`
break
}
post
({
type
,
content
})
}
...
...
@@ -281,6 +280,10 @@ async function handleSave(message) {
border-top
:
1px
solid
#edeff1
;
}
.chat-message-extra
button
{
margin-bottom
:
10px
;
}
.dot-flashing
{
animation
:
dot-flashing
0
.8s
infinite
alternate
;
animation-delay
:
-0
.2s
;
...
...
src/modules/material/all/components/ChuangKitDesign.vue
浏览文件 @
4c4b2222
...
...
@@ -62,8 +62,8 @@ window.chuangkitComplete = async result => {
let
cktInstance
function
openDesignPage
()
{
const
appId
=
'
f184cee934e648ac989b795fcffdeceb
'
const
appSecret
=
'
5E6DC58007D6567817A88809740CE4D2
'
const
appId
=
'
54d9adec77d0402794018d166110f3dd
'
const
appSecret
=
'
08097010E0EF4B85EE2B8CE438328249
'
const
userFlag
=
userStore
.
user
.
id
const
expireTime
=
Date
.
now
()
const
sign
=
buildVersion2Sign
(
appId
,
expireTime
,
userFlag
,
appSecret
)
...
...
src/modules/material/all/composables/useChat.ts
浏览文件 @
4c4b2222
...
...
@@ -84,18 +84,36 @@ export function useChat(options: any) {
// }
// })
// }
async
function
generateText
(
data
:
any
)
{
console
.
log
(
data
.
type
,
'data.type'
)
isLoading
.
value
=
true
let
params
=
{}
if
(
data
.
type
===
'1'
)
{
params
=
{
chat_history
:
messages
.
value
}
}
else
{
const
docAction
:
any
=
{
2
:
'write'
,
3
:
'rewrite'
,
4
:
'expand'
,
5
:
'rewrite'
,
7
:
'abbreviate'
,
8
:
'summary'
}
params
=
{
content
:
data
.
content
,
doc_action
:
docAction
[
data
.
type
],
full_text
:
!!
(
data
.
type
===
2
)
}
}
await
fetchEventSource
(
'/api/lab/v1/experiment/marketing-ai/sky-agent3-chat'
,
{
method
:
'POST'
,
headers
:
{
'Content-Type'
:
'application/json'
},
body
:
JSON
.
stringify
({
...
options
,
...
data
,
api_type
:
parseInt
(
data
.
type
)
===
1
?
3
:
2
,
context
:
data
.
content
,
params
:
{
chat_history
:
messages
.
value
}
}
),
body
:
JSON
.
stringify
({
...
options
,
...
data
,
api_type
:
parseInt
(
data
.
type
)
===
1
?
1
:
2
,
context
:
data
.
content
,
params
:
params
}),
async
onopen
(
response
)
{
if
(
response
.
ok
)
{
return
...
...
@@ -104,23 +122,37 @@ export function useChat(options: any) {
}
},
onmessage
(
res
)
{
console
.
log
(
res
,
'res'
)
const
message
=
JSON
.
parse
(
res
.
data
)
if
(
message
.
code
===
0
)
{
ElMessage
.
error
(
message
.
message
)
return
// 聊天返回内容
if
(
data
.
type
===
'1'
)
{
if
(
message
.
code
===
0
)
{
ElMessage
.
error
(
message
.
message
)
return
}
const
conversationId
=
message
.
conversation_id
const
messageIndex
=
messages
.
value
.
findIndex
(
session
=>
session
.
conversationId
===
conversationId
)
const
content
=
message
?.
arguments
?.
reduce
((
a
:
any
,
b
:
any
)
=>
{
a
=
b
?.
messages
[
0
]?.
text
||
''
return
a
},
''
)
if
(
messageIndex
===
-
1
)
{
messages
.
value
.
push
({
conversationId
,
role
:
'bot'
,
content
,
input
:
data
.
context
})
}
else
{
if
(
content
)
{
messages
.
value
[
messageIndex
].
content
=
content
}
}
}
else
{
// 按钮功能返回内容
const
requestId
=
message
.
request_id
const
messageIndex
=
messages
.
value
.
findIndex
(
session
=>
session
.
conversationId
===
requestId
)
if
(
messageIndex
===
-
1
)
{
messages
.
value
.
push
({
conversationId
:
requestId
,
role
:
'bot'
,
content
:
message
.
data
?.
text
||
''
,
input
:
data
.
context
})
}
else
{
messages
.
value
[
messageIndex
].
content
=
message
.
data
?.
text
}
}
// chatId.value = message.chatId + ''
// const conversationId = message.conversationId
// const messageIndex = messages.value.findIndex(session => session.conversationId === conversationId)
// const content = message.content || ''
// // if (message.content === '\n') content = '<br/>'
// if (messageIndex === -1) {
// messages.value.push({ conversationId, role: 'bot', content, input: data.context })
// } else {
// messages.value[messageIndex].content = messages.value[messageIndex].content + content
// }
// isLoading.value = false
isLoading
.
value
=
false
},
onclose
()
{
fetchUsages
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论