|
|
@@ -36,6 +36,7 @@
|
|
|
:suggestion="chat_suggestion"
|
|
|
:answer_action_list="answer_action_list"
|
|
|
:is_show_right_page="show_right"
|
|
|
+ :loading_mind_map="loading_mind_map"
|
|
|
@share="handleChatShare"
|
|
|
@edit="handleEditChat"
|
|
|
@retry="handleRetryChat"
|
|
|
@@ -92,7 +93,7 @@
|
|
|
|
|
|
<div class="conversation-chat-main-right" :style="style_conversation_chat_right">
|
|
|
<div class="conversation-chat-expand" :style="style_conversation_chat_expand" v-if="is_show_right_page">
|
|
|
- <div class="conversation-chat-mind-map" ref="fullScreen_mindMap">
|
|
|
+ <div class="conversation-chat-mind-map" :style="style_conversation_chat_mind_map" ref="fullScreen_mindMap">
|
|
|
<!-- 全屏时显示的退出按钮 -->
|
|
|
<button v-if="isFullScreen" class="exit-button" @click="exitFullScreen">X</button>
|
|
|
<MindMap
|
|
|
@@ -103,7 +104,7 @@
|
|
|
:svg_style="svg_style"
|
|
|
@extend="extendMindMap"
|
|
|
></MindMap>
|
|
|
- <div class="mind_map_error" v-if="mindMap_err.length">{{ mindMap_err }}</div>
|
|
|
+ <div class="mind_map_error" :style="style_map_error" v-if="mindMap_err.length">{{ mindMap_err }}</div>
|
|
|
|
|
|
<div class="conversation-chat-mind-map-tools">
|
|
|
<ConversationChatMindMapTools
|
|
|
@@ -117,10 +118,10 @@
|
|
|
></ConversationChatMindMapTools>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="conversation-chat-mind-map-spin" v-if="loading_mind_map">
|
|
|
+ <div class="conversation-chat-mind-map-spin" :style="style_map_error" v-if="loading_mind_map">
|
|
|
<a-spin tip="加载中..."></a-spin>
|
|
|
</div>
|
|
|
- <div class="conversation-chat-web-page" v-if="show_web_page">
|
|
|
+ <div class="conversation-chat-web-page" :style="style_conversation_chat_web_page" v-if="show_web_page">
|
|
|
<ConversationChatWebPage :search_list="search_list" @toClose="closeWebPage"></ConversationChatWebPage>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -186,6 +187,7 @@ import useScroll2Bottom from './use-scroll-bottom';
|
|
|
import { IconEye } from '@arco-design/web-vue/es/icon';
|
|
|
import { file, files } from 'jszip';
|
|
|
import { getFileType } from '../../modules/form-dynamic/file-accept';
|
|
|
+import { value } from 'lodash-es';
|
|
|
|
|
|
const props = defineProps({
|
|
|
/**
|
|
|
@@ -329,6 +331,47 @@ const style_conversation_chat_list = computed(() => {
|
|
|
};
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+const style_conversation_chat_web_page = computed(() => {
|
|
|
+ if (!show_mind_map.value) {
|
|
|
+ return {
|
|
|
+ height: 100 + '%',
|
|
|
+ transition: 'all 0.2s ease',
|
|
|
+ marginTop: 0 + 'px'
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ return {
|
|
|
+ marginTop: 20 + 'px',
|
|
|
+ transition: 'all 0.2s ease',
|
|
|
+ height: 'calc(100 % - 380px)'
|
|
|
+ };
|
|
|
+ }
|
|
|
+});
|
|
|
+const style_conversation_chat_mind_map = computed(() => {
|
|
|
+ if (show_mind_map.value) {
|
|
|
+ return {
|
|
|
+ height: 330 + 'px',
|
|
|
+ transition: 'all 0.2s ease'
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ return {
|
|
|
+ display: 'none'
|
|
|
+ };
|
|
|
+ }
|
|
|
+});
|
|
|
+const style_map_error = computed(() => {
|
|
|
+ if (show_mind_map.value) {
|
|
|
+ return {
|
|
|
+ height: 330 + 'px',
|
|
|
+ transition: 'all 0.2s ease',
|
|
|
+ display: 'flex'
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ return {
|
|
|
+ display: 'none'
|
|
|
+ };
|
|
|
+ }
|
|
|
+});
|
|
|
// ------------------------------------------------------------------
|
|
|
// ------------------------------------------------------------------
|
|
|
// ------------------------------------------------------------------
|
|
|
@@ -845,21 +888,40 @@ const closeWebPage = () => {
|
|
|
};
|
|
|
|
|
|
// 展示右侧页面按钮
|
|
|
-const show_right_page_btn = computed(() => {
|
|
|
- return !show_word_viewer.value && !show_welcome.value;
|
|
|
-}); //控制右侧顶部按钮开关
|
|
|
+// const show_right_page_btn = computed(() => {
|
|
|
+// if (chat_display_list.value.length) {
|
|
|
+// const last_item = chat_display_list.value.at(-1);
|
|
|
+// if (last_item.client_custom_item_internet && last_item.client_custom_item_internet_list.length) {
|
|
|
+// return true;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return false;
|
|
|
+// });
|
|
|
+
|
|
|
+//控制右侧顶部按钮开关
|
|
|
+const show_right_page_btn = ref(false);
|
|
|
/**
|
|
|
* 控制右侧显示/隐藏
|
|
|
+ * 展开 永远显示最后一项的网页和思维导图,如果二者都没有则,不显示
|
|
|
* */
|
|
|
-
|
|
|
const toggleRight = () => {
|
|
|
is_show_right_page.value = !is_show_right_page.value;
|
|
|
if (is_show_right_page.value) {
|
|
|
- mindMap_content.value = mindMap_str.value;
|
|
|
- setTimeout(() => {
|
|
|
+ const last = chat_display_list.value.at(-1);
|
|
|
+ if (last.client_custom_item_internet_list.length) {
|
|
|
+ show_web_page.value = true;
|
|
|
+ search_list.value = last.client_custom_item_internet_list;
|
|
|
+ }
|
|
|
+ if (last.client_custom_item_mind_map) {
|
|
|
show_mind_map.value = true;
|
|
|
- }, 200);
|
|
|
- show_web_page.value = true;
|
|
|
+ console.log(last);
|
|
|
+ getMindMapData({ messageId: last.client_custom_chat_message_id.value, query: mindMap_txt.value }).then((res) => {
|
|
|
+ if (res.code / 1 === 200) {
|
|
|
+ mindMap_str.value = res.data.mindmap;
|
|
|
+ mindMap_content.value = res.data.mindmap;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
} else {
|
|
|
show_mind_map.value = false;
|
|
|
show_web_page.value = false;
|
|
|
@@ -1234,9 +1296,13 @@ const handleInputSubmit = async (options) => {
|
|
|
};
|
|
|
// 首页对话
|
|
|
const toSubmitNewChat = async (options) => {
|
|
|
+ // 每次问答时,先隐藏右侧按钮
|
|
|
+ show_right_page_btn.value = false;
|
|
|
+ is_show_right_page.value = false;
|
|
|
+
|
|
|
let ask_text = options.text; // 文本
|
|
|
const ask_files = options.files; // 文件列表
|
|
|
- const action_config = options.config; //是否深度思考,是否联网,是否选择知识库
|
|
|
+ const action_config = options.config; //是否深度思考,是否联网,是否选择知识库,是否生成思维导图
|
|
|
target_action_config.value = options.config;
|
|
|
let parent_id = '';
|
|
|
if (chat_display_list.value.length) {
|
|
|
@@ -1248,8 +1314,18 @@ const toSubmitNewChat = async (options) => {
|
|
|
if (options.parent_id) {
|
|
|
parent_id = options.parent_id;
|
|
|
}
|
|
|
+ console.log(target_action_config.value);
|
|
|
+ /**
|
|
|
+ *判断是否要生成思维导图
|
|
|
+ * 如果是生成思维导图,则将文本内容保存到mindMap_txt中,用于生成思维导图
|
|
|
+ * */
|
|
|
+ if (target_action_config.value.mind_map) {
|
|
|
+ mindMap_txt.value = options.text;
|
|
|
+ } else {
|
|
|
+ mindMap_txt.value = '';
|
|
|
+ show_mind_map.value = false;
|
|
|
+ }
|
|
|
|
|
|
- mindMap_txt.value = options.text;
|
|
|
// 用户选定的文件数量
|
|
|
const file_total = ask_files.length;
|
|
|
if (!ask_text) {
|
|
|
@@ -1323,13 +1399,13 @@ const search_list = ref([]);
|
|
|
|
|
|
const toSearchPage = (item) => {
|
|
|
search_list.value = [...item.client_custom_item_internet_list];
|
|
|
- minMap_messageId.value = item.client_custom_chat_message_id;
|
|
|
+ // minMap_messageId.value = item.client_custom_chat_message_id;
|
|
|
if (!is_show_right_page.value) {
|
|
|
is_show_right_page.value = true;
|
|
|
// if (!mindMap_content.value) {
|
|
|
// mindMap_err.value = '暂无内容';
|
|
|
// }
|
|
|
- toShowMindMap(item);
|
|
|
+ // toShowMindMap(item);
|
|
|
}
|
|
|
if (!show_web_page.value) {
|
|
|
show_web_page.value = true;
|
|
|
@@ -1343,10 +1419,12 @@ const toShowMindMap = async (item) => {
|
|
|
mindMap_content.value = res.data.mindmap;
|
|
|
mindMap_err.value = '';
|
|
|
} else {
|
|
|
- (mindMap_content.value = ''), (mindMap_err.value = '暂无内容');
|
|
|
+ mindMap_content.value = '';
|
|
|
+ mindMap_err.value = '暂无内容';
|
|
|
}
|
|
|
} else {
|
|
|
- (mindMap_content.value = ''), (mindMap_err.value = '暂无内容');
|
|
|
+ mindMap_content.value = '';
|
|
|
+ mindMap_err.value = '暂无内容';
|
|
|
}
|
|
|
is_show_right_page.value = true;
|
|
|
minMap_messageId.value = item.client_custom_chat_message_id;
|
|
|
@@ -1354,6 +1432,37 @@ const toShowMindMap = async (item) => {
|
|
|
show_mind_map.value = true;
|
|
|
}, 200);
|
|
|
};
|
|
|
+/**
|
|
|
+ * 生成思维导图的函数
|
|
|
+ *
|
|
|
+ * */
|
|
|
+const toGenerateMindMap = async () => {
|
|
|
+ // is_show_right_page.value = false;
|
|
|
+ loading_mind_map.value = true;
|
|
|
+ getMindMapData({ messageId: minMap_messageId.value, query: mindMap_txt.value })
|
|
|
+ .then((res) => {
|
|
|
+ if (res.code / 1 === 200) {
|
|
|
+ mindMap_str.value = res.data.mindmap;
|
|
|
+ mindMap_content.value = res.data.mindmap;
|
|
|
+ mindMap_err.value = '';
|
|
|
+ if (!res.data.mindmap) {
|
|
|
+ mindMap_err.value = '文本内容太少,不足以生成思维导图';
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ mindMap_err.value = '文本内容太少,不足以生成思维导图';
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((e) => {
|
|
|
+ mindMap_err.value = '文本内容太少,不足以生成思维导图';
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ loading_mind_map.value = false;
|
|
|
+
|
|
|
+ // setTimeout(() => {
|
|
|
+ // show_mind_map.value = true;
|
|
|
+ // }, 200);
|
|
|
+ });
|
|
|
+};
|
|
|
|
|
|
/**
|
|
|
* sseOnMessage处理函数
|
|
|
@@ -1375,38 +1484,22 @@ const sseOnMessage = (ev) => {
|
|
|
if (props.agent_id) {
|
|
|
// return;
|
|
|
} else {
|
|
|
- is_show_right_page.value = true;
|
|
|
- loading_mind_map.value = true;
|
|
|
- getMindMapData({ messageId: minMap_messageId.value, query: mindMap_txt.value })
|
|
|
- .then((res) => {
|
|
|
- if (res.code / 1 === 200) {
|
|
|
- mindMap_str.value = res.data.mindmap;
|
|
|
- mindMap_content.value = res.data.mindmap;
|
|
|
- mindMap_err.value = '';
|
|
|
- if (!res.data.mindmap) {
|
|
|
- mindMap_err.value = '文本内容太少,不足以生成思维导图,请重新尝试';
|
|
|
- }
|
|
|
- } else {
|
|
|
- mindMap_err.value = '文本内容太少,不足以生成思维导图,请重新尝试';
|
|
|
- }
|
|
|
- })
|
|
|
- .catch((e) => {
|
|
|
- mindMap_err.value = '文本内容太少,不足以生成思维导图,请重新尝试';
|
|
|
- })
|
|
|
- .finally(() => {
|
|
|
- loading_mind_map.value = false;
|
|
|
-
|
|
|
- setTimeout(() => {
|
|
|
- show_mind_map.value = true;
|
|
|
- }, 200);
|
|
|
- });
|
|
|
+ // 如果mimndMap_txt有值,则生成思维导图
|
|
|
+ res_data.isMindMap = target_action_config.value.mind_map;
|
|
|
+ if (mindMap_txt.value) {
|
|
|
+ toGenerateMindMap();
|
|
|
+ } else {
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (res_data.event === 'node_finished' && res_data.data.title && res_data.data.title === 'SearXNG 搜索') {
|
|
|
if (res_data.data.outputs?.json) {
|
|
|
search_list.value = res_data.data.outputs.json;
|
|
|
if (search_list.value.length) {
|
|
|
+ // 当有网页时,显示右侧按钮
|
|
|
+ show_right_page_btn.value = true;
|
|
|
show_web_page.value = true;
|
|
|
+ is_show_right_page.value = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1435,6 +1528,7 @@ const sseOnMessage = (ev) => {
|
|
|
if (Object.keys(target_action_config.value)) {
|
|
|
res_data.isDeep = target_action_config.value.isDeep / 1 === 2 ? true : false;
|
|
|
res_data.isInternet = target_action_config.value.chatMode / 1 === 2 ? true : false;
|
|
|
+ res_data.isMindMap = target_action_config.value.mind_map;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1442,8 +1536,9 @@ const sseOnMessage = (ev) => {
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
-
|
|
|
+ console.log(res_data, last_msg);
|
|
|
const currentChat = formatDialogAnswerFromSseReceiveMessage(res_data, last_msg, props.CHAT_AGENT_INFOMATION);
|
|
|
+ // console.log(currentChat);
|
|
|
const chat_status = currentChat.status;
|
|
|
|
|
|
// 处理对话数据
|
|
|
@@ -1509,6 +1604,18 @@ const stopResponse = () => {
|
|
|
scroll2ListBottom();
|
|
|
};
|
|
|
|
|
|
+const toShowRightBtn = () => {
|
|
|
+ if (chat_display_list.value.length) {
|
|
|
+ const last_item = chat_display_list.value.at(-1);
|
|
|
+ if (last_item.mindmap) {
|
|
|
+ show_right_page_btn.value = true;
|
|
|
+ }
|
|
|
+ if (last_item.client_custom_item_internet && last_item.client_custom_item_internet_list.length) {
|
|
|
+ show_right_page_btn.value = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
watch(
|
|
|
() => props.agent_id,
|
|
|
() => {
|
|
|
@@ -1641,6 +1748,9 @@ onMounted(() => {
|
|
|
}
|
|
|
|
|
|
chat_log_list.value = list;
|
|
|
+ console.log(chat_display_list.value);
|
|
|
+ // 处理最后一项是否有思维导图或者网页,有的话暂时右侧按钮
|
|
|
+ toShowRightBtn();
|
|
|
} else {
|
|
|
// 异常
|
|
|
// TODO:处理异常
|
|
|
@@ -1793,6 +1903,7 @@ defineExpose({
|
|
|
padding: 10px;
|
|
|
border-radius: 12px;
|
|
|
background-color: var(--color-bg-1);
|
|
|
+ box-sizing: border-box;
|
|
|
}
|
|
|
.conversation-chat-content {
|
|
|
flex-grow: 1;
|