| | |
| | | v-if="item.role === RoleEnum.assistant && item.content.origin?.ext_call_list" |
| | | class="flex font-bold items-center mt-6" |
| | | > |
| | | <div class="flex-0 mr-1.5">关联功能:</div> |
| | | <div class="flex-0 space-x-5 flex"> |
| | | <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="flex-0 cursor-pointer hover:underline" |
| | | class="cursor-pointer hover:underline first-of-type:ml-5" |
| | | > |
| | | {{ callItem.question }} |
| | | </div> |
| | |
| | | v-if="item.content?.type === AnswerType.Text || item.content?.type === AnswerType.Knowledge" |
| | | > |
| | | <i |
| | | class="p-2 ywicon icon-copy cursor-pointer hover:text-[#0284ff] hover:!text-[18px]" |
| | | class="p-2 ywifont ywicon-copy cursor-pointer hover:text-[#0284ff] hover:!text-[18px]" |
| | | @click="copyClick(item)" |
| | | /> |
| | | </div> |
| | |
| | | <div class="flex items-center justify-center size-[15px]"> |
| | | <i |
| | | :class="{ 'text-[#0284ff]': item.state === AnswerState.Like }" |
| | | class="p-2 ywicon icon-dianzan cursor-pointer hover:text-[#0284ff] font-medium hover:!text-[18px]" |
| | | class="p-2 ywifont ywicon-dianzan cursor-pointer hover:text-[#0284ff] font-medium hover:!text-[18px]" |
| | | @click="likeClick(item)" |
| | | /> |
| | | </div> |
| | | <div class="flex items-center justify-center size-[15px]"> |
| | | <i |
| | | :class="{ 'text-[#0284ff]': item.state === AnswerState.Unlike }" |
| | | class="p-2 ywicon icon-buzan cursor-pointer hover:text-[#0284ff] !text-[13px] hover:!text-[15px]" |
| | | class="p-2 ywifont ywicon-buzan cursor-pointer hover:text-[#0284ff] !text-[13px] hover:!text-[15px]" |
| | | @click="unLikeClick(item)" |
| | | /> |
| | | </div> |
| | |
| | | |
| | | <div class="flex items-center justify-center size-[15px] relative"> |
| | | <i |
| | | class="p-2 ywicon icon-wentifankui cursor-pointer hover:text-[#0284ff] !text-[13px] hover:!text-[15px]" |
| | | class="p-2 ywifont ywicon-wentifankui cursor-pointer hover:text-[#0284ff] !text-[13px] hover:!text-[15px]" |
| | | @click=" |
| | | ($event) => |
| | | feedbackClick( |
| | |
| | | </div> |
| | | </div> |
| | | |
| | | <Loding v-else class="w-fit" :process="process" /> |
| | | <Loding v-if="isTalking && index === messageList.length - 1" class="w-fit" :process="process" /> |
| | | </div> |
| | | </div> |
| | | </div> |
| | |
| | | }; |
| | | |
| | | const { clearQueryProcess, process, processId, queryProcess } = useQueryProcess(); |
| | | const DEFAULT_SECTION_A_ID = 'knowledge_base'; |
| | | |
| | | let questionRes = null; |
| | | |
| | | let finalCalcSectionAId = null; |
| | | const questionAi = async (text) => { |
| | | if (!currentSectionId) { |
| | | ElMessage.warning('发送失败,未确定应用场景!'); |
| | | } |
| | | |
| | | processId.value = uuidv4(); |
| | | const judgeParams = !preQuestion.value |
| | | ? {} |
| | | : { |
| | | prev_question: preQuestion.value, |
| | | }; |
| | | let judgeParams = null; |
| | | if (!preQuestion.value) { |
| | | // const aiContent = computedMessageList.value.filter((item) => item.role === RoleEnum.assistant); |
| | | // const lastQuestion = aiContent[aiContent.length - 2]?.content?.origin?.question; |
| | | // judgeParams = lastQuestion |
| | | // ? { |
| | | // prev_question: lastQuestion, |
| | | // } |
| | | // : {}; |
| | | // 正常回答暂时不采用 |
| | | judgeParams = {}; |
| | | } else { |
| | | judgeParams = { |
| | | prev_question: preQuestion.value, |
| | | }; |
| | | } |
| | | let currentSectionAId = ''; |
| | | if (activeSectionAId.value) { |
| | | currentSectionAId = activeSectionAId.value; |
| | | activeSectionAId.value = ''; |
| | | } else { |
| | | const lastSectionAItem = _.findLast(computedMessageList.value as any, (item) => item.role === RoleEnum.assistant && !!item.sectionAId); |
| | | currentSectionAId = lastSectionAItem?.sectionAId ?? DEFAULT_SECTION_A_ID; |
| | | } |
| | | finalCalcSectionAId = currentSectionAId; |
| | | |
| | | const params = { |
| | | process_id: processId.value, |
| | | question: text, |
| | | // FIXME: 暂时这样 |
| | | section_a_id: currentSectionId, |
| | | section_a_id: currentSectionAId, |
| | | history_group_id: currentRouteId, |
| | | raw_mode: roomConfig.value?.[currentRouteId]?.isAnswerByLLM ?? false, |
| | | ...judgeParams, |
| | |
| | | |
| | | if (currentSampleId) { |
| | | params.sample_id = currentSampleId; |
| | | currentSampleId = ''; |
| | | } |
| | | |
| | | if (currentLLMId) { |
| | | params.llm_id = currentLLMId; |
| | | } |
| | | // if (currentLLMId) { |
| | | // params.llm_id = currentLLMId; |
| | | // } |
| | | clearQueryProcess(); |
| | | queryProcess(); |
| | | const res = await QuestionAi(params).finally(() => { |
| | |
| | | values: '', |
| | | }); |
| | | |
| | | let currentSectionId = null; |
| | | let currentSampleId = null; |
| | | let currentSampleId = ''; |
| | | |
| | | let currentLLMId = null; |
| | | |
| | |
| | | }; |
| | | |
| | | const sendChatMessage = async (content: ChatContent = messageContent.value, cb?: any, isCallExtParams?: any) => { |
| | | if (!content?.values) return; |
| | | if (!content?.values || isTalking.value) return; |
| | | const isNewChat = messageList.value.length === 0; |
| | | if (isNewChat) { |
| | | if (activeSampleId.value) { |
| | |
| | | currentLLMId = activeLLMId.value; |
| | | } |
| | | |
| | | if (activeSectionAId.value) { |
| | | currentSectionId = activeSectionAId.value; |
| | | } |
| | | |
| | | } |
| | | let resMsgContent: ChatContent = null; |
| | | |
| | |
| | | const extRes = await extCallQuery(isCallExtParams); |
| | | questionRes = extRes; |
| | | resMsgContent = parseContent(extRes); |
| | | |
| | | } else { |
| | | resMsgContent = await questionAi(content.values); |
| | | } |
| | |
| | | cb?.(resMsgContent); |
| | | } |
| | | userItem.historyId = questionRes.history_id; |
| | | userItem.content.values = questionRes?.question ?? userItem.content.values; |
| | | assistantItem.historyId = questionRes.history_id; |
| | | assistantItem.sectionAId = finalCalcSectionAId; |
| | | appendLastMessageContent(resMsgContent); |
| | | } catch (error: any) { |
| | | // appendLastMessageContent({ |
| | |
| | | }, |
| | | } as ChatMessage; |
| | | }); |
| | | currentSectionId = res?.details?.[0]?.section_a_id; |
| | | currentSampleId = res?.details?.[0]?.sample_id; |
| | | const resList = await Promise.all((res.details ?? []).map((item) => getAnswerById(item.history_id))); |
| | | let i = 0; |
| | | const sectionAIdMap = new Map(); |
| | | |
| | | const resList = await Promise.all( |
| | | (res.details ?? []).map((item) => { |
| | | sectionAIdMap.set(item.history_id, item.section_a_id); |
| | | return getAnswerById(item.history_id); |
| | | }) |
| | | ); |
| | | let i = 0; |
| | | resList.map((item, index) => { |
| | | const insertIndex = index + 1 + i; |
| | | const userMsg = messageList.value[insertIndex - 1]; |
| | | userMsg.content.values = item?.answer?.question ??userMsg.content.values; |
| | | messageList.value.splice( |
| | | insertIndex, |
| | | 0, |
| | |
| | | role: RoleEnum.assistant, |
| | | content: parseContent(item.answer), |
| | | state: item.answer_state, |
| | | sectionAId: sectionAIdMap.get(item.answer.history_id), |
| | | |
| | | } |
| | | ); |
| | | i++; |