| | |
| | | |
| | | <div class="sticky bottom-0 w-full p-6 pb-8 bg-[rgb(247,248,250)] flex justify-center"> |
| | | <PlayBar |
| | | v-model:voicePageIsShow="voicePageIsShow" |
| | | :isTalking="isTalking" |
| | | :isHome="false" |
| | | v-model="messageContent.values" |
| | | @sendClick="sendChatMessage" |
| | | @sendClick="sendClick" |
| | | :style="{ width: chatWidth }" |
| | | ></PlayBar> |
| | | </div> |
| | |
| | | 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 } from '/@/stores/chatRoom'; |
| | | 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 CustomDrawer from '/@/components/drawer/CustomDrawer.vue'; |
| | | |
| | | const chatWidth = '75%'; |
| | | |
| | | const voicePageIsShow = ref(false); |
| | | let isTalking = ref(false); |
| | | let messageContent = ref<ChatContent>({ |
| | | type: AnswerType.Text, |
| | |
| | | }); |
| | | }; |
| | | |
| | | const sendChatMessage = async (content: ChatContent = messageContent.value) => { |
| | | const sendChatMessage = async (content: ChatContent = messageContent.value, cb?: any) => { |
| | | if (!content?.values) return; |
| | | if (messageList.value.length === 0) { |
| | | |
| | | const isNewChat = messageList.value.length === 0 |
| | | if (isNewChat) { |
| | | if (activeSampleId.value) { |
| | | currentSampleId = activeSampleId.value; |
| | | } |
| | |
| | | |
| | | let resMsgContent: ChatContent = null; |
| | | resMsgContent = await questionAi(content.values); |
| | | if (isNewChat) { |
| | | const firstResCb = getRoomConfig(currentRouteId, 'firstResCb'); |
| | | 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, |
| | |
| | | isTalking.value = false; |
| | | } |
| | | }; |
| | | |
| | | const sendClick = (cb) => { |
| | | sendChatMessage(messageContent.value, cb); |
| | | }; |
| | | const appendLastMessageContent = (content: ChatContent) => { |
| | | if (messageList.value.at(-1)) { |
| | | messageList.value.at(-1).content = content; |