【解决todo】AI Chat 增加 useContext 控制

This commit is contained in:
cherishsince 2024-05-22 15:14:17 +08:00
parent 689d92dc66
commit aa93172c1d
2 changed files with 8 additions and 2 deletions

View File

@ -39,6 +39,7 @@ export const ChatMessageApi = {
conversationId: number, conversationId: number,
content: string, content: string,
ctrl, ctrl,
enableContext: boolean,
onMessage, onMessage,
onError, onError,
onClose onClose
@ -53,7 +54,8 @@ export const ChatMessageApi = {
openWhenHidden: true, openWhenHidden: true,
body: JSON.stringify({ body: JSON.stringify({
conversationId, conversationId,
content content,
useContext: enableContext,
}), }),
onmessage: onMessage, onmessage: onMessage,
onerror: onError, onerror: onError,

View File

@ -54,7 +54,9 @@
placeholder="问我任何问题...Shift+Enter 换行,按下 Enter 发送)" placeholder="问我任何问题...Shift+Enter 换行,按下 Enter 发送)"
></textarea> ></textarea>
<div class="prompt-btns"> <div class="prompt-btns">
<el-switch/> <div>
<el-switch v-model="enableContext" /> <span style="font-size: 14px; color: #8f8f8f;">上下文</span>
</div>
<el-button <el-button
type="primary" type="primary"
size="default" size="default"
@ -110,6 +112,7 @@ const conversationInAbortController = ref<any>() // 对话进行中 abort 控制
const inputTimeout = ref<any>() // const inputTimeout = ref<any>() //
const prompt = ref<string>() // prompt const prompt = ref<string>() // prompt
const userInfo = ref<ProfileVO>() // const userInfo = ref<ProfileVO>() //
const enableContext = ref<boolean>(true) //
const fullText = ref(''); const fullText = ref('');
const displayedText = ref(''); const displayedText = ref('');
@ -327,6 +330,7 @@ const doSendStream = async (userMessage: ChatMessageVO) => {
userMessage.conversationId, // TODO userMessage.conversationId, // TODO
userMessage.content, userMessage.content,
conversationInAbortController.value, conversationInAbortController.value,
enableContext.value,
async (message) => { async (message) => {
const data = JSON.parse(message.data) // TODO const data = JSON.parse(message.data) // TODO
// //