Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ebd593bf
authored
May 15, 2024
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【新增】AI:聊天对话的更新标题
parent
67ece2ac
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
17 deletions
+23
-17
src/api/ai/chat/conversation/index.ts
+3
-13
src/views/ai/chat/index.vue
+20
-4
No files found.
src/api/ai/chat/conversation/index.ts
View file @
ebd593bf
...
...
@@ -18,25 +18,15 @@ export interface ChatConversationVO {
modelMaxContexts
?:
string
// 模型的上下文的最大 Message 数量
}
export
interface
ChatConversationUpdateVO
{
id
:
string
// 会话编号
title
:
string
// 会话标题
pinned
:
string
// 是否置顶
modelId
:
number
// 模型编号
temperature
:
string
// 温度参数
maxTokens
:
string
// 单条回复的最大 Token 数量
maxContexts
:
string
// 上下文的最大 Message 数量
}
// AI 聊天会话 API
export
const
ChatConversationApi
=
{
// 获取 Conversation
get
:
async
(
id
:
string
)
=>
{
return
await
request
.
get
({
url
:
`/ai/chat/conversation/get?id=
${
id
}
`
})
return
await
request
.
get
({
url
:
`/ai/chat/conversation/get?id=
${
id
}
`
})
},
// 更新 Conversation
update
:
async
(
data
:
ChatConversationUpdate
VO
)
=>
{
return
await
request
.
put
({
url
:
`/ai/chat/conversation/update
`
,
data
})
update
ConversationMy
:
async
(
data
:
ChatConversation
VO
)
=>
{
return
await
request
.
put
({
url
:
`/ai/chat/conversation/update
-my`
,
data
})
},
// 新增【我的】聊天会话
...
...
src/views/ai/chat/index.vue
View file @
ebd593bf
...
...
@@ -203,6 +203,9 @@ import { marked } from 'marked'
import
'highlight.js/styles/vs2015.min.css'
import
hljs
from
'highlight.js'
const
{
t
}
=
useI18n
()
// 国际化
const
message
=
useMessage
()
// 消息弹窗
// 自定义渲染器
const
renderer
=
{
code
(
code
,
language
,
c
)
{
...
...
@@ -256,9 +259,22 @@ const changeConversation = (id: number) => {
// TODO 芋艿:待实现
}
const
updateConversationTitle
=
(
conversation
)
=>
{
console
.
log
(
conversation
)
// TODO 芋艿:待实现
/** 更新聊天会话的标题 */
const
updateConversationTitle
=
async
(
conversation
:
ChatConversationVO
)
=>
{
// 二次确认
const
{
value
}
=
await
ElMessageBox
.
prompt
(
'修改标题'
,
{
inputPattern
:
/^
[\s\S]
*.*
\S[\s\S]
*$/
,
// 判断非空,且非空格
inputErrorMessage
:
'标题不能为空'
,
inputValue
:
conversation
.
title
})
// 发起修改
await
ChatConversationApi
.
updateConversationMy
({
id
:
conversation
.
id
,
title
:
value
}
as
ChatConversationVO
)
message
.
success
(
'修改标题成功'
)
// 刷新列表
await
getChatConversationList
()
}
const
deleteConversationTitle
=
(
conversation
)
=>
{
...
...
@@ -445,7 +461,7 @@ const modalClick = async (command) => {
// 切换 modal
useModal
.
value
=
command
// 更新
await
ChatConversationApi
.
update
(
update
)
await
ChatConversationApi
.
update
ConversationMy
(
update
)
}
const
getModalList
=
async
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment