ソースを参照

feat: 调整文档来源的呈现形式

1. 将来源相关的引用呈现调整至答案外部
2. 将来源数量调整为3个
3. 补充缺失的多语言
zhupei@smartai.com 1 年間 前
コミット
f2563f98ba

+ 3 - 1
public/i18n/lang-en.json

@@ -203,6 +203,8 @@
     "file_upload_message": "Upload",
     "input_message": "Enter your question",
     "input_placholder": "Enter text content",
-    "input_confirm": "Confirm"
+    "input_confirm": "Confirm",
+
+    "back": "Back"
   }
 }

+ 3 - 1
public/i18n/lang-zh.json

@@ -204,6 +204,8 @@
     "file_upload_message": "文件上传",
     "input_message": "输入您的问题",
     "input_placholder": "输入文本内容",
-    "input_confirm": "发送"
+    "input_confirm": "发送",
+
+    "back": "返回"
   }
 }

+ 32 - 26
src/modules/answer-refference/RefferenceFileBlocks.vue

@@ -47,33 +47,39 @@ const document_list = computed(() => {
 
   const res_list = [];
 
-  const len = doc_list.length;
-  for (let i = 0; i < len; i++) {
-    const doc = doc_list[i];
-
-    const res_doc = {
-      doc_id: doc.doc_id,
-      doc_name: doc.doc_name,
-      count: doc.count,
-      page: i
-    };
-
-    const cur_doc_id = doc.doc_id;
-
-    const cur_doc_peaces = [];
-    if (chunks && Array.isArray(chunks)) {
-      chunks.forEach((item, index) => {
-        const chunk_doc_id = item.doc_id;
-
-        if (cur_doc_id === chunk_doc_id) {
-          cur_doc_peaces.push(item.content_ltks);
-        }
-      });
+  if (Array.isArray(doc_list)) {
+    const len = doc_list.length;
+    for (let i = 0; i < len; i++) {
+      if (i >= 3) {
+        break;
+      }
+
+      const doc = doc_list[i];
+
+      const res_doc = {
+        doc_id: doc.doc_id,
+        doc_name: doc.doc_name,
+        count: doc.count,
+        page: i
+      };
+
+      const cur_doc_id = doc.doc_id;
+
+      const cur_doc_peaces = [];
+      if (chunks && Array.isArray(chunks)) {
+        chunks.forEach((item, index) => {
+          const chunk_doc_id = item.doc_id;
+
+          if (cur_doc_id === chunk_doc_id) {
+            cur_doc_peaces.push(item.content_ltks);
+          }
+        });
+      }
+
+      res_doc.content_ltks = cur_doc_peaces;
+
+      res_list.push(res_doc);
     }
-
-    res_doc.content_ltks = cur_doc_peaces;
-
-    res_list.push(res_doc);
   }
 
   return res_list;

+ 45 - 1
src/modules/conversation-item/DialogAnswer.vue

@@ -20,6 +20,16 @@
           </DialogContent>
 
           <BtnStopChat v-if="answer_status === 1" @stop="handleStopChat" />
+
+          <!-- 对话已经结束,并且有引用数据 -->
+          <template v-if="has_refference && answer_status === 2">
+            <RefferenceFileBlocks
+              class="refference-files-blocks-container"
+              :doc_aggs="full_refference.doc_aggs"
+              :chunks="full_refference.chunks"
+              :total="full_refference.total"
+            />
+          </template>
         </div>
       </div>
     </div>
@@ -49,6 +59,8 @@ import applyRefferencePopover4RefFlag from '../answer-refference/apply-refferenc
 import applyRefferencePopover4FileName from '../answer-refference/apply-refference-popover-4-filename';
 import { applyCodeHighLight } from '../conversation-dialog/format-code-string';
 
+import RefferenceFileBlocks from '../answer-refference/RefferenceFileBlocks.vue';
+
 import copyText from '../../3rd-libs/clipboard';
 
 const props = defineProps({
@@ -173,6 +185,34 @@ const anwser_klass = computed(() => {
   return `klass-${answer.client_custom_unique_id}-answer-content`;
 });
 
+/**
+ * 完整引用数据
+ */
+const full_refference = computed(() => {
+  if (!props.answer) {
+    return null;
+  }
+
+  const answer = props.answer;
+
+  if (!answer.client_custom_linked_refference_full_content) {
+    return null;
+  }
+
+  return answer.client_custom_linked_refference_full_content;
+});
+
+/**
+ * 是否显示引用效果
+ */
+const has_refference = computed(() => {
+  if (!full_refference.value) {
+    return false;
+  }
+
+  return true;
+});
+
 const handleSelectChange = () => {
   emit('select');
 };
@@ -214,7 +254,7 @@ onMounted(() => {
    * 文档引用效果
    */
   applyRefferencePopover4RefFlag(container_klass, full_refference);
-  applyRefferencePopover4FileName(container_klass, full_refference);
+  // applyRefferencePopover4FileName(container_klass, full_refference);
   /**
    * 处理代码样式: 美化代码的展示
    */
@@ -248,4 +288,8 @@ onMounted(() => {
 .answer-actions-btns {
   margin-top: 5px;
 }
+
+.refference-files-blocks-container {
+  margin-top: 10px;
+}
 </style>

+ 1 - 1
src/views/ConversationQA.vue

@@ -16,7 +16,7 @@
         <a-result status="error" :title="query_value_message">
           <template #extra>
             <a-space>
-              <a-button type="primary" @click="handleBack">返回</a-button>
+              <a-button type="primary" @click="handleBack">{{ $t('conversation.back') }}</a-button>
             </a-space>
           </template>
         </a-result>