Selaa lähdekoodia

知识库问题

CzRger 2 kuukautta sitten
vanhempi
commit
e43d464564

+ 6 - 0
src/api/modules/knowledge/document.ts

@@ -29,3 +29,9 @@ export const documentNoArchive = (params) =>
 // 知识库文档删除
 export const documentDocsDelete = (params) =>
   post(`/document/docs/delete`, params, {})
+// 知识库文档分段删除
+export const documentSegmentDelete = (params) =>
+  post(`/document/segment/delete`, params, {})
+// 知识库文档分段启用/停用
+export const documentSegmentIfUse = (params) =>
+  post(`/document/segment/ifUse`, params, {})

+ 2 - 0
src/api/modules/knowledge/test.ts

@@ -3,3 +3,5 @@ import { get, post, put, del } from '@/api/request'
 // 知识库召回测试-测试
 export const datasetsCallback = (params) =>
   post(`/datasets/callback`, params, {})
+// 知识库召回测试-记录
+export const queriesAnswer = (params) => get(`/queries/answer`, params, {})

+ 1 - 1
src/views/manage/knowledge/documents/document/detail.vue

@@ -15,7 +15,7 @@
         <CzrFormColumn
           required
           :span="24"
-          label="分段名称"
+          label="文档名称"
           v-model:param="state.form.name"
         />
         <CzrFormColumn

+ 2 - 2
src/views/manage/knowledge/documents/document/index.vue

@@ -199,7 +199,7 @@ const state: any = reactive({
         width: 100,
         dictList: computed(() => DictionaryStore.indexingStatusList),
       },
-      { value: 'p1', label: '召回次数(无)', show: true },
+      { value: 'recallCount', label: '召回次数', show: true, width: 100 },
       {
         value: 'isUse',
         label: '启用/停用',
@@ -328,7 +328,7 @@ const onDel = (row: any = null) => {
   if (row) {
     DialogStore.confirm({
       title: '删除确认',
-      content: `是否删除文档:${row.name}?<br/>此文档下的${row.p1 ? row.p1 + '个' : ''}分段都会被删除,请谨慎操作。`,
+      content: `是否删除文档:${row.name}?<br/>此文档下的${row.segmentCount ? row.segmentCount + '个' : ''}分段都会被删除,请谨慎操作。`,
       onSubmit: () => {
         documentDocsDelete([row.id])
           .then(() => {

+ 57 - 32
src/views/manage/knowledge/documents/document/stage-index.vue

@@ -26,32 +26,18 @@
           />
           <CzrButton type="del" title="删除" @click="onDel()" />
         </template>
-        <!--        <CzrButton type="primary" title="添加分段"/>-->
       </div>
     </div>
     <div class="flex items-center">
       <div class="ml-auto flex items-center gap-[var(--czr-gap)]">
         <CzrForm class="bm-filter" label-width="0px" @handleEnter="onSearch">
           <CzrFormColumn
-            width="5rem"
-            class="__czr-table-form-column"
-            :span="24"
-            label-width="0px"
-            v-model:param="state.query.form.type"
-            link="select"
-            :options="[
-              { label: '标题', value: 1 },
-              { label: '内容', value: 2 },
-            ]"
-            :clearable="false"
-          />
-          <CzrFormColumn
             width="15.63rem"
             class="__czr-table-form-column"
             :span="24"
             label-width="0px"
             v-model:param="state.text"
-            placeholder="按名称搜索"
+            placeholder="按内容搜索"
             :prefix-icon="Search"
           />
         </CzrForm>
@@ -92,7 +78,11 @@
           >
             <div class="flex items-center gap-[0.5rem]">
               <div class="text-[1.13rem] font-bold text-[#303133]" v-title>
-                {{ row.name }}
+                分段
+                {{
+                  (state.query.page.pageNum - 1) * state.query.page.pageSize +
+                  (index + 1)
+                }}
               </div>
               <div class="ml-auto" @click.capture.stop="onSwitch(row)">
                 <a-switch v-model:checked="row.enabled" size="small" />
@@ -149,7 +139,8 @@ import { useDialogStore } from '@/stores'
 import knowledgeSelectCom from './knowledge-select.vue'
 import {
   documentGetSegmentsByPage,
-  documentIfUse,
+  documentSegmentDelete,
+  documentSegmentIfUse,
 } from '@/api/modules/knowledge/document'
 
 const DialogStore = useDialogStore()
@@ -239,9 +230,7 @@ const onReset = () => {
     pageNum: 1,
     pageSize: 20,
   }
-  state.query.form = {
-    type: 1,
-  }
+  state.query.form = {}
   onSearch()
 }
 const onDel = (row: any = null) => {
@@ -250,8 +239,14 @@ const onDel = (row: any = null) => {
       title: '删除确认',
       content: `是否删除此分段?删除后无法恢复,请谨慎操作。`,
       onSubmit: () => {
-        ElMessage.success('删除成功!')
-        onSearch()
+        documentSegmentDelete([row.id])
+          .then(() => {
+            ElMessage.success('删除成功!')
+          })
+          .catch(() => {})
+          .finally(() => {
+            onSearch()
+          })
       },
     })
   } else {
@@ -263,21 +258,51 @@ const onDel = (row: any = null) => {
       title: '删除确认',
       content: `是否删除${state.query.selectedMap.size}个分段?删除后无法恢复,请谨慎操作。`,
       onSubmit: () => {
-        ElMessage.success('删除成功!')
-        onSearch()
+        documentSegmentDelete(Array.from(state.query.selectedMap.keys()))
+          .then(() => {
+            ElMessage.success('删除成功!')
+          })
+          .catch(() => {})
+          .finally(() => {
+            onSearch()
+          })
       },
     })
   }
 }
 const onSwitch = (row) => {
-  // documentIfUse(row.id)
-  //   .then(() => {
-  //     ElMessage.success('操作成功!')
-  //   })
-  //   .catch(() => {})
-  //   .finally(() => {
-  //     onPage(state.query.page.pageNum, state.query.page.pageSize)
-  //   })
+  if (row.enabled) {
+    DialogStore.confirm({
+      title: '停用确认',
+      content: `请确认是否停用分段?`,
+      onSubmit: () => {
+        documentSegmentIfUse({
+          booleanType: 'FALSE',
+          ids: [row.id],
+        })
+          .then(() => {
+            ElMessage.success('停用成功!')
+          })
+          .catch(() => {})
+          .finally(() => {
+            onPage(state.query.page.pageNum, state.query.page.pageSize)
+          })
+      },
+      onCancel: () => {},
+    })
+  } else {
+    documentSegmentIfUse({
+      booleanType: 'TRUE',
+      ids: [row.id],
+    })
+      .then(() => {
+        ElMessage.success('启用成功!')
+      })
+      .catch(() => {})
+      .finally(() => {
+        onPage(state.query.page.pageNum, state.query.page.pageSize)
+      })
+  }
 }
 onMounted(() => {
   onReset()