Explorar el Código

fix: 修复下载链接异常的问题

zhupei@smartai.com hace 1 año
padre
commit
80bc73308a

+ 3 - 1
public/config.js

@@ -38,5 +38,7 @@ window.XIAOSHU_URL = 'http://192.168.20.119:9301';
  * 当用户第一次进入系统时,进入的第一个页面就是对话页面
  * 此时需要一个默认的Agent用来创建对话
  * 此处对默认的Agent ID进行配置
+ *
+ * 知识问答
  */
-window.DEFAULT_CHAT_AGENT_ID = '42e4fcdc-9bea-11ef-ac30-0242ac160006';
+window.DEFAULT_CHAT_AGENT_ID = 'e476db7cbdbb11ef82b50242ac130006';

+ 1 - 0
src/modules/conversation-dialog/format-dialog-answer-custom-markdown-str.js

@@ -79,6 +79,7 @@ export function formatRefferenceFlag(answer) {
 export function formatFileDownloadStr(file_name, file_url, file_id) {
   let real_url = file_url.replace('//', '/');
   real_url = file_url.replace('/./', '/');
+  real_url = file_url.replace('./', '/');
   real_url = formatStaticAssetsUrl(real_url);
 
   return `<div class="client-formated-markdown-element-item client-formated-download-container">

+ 37 - 2
src/views/ConversationQA.vue

@@ -105,15 +105,50 @@ onMounted(async () => {
 
   if (!agent_id) {
     // 不存在参数
-
+    // ------------------------------------------------------
+    // ------------------------------------------------------
+    // ------------------------------------------------------
+    // ------------------------------------------------------
     // 使用默认的通用agent创建对话
     /**
      * 如果没有agent参数,则使用默认的agent
      * 默认的agent,和赵秦刚沟通,为知识问答(2024-12-18)
      * 下列为知识问答的ID
      */
-    const default_agent_id = getConfigField('DEFAULT_CHAT_AGENT_ID');
+    let default_agent_id = null;
+
+    const agent_list = allAgent.getList();
+    const len = agent_list.length;
+
+    if (len > 1) {
+      for (let i = 0; i < len; i++) {
+        const item = agent_list[i];
+        if (item.name === '知识问答') {
+          default_agent_id = item.id;
+          break;
+        }
+      }
+      if (!default_agent_id) {
+        // 未搜索到: 使用第一个
+        default_agent_id = agent_list[0].id;
+      }
+    } else if (len === 1) {
+      // 仅有一个
+      default_agent_id = agent_list[0].id;
+    } else {
+      // 为0: 使用配置的ID
+      default_agent_id = getConfigField('DEFAULT_CHAT_AGENT_ID');
+    }
+    if (!default_agent_id) {
+      // 如果ID依然不生效,则需要请求api
+      // TODO: 请求API
+    }
+
     chat_agent.value = default_agent_id;
+    // ------------------------------------------------------
+    // ------------------------------------------------------
+    // ------------------------------------------------------
+    // ------------------------------------------------------
 
     query_value_status.value = 2;
     query_value_message.value = 'success';