From e09134e6da364eb255a7cd1c143f21432a825f08 Mon Sep 17 00:00:00 2001
From: liudong <liudong>
Date: 星期六, 24 八月 2024 16:34:00 +0800
Subject: [PATCH] 上传文档解析方法

---
 src/views/sessionManager/components/updataFile.vue |  176 ++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 151 insertions(+), 25 deletions(-)

diff --git a/src/views/sessionManager/components/updataFile.vue b/src/views/sessionManager/components/updataFile.vue
index ec81b7a..7457a25 100644
--- a/src/views/sessionManager/components/updataFile.vue
+++ b/src/views/sessionManager/components/updataFile.vue
@@ -5,7 +5,6 @@
     trigger="click"
     position="tl">
     <a-button
-      :disabled="onFileSelectedLoading"
       type="text"
       style="border-radius: 24px"
       @click="visibleChange"
@@ -33,18 +32,28 @@
         @change="onChange"
         multiple
       />
-      <div style="width: 100%;margin-top: 10px;display: flex; justify-content: space-between;">
+      <div style="width: 100%;margin-top: 10px;display: flex; justify-content: space-between;" class="upload-wrap">
         <div>
           <span>瑙f瀽鏂规硶: </span>
-          <a-radio-group v-model="parser_id">
-            <a-radio
-              v-for="item in parser_ids"
-              :key="item.value"
-              :value="item.value"
-              style="margin-right: 10px"
-            >{{item.name}}</a-radio>
+          <a-radio-group v-model="parser_id" style="width: 500px;">
+            <a-popover title=""
+             v-for="item in parser_ids.filter(val => parser_configs.includes(val.name)).reverse().slice(0,4).reverse()"
+             :key="item.value"
+            >
+              <a-radio
+                :value="item.value"
+                style="margin-right: 10px"
+              >{{item.name}}</a-radio>
+              <template #content>
+                <p style="max-width: 300px">{{item.parser_config_str}}</p>
+              </template>
+            </a-popover>
           </a-radio-group>
         </div>
+        <a-select :style="{width:'100px', margin: '0 10px'}" :default-value="['閫氱敤', '澶氭ā鎬�']" v-model="parser_configs" multiple size="small">
+          <a-option v-for="item in parser_ids" :key="item.value">{{ item.name }}</a-option>
+        </a-select>
+        <p class="config-text">鏇村閰嶇疆</p>
         <a-button
           :loading="onFileSelectedLoading"
           @click="upDataFile"
@@ -74,7 +83,6 @@
 const filesBtn = ref(null);
 const onFileSelectedLoading = ref(false);
 const parser_id = ref("");
-const parser_ids = ref([]);
 const uploaditemList = ref([]);
 const activeSessionId = ref('');
 let kbtenantInfo = reactive({
@@ -83,14 +91,13 @@
   img2txt_id: 'qwen-vl-max',
   llm_id: 'qwen-plus',
   name: 'wanghaos Kingdom',
-  parser_ids:
-    'naive:General,qa:Q&A,resume:Resume,manual:Manual,table:Table,paper:Paper,book:Book,laws:Laws,presentation:Presentation,picture:Picture,one:One',
+  // parser_ids: 'naive:General,qa:Q&A,resume:Resume,manual:Manual,table:Table,paper:Paper,book:Book,laws:Laws,presentation:Presentation,picture:Picture,one:One',
+  parser_ids: 'naive:閫氱敤,qa:Q&A,resume:绠�鍘�,manual:璇存槑涔�,table:琛ㄦ牸,paper:澶氭ā鎬�,book:涔︾睄,laws:娉曞緥鏂囦欢,presentation:PPT,picture:鍥剧墖,one:鏁翠綋',
   rerank_id: 'BAAI/bge-reranker-v2-m3',
   role: 'owner',
   tenant_id: '948fc6fa41ab11ef8fb80242ac120004',
   parser_idObj: {},
 });
-const uploadList = ref([]);
 const parser = reactive({
   naive: {
     "chunk_token_num": 676,
@@ -104,8 +111,103 @@
       "random_seed": 1500
     }
   }, // 鐢ㄦ埛鍚�
+  qa: {
+    "entity_types": [
+      "organization",
+      "person",
+      "location",
+      "event",
+      "time"
+    ],
+    "raptor": {
+      "use_raptor": false
+    }
+  },
+  resume: {},
+  manual: {},
+  table: {},
+  paper: {},
+  book: {},
+  laws: {},
+  presentation: {},
+  picture: {},
+  one: {},
 
 });
+const parser_configs = ref(['閫氱敤', '澶氭ā鎬�']);
+const parser_ids = ref([
+  {
+    name: '閫氱敤',
+    value: 'naive',
+    parser_config: parser.naive,
+    parser_config_str: '鏀寔鐨勬枃浠舵牸寮忎负DOCX銆丒XCEL銆丳PT銆両MAGE銆丳DF銆乀XT'
+  },
+  {
+    name: 'Q&A',
+    value: 'qa',
+    parser_config: parser.qa,
+    parser_config_str: '鏀寔 excel 鍜� csv/txt 鏂囦欢鏍煎紡銆� \n' +
+      '濡傛灉鏂囦欢浠� excel 鏍煎紡锛屽垯搴旂敱涓や釜鍒楃粍鎴� 娌℃湁鏍囬锛氫竴涓彁鍑洪棶棰橈紝鍙︿竴涓敤浜庣瓟妗堬紝 绛旀鍒椾箣鍓嶇殑闂鍒椼�俓n' +
+      '濡傛灉鏂囦欢浠� csv/txt 鏍煎紡涓� 鐢ㄤ綔鍒嗗紑闂鍜岀瓟妗堢殑瀹氱晫绗︺�俓n'
+  },
+  {
+    name: '绠�鍘�',
+    value: 'resume',
+    parser_config: parser.resume,
+    parser_config_str: '鏀寔鐨勬枃浠舵牸寮忎负DOCX銆丳DF銆乀XT'
+  },
+  {
+    name: '璇存槑涔�',
+    value: 'manual',
+    parser_config: parser.manual,
+    parser_config_str: '浠呮敮鎸丳DF'
+  },
+  {
+    name: '琛ㄦ牸',
+    value: 'table',
+    parser_config: parser.table,
+    parser_config_str: '鏀寔EXCEL鍜孋SV/TXT鏍煎紡鏂囥�� \n' +
+      '瀵逛簬 csv 鎴� txt 鏂囦欢锛屽垪涔嬮棿鐨勫垎闅旂涓� TAB锛孿n' +
+      '绗竴琛屽繀椤绘槸鍒楁爣棰樸�俓n'
+  },
+  {
+    name: '澶氭ā鎬�',
+    value: 'paper',
+    parser_config: parser.paper,
+    parser_config_str: '浠呮敮鎸丳DF鏂囦欢'
+  },
+  {
+    name: '涔︾睄',
+    value: 'book',
+    parser_config: parser.book,
+    parser_config_str: '鏀寔鐨勬枃浠舵牸寮忎负DOCX銆丳DF銆乀XT'
+  },
+  {
+    name: '娉曞緥鏂囦欢',
+    value: 'laws',
+    parser_config: parser.laws,
+    parser_config_str: '鏀寔鐨勬枃浠舵牸寮忎负DOCX銆丳DF銆乀XT'
+  },
+  {
+    name: 'PPT',
+    value: 'presentation',
+    parser_config: parser.presentation,
+    parser_config_str: '鏀寔鐨勬枃浠舵牸寮忎负PDF銆丳PTX'
+  },
+  {
+    name: '鍥剧墖',
+    value: 'picture',
+    parser_config: parser.picture,
+    parser_config_str: '鏀寔鍥惧儚鏂囦欢'
+  },
+  {
+    name: '鏁翠綋',
+    value: 'one',
+    parser_config: parser.one,
+    parser_config_str: '鏀寔鐨勬枃浠舵牸寮忎负DOCX銆丒XCEL銆丳DF銆乀XT'
+  },
+]);
+const uploadList = ref([]);
 const props = defineProps(["sessionId"]);
 const emit = defineEmits(["selectFileCallback"]);
 const uploadRef = ref();
@@ -115,14 +217,18 @@
 });
 
 const init = () => {
-  parser_ids.value = kbtenantInfo.parser_ids.split(",").map((item) => {
-    const [value1, value2] = item.split(":");
-    return {
-      name: value2,
-      value: value1
-    };
-  });
+  // parser_ids.value = kbtenantInfo.parser_ids.split(",").map((item) => {
+  //   const [value1, value2] = item.split(":");
+  //   return {
+  //     name: value2,
+  //     value: value1
+  //   };
+  // });
 }
+
+const chooseParser = (item) => {
+  console.log(item);
+};
 
 const onChange = (fileList) => {
   files.value = fileList;
@@ -140,8 +246,9 @@
     Message.warning('璇烽�夋嫨鏂囦欢');
     return;
   }
-  uploaditemList.value = files.value.map((item)=>{
+  uploaditemList.value = files.value.map((item,index)=>{
     return {
+      index: index,
       name: item.name,
       size: (item.file.size/1024).toFixed(2) + 'K',
     }
@@ -155,9 +262,9 @@
     formData.append('parser_config', '');
   }
   uploadWithoutKb(formData).then((res) => {
+    onFileSelectedLoading.value = false;
     if (res.code == 200) {
-      cancel()
-      onFileSelectedLoading.value = false;
+      cancel();
       // uploaditemList.value = [];
       emit('selectFileCallback', uploaditemList.value);
       Message.success('涓婁紶鎴愬姛');
@@ -166,13 +273,19 @@
     }
   });
 
+  // cancel();
+  // emit('selectFileCallback', uploaditemList.value);
+
 
 
 };
 
 
 const cancel = () => {
-  visible.value = false;
+  if(!onFileSelectedLoading.value){
+    visible.value = false;
+    parser_id.value = "";
+  }
 };
 
 defineExpose({
@@ -198,7 +311,11 @@
 
 
 </script>
-
+<style>
+.upload-wrap .arco-select-view-inner{
+  display: none;
+}
+</style>
 <style scoped lang="less">
 .aUpload {
   width: 100%;
@@ -206,4 +323,13 @@
   overflow: hidden;
   overflow-y: auto;
 }
+.upload-wrap {
+  position: relative;
+}
+.config-text {
+  position: absolute;
+  right: 70px;
+  bottom: -11px;
+  font-size: 12px;
+}
 </style>

--
Gitblit v1.8.0