From aa93172c1dd94b15f99c7c65bcc7760e2139d6ca Mon Sep 17 00:00:00 2001 From: cherishsince Date: Wed, 22 May 2024 15:14:17 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=A7=A3=E5=86=B3todo=E3=80=91AI=20Ch?= =?UTF-8?q?at=20=E5=A2=9E=E5=8A=A0=20useContext=20=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/ai/chat/message/index.ts | 4 +++- src/views/ai/chat/index.vue | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/api/ai/chat/message/index.ts b/src/api/ai/chat/message/index.ts index 802061af..0547ab1b 100644 --- a/src/api/ai/chat/message/index.ts +++ b/src/api/ai/chat/message/index.ts @@ -39,6 +39,7 @@ export const ChatMessageApi = { conversationId: number, content: string, ctrl, + enableContext: boolean, onMessage, onError, onClose @@ -53,7 +54,8 @@ export const ChatMessageApi = { openWhenHidden: true, body: JSON.stringify({ conversationId, - content + content, + useContext: enableContext, }), onmessage: onMessage, onerror: onError, diff --git a/src/views/ai/chat/index.vue b/src/views/ai/chat/index.vue index 67f77d94..999e1736 100644 --- a/src/views/ai/chat/index.vue +++ b/src/views/ai/chat/index.vue @@ -54,7 +54,9 @@ placeholder="问我任何问题...(Shift+Enter 换行,按下 Enter 发送)" >
- +
+ 上下文 +
() // 对话进行中 abort 控制 const inputTimeout = ref() // 处理输入中回车的定时器 const prompt = ref() // prompt const userInfo = ref() // 用户信息 +const enableContext = ref(true) // 是否开启上下文 const fullText = ref(''); const displayedText = ref(''); @@ -327,6 +330,7 @@ const doSendStream = async (userMessage: ChatMessageVO) => { userMessage.conversationId, // TODO 芋艿:这里可能要在优化; userMessage.content, conversationInAbortController.value, + enableContext.value, async (message) => { const data = JSON.parse(message.data) // TODO 芋艿:类型处理; // 如果内容为空,就不处理。