From b50db413cf86b60bab28d9801f9a16fcf29132db Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Fri, 21 Feb 2025 18:54:05 +0800 Subject: [PATCH] feat: History record supports modifying chat abstract --- ui/src/api/log.ts | 26 +++++++- ui/src/locales/lang/en-US/ai-chat.ts | 3 +- ui/src/locales/lang/zh-CN/ai-chat.ts | 4 +- ui/src/locales/lang/zh-Hant/ai-chat.ts | 3 +- ui/src/stores/modules/log.ts | 12 ++++ ui/src/views/chat/pc/EditTitleDialog.vue | 85 ++++++++++++++++++++++++ ui/src/views/chat/pc/index.vue | 33 +++++++-- 7 files changed, 154 insertions(+), 12 deletions(-) create mode 100644 ui/src/views/chat/pc/EditTitleDialog.vue diff --git a/ui/src/api/log.ts b/ui/src/api/log.ts index 20973a371..edcd4d93e 100644 --- a/ui/src/api/log.ts +++ b/ui/src/api/log.ts @@ -220,6 +220,29 @@ const delChatClientLog: ( return del(`${prefix}/${application_id}/chat/client/${chat_id}`, undefined, {}, loading) } +/** + * 修改历史日志abstract + * @param 参数 + * application_id, chat_id, + * data { + "abstract": "string", + } + */ + +const putChatClientLog: ( + application_id: string, + chat_id: string, + data: any, + loading?: Ref +) => Promise> = (application_id, chat_id, data, loading) => { + return put( + `${prefix}/${application_id}/chat/client/${chat_id}`, + data, + undefined, + loading + ) +} + export default { getChatLog, delChatLog, @@ -231,5 +254,6 @@ export default { exportChatLog, getChatLogClient, delChatClientLog, - postChatRecordLog + postChatRecordLog, + putChatClientLog } diff --git a/ui/src/locales/lang/en-US/ai-chat.ts b/ui/src/locales/lang/en-US/ai-chat.ts index d5629716e..ac6cc886d 100644 --- a/ui/src/locales/lang/en-US/ai-chat.ts +++ b/ui/src/locales/lang/en-US/ai-chat.ts @@ -90,5 +90,6 @@ export default { title: 'Knowledge Quote', question: 'User Question', optimizationQuestion: 'Optimized Question' - } + }, + editTitle: 'Edit Title', } diff --git a/ui/src/locales/lang/zh-CN/ai-chat.ts b/ui/src/locales/lang/zh-CN/ai-chat.ts index a4b54ad03..fdc4a55f7 100644 --- a/ui/src/locales/lang/zh-CN/ai-chat.ts +++ b/ui/src/locales/lang/zh-CN/ai-chat.ts @@ -25,7 +25,6 @@ export default { continue: '继续', stopChat: '停止回答' }, - tip: { error500Message: '抱歉,当前正在维护,无法提供服务,请稍后再试!', errorIdentifyMessage: '无法识别用户身份', @@ -91,5 +90,6 @@ export default { title: '知识库引用', question: '用户问题', optimizationQuestion: '优化后问题' - } + }, + editTitle: '编辑标题', } diff --git a/ui/src/locales/lang/zh-Hant/ai-chat.ts b/ui/src/locales/lang/zh-Hant/ai-chat.ts index a0aa1c27b..2972bfe4f 100644 --- a/ui/src/locales/lang/zh-Hant/ai-chat.ts +++ b/ui/src/locales/lang/zh-Hant/ai-chat.ts @@ -90,5 +90,6 @@ export default { title: '知識庫引用', question: '用戶問題', optimizationQuestion: '優化後問題' - } + }, + editTitle: '編輯標題', } diff --git a/ui/src/stores/modules/log.ts b/ui/src/stores/modules/log.ts index d7a8d6498..d487c1baf 100644 --- a/ui/src/stores/modules/log.ts +++ b/ui/src/stores/modules/log.ts @@ -60,6 +60,18 @@ const useLogStore = defineStore({ reject(error) }) }) + }, + async asyncPutChatClientLog(id: string, chatId: string, data: any, loading?: Ref) { + return new Promise((resolve, reject) => { + logApi + .putChatClientLog(id, chatId, data, loading) + .then((data) => { + resolve(data) + }) + .catch((error) => { + reject(error) + }) + }) } } }) diff --git a/ui/src/views/chat/pc/EditTitleDialog.vue b/ui/src/views/chat/pc/EditTitleDialog.vue new file mode 100644 index 000000000..eea839ea8 --- /dev/null +++ b/ui/src/views/chat/pc/EditTitleDialog.vue @@ -0,0 +1,85 @@ + + + diff --git a/ui/src/views/chat/pc/index.vue b/ui/src/views/chat/pc/index.vue index ba4338ed1..3bcaca657 100644 --- a/ui/src/views/chat/pc/index.vue +++ b/ui/src/views/chat/pc/index.vue @@ -66,10 +66,22 @@ {{ row.abstract }} -
- - - +
+ + + +
@@ -145,6 +157,7 @@ +