From 214ff84f713d197269ea41d563b239ada0d71d5b Mon Sep 17 00:00:00 2001 From: godo Date: Thu, 28 Nov 2024 18:53:44 +0800 Subject: [PATCH] change chat ai --- README.md | 2 + frontend/components.d.ts | 1 + frontend/src/assets/chat.scss | 2 +- .../src/components/localchat/AiChatInfo.vue | 93 ++++++----- .../src/components/localchat/AiChatLeft.vue | 145 ++++++++++++++---- .../src/components/localchat/AiChatMain.vue | 76 +++++---- frontend/src/stores/aichat.ts | 41 +++-- packages/kanban/package.json | 2 +- 8 files changed, 239 insertions(+), 123 deletions(-) diff --git a/README.md b/README.md index 490228a..70abfa6 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ - 新增文件密码箱(系统设置里),可根据不同文件进行加密存储 - 美化日程提醒弹窗 - 修复word格式问题以及导出名字不对 +- markdown新增ai优化/续写/纠错/翻译/总结,生成大纲,根据大纲一键创建文章 +- 更改文档存储方式,支持选择文件夹 ## 🏭 第三阶段目标(十二月底发布) 1. **文档处理与Markdown智能升级**: diff --git a/frontend/components.d.ts b/frontend/components.d.ts index c50a25e..9c7c1f4 100644 --- a/frontend/components.d.ts +++ b/frontend/components.d.ts @@ -76,6 +76,7 @@ declare module 'vue' { ElEmpty: typeof import('element-plus/es')['ElEmpty'] ElForm: typeof import('element-plus/es')['ElForm'] ElFormItem: typeof import('element-plus/es')['ElFormItem'] + ElHeader: typeof import('element-plus/es')['ElHeader'] ElIcon: typeof import('element-plus/es')['ElIcon'] ElImage: typeof import('element-plus/es')['ElImage'] ElInput: typeof import('element-plus/es')['ElInput'] diff --git a/frontend/src/assets/chat.scss b/frontend/src/assets/chat.scss index f408f9c..9be0919 100644 --- a/frontend/src/assets/chat.scss +++ b/frontend/src/assets/chat.scss @@ -4,7 +4,7 @@ display: flex; flex-direction: column; position: relative; - + background: #fff; .messsage-area { display: flex; flex-direction: column; diff --git a/frontend/src/components/localchat/AiChatInfo.vue b/frontend/src/components/localchat/AiChatInfo.vue index ad37c82..70243c2 100644 --- a/frontend/src/components/localchat/AiChatInfo.vue +++ b/frontend/src/components/localchat/AiChatInfo.vue @@ -1,58 +1,75 @@ + \ No newline at end of file diff --git a/frontend/src/components/localchat/AiChatMain.vue b/frontend/src/components/localchat/AiChatMain.vue index 2f580c5..2f42550 100644 --- a/frontend/src/components/localchat/AiChatMain.vue +++ b/frontend/src/components/localchat/AiChatMain.vue @@ -9,6 +9,7 @@ import { Vue3Lottie } from "vue3-lottie"; const chatStore = useAiChatStore(); const modelStore = useModelStore(); const isPadding = ref(false); //是否发送中 + const imageInput: any = ref(null); let imageData = ref(""); const messageContainerRef = ref>(); @@ -77,7 +78,7 @@ const createCompletion = async () => { id: messageId, createdAt: messageId, }; - + const chatConfig = modelStore.chatConfig.chat; let postMsg: any = { messages: requestMessages.value, @@ -106,7 +107,7 @@ const createCompletion = async () => { method: "POST", body: JSON.stringify(postMsg), }; - + const completion = await fetch(config.apiUrl + '/ai/chat', postData); //const completion:any = await modelStore.getModel(postData) imageData.value = ""; @@ -118,8 +119,8 @@ const createCompletion = async () => { } const res = await completion.json(); //console.log(res) - if(res && res.choices && res.choices.length > 0){ - if(res.choices[0].message.content){ + if (res && res.choices && res.choices.length > 0) { + if (res.choices[0].message.content) { const msg = res.choices[0].message.content; saveMessage.content = msg; chatStore.messageList.push(saveMessage); @@ -127,7 +128,7 @@ const createCompletion = async () => { } } isPadding.value = false; - } catch (error:any) { + } catch (error: any) { isPadding.value = false; notifyError(error.message); } @@ -150,7 +151,7 @@ watch( deep: true, } ); -const handleKeydown = (e:any) => { +const handleKeydown = (e: any) => { if (e.key === "Enter" && (e.altKey || e.shiftKey)) { // 当同时按下 alt或者shift 和 enter 时,插入一个换行符 e.preventDefault(); @@ -182,43 +183,40 @@ const uploadImage = async (event: any) => { reader.readAsDataURL(file); }; +