| | |
| | | </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]" |
| | |
| | | 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'; |
| | |
| | | const chatListDom = ref<HTMLDivElement>(); |
| | | const messageList = ref<ChatMessage[]>([]); |
| | | const computedMessageList = computed(() => { |
| | | return messageList.value.filter((v) => !!v); |
| | | |
| | | |
| | | |
| | | for (let index = 0; index < messageList.value.length; index++) { |
| | | const item = messageList.value[index]; |
| | | if(item?.role===RoleEnum.assistant || !item){ |
| | | continue |
| | | } |
| | | item.content.values = messageList.value[index+1]?.content?.origin?.question; |
| | | } |
| | | const filterList = messageList.value.filter((v) => !!v); |
| | | return filterList; |
| | | }); |
| | | |
| | | const parseContent = (res) => { |
| | |
| | | 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, |
| | | } |
| | | : {}; |
| | | } else { |
| | | judgeParams = { |
| | | prev_question: preQuestion.value, |
| | | }; |
| | | } |
| | | // const judgeParams = !preQuestion.value |
| | | // ? {} |
| | | // : { |
| | | // prev_question: preQuestion.value, |
| | | // }; |
| | | const params = { |
| | | process_id: processId.value, |
| | | question: text, |
| | |
| | | }); |
| | | }; |
| | | |
| | | 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) { |
| | |
| | | |
| | | // 出现回复,置空出现等待动画 |
| | | 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); |
| | |
| | | i++; |
| | | }); |
| | | |
| | | |
| | | if (messageList.value.length === 0) { |
| | | messageContent.value = { |
| | | type: AnswerType.Text, |
| | |
| | | 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, |