| | |
| | | |
| | | <script setup lang="ts"> |
| | | import { ElMessage } from 'element-plus'; |
| | | import _ from 'lodash'; |
| | | import { v4 as uuidv4 } from 'uuid'; |
| | | import { computed, nextTick, onActivated, onMounted, ref, watch } from 'vue'; |
| | | import useClipboard from 'vue-clipboard3'; |
| | | import FeedbackPanel from './components/FeedbackPanel.vue'; |
| | | import Loding from './components/Loding.vue'; |
| | | import type { ChatContent } from './model/types'; |
| | | import { AnswerType, RoleEnum, answerTypeMapCom, roleImageMap, type ChatMessage, AnswerState } from './model/types'; |
| | | import { AnswerState, AnswerType, RoleEnum, answerTypeMapCom, roleImageMap, type ChatMessage } from './model/types'; |
| | | import { GetHistoryAnswer, QueryHistoryDetail, QuestionAi, SetHistoryAnswerState, getQuestionProcess } from '/@/api/ai/chat'; |
| | | import PlayBar from '/@/components/chat/components/playBar/PlayBar.vue'; |
| | | import router from '/@/router'; |
| | | import { |
| | | activeChatRoom, |
| | | activeLLMId, |
| | | activeRoomId, |
| | | activeSampleId, |
| | | activeSectionAId, |
| | | roomConfig, |
| | | setRoomConfig, |
| | | getRoomConfig, |
| | | } from '/@/stores/chatRoom'; |
| | | import { v4 as uuidv4 } from 'uuid'; |
| | | import _ from 'lodash'; |
| | | import { ErrorCode } from '/@/utils/request'; |
| | | import FeedbackPanel from './components/FeedbackPanel.vue'; |
| | | import { useClickOther } from '/@/hooks/useClickOther'; |
| | | import CustomDrawer from '/@/components/drawer/CustomDrawer.vue'; |
| | | import { useClickOther } from '/@/hooks/useClickOther'; |
| | | import router from '/@/router'; |
| | | import { activeChatRoom, activeLLMId, activeSampleId, activeSectionAId, getRoomConfig, roomConfig } from '/@/stores/chatRoom'; |
| | | import { ErrorCode } from '/@/utils/request'; |
| | | |
| | | const chatWidth = '75%'; |
| | | const voicePageIsShow = ref(false); |
| | |
| | | |
| | | const sendChatMessage = async (content: ChatContent = messageContent.value, cb?: any) => { |
| | | if (!content?.values) return; |
| | | |
| | | const isNewChat = messageList.value.length === 0 |
| | | const isNewChat = messageList.value.length === 0; |
| | | if (isNewChat) { |
| | | if (activeSampleId.value) { |
| | | currentSampleId = activeSampleId.value; |
| | |
| | | currentSectionId = activeSectionAId.value; |
| | | } |
| | | } |
| | | let resMsgContent: ChatContent = null; |
| | | |
| | | try { |
| | | isTalking.value = true; |
| | |
| | | // 出现回复,置空出现等待动画 |
| | | messageList.value.push(assistantItem); |
| | | |
| | | let resMsgContent: ChatContent = null; |
| | | resMsgContent = await questionAi(content.values); |
| | | if (isNewChat) { |
| | | const firstResCb = getRoomConfig(currentRouteId, 'firstResCb'); |
| | | firstResCb(resMsgContent); |
| | | firstResCb?.(resMsgContent); |
| | | } else { |
| | | cb?.(resMsgContent); |
| | | } |
| | | userItem.historyId = questionRes.history_id; |
| | | assistantItem.historyId = questionRes.history_id; |
| | | appendLastMessageContent(resMsgContent); |
| | | |
| | | return resMsgContent; |
| | | } catch (error: any) { |
| | | // appendLastMessageContent({ |
| | | // type: AnswerType.Text, |