|
@@ -36,6 +36,8 @@ const isExistInHistory = computed(() => (recordList.value.findIndex(({ sessionId
|
|
|
const handleCreateDialog = async () => {
|
|
|
message.destroyAll();
|
|
|
|
|
|
+ inputRef.value.clearFileList();
|
|
|
+
|
|
|
if (unref(isLoading)) {
|
|
|
return message.warning('当前对话生成中');
|
|
|
}
|
|
@@ -64,21 +66,53 @@ const handleChatDetail = async ({ sessionId }) => {
|
|
|
|
|
|
const { data } = await chatApi.getAnswerHistoryDetail({ sessionId });
|
|
|
|
|
|
- chatDataSource.value = data.map(item => ({ ...item, loading: false, }));
|
|
|
+ chatDataSource.value = data.map(item => {
|
|
|
+
|
|
|
+ const uploadFileList = []
|
|
|
+
|
|
|
+ if ( item.question.includes('file:') ) {
|
|
|
+
|
|
|
+ const fileInfo = item.question.split("||");
|
|
|
+ const fileArr = fileInfo[0].split(":");
|
|
|
+ const file = fileArr[1];
|
|
|
+ const url = fileInfo[1];
|
|
|
+ const suffix = file.substring( file.lastIndexOf('.') + 1 ).toUpperCase();
|
|
|
+ const originSuffix = file.substring( file.lastIndexOf('.') );
|
|
|
+ const name = file.substring(0, file.lastIndexOf('.'))
|
|
|
+
|
|
|
+ uploadFileList.push({
|
|
|
+ name,
|
|
|
+ originSuffix,
|
|
|
+ suffix,
|
|
|
+ url
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ return ({ ...item, loading: false, uploadFileList})
|
|
|
+ });
|
|
|
+
|
|
|
currenSessionId.value = sessionId;
|
|
|
|
|
|
scrollToBottom();
|
|
|
}
|
|
|
|
|
|
-const onRegenerate = async ({ question, realQuestion, tools }) => {
|
|
|
+const onRegenerate = async ({ showVal, question, realQuestion, tools, uploadFileList }) => {
|
|
|
controller = new AbortController();
|
|
|
|
|
|
const sessionId = unref(currenSessionId);
|
|
|
+
|
|
|
+ let fileQuestionStr = '';
|
|
|
+
|
|
|
+ if ( uploadFileList && uploadFileList.length ) {
|
|
|
+ const [ fileItem ] = uploadFileList;
|
|
|
+ fileQuestionStr = `file:${fileItem.name + fileItem.originSuffix}||${fileItem.url}||${question}`
|
|
|
+ }
|
|
|
+
|
|
|
const params = {
|
|
|
data: {
|
|
|
sessionId,
|
|
|
- showVal: question,
|
|
|
- question: realQuestion || question,
|
|
|
+ showVal: showVal,
|
|
|
+ question: realQuestion || fileQuestionStr || question,
|
|
|
module: 0,
|
|
|
isStrong: Number(unref(switchActive)),
|
|
|
tools,
|
|
@@ -95,10 +129,12 @@ const onRegenerate = async ({ question, realQuestion, tools }) => {
|
|
|
|
|
|
updateChat({
|
|
|
sessionId,
|
|
|
+ showVal: showVal,
|
|
|
question,
|
|
|
answer,
|
|
|
loading: true,
|
|
|
- delayLoading: false
|
|
|
+ delayLoading: false,
|
|
|
+ uploadFileList
|
|
|
})
|
|
|
|
|
|
scrollToBottomIfAtBottom();
|
|
@@ -112,11 +148,13 @@ const onRegenerate = async ({ question, realQuestion, tools }) => {
|
|
|
|
|
|
updateChat({
|
|
|
id,
|
|
|
+ showVal: showVal,
|
|
|
sessionId,
|
|
|
question,
|
|
|
answer,
|
|
|
loading: false,
|
|
|
- delayLoading: false
|
|
|
+ delayLoading: false,
|
|
|
+ uploadFileList
|
|
|
})
|
|
|
|
|
|
scrollToBottomIfAtBottom();
|
|
@@ -130,7 +168,7 @@ const onRegenerate = async ({ question, realQuestion, tools }) => {
|
|
|
}
|
|
|
}
|
|
|
// 提交问题
|
|
|
-const handleSubmit = async ({question, selectedOption, realQuestion = ''}) => {
|
|
|
+const handleSubmit = async ({ showVal, question, selectedOption, realQuestion = '', uploadFileList = []}) => {
|
|
|
// 用于模拟 - 内容生成前置等待状态
|
|
|
if (unref(isExistInHistory)) {
|
|
|
const { data: sessionId } = await chatApi.getChatSessionTag();
|
|
@@ -141,21 +179,23 @@ const handleSubmit = async ({question, selectedOption, realQuestion = ''}) => {
|
|
|
|
|
|
addChat({
|
|
|
sessionId: unref(currenSessionId),
|
|
|
+ showVal,
|
|
|
question,
|
|
|
realQuestion,
|
|
|
answer: '',
|
|
|
loading: true,
|
|
|
- delayLoading: true
|
|
|
+ delayLoading: true,
|
|
|
+ uploadFileList
|
|
|
})
|
|
|
|
|
|
scrollToBottom();
|
|
|
|
|
|
- setTimeout(() => onRegenerate({ question, realQuestion, tools: selectedOption?.tools || null }), 2 * 1000);
|
|
|
+ setTimeout(() => onRegenerate({ showVal, question, realQuestion, tools: selectedOption?.tools || null, uploadFileList }), 2 * 1000);
|
|
|
}
|
|
|
|
|
|
// 处理推荐问题
|
|
|
const handleWelcomeRecommend = ({ question, realQuestion }) => {
|
|
|
- handleSubmit({question, realQuestion});
|
|
|
+ handleSubmit({showVal: question, question, realQuestion});
|
|
|
}
|
|
|
|
|
|
// 删除历史对话
|
|
@@ -173,8 +213,10 @@ const onStopChatStream = async ({ sessionId }) => {
|
|
|
}
|
|
|
|
|
|
// 重新生成问题
|
|
|
-const onChatResetStream = ({ question }) => {
|
|
|
- handleSubmit({question});
|
|
|
+const onChatResetStream = (item) => {
|
|
|
+ const { question, uploadFileList, showVal } = item;
|
|
|
+ console.log(item);
|
|
|
+ handleSubmit({showVal, question, uploadFileList});
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
@@ -215,7 +257,7 @@ onUnmounted(() => {
|
|
|
|
|
|
<div class="conversation-item" v-if="chatDataSource.length">
|
|
|
<template v-for="item, index in chatDataSource" :key="item.id">
|
|
|
- <ChatAsk :content="item.question" :sessionId="item.sessionId"></ChatAsk>
|
|
|
+ <ChatAsk :content="item.showVal" :sessionId="item.sessionId" :uploadFileList="item.uploadFileList"></ChatAsk>
|
|
|
<ChatAnswer
|
|
|
:id="item.id"
|
|
|
:content="item.answer"
|
|
@@ -241,8 +283,6 @@ onUnmounted(() => {
|
|
|
@on-click="handleSubmit"
|
|
|
@on-enter="handleSubmit"
|
|
|
></ChatAgentInput>
|
|
|
- <!-- <ChatInput ref="inputRef" v-model:loading="isLoading" v-model:switch="switchActive" @on-click="handleSubmit"
|
|
|
- @on-enter="handleSubmit"></ChatInput> -->
|
|
|
</template>
|
|
|
</TheChatView>
|
|
|
</section>
|