| | |
| | | <template> |
| | | <div class="flex h-full"> |
| | | <div class="flex h-full px-5"> |
| | | <div class="flex flex-col h-full flex-auto"> |
| | | <div class="h-full flex flex-col items-center overflow-y-auto"> |
| | | <div ref="chatListDom" class="h-full" :style="{ width: chatWidth }"> |
| | |
| | | srcset="" |
| | | /> |
| | | <div class="flex-auto flex" :class="{ 'justify-end': item.role === RoleEnum.user }"> |
| | | <div class="inline-flex flex-col" :class="{ 'w-full': item.role === RoleEnum.assistant }"> |
| | | <div class="inline-flex flex-col w-full" :class="{ 'w-full': item.role === RoleEnum.assistant }"> |
| | | <div class="w-full" v-if="item.content?.values"> |
| | | <div |
| | | class="text-sm rounded-[6px] p-4 leading-relaxed" |
| | |
| | | @click="copyClick(item)" |
| | | /> |
| | | </div> |
| | | <template v-if="item.content.errCode !== ErrorCode.Message"> |
| | | <!-- <template v-if="item.content.errCode !== ErrorCode.Message"> |
| | | <div class="flex items-center justify-center size-[15px]"> |
| | | <i |
| | | :class="{ 'text-[#0284ff]': item.state === AnswerState.Like }" |
| | |
| | | @click="unLikeClick(item)" |
| | | /> |
| | | </div> |
| | | </template> |
| | | </template> --> |
| | | |
| | | <div class="flex items-center justify-center size-[15px] relative"> |
| | | <!-- <div class="flex items-center justify-center size-[15px] relative"> |
| | | <i |
| | | class="p-2 ywifont ywicon-wentifankui cursor-pointer hover:text-[#0284ff] !text-[13px] hover:!text-[15px]" |
| | | @click=" |
| | |
| | | :chatItem="currentFeedbackMapItem" |
| | | :position="feedbackPosition" |
| | | /> |
| | | </div> |
| | | </div> --> |
| | | </div> |
| | | </div> |
| | | |
| | | <Loading v-if="isTalking && index === messageList.length - 1" class="w-fit" /> |
| | | <Loading v-if="isTalking && index === messageList.length - 1" class="w-fit my-auto" /> |
| | | </div> |
| | | </div> |
| | | </div> |
| | |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="sticky bottom-0 w-full p-6 pb-8 bg-[rgb(247,248,250)] flex justify-center"> |
| | | <div class="sticky bottom-0 w-full py-6 flex justify-center"> |
| | | <PlayBar |
| | | v-model:voicePageIsShow="voicePageIsShow" |
| | | :isTalking="isTalking" |
| | |
| | | |
| | | <script setup lang="ts"> |
| | | import _ from 'lodash'; |
| | | import type { PropType } from 'vue'; |
| | | import { computed, ref } from 'vue'; |
| | | import FeedbackPanel from './components/FeedbackPanel.vue'; |
| | | import Loading from './components/Loading/Loading.vue'; |
| | | import { useAssistantContentOpt } from './hooks/useAssistantContentOpt'; |
| | | import { useScrollToBottom } from './hooks/useScrollToBottom'; |
| | |
| | | import { GetHistoryAnswer, extCallQuery } from '/@/api/ai/chat'; |
| | | import PlayBar from '/@/components/chat/components/playBar/PlayBar.vue'; |
| | | import { ErrorCode } from '/@/utils/request'; |
| | | import { checkSupervisorValidate } from '/@/api/supervisorAdmin'; |
| | | import { CancelTokenSource } from 'axios'; |
| | | |
| | | const emit = defineEmits<{ |
| | | (event: 'question',inputText): any; |
| | | }>(); |
| | | const props = defineProps({ |
| | | questionApi: Function as PropType<(text: string, sourceObj: { source: CancelTokenSource }) => any>, |
| | | }); |
| | | |
| | | const chatWidth = '75%'; |
| | | const chatWidth = '100%'; |
| | | const voicePageIsShow = ref(false); |
| | | let isTalking = ref(false); |
| | | let messageContent = ref<ChatContent>({ |
| | |
| | | type: AnswerType.Text, |
| | | values: '解析失败!', |
| | | }; |
| | | |
| | | switch (res.answer_type) { |
| | | case AnswerType.RecordSet: |
| | | content = { |
| | |
| | | }; |
| | | |
| | | let questionRes = null; |
| | | const questionAi = async (text) => { |
| | | const params = { |
| | | id: 'net3_summary', |
| | | question: text, |
| | | } as any; |
| | | // 作为参数传进去,携带参数出来 |
| | | let lastSourceObj: { source: CancelTokenSource } = { |
| | | source:null |
| | | }; |
| | | |
| | | // const res = await emit('question',text); |
| | | const res = await checkSupervisorValidate(params); |
| | | const questionAi = async (text) => { |
| | | const res = await props.questionApi(text, lastSourceObj); |
| | | questionRes = res?.values; |
| | | const content = parseContent(res?.values); |
| | | return content; |
| | |
| | | history_id: historyId, |
| | | }); |
| | | }; |
| | | |
| | | const sendChatMessage = async (content: ChatContent = messageContent.value, cb?: any, isCallExtParams?: any) => { |
| | | if (!content?.values || isTalking.value) return; |
| | | const isNewChat = messageList.value.length === 0; |
| | | |
| | | let resMsgContent: ChatContent = null; |
| | | |
| | | try { |
| | |
| | | } |
| | | }; |
| | | |
| | | const sendClick = (cb) => { |
| | | const sendClick = (cb?) => { |
| | | sendChatMessage(messageContent.value, cb); |
| | | }; |
| | | const appendLastMessageContent = (content: ChatContent) => { |
| | |
| | | displayMessageList: computedMessageList, |
| | | }); |
| | | |
| | | const autoSend = (text) => { |
| | | messageContent.value.values = text; |
| | | sendClick(); |
| | | }; |
| | | |
| | | const clearContent = () => { |
| | | lastSourceObj.source?.cancel(); |
| | | messageList.value = []; |
| | | // 清空输入框 |
| | | clearMessageContent(); |
| | | }; |
| | | |
| | | defineExpose({ |
| | | autoSend, |
| | | clear: clearContent, |
| | | }); |
| | | |
| | | //#region ====================== 关联查询 ====================== |
| | | // const relativeQueryClick = async (val) => { |
| | | // sendChatMessage( |