From a7a49407b128226e79070e4a413d6667669fa7c8 Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期四, 08 八月 2024 15:24:20 +0800 Subject: [PATCH] 图片位置修改 --- src/components/chat/Chat.vue | 67 +++++++++++++++++++++++++++++---- 1 files changed, 58 insertions(+), 9 deletions(-) diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue index 154e00e..d9328d5 100644 --- a/src/components/chat/Chat.vue +++ b/src/components/chat/Chat.vue @@ -25,7 +25,7 @@ > <div v-if="item.content.errCode === ErrorCode.Message" class="flex-column w-full"> <p class="text-red-500"> - {{ item.content.msg }} + {{ item.content.errMsg }} </p> <div class="mt-5 flex items-center" v-if="showFixQuestion(item)"> <div class="text-gray-600 flex-0"> @@ -36,16 +36,36 @@ v-for="fixItem in item.content.origin.err_json.fix_question?.values" :key="fixItem" class="bg-gray-200 p-3 hover:bg-[#c5e0ff] hover:text-[#1c86ff] cursor-pointer rounded-lg" - @click="fixQuestionClick(fixItem)" + @click="fixQuestionClick(fixItem, item.content.origin)" > {{ fixItem.title }} </div> </div> </div> </div> - <component v-else :is="answerTypeMapCom[item.content.type]" :data="item.content.values" :originData="item" /> + <template v-else> + <component :is="answerTypeMapCom[item.content.type]" :data="item.content.values" :originData="item" /> + + <div + v-if="item.role === RoleEnum.assistant && item.content.origin?.ext_call_list" + class="flex font-bold items-center mt-6" + > + <div class="flex-0 mb-auto -mr-4">鍏宠仈鍔熻兘锛�</div> + <div class="space-x-5 flex flex-wrap"> + <div + v-for="callItem in item.content.origin?.ext_call_list" + :key="callItem.call_ext_id" + @click="relativeQueryClick(callItem)" + class="cursor-pointer hover:underline first-of-type:ml-5" + > + {{ callItem.question }} + </div> + </div> + </div> + </template> </div> + <!-- 鎿嶄綔 --> <div v-if="item.role === RoleEnum.assistant" class="absolute flex items-center right-0 mr-4 mt-2 space-x-2"> <div class="flex items-center justify-center size-[15px]" @@ -147,7 +167,7 @@ import { useScrollToBottom } from './hooks/useScrollToBottom'; import type { ChatContent } from './model/types'; import { AnswerState, AnswerType, RoleEnum, answerTypeMapCom, roleImageMap, type ChatMessage } from './model/types'; -import { GetHistoryAnswer, QueryHistoryDetail, QuestionAi } from '/@/api/ai/chat'; +import { GetHistoryAnswer, QueryHistoryDetail, QuestionAi, extCallQuery } from '/@/api/ai/chat'; import PlayBar from '/@/components/chat/components/playBar/PlayBar.vue'; import CustomDrawer from '/@/components/drawer/CustomDrawer.vue'; import router from '/@/router'; @@ -224,7 +244,7 @@ } content.askMoreList = _.orderBy(res.context_history, [(item) => Number(item.radio)], ['desc']); content.errCode = res?.err_code; - content.msg = res?.json_msg; + content.errMsg = res?.json_msg; content.origin = res; return content; }; @@ -237,6 +257,11 @@ ElMessage.warning('鍙戦�佸け璐ワ紝鏈‘瀹氬簲鐢ㄥ満鏅紒'); } processId.value = uuidv4(); + const judgeParams = !preQuestion.value + ? {} + : { + prev_question: preQuestion.value, + }; const params = { process_id: processId.value, question: text, @@ -244,7 +269,7 @@ section_a_id: currentSectionId, history_group_id: currentRouteId, raw_mode: roomConfig.value?.[currentRouteId]?.isAnswerByLLM ?? false, - next_chat: isNextChat.value, + ...judgeParams, } as any; if (currentSampleId) { @@ -281,7 +306,7 @@ }); }; -const sendChatMessage = async (content: ChatContent = messageContent.value, cb?: any) => { +const sendChatMessage = async (content: ChatContent = messageContent.value, cb?: any, isCallExtParams?: any) => { if (!content?.values) return; const isNewChat = messageList.value.length === 0; if (isNewChat) { @@ -310,8 +335,14 @@ // 鍑虹幇鍥炲锛岀疆绌哄嚭鐜扮瓑寰呭姩鐢� messageList.value.push(assistantItem); + if (isCallExtParams) { + const extRes = await extCallQuery(isCallExtParams); + questionRes = extRes; + resMsgContent = parseContent(extRes); + } else { + resMsgContent = await questionAi(content.values); + } - resMsgContent = await questionAi(content.values); if (isNewChat) { const firstResCb = getRoomConfig(currentRouteId, 'firstResCb'); firstResCb?.(resMsgContent); @@ -392,6 +423,24 @@ displayMessageList: computedMessageList, }); +//#region ====================== 鍏宠仈鏌ヨ ====================== +const relativeQueryClick = async (val) => { + sendChatMessage( + { + type: AnswerType.Text, + values: val.question, + }, + undefined, + { + history_group_id: currentRouteId, + question: val.question, + call_ext_id: val.call_ext_id, + call_ext_args: val.agrs ? JSON.stringify(val.agrs) : null, + } + ); +}; +//#endregion + const { copyClick, likeClick, @@ -404,7 +453,7 @@ feedbackClick, askMoreClick, fixQuestionClick, - isNextChat, + preQuestion, showFixQuestion, showAskMore, } = useAssistantContentOpt({ -- Gitblit v1.9.3