【新增】AI:聊天对话的更新标题

This commit is contained in:
YunaiV 2024-05-15 08:59:30 +08:00
parent 67ece2ac5c
commit ebd593bf92
2 changed files with 23 additions and 17 deletions

View File

@ -18,25 +18,15 @@ export interface ChatConversationVO {
modelMaxContexts?: string // 模型的上下文的最大 Message 数量 modelMaxContexts?: string // 模型的上下文的最大 Message 数量
} }
export interface ChatConversationUpdateVO {
id: string // 会话编号
title: string // 会话标题
pinned: string // 是否置顶
modelId: number // 模型编号
temperature: string // 温度参数
maxTokens: string // 单条回复的最大 Token 数量
maxContexts: string // 上下文的最大 Message 数量
}
// AI 聊天会话 API // AI 聊天会话 API
export const ChatConversationApi = { export const ChatConversationApi = {
// 获取 Conversation // 获取 Conversation
get: async (id: string) => { 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 // 更新 Conversation
update: async (data: ChatConversationUpdateVO) => { updateConversationMy: async (data: ChatConversationVO) => {
return await request.put({ url: `/ai/chat/conversation/update`, data}) return await request.put({ url: `/ai/chat/conversation/update-my`, data })
}, },
// 新增【我的】聊天会话 // 新增【我的】聊天会话

View File

@ -203,6 +203,9 @@ import { marked } from 'marked'
import 'highlight.js/styles/vs2015.min.css' import 'highlight.js/styles/vs2015.min.css'
import hljs from 'highlight.js' import hljs from 'highlight.js'
const { t } = useI18n() //
const message = useMessage() //
// //
const renderer = { const renderer = {
code(code, language, c) { code(code, language, c) {
@ -256,9 +259,22 @@ const changeConversation = (id: number) => {
// TODO // TODO
} }
const updateConversationTitle = (conversation) => { /** 更新聊天会话的标题 */
console.log(conversation) const updateConversationTitle = async (conversation: ChatConversationVO) => {
// TODO //
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) => { const deleteConversationTitle = (conversation) => {
@ -445,7 +461,7 @@ const modalClick = async (command) => {
// modal // modal
useModal.value = command useModal.value = command
// //
await ChatConversationApi.update(update) await ChatConversationApi.updateConversationMy(update)
} }
const getModalList = async () => { const getModalList = async () => {