Bladeren bron

feat|fix: 修复bug,完善项目

1. 修复FileNameDisplay.vue组件中的报错
2. 历史记录相关内容接入新的接口
zhupei 1 jaar geleden
bovenliggende
commit
5026fe2c40

+ 0 - 9
src/index.html

@@ -4,15 +4,6 @@
     <meta charset="UTF-8" />
     <link rel="icon" type="image/png" href="/logo.png" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-    <meta
-      name="keywords"
-      content="北京贝思科技术有限公司,贝思科,BASIC,basic,aiotlink,人工智能,大数据,AI技术,万物智能,人脸识别,智能安防,视频结构化,物联网,平安校园,公共安全,智能交通"
-    />
-    <meta
-      name="description"
-      content="北京贝思科技术有限公司是一家以“万物智能”为经营理念的创新型科技公司,是“人工智能+大数据”综合应用的解决方案供应商。在智能安防领域提供人脸识别、视频监控结构化分析等一系列人工智能产品及解决方案。"
-    />
-    <meta name="author" content="BASIC- 北京贝思科技术有限公司" />
     <title>大模型2.0</title>
     <script type="module" src="/config.js"></script>
   </head>

+ 2 - 2
src/modules/conversation-chat/DialogHeader.vue

@@ -1,12 +1,12 @@
 <template>
   <div class="dialog-header">
-    <div>{{ agent_info.agent.name }}</div>
+    <div>{{ agent_name }}</div>
   </div>
 </template>
 
 <script setup>
 const props = defineProps({
-  agent_info: Object
+  agent_name: String
 });
 </script>
 

+ 0 - 113
src/modules/conversation-chat/DialogInputTop copy.vue

@@ -1,113 +0,0 @@
-<template>
-  <div class="dialog-input-area-top-container">
-    <!-- 文档出卷 -->
-    <template v-if="menu_id === 7">
-      <!-- <BtnIframeChujuan /> -->
-
-      <BtnConfigChujuan @confirm="handleChujuanConfirm" />
-      <BtnConfigDynamic @confirm="handleChujuanConfirm" />
-    </template>
-
-    <template v-if="menu_id === 9">
-      <!-- 文档报告 -->
-      <a-space size="large">
-        <a-tooltip :content="radio_qingxi_text">
-          <a-radio :value="1" :model-value="act_type" @click="handleRadioClick(1)">文档清洗</a-radio>
-        </a-tooltip>
-
-        <a-tooltip :content="radio_shengcheng_text">
-          <a-radio :value="2" :model-value="act_type" @click="handleRadioClick(2)">报告生成</a-radio>
-        </a-tooltip>
-      </a-space>
-    </template>
-  </div>
-</template>
-
-<script setup>
-import { ref, onMounted, onUnmounted } from 'vue';
-
-import BtnIframeChujuan from '../btn-iframe-chujuan/BtnIframeChujuan.vue';
-import BtnConfigChujuan from '../btn-iframe-chujuan/BtnConfigChujuan.vue';
-import BtnConfigDynamic from '../form-dynamic/BtnConfigDynamic.vue';
-
-/**
- * 此组件用以处理对话的附加参数
- * 父组件通过ref调用此组件expose的两个方法
- */
-
-const props = defineProps({
-  disabled: Boolean,
-  /**
-   * 菜单ID
-   * 不同的值,对应不同的智能体
-   */
-  menu_id: Number
-});
-
-const act_type = ref(1);
-// const upload_warning_text = `支持上传文件pdf、docx文档(最多${MAX_ACCEPT_FILE}个,每个大小不超过10MB)`;
-const radio_qingxi_text = '对上传的文档进行清洗,输出生成清洗后的文档';
-const radio_shengcheng_text = '对上传的(经过清洗的)文档生成报告,输出生成的报告文档';
-// const emit = defineEmits(['change']);
-
-const menuid7_config_datas = ref({});
-
-const handleRadioClick = (value) => {
-  act_type.value = value / 1;
-};
-
-/**
- * 清空表单的内容
- */
-const clear = () => {};
-
-/**
- * 出卷的数据
- */
-const handleChujuanConfirm = (data) => {
-  menuid7_config_datas.value = data;
-};
-
-/**
- * 获取所有的数据
- * 父组件应该使用 ref,调用此参数
- */
-const getOptions = () => {
-  if (props.menu_id === 7) {
-    const obj = {};
-
-    const params = menuid7_config_datas.value;
-
-    for (let key in params) {
-      obj[key] = params[key];
-    }
-
-    return obj;
-  }
-
-  if (props.menu_id === 9) {
-    return {
-      workflow: act_type.value
-    };
-  }
-
-  return {};
-};
-
-defineExpose({
-  /**
-   * 清空表单里的内容
-   */
-  clear: clear,
-  /**
-   * 获取附件参数的键值对
-   */
-  getOptions: getOptions
-});
-</script>
-
-<style lang="css" scoped>
-.dialog-input-area-top-container {
-  margin-bottom: 10px;
-}
-</style>

+ 1 - 25
src/modules/conversation-chat/DialogInputTop.vue

@@ -16,11 +16,7 @@ import BtnConfigDynamic from '../form-dynamic/BtnConfigDynamic.vue';
 
 const props = defineProps({
   disabled: Boolean,
-  /**
-   * 菜单ID
-   * 不同的值,对应不同的智能体
-   */
-  menu_id: Number,
+
   /**
    * 对应的表单数据
    *
@@ -63,26 +59,6 @@ const getOptions = () => {
     obj[key] = params[key];
   }
   return obj;
-
-  // if (props.menu_id === 7) {
-  //   const obj = {};
-
-  //   const params = menuid7_config_datas.value;
-
-  //   for (let key in params) {
-  //     obj[key] = params[key];
-  //   }
-
-  //   return obj;
-  // }
-
-  // if (props.menu_id === 9) {
-  //   return {
-  //     workflow: act_type.value
-  //   };
-  // }
-
-  // return {};
 };
 
 defineExpose({

+ 1 - 3
src/modules/conversation-chat/DialogWelcome.vue

@@ -7,9 +7,7 @@
 </template>
 
 <script setup>
-const props = defineProps({
-  agent_info: Object
-});
+// const props = defineProps({});
 </script>
 
 <style lang="css" scoped>

+ 18 - 5
src/modules/conversation-dialog/api-dialog.js

@@ -136,13 +136,10 @@ export const uploadFileByAgentInfo = async (agent_id, chat_id, client_file, menu
     }
   } else {
     // 其他类型
-
-    console.log('uploadFileByAgentInfo', agent_id, chat_id, client_file, menu_id);
     const file_params = files2Formdata(client_file, 'file');
-    console.log(file_params, 11);
+
     // const uploadResult = await uploadFiles(agent_id, chat_id, file_params);
     const uploadResult = await uploadFilesV2(agent_id, chat_id, file_params);
-    console.log(uploadResult, 22);
 
     if (uploadResult.code / 1 === 200) {
       const file_uploaded = uploadResult.data;
@@ -185,6 +182,22 @@ export const getDialogChatId = (agent_id) => {
  * @param {String} conversation_id - 会话ID
  * @returns {Promise<Object>}
  */
-export const getHistoryLogs = (agent_id, conversation_id) => {
+export const getHistoryLogsV0 = (agent_id, conversation_id) => {
   return ajax.get(`/api/agent/${agent_id}/${conversation_id}/session_log`);
 };
+
+export const getHistoryLogs = (conversation_id) => {
+  return new Promise((resolve, reject) => {
+    ajax
+      .get(`/api/v1/chat/session_log?sessionId=${conversation_id}`)
+      .then((res) => {
+        resolve({
+          code: 200,
+          data: res
+        });
+      })
+      .catch((err) => {
+        reject(err);
+      });
+  });
+};

+ 19 - 4
src/modules/conversation-dialog/format-dialog-history.js

@@ -7,12 +7,27 @@ import formatDialogAnswerFromHistory from './format-dialog-answer-from-history';
 export default function formatDialogHistoryMessages(session_list, agentInfo) {
   const arr = [];
 
+  // session_list.forEach((item) => {
+  //   const question = formatDialogQuestionByHistory(item, agentInfo);
+  //   const answer = formatDialogAnswerFromHistory(item, agentInfo);
+
+  //   arr.push(question);
+  //   arr.push(answer);
+  // });
+
   session_list.forEach((item) => {
-    const question = formatDialogQuestionByHistory(item, agentInfo);
-    const answer = formatDialogAnswerFromHistory(item, agentInfo);
+    const role = item.role;
+
+    if (role === 'user') {
+      const question = formatDialogQuestionByHistory(item, agentInfo);
+      arr.push(question);
+    }
+
+    if (role === 'assistant') {
+      const answer = formatDialogAnswerFromHistory(item, agentInfo);
 
-    arr.push(question);
-    arr.push(answer);
+      arr.push(answer);
+    }
   });
 
   return arr;

+ 2 - 2
src/modules/conversation-dialog/format-dialog-question-by-history.js

@@ -33,7 +33,7 @@ export default function formatDialogQuestionByHistory(item, agentInfo) {
     // 图标
     client_custom_icon: icon_src,
 
-    client_custom_unique_id: generateClientUniqueId(item.question),
-    question: item.question
+    client_custom_unique_id: generateClientUniqueId(item.content),
+    question: item.content
   };
 }

+ 3 - 3
src/modules/conversation-history/HistoryItem.vue

@@ -90,7 +90,7 @@ const item_klass = computed(() => {
   };
 
   obj[`item-${props.index}`] = true; // 绑定序号
-  obj[`item-${props.history.id}`] = true; // 绑定唯一ID
+  obj[`item-${props.history.session_id}`] = true; // 绑定唯一ID
   obj[props.history.client_field_timestamp_type] = true;
 
   if (is_label_item.value) {
@@ -134,11 +134,11 @@ const time_display = computed(() => {
  * 分发ID值
  */
 const handleClick = () => {
-  emit('active', props.history.id);
+  emit('active', props.history.session_id);
 };
 
 const handleItemDelete = () => {
-  emit('delete', props.history.id);
+  emit('delete', props.history.session_id);
 };
 
 const handleDeleteSuccess = () => {

+ 60 - 1
src/modules/conversation-history/api-conversation-history.js

@@ -16,7 +16,7 @@ import { jsonStringify } from '../../utils/utils';
  * @param {number} params.page - 当前页码,从1开始
  * @param {number} params.per_page - 每页返回的数量
  */
-export const apiConversationHistoryList = (params) => {
+export const apiConversationHistoryListV1 = (params) => {
   // http://192.168.20.119:9301/api/agent/90d533729c0211efbf6b0242ac160006/sessions
 
   const agent_id = params.agent_id;
@@ -46,6 +46,65 @@ export const apiConversationHistoryList = (params) => {
   });
 };
 
+/**
+ * 获取会话历史记录
+ * 可以进入 http://192.168.20.116:8103/#/sessionManager 项目(以 admin/000000 登录),查看相关请求
+ * 示例链接1(普通列表):http://192.168.20.116:8103/api/conversation/list?modeltype=localragflow&dialogid=&page=1&per_page=50
+ * 示例链接2(搜索): http://192.168.20.116:8103/api/conversation/list?modeltype=localragflow&search=%E5%A6%82%E4%BD%95&dialogid=&page=1&per_page=50
+ * 注意:示例链接已经废弃
+ * 改为 同 小数 会话历史记录同接口
+ * @param {object} params
+ * @param {string} params.modeltype - 模型ID,例如:localragflow
+ * @param {string} params.dailogid - 会话ID
+ * @param {string} params.agent_id - 智能体的ID
+ * @param {string} params.search - 搜索字符串
+ * @param {number} params.page - 当前页码,从1开始
+ * @param {number} params.per_page - 每页返回的数量
+ */
+export const apiConversationHistoryList = (params) => {
+  // http://192.168.20.119:9301/api/agent/90d533729c0211efbf6b0242ac160006/sessions
+
+  const agent_id = params.agent_id;
+
+  if (!agent_id) {
+    return Promise.reject(new Error('前端异常:Invalid Agent ID'));
+  }
+
+  const request_url = `/api/v1/chat/sessions`;
+
+  const send_data = {
+    chatId: agent_id
+  };
+
+  if ('per_page' in params) {
+    send_data.pageSize = params.per_page / 1;
+  }
+  if ('page' in params) {
+    send_data.current = params.page / 1;
+  }
+  if ('search' in params && params.search) {
+    send_data.keyword = params.search;
+  }
+
+  return new Promise((resolve, reject) => {
+    ajax({
+      url: request_url,
+      method: 'get',
+      params: send_data
+    })
+      .then((res) => {
+        // 后端接口没有再返回code字段,此处统一返回code=200
+        resolve({
+          code: 200,
+          data: res
+        });
+      })
+      .catch((err) => {
+        reject(err);
+      });
+  });
+};
+
 /**
  * 删除某个会话记录
  * 链接:http://192.168.20.116:8103/api/v1/conversation/rm?modeltype=localragflow

+ 8 - 3
src/modules/file-name/FileNameDisplay.vue

@@ -18,11 +18,16 @@ const props = defineProps({
  * 文件后缀名
  */
 const file_endfix = (function () {
-  const arr = props.file_name.split('.');
+  const f_name = props.file_name;
+  if (f_name) {
+    const arr = props.file_name.split('.');
 
-  const str = arr[arr.length - 1];
+    const str = arr[arr.length - 1];
 
-  return str;
+    return str;
+  } else {
+    return '';
+  }
 })();
 
 const is_pdf = file_endfix === 'pdf';

+ 36 - 29
src/views/ConversationQA.vue

@@ -8,7 +8,7 @@
           :agent_id="chat_agent"
           :CHAT_AGENT_INFOMATION="CHAT_AGENT_INFOMATION"
           :session_id="chat_session"
-          :key="chat_agent"
+          :key="chat_key"
           :conversation_params="conversation_params"
         />
       </template>
@@ -27,7 +27,7 @@
 </template>
 
 <script setup>
-import { ref, onMounted, onBeforeUpdate } from 'vue';
+import { ref, computed, onMounted, onBeforeUpdate, watch } from 'vue';
 import { useRoute, useRouter, onBeforeRouteUpdate } from 'vue-router';
 import LayoutExperience from './layout/LayoutExperience.vue';
 import ContentContainer from './layout/ContentContainer.vue';
@@ -72,6 +72,16 @@ const allAgent = useAllAgentStore();
 const chat_agent = ref('');
 const chat_session = ref('');
 
+/**
+ * 对话区域的唯一ID
+ * 智能体的ID + 当前路由地址
+ */
+const chat_key = ref(chat_agent.value + window.location.href);
+
+watch(route, (to) => {
+  chat_key.value = chat_agent.value + window.location.href;
+});
+
 /**
  * 对话使用到的agent信息
  * agent属性是由接口返回的数据
@@ -183,41 +193,35 @@ function comfirmAgent(agent_id) {
 }
 
 async function init() {
+  const route = useRoute();
+
   const query = route.query;
 
   const agent_id = query.agent;
   const session_id = query.session;
 
   if (!agent_id) {
-    // 不存在参数
-    // ------------------------------------------------------
-    // ------------------------------------------------------
-    // ------------------------------------------------------
-    // ------------------------------------------------------
-    // 使用默认的通用agent创建对话
-    /**
-     * 如果没有agent参数,则使用默认的agent
-     * 默认的agent,和赵秦刚沟通,为知识问答(2024-12-18)
-     * 下列为知识问答的ID
-     */
+    // 路由中不存在智能体ID参数
+    // 获取到默认的智能体ID
     const default_agent_id = await getDefaultAgentId();
 
-    // /**
-    //  * 根据agent_id 查询到agent的基本信息
-    //  * 从而确定agent的相关功能支持,例如:是否需要上传文件,支持上传什么类型的文件、支持上传多少个文件?
-    //  * 例如:主题、背景、等等
-    //  */
-    // CHAT_AGENT_INFOMATION.value = getChatAgentInfomation(default_agent_id);
+    // 将路由重置为包含agent参数的地址
+    router.replace({
+      path: '/chat/qa',
+      query: {
+        agent: default_agent_id
+      }
+    });
 
-    // chat_agent.value = default_agent_id;
-    comfirmAgent(default_agent_id);
-    // ------------------------------------------------------
-    // ------------------------------------------------------
-    // ------------------------------------------------------
-    // ------------------------------------------------------
+    // // chat_agent.value = default_agent_id;
+    // comfirmAgent(default_agent_id);
+    // // ------------------------------------------------------
+    // // ------------------------------------------------------
+    // // ------------------------------------------------------
+    // // ------------------------------------------------------
 
-    query_value_status.value = 2;
-    query_value_message.value = 'success';
+    // query_value_status.value = 2;
+    // query_value_message.value = 'success';
   } else {
     // 有agent参数
     // 判断已经缓存的agent列表是否存在
@@ -254,11 +258,14 @@ async function init() {
  * 监听路由参数的变化
  */
 onBeforeRouteUpdate(async (to, from) => {
-  // // 路由发生了变化
   if (to.path === '/chat' || to.path === '/chat/qa') {
-    const default_agent_id = await getDefaultAgentId();
+    if (!to.query.session) {
+      chat_session.value = null;
+    }
 
     if (!to.query.agent) {
+      const default_agent_id = await getDefaultAgentId();
+
       chat_agent.value = default_agent_id;
 
       router.replace({

+ 0 - 1040
src/views/conversation/ConversationChatContainer copy.vue

@@ -1,1040 +0,0 @@
-<template>
-  <div class="conversation-chat-container">
-    <div class="conversation-chat-main" ref="chat_scrren_container">
-      <DialogHeader class="conversation-chat-header" :agent_info="CHAT_AGENT_INFOMATION" :style="style_header" />
-
-      <div class="conversation-chat-content" :style="style_body">
-        <div class="conversation-chat-main-container">
-          <template v-if="show_welcome">
-            <!-- 有会话ID 获取历史记录,显示加载中状态 -->
-            <div v-if="session_id" class="conversation-chat-area history-list-loading">
-              <div class="scroll-left"></div>
-              <div class="history-list-loading-container"><a-spin /></div>
-              <div class="scroll-right"></div>
-            </div>
-
-            <!-- 无会话ID,直接对话,此时可现实欢迎消息:欢迎使用报表合并、欢迎使用文档智能、欢迎使用小数绘图 -->
-            <DialogWelcome v-if="!session_id" class="conversation-chat-area" :agent_info="CHAT_AGENT_INFOMATION" />
-          </template>
-
-          <DialogList
-            v-if="!show_welcome"
-            ref="list_scroller"
-            class="conversation-chat-area"
-            :height="list_height"
-            :width="chat_width / 2"
-            :agent_id="agent_id"
-            :list="chat_display_list"
-            :suggestion="chat_suggestion"
-            :answer_action_list="answer_action_list"
-            @share="handleChatShare"
-            @submit="handleSuggestSubmit"
-          >
-            <template v-slot:left>
-              <div class="scroll-left"></div>
-            </template>
-            <template v-slot:right>
-              <div class="scroll-right"></div>
-            </template>
-          </DialogList>
-        </div>
-
-        <DialogInput
-          ref="dialog_input"
-          class="conversation-chat-input"
-          :style="input_style"
-          :disabled="input_disabled"
-          :enable_text_input="enable_text_input"
-          :enable_file_upload="enable_file_upload"
-          :file_accept="file_accept"
-          :width="chat_width / 2"
-          @sizeChange="handleInputSizeChange"
-          @submit="handleInputSubmit"
-        >
-          <template v-if="show_input_others_opts" v-slot:top>
-            <DialogInputTop
-              :menu_id="current_menu_id"
-              :agent_info="CHAT_AGENT_INFOMATION"
-              :user_input_form="conversation_params.user_input_form"
-              ref="dialog_input_top"
-            />
-          </template>
-
-          <template v-slot:left>
-            <div class="scroll-left"></div>
-          </template>
-          <template v-slot:right>
-            <div class="scroll-right"></div>
-          </template>
-        </DialogInput>
-      </div>
-
-      <DialogFooter class="conversation-chat-footer" :style="style_footer" />
-    </div>
-  </div>
-</template>
-
-<script setup>
-import { ref, onMounted, onUnmounted, computed, nextTick } from 'vue';
-import { useI18n } from 'vue-i18n';
-// import { Message } from '@arco-design/web-vue';
-import { Message } from '../../3rd-libs/arco-vue-libs';
-
-import { jsonStringify } from '../../utils/utils';
-
-import DialogHeader from '../../modules/conversation-chat/DialogHeader.vue';
-import DialogWelcome from '../../modules/conversation-chat/DialogWelcome.vue';
-import DialogList from '../../modules/conversation-chat/DialogList.vue';
-import DialogInput from '../../modules/conversation-chat/DialogInput.vue';
-// import DialogInputAttachedAttrs from '../../modules/conversation-chat/DialogInputAttachedAttrs.vue';
-import DialogInputTop from '../../modules/conversation-chat/DialogInputTop.vue';
-import DialogFooter from '../../modules/conversation-chat/DialogFooter.vue';
-
-import useWebSocketChat from '../../modules/conversation-dialog/use-websocket-chat';
-import { getHistoryLogs, getDialogChatId, uploadFileByAgentInfo } from '../../modules/conversation-dialog/api-dialog';
-
-import formatDialogSendOptions from '../../modules/conversation-dialog/format-dialog-send-options';
-
-import formatDialogHistory from '../../modules/conversation-dialog/format-dialog-history';
-
-import formatDialogQuestionByClient from '../../modules/conversation-dialog/format-dialog-question-by-client';
-import formatDialogAnswerForLoading from '../../modules/conversation-dialog/format-dialog-answer-for-loading';
-import formatDialogAnswerForException from '../../modules/conversation-dialog/format-dialog-answer-for-exception';
-import formatDialogAnswerFromWebsocketReceiveMessage from '../../modules/conversation-dialog/format-dialog-answer-from-websocket_receive_message';
-
-import useEleSizeV1 from '../../utils/use-ele-size-v1';
-import useInputClear from './use-input-clear';
-import useInputGetOptions from './use-input-get-options';
-import useScroll2Bottom from './use-scroll-bottom';
-
-const props = defineProps({
-  /**
-   * 智能体的ID
-   * 此参数必须传递
-   */
-  agent_id: String,
-  /**
-   * 智能体的一些关键信息
-   */
-  CHAT_AGENT_INFOMATION: Object,
-
-  /**
-   * 会话ID
-   * 如果有此参数,则意味着获取该对话的记录内容
-   */
-  session_id: String,
-  /**
-   * 动态表单数据
-   * 根据智能体的agent_id 获取到动态表单数据
-   * */
-  conversation_params: Object
-});
-
-const i18n = useI18n();
-
-/**
- * input的一些操作方法
- */
-const inputClearFn1 = useInputClear('dialog_input'); // 主表单清空
-const inputClearFn2 = useInputClear('dialog_input_top'); // 顶部附加表单的数据
-const getInputTopOptions = useInputGetOptions('dialog_input_top'); // 获取附加表单参数的方法
-
-/**
- * 对话区域滚动到底部
- */
-const scroll2Bottom = useScroll2Bottom('list_scroller');
-const scroll2ListBottom = () => {
-  nextTick(() => {
-    scroll2Bottom();
-  });
-};
-
-/**
- * 整个对话区域的一些尺寸定义
- */
-const header_height = 30;
-const footer_height = 30;
-const input_height = ref(100);
-
-/**
- * 获取到对话区域的宽度和高度
- */
-const { width: chat_width, height: chat_height } = useEleSizeV1('chat_scrren_container');
-
-/**
- * 对话列表区域的高度
- */
-const list_height = computed(() => {
-  return chat_height.value - header_height - footer_height - input_height.value - 20;
-});
-
-const input_style = computed(() => {
-  return {
-    // height: input_height + 'px'
-  };
-});
-
-const style_header = computed(() => {
-  return { height: header_height + 'px' };
-});
-const style_body = computed(() => {
-  return { height: chat_height - 30 - 30 + 'px' };
-});
-const style_footer = computed(() => {
-  return { height: footer_height + 'px' };
-});
-
-// ------------------------------------------------------------------
-// ------------------------------------------------------------------
-// ------------------------------------------------------------------
-
-/**
- * 对话数据列表
- */
-const chat_log_list = ref([]); // 历史对话的数据列表
-const chat_new_list = ref([]); // 新对话的数据列表
-const chat_suggestion = ref([]); // 对话推荐项目
-
-/**
- * 当前对话使用的ID
- * 当用户有输入后,点击提交,此时创建新对话,新对话的ID为此ID
- * 之后用户可以一直使用此ID进行对话。
- */
-const chat_round_id = ref(null);
-
-/**
- * 对话发起的次数记录
- * 用户每发起一次会话,此值会加1
- */
-const chat_round_sent_count = ref(0);
-
-/**
- * 新对话,客户端的提问数据
- * 用以临时保存客户端的提问数据
- * 每当用户确认进行提问时,将新提问赋给此值
- * 一旦对话消息通过websocket发送到服务器,此值可清空
- */
-const chat_new_question = ref({});
-
-/**
- * 界面展示的对话列表
- * 当用户从历史会话进入时,历史会话记录有数据,当用户基于历史会话进行对话时,新会话也有数据,
- * 当用户从agent进入时,仅有新会话,没有历史会话
- *
- * 页面渲染的会话列表是 历史会话 + 新会话数据
- */
-const chat_display_list = computed(() => {
-  return [].concat(chat_log_list.value, chat_new_list.value);
-});
-
-/**
- * 是否禁用输入组件
- */
-const input_disabled = ref(false);
-
-/**
- * 菜单ID编号
- * 1 报表合并
- * 2 知识问答
- * 3 文档智能
- * 4 智能问答
- * 5 智能数据
- * 6 小数绘图
- * 7 文档出卷
- * 8 出题组卷
- * 9 文档报告
- */
-const current_menu_id = computed(() => {
-  const agent = props.CHAT_AGENT_INFOMATION.agent;
-  const menu_id = agent.menuId / 1;
-  return menu_id;
-});
-
-/**
- * 是否显示欢迎页
- * 当用户进入对话页面,还未正式开始对话时
- * 对话区域会显示欢迎内容
- * 当用户开始对话时,欢迎内容消失,对话列表开始展示
- */
-const show_welcome = ref(true);
-
-/**
- * 表单区域:是否显示附加参数表单
- *
- * 根据动态表单返回的数据中user_input_form中是否有数据来控制是否显示附加参数表单
- */
-const show_input_others_opts = computed(() => {
-  if (
-    props.conversation_params &&
-    props.conversation_params.user_input_form &&
-    props.conversation_params.user_input_form.length
-  ) {
-    return true;
-  }
-  return false;
-
-  // const menu_id = current_menu_id.value;
-
-  // /**
-  //  * 7 文档出卷
-  //  * 9 文档报告
-  //  */
-  // if (menu_id === 7 || menu_id === 9) {
-  //   return true;
-  // }
-
-  // return false;
-});
-
-/**
- * 是否支持文本输入
- * 返回 true,输入区域将不存在文本输入框
- * 返回 false,输入区域将可以进行文本输入
- *
- *通过conversation_params.retriever_resource.enabled来控制是否支持文本输入
- */
-const enable_text_input = computed(() => {
-  let enabled = false;
-  if (props.conversation_params && props.conversation_params.retriever_resource) {
-    enabled = props.conversation_params.retriever_resource.enabled;
-    console.log('enable_text_input', enabled);
-  }
-  return enabled;
-  // const menu_id = current_menu_id.value;
-
-  // /**
-  //  * 1 报表合并:上传几个文档,进行合并  允许 .xlsx
-  //  * 无需输入
-  //  */
-  // if (menu_id === 1) {
-  //   return false;
-  // }
-
-  // // if (menu_id === 7) {
-  // //   return false;
-  // // }
-
-  // return true;
-});
-
-/**
- * 对话文本是否必须
- * 此值如果为 true,则在发起对话之前,会进行 文本的存在性检查
- * 此值如果为 false,则在发起对话之前,不会进行 文件存在性检查
- */
-const is_chat_text_required = computed(() => {
-  const is_enable = enable_text_input.value;
-  if (!is_enable) {
-    return false;
-  }
-
-  return true;
-});
-
-/**
- * 默认的文本值
- */
-const default_text_value = computed(() => {
-  const menu_id = current_menu_id.value;
-
-  /**
-   * 某些情况下,无需输入文本
-   * 但是在对话部分,需要展示用户的提问,此时可以给一个默认的文本值
-   * 例如在报表合并情况下,仅需要上传文件,不需要输入文字
-   */
-  if (menu_id === 1) {
-    return '合并Excel';
-  }
-
-  return '';
-});
-
-/**
- * 表单区域:是否允许文件上传
- * 返回 ture,输入区域将会有文件上传按钮
- * 返回 false,输入区域将没有文件上传按钮
- *
- * 根据 conversation_params.file_upload.enabled来控制是否允许文件上传
- */
-const enable_file_upload = computed(() => {
-  let enabled = false;
-  if (props.conversation_params && props.conversation_params.file_upload) {
-    enabled = props.conversation_params.file_upload.enabled;
-  }
-  return enabled;
-
-  // const menu_id = current_menu_id.value;
-  // /**
-  //  * 1 报表合并:上传几个文档,进行合并  允许 .xlsx
-  //  * 3 文档智能:上传文档,让智能体进行解析 允许: .pdf/.docx
-  //  * 5 智能数据:上传Excel,生成饼状图 允许 .xlsx
-  //  * 6 小数绘图:上传图片,描述图片的内容 允许 .png/jpg/jpeg
-  //  * 9 文档报告: 允许 .docx
-  //  */
-  // if (menu_id === 1 || menu_id === 3 || menu_id === 5 || menu_id === 6 || menu_id === 9) {
-  //   return true;
-  // }
-  // // 文档出卷
-  // if (menu_id === 7) {
-  //   return true;
-  // }
-  // return false;
-});
-
-/**
- * 对话文件是否必须上传
- * 此值如果返回 true,则 在对话时,会进行文件检查
- * 此值如果返回 false,则 在对话时,不会检查文件的存在性
- */
-const is_chat_file_required = computed(() => {
-  const is_enable = enable_file_upload.value;
-  if (!is_enable) {
-    return false;
-  }
-
-  const menu_id = current_menu_id.value;
-
-  // 报表合并: 文件必须
-  if (menu_id === 1) {
-    // 当第一次会话时,要求必须上传文件
-    // 非第一次,不做要求
-    if (chat_round_sent_count.value === 0) {
-      return true;
-    }
-  }
-
-  // 文档出卷:文件必须上传
-  if (menu_id === 7) {
-    // 当第一次对话时,必须上传文件,
-    // 非第一次,不做要求
-    if (chat_round_sent_count.value === 0) {
-      return true;
-    }
-  }
-
-  return false;
-});
-/**
- * 此值在 enable_file_upload === true 的前提下有效
- * 表单区域:文件上传允许的文件类型
- * 对应表单参数的 accept
- */
-const file_accept = computed(() => {
-  const menu_id = current_menu_id.value;
-
-  /**
-   * 1 报表合并:上传几个文档,进行合并  允许 .xlsx
-   * 3 文档智能:上传文档,让智能体进行解析 允许: .pdf/.docx
-   * 5 智能数据:上传Excel,生成饼状图 允许 .xlsx
-   * 6 小数绘图:上传图片,描述图片的内容 允许 .png/jpg/jpeg
-   * 9 文档报告: 允许 .docx
-   */
-  if (menu_id === 1) {
-    return '.xlsx';
-  }
-
-  if (menu_id === 3) {
-    /**
-     * 2025-2-8 16:50
-     * 王永新和赵源在测试deepseek时发现 文档智能 能上传的文件类型有限
-     * 要求将accept调整为和dify的 文档 类型一致
-     */
-    // return '.pdf,.docx';
-    return '.txt,.md,.markdown,.pdf,.html,.xlsx,.xls,.docx,.csv,.eml,.msg,.pptx,.ppt,.xml,.epub';
-  }
-
-  // 智能数据
-  if (menu_id === 5) {
-    return '.xlsx,.xls,.csv';
-  }
-
-  if (menu_id === 6) {
-    return '.jpg,.jpeg,.png';
-  }
-
-  if (menu_id === 9) {
-    return '.docx';
-  }
-
-  return '*';
-});
-
-/**
- * 答案可用的操作按钮
- * 可用的值有 [] 或者 ['copy']
- * 后续可能有新值添加
- */
-const answer_action_list = computed(() => {
-  const menu_id = current_menu_id.value;
-
-  // 报表合并无操作按钮
-  if (menu_id === 1) {
-    return [];
-  }
-
-  return ['copy'];
-});
-
-/**
- * 内容分享操作
- * @param chat_id
- */
-const handleChatShare = (chat_id) => {};
-/**
- * 在聊天界面点击推荐项
- * 继续对话
- */
-const handleSuggestSubmit = (suggest) => {};
-
-/**
- * 处理页面中的错误消息
- * @param msg
- */
-const handleErrorMessage = (msg) => {
-  Message.error({ content: msg, position: 'top' });
-};
-// ---------------------------------------------
-
-/**
- * 异常处理
- * 异常处理过程是一个会话模拟的过程
- * 先在界面上显示加载动画,然后紧接着显示错误提示
- * 让用户感知到智能体有处理数据的过程
- * 所以在异常处理阶段,有一些需要处理的关键点,比如欢迎界面的显示(如果在显示,则需要隐藏,否则对话显示不了)
- * @param exceptionInfo
- */
-const handleChatRequestionException = (exceptionInfo) => {
-  // 已结束
-  const answerData = formatDialogAnswerForException(props.CHAT_AGENT_INFOMATION, exceptionInfo);
-
-  // 原来的最后一项弹出
-  chat_new_list.value.pop();
-  // 添加新的最后一项
-  chat_new_list.value.push(answerData);
-
-  // 对话已结束:文件上传、文本输入区域放开使用
-  input_disabled.value = false;
-  // 对话区域滚动到底部
-  scroll2ListBottom();
-};
-
-/**
- * 输入区域的尺寸发生了变化
- * 整个对话区域的尺寸也需要依据此变化而变化
- * @param size
- */
-const handleInputSizeChange = (size) => {
-  const input_width = size.width;
-  // const input_height = size.height;
-
-  setTimeout(() => {
-    input_height.value = size.height;
-  });
-};
-
-/**
- * 输入已经确认要提交了
- *
- * 1. 创建会话 get-chat-id
- * 2. 文件上传 如果有文件,则需要文件上传,没有文件,则不需要文件上传
- * 3. 连接socket,socket 发送文本与文件数据内容
- * 4. 接收 socket 返回的数据项
- */
-const handleInputSubmit = async (options) => {
-  let ask_text = options.text; // 文本
-  const ask_files = options.files; // 文件列表
-
-  // 用户选定的文件数量
-  const file_total = ask_files.length;
-
-  const is_text_required = is_chat_text_required.value;
-  const is_file_required = is_chat_file_required.value;
-
-  // 检查对话文字是否必须
-  if (is_text_required) {
-    if (!ask_text) {
-      const msg = i18n.t('conversation.please_input_text');
-
-      handleErrorMessage(msg);
-      return;
-    }
-  } else {
-    ask_text = default_text_value.value;
-  }
-
-  // 检查对话文件是否必须
-  if (is_file_required) {
-    if (file_total === 0) {
-      const msg = i18n.t('conversation.please_upload_file');
-
-      handleErrorMessage(msg);
-      return;
-    }
-  }
-
-  // --------------------------------------------
-  // --------------------------------------------
-  // --------------------------------------------
-  // --------------------------------------------
-  // --------------------------------------------消息发送前的准备工作
-  // 保存附加参数数据,由于下方有一个 inputClearFn2() 方法的执行
-  // 会将所有数据清空,故附件参数需要在清理之前保存
-  const other_options = getInputTopOptions();
-
-  /**
-   * 当新消息发送时
-   * 意味着新一轮对话的开始
-   * 此时应该将之前一轮对话的信息进行清空
-   *
-   * 整理客户端提问的数据
-   * 组装Question数据
-   */
-  const client_question = formatDialogQuestionByClient(ask_text, ask_files);
-  // 保存用户的提问信息
-  // 当消息正式发出后,将提问数据放入列表中
-  chat_new_question.value = client_question;
-  // 消息即将发送,记录用户的提问数据
-  chat_new_list.value.push(chat_new_question.value);
-  // 客户端答案数据(loading状态),客户端模拟的答案数据,依据此数据展示加载中的动画
-  const answerLoadingMsg = formatDialogAnswerForLoading(props.CHAT_AGENT_INFOMATION);
-  chat_new_list.value.push(answerLoadingMsg);
-  /**
-   * 会话已确认发送
-   * 隐藏欢迎内容,显示对话内容
-   */
-  show_welcome.value = false;
-  // 清空文本数据和文件数据,避免下一次会话冲突
-  // 清空表单里的数据
-  inputClearFn1();
-  inputClearFn2();
-  // 清空可能存在的推荐项目
-  chat_suggestion.value = [];
-  // 清空已保存的提问数据(提问数据已经推入数组,此处无需继续保存)
-  chat_new_question.value = null;
-  // 文件上传、文本输入区域禁用
-  input_disabled.value = true;
-  // 对话区域滚动到底部
-  scroll2ListBottom();
-  // --------------------------------------------
-  // --------------------------------------------
-  // --------------------------------------------
-  // --------------------------------------------
-  // --------------------------------------------
-
-  const agent_id = props.agent_id;
-
-  // 对话分为三个步骤
-  // 1. 创建会话,如果已经创建,则不需要再次创建
-  // 2. 上传文件,如果不存在文件,则无需文件上传
-  // 3. 连接websocket
-
-  /**
-   * 创建会话 get chat id
-   * 判断对话是否已经创建
-   * 如果对话已经创建,则使用已经创建的对话
-   * 否则,创建新对话
-   */
-  if (chat_round_id.value === null) {
-    // 未创建chat,开始创建
-    try {
-      const chatResult = await getDialogChatId(agent_id);
-
-      if (chatResult.code / 1 === 200) {
-        // 成功
-        const res_data = chatResult.data;
-
-        chat_round_id.value = res_data.chat_id;
-      } else {
-        // 失败
-        // 处理异常:直接在界面上显示
-        handleChatRequestionException({
-          message: `code: ${chatResult.code} message: ${chatResult.msg}`
-        });
-
-        return;
-      }
-    } catch (err) {
-      console.log('err-nfsdnakiuwirea7', err);
-
-      // 处理错误
-      handleChatRequestionException({
-        message: err.message
-      });
-
-      return;
-    }
-  } else {
-    // 已创建chat,使用已创建的会话ID,进入下一步流程
-  }
-
-  // 文件上传后的信息
-  let files_response = null;
-  /**
-   * 如果存在文件数据,则进行文件上传
-   */
-  if (file_total !== 0) {
-    // 进行文件上传,获取文件信息
-    const chat_id = chat_round_id.value;
-
-    try {
-      const menu_id = current_menu_id.value;
-      const uploadResult = await uploadFileByAgentInfo(agent_id, chat_id, ask_files, menu_id);
-
-      if (uploadResult.code / 1 === 200) {
-        // 文件上传成功
-        files_response = uploadResult.data;
-      } else {
-        // 文件上传异常
-        handleChatRequestionException({
-          message: `code: ${uploadResult.code} \n\n message: ${uploadResult.msg}`
-        });
-
-        return;
-      }
-    } catch (err) {
-      console.log('err-fhskafhakfjslkfjl', err);
-
-      handleChatRequestionException({
-        message: err.message
-      });
-
-      return;
-    }
-  }
-  // TODO: 重新组装sse参数,调用sse接口问答
-
-  /**
-   * 组装参数
-   * 组装socket参数: 文本和文件
-   * 此方法会依据当前使用的agent,组装好传递给websocket的 基础的文本和文件的参数
-   */
-  const menu_id = current_menu_id.value;
-  const msg_obj = formatDialogSendOptions(ask_text, files_response, menu_id);
-
-  /**
-   * 文本和文件的数据已经组装完成
-   * 在某些情况下,仅有文本和文件还不够,可能还有其他控制参数
-   * 在这种情况下,可以通过 DialogInputTop 获取到附加参数
-   * 添加附加参数
-   * 附加参数应该是 一个 键值对 对象,最终和和已有的 文本参数和文件参数 合并成 一个 新的键值对 对象 发送给websocket
-   */
-  // 获取附加表单的数据项目
-  if (other_options && typeof other_options === 'object') {
-    for (let key in other_options) {
-      msg_obj[key] = other_options[key];
-    }
-  }
-
-  /**
-   * 所有参数已经正式组装完成,将对象格式转换为字符串
-   */
-  const msg_str = jsonStringify(msg_obj);
-  // 发送websocket消息
-  handleWSSend(chat_round_id.value, msg_str);
-};
-
-/**
- * ------------------------------------------------------------
- * websocket定义以及初始化
- */
-const wsTrigger = {
-  /**
-   * 当websocket消息回来后
-   * @param e
-   */
-  onMessage: handleWSMessage,
-  /**
-   * 当websocket消息出错时
-   * @param e
-   */
-  onError: handleWSError,
-  /**
-   * 当websocket消息关闭时
-   * @param e
-   */
-  onClose: handleWSClose
-};
-
-/**
- * 初始化websocket相关的一些方法
- */
-const { initWSConnection, sendWSMessage, getWSInstance, closeWSConnect } = useWebSocketChat(wsTrigger);
-
-/**
- * 发送websocket消息
- * @param chat_id - 对话记录的ID
- * @param value
- */
-function handleWSSend(chat_id, value) {
-  /**
-   * -----------------------------------------------------------
-   * -----------------------------------------------------------
-   * -----------------------------------------------------------
-   * websocket消息正式发送,发送步骤:
-   * 1. 初始化链接
-   * 2. 发送消息
-   */
-
-  //  初始化websocket连接
-  const menu_id = current_menu_id.value;
-  initWSConnection(props.agent_id, chat_id, menu_id);
-  // 发送socket连接
-  sendWSMessage(value);
-  // 统计会话发起的次数
-  chat_round_sent_count.value = chat_round_sent_count.value + 1;
-  /**
-   * websocket消息发送流程完成
-   * ------------------------------------------------------------
-   * ------------------------------------------------------------
-   * ------------------------------------------------------------
-   */
-}
-
-/**
- * 接收websocket消息
- * @param e
- */
-function handleWSMessage(e) {
-  const res_data = e.data;
-
-  // 获取当前对话中最后一个对话数据
-  // 最后一个对话数据为当前正在进行的对话
-  const last_msg = chat_new_list.value[chat_new_list.value.length - 1];
-
-  /**
-   * 整理返回的数据
-   */
-  const currentChat = formatDialogAnswerFromWebsocketReceiveMessage(res_data, last_msg, props.CHAT_AGENT_INFOMATION);
-  const chat_status = currentChat.status;
-  const chat_message = currentChat.message;
-
-  // 处理对话数据
-  const handleChatData = () => {
-    const chat_data = currentChat.data; // 对话相关的数据项
-
-    // 原来的最后一项弹出
-    chat_new_list.value.pop();
-    // 添加新的最后一项
-    chat_new_list.value.push(chat_data);
-
-    // 滚动到底部
-    scroll2ListBottom();
-  };
-
-  if (chat_status === 0) {
-    // 未开始: 此状态不存在,无需处理
-  }
-
-  if (chat_status === 1) {
-    // 此轮对话仍然在进行中
-    handleChatData();
-  }
-
-  if (chat_status === 2) {
-    // 此轮对话已结束
-    handleChatData();
-
-    // 对话已结束:检查是否存在推荐数据
-    const chat_suggest = currentChat.suggest; // 对话相关的推荐数据
-    if (chat_suggest) {
-      chat_suggestion.value = chat_suggest;
-    }
-
-    // 对话已结束:文件上传、文本输入区域放开使用
-    input_disabled.value = false;
-  }
-
-  if (chat_status === 3) {
-    // 此轮对话出错了
-    // TODO: 错误处理
-
-    // 此轮对话已结束
-    handleChatData();
-    // 对话已结束:文件上传、文本输入区域放开使用
-    input_disabled.value = false;
-  }
-}
-
-/**
- * 处理websocket错误
- * @param e
- */
-function handleWSError(e) {
-  console.log('socket-error-8jfdksagjsfdjaklnfsdajkl', e);
-  handleChatRequestionException({
-    message: `对话无法继续:WebSocket Error: ${e.target.url}`
-  });
-}
-
-/**
- * 处理websocket关闭事件
- * @param e
- */
-function handleWSClose(e) {}
-
-onMounted(() => {
-  const agent_id = props.agent_id;
-  const session_id = props.session_id;
-
-  // 组件挂载
-  if (session_id) {
-    // 有历史记录:获取历史记录内容进行展示
-    getHistoryLogs(agent_id, session_id)
-      .then((res) => {
-        if (res.code / 1 === 200) {
-          // 成功
-          const session_list = res.data;
-
-          // 将列表数据进行转化
-          const list = formatDialogHistory(session_list, props.CHAT_AGENT_INFOMATION);
-
-          // 如果历史记录不为空
-          // 则需要展示对话内容
-          // 此时欢迎内容就不需要展示
-          if (list.length !== 0) {
-            show_welcome.value = false;
-            // 滚动到底部
-            scroll2ListBottom();
-          }
-
-          chat_log_list.value = list;
-        } else {
-          // 异常
-          // TODO:处理异常
-          show_welcome.value = false;
-          // handleChatRequestionException({
-          //   message: res.msg
-          // });
-
-          // 使用消息提示,而非界面错误提示
-          handleErrorMessage('历史会话异常:' + res.msg);
-        }
-      })
-      .catch((err) => {
-        console.log('err-mfsjakfjsdkalfjs', err);
-
-        show_welcome.value = false;
-        // handleChatRequestionException({
-        //   message: err.message
-        // });
-
-        handleErrorMessage('历史会话错误:' + err.message);
-      });
-  } else {
-    // 无历史记录:等待创建会话内容(用户开始输入、提交完成),列表区域显示欢迎界面
-  }
-});
-
-// ---------------------------------------------------------
-onUnmounted(() => {
-  // 组件卸载,关闭组件内的websocket连接
-  closeWSConnect();
-});
-</script>
-
-<style lang="css" scoped>
-.conversation-chat-container {
-  display: flex;
-  justify-content: center;
-
-  margin-left: auto;
-  margin-right: auto;
-
-  height: calc(100% - 52px);
-
-  padding-top: 52px;
-}
-
-.conversation-chat-left {
-  width: 25%;
-  flex-shrink: 0;
-}
-.conversation-chat-right {
-  width: 25%;
-  flex-shrink: 0;
-}
-.conversation-chat-main {
-  flex-grow: 1;
-  height: 100%;
-  /* max-width: 960px; */
-  margin-left: auto;
-  margin-right: auto;
-
-  display: flex;
-  flex-direction: column;
-
-  /* background-color: #aaa; */
-}
-.conversation-chat-content {
-  flex-grow: 1;
-
-  display: flex;
-  flex-direction: column;
-
-  overflow: hidden;
-
-  padding-top: 8px;
-}
-.conversation-chat-main-container {
-  /* height: 80%; */
-  flex-grow: 1;
-}
-.conversation-chat-area {
-  flex-grow: 1;
-  overflow: auto;
-  /* max-width: 960px; */
-}
-
-.history-list-loading {
-  display: flex;
-  justify-content: space-between;
-  align-items: center;
-  min-height: 300px;
-  width: 100%;
-}
-.history-list-loading-container {
-  display: flex;
-  justify-content: center;
-  align-items: center;
-}
-.conversation-input-attached {
-  flex-shrink: 0;
-
-  width: 100%;
-
-  margin-left: auto;
-  margin-right: auto;
-
-  /* margin-top: 5px; */
-  margin-bottom: -10px;
-  padding: 5px;
-  border-radius: 10px;
-
-  display: flex;
-}
-.conversation-chat-input {
-  flex-shrink: 0;
-
-  width: 100%;
-
-  margin-left: auto;
-  margin-right: auto;
-
-  margin-top: 5px;
-  margin-bottom: 5px;
-  padding: 5px;
-  border-radius: 10px;
-
-  display: flex;
-}
-
-.scroll-left {
-  width: 25%;
-  flex-shrink: 0;
-}
-
-.scroll-right {
-  width: 25%;
-  flex-shrink: 0;
-}
-</style>

+ 44 - 31
src/views/conversation/ConversationChatContainer.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="conversation-chat-container">
     <div class="conversation-chat-main" ref="chat_scrren_container">
-      <DialogHeader class="conversation-chat-header" :agent_info="CHAT_AGENT_INFOMATION" :style="style_header" />
+      <DialogHeader class="conversation-chat-header" :agent_name="current_agent_name" :style="style_header" />
 
       <div class="conversation-chat-content" :style="style_body">
         <div class="conversation-chat-main-container">
@@ -14,7 +14,7 @@
             </div>
 
             <!-- 无会话ID,直接对话,此时可现实欢迎消息:欢迎使用报表合并、欢迎使用文档智能、欢迎使用小数绘图 -->
-            <DialogWelcome v-if="!session_id" class="conversation-chat-area" :agent_info="CHAT_AGENT_INFOMATION" />
+            <DialogWelcome v-if="!session_id" class="conversation-chat-area" />
           </template>
 
           <DialogList
@@ -52,12 +52,7 @@
           @submit="handleInputSubmit"
         >
           <template v-if="show_input_others_opts" v-slot:top>
-            <DialogInputTop
-              :menu_id="current_menu_id"
-              :agent_info="CHAT_AGENT_INFOMATION"
-              :user_input_form="conversation_params.user_input_form"
-              ref="dialog_input_top"
-            />
+            <DialogInputTop :user_input_form="conversation_params.user_input_form" ref="dialog_input_top" />
           </template>
 
           <template v-slot:left>
@@ -255,6 +250,16 @@ const current_menu_id = computed(() => {
   const menu_id = agent.menuId / 1;
   return menu_id;
 });
+const current_agent_name = computed(() => {
+  const agent = props.CHAT_AGENT_INFOMATION.agent;
+  const name = agent.name;
+  return name;
+});
+const current_agent_mode = computed(() => {
+  const agent = props.CHAT_AGENT_INFOMATION.agent;
+  const mode = agent.mode;
+  return mode;
+});
 
 /**
  * 是否显示欢迎页
@@ -610,33 +615,40 @@ const handleInputSubmit = async (options) => {
    * 否则,创建新对话
    */
   if (chat_round_id.value === null) {
-    // 未创建chat,开始创建
-    try {
-      const chatResult = await getDialogChatId(agent_id);
+    const session_id = props.session_id;
+    if (session_id) {
+      // 已有会话ID,使用此会话ID
+      chat_round_id.value = session_id;
+    } else {
+      // 无会话ID,创建新会话
+      // 未创建chat,开始创建
+      try {
+        const chatResult = await getDialogChatId(agent_id);
+
+        if (chatResult.code / 1 === 200) {
+          // 成功
+          const res_data = chatResult.data;
+
+          chat_round_id.value = res_data.chat_id;
+        } else {
+          // 失败
+          // 处理异常:直接在界面上显示
+          handleChatRequestionException({
+            message: `code: ${chatResult.code} message: ${chatResult.msg}`
+          });
 
-      if (chatResult.code / 1 === 200) {
-        // 成功
-        const res_data = chatResult.data;
+          return;
+        }
+      } catch (err) {
+        console.log('err-nfsdnakiuwirea7', err);
 
-        chat_round_id.value = res_data.chat_id;
-      } else {
-        // 失败
-        // 处理异常:直接在界面上显示
+        // 处理错误
         handleChatRequestionException({
-          message: `code: ${chatResult.code} message: ${chatResult.msg}`
+          message: err.message
         });
 
         return;
       }
-    } catch (err) {
-      console.log('err-nfsdnakiuwirea7', err);
-
-      // 处理错误
-      handleChatRequestionException({
-        message: err.message
-      });
-
-      return;
     }
   } else {
     // 已创建chat,使用已创建的会话ID,进入下一步流程
@@ -712,7 +724,7 @@ const handleInputSubmit = async (options) => {
   // TODO: 重新组装sse参数,调用sse接口问答
   const query_params = {
     agent_id,
-    mode: props.CHAT_AGENT_INFOMATION.agent.mode, //智能体类型
+    mode: current_agent_mode.value, //智能体类型
     query: ask_text,
     files: files_response || [],
     inputs: other_options ? other_options.options : [],
@@ -944,11 +956,12 @@ onMounted(() => {
   // 组件挂载
   if (session_id) {
     // 有历史记录:获取历史记录内容进行展示
-    getHistoryLogs(agent_id, session_id)
+    getHistoryLogs(session_id)
       .then((res) => {
         if (res.code / 1 === 200) {
+          const res_data = res.data;
           // 成功
-          const session_list = res.data;
+          const session_list = res_data.message;
 
           // 将列表数据进行转化
           const list = formatDialogHistory(session_list, props.CHAT_AGENT_INFOMATION);

+ 3 - 1
src/views/conversation/ConversationHistoryContainer.vue

@@ -178,6 +178,7 @@ function dropListByType(res_list) {
     if (label_item) {
       list_history.value.push(label_item);
     }
+
     list_history.value.push(content_item);
   });
 }
@@ -212,8 +213,9 @@ const handleApiRequest = () => {
   apiConversationHistoryList(opts)
     .then((res) => {
       if (res.code / 1 === 200) {
+        const res_data = res.data;
         // 成功
-        const res_list = res.data; // 历史记录列表
+        const res_list = res_data.rows; // 历史记录列表
 
         if (res_list.length < page_count.value) {
           // 数据已经加载完成,不能加载更多了