CzRger 2 nedēļas atpakaļ
vecāks
revīzija
c77e6fa360

+ 9 - 3
src/components/czr-ui/CzrContent.vue

@@ -33,7 +33,10 @@
           <slot name="buttons" />
         </div>
         <div class="filters" v-if="noFilter === false">
-          <div class="tools __hover" @click="state.showFieldColumn = true">
+          <div
+            class="tools __hover"
+            @click="() => (state.showFieldColumn = true)"
+          >
             <SvgIcon name="czr_tools" size="18" color="#666666" />
           </div>
         </div>
@@ -62,7 +65,7 @@
           class="__hover"
           name="close_2"
           size="16"
-          @click="state.showFieldColumn = false"
+          @click="() => (state.showFieldColumn = false)"
         />
       </template>
       <div class="field-column">
@@ -158,7 +161,10 @@
       </div>
       <template #footer>
         <div class="buttons">
-          <div class="cancel __hover" @click="state.showFieldColumn = false">
+          <div
+            class="cancel __hover"
+            @click="() => (state.showFieldColumn = false)"
+          >
             取消
           </div>
           <div

+ 2 - 2
src/views/demo/dialog/dialog1.vue

@@ -10,8 +10,8 @@
     :show-submit="false"
   >
     <div class="__normal-form">
-      <el-button @click="state.length++">新增一行</el-button>
-      <el-button @click="state.length--">删除一行</el-button>
+      <el-button @click="() => state.length++">新增一行</el-button>
+      <el-button @click="() => state.length--">删除一行</el-button>
       <template v-for="(item, index) in state.length">
         <h1>{{ index }}</h1>
       </template>

+ 2 - 2
src/views/demo/dialog/dialog2.vue

@@ -10,8 +10,8 @@
     :show-submit="false"
   >
     <div class="__normal-form">
-      <el-button @click="state.length++">新增一行</el-button>
-      <el-button @click="state.length--">删除一行</el-button>
+      <el-button @click="() => state.length++">新增一行</el-button>
+      <el-button @click="() => state.length--">删除一行</el-button>
       <template v-for="(item, index) in state.length">
         <h1>{{ index }}</h1>
       </template>

+ 2 - 2
src/views/demo/dialog/index.vue

@@ -1,8 +1,8 @@
 <template>
   <div class="main">
-    <el-button @click="state.show1 = true">默认弹窗</el-button>
+    <el-button @click="() => (state.show1 = true)">默认弹窗</el-button>
     <Dialog1 v-model:show="state.show1" />
-    <el-button @click="state.show2 = true">hiddenStyle</el-button>
+    <el-button @click="() => (state.show2 = true)">hiddenStyle</el-button>
     <Dialog2 v-model:show="state.show2" :hiddenStyle="true" />
   </div>
 </template>

+ 4 - 2
src/views/demo/table/index.vue

@@ -2,8 +2,10 @@
   <div class="main">
     <el-collapse v-model="state.activeNames" accordion>
       <el-collapse-item title="高度(full)" name="height">
-        <el-button @click="state.table1.data.push({})">添加一行</el-button>
-        <el-button type="danger" @click="state.table1.data.splice(0, 1)"
+        <el-button @click="() => state.table1.data.push({})"
+          >添加一行</el-button
+        >
+        <el-button type="danger" @click="() => state.table1.data.splice(0, 1)"
           >删除一行</el-button
         >
         <div class="content">

+ 31 - 16
src/views/manage/knowledge/detail.vue

@@ -52,7 +52,7 @@
           required
           :span="24"
           label="知识库描述"
-          v-model:param="state.form.remark"
+          v-model:param="state.form.description"
           type="textarea"
           :rows="4"
           placeholder="描述知识库的内容,详尽的描述将帮助AI能深入理解该知识库的内容,能更准确的检索到内容,提高该知识库的命中率。"
@@ -61,12 +61,15 @@
           required
           :span="24"
           label="知识分组"
-          v-model:param="state.form.group"
+          v-model:param="state.form.groupId"
           link="select"
           :options="DictionaryStore.knowledgeGroups.list"
         />
       </CzrForm>
-      <modelConfig :transfer="state.modelConfigTransfer" />
+      <modelConfig
+        :transfer="state.modelConfigTransfer"
+        @refresh="getModelConfig"
+      />
     </div>
   </CzrDialog>
 </template>
@@ -84,6 +87,7 @@ import { ElMessage, ElMessageBox } from 'element-plus'
 import { useDialogStore, useDictionaryStore } from '@/stores'
 import { useRouter } from 'vue-router'
 import modelConfig from './model-config.vue'
+import { datasetsCreate, datasetsDetail } from '@/api/modules/knowledge'
 
 const router = useRouter()
 const DictionaryStore = useDictionaryStore()
@@ -132,7 +136,9 @@ watch(
   },
 )
 const initDictionary = () => {}
-const initData = () => {}
+const initData = () => {
+  datasetsDetail(props.transfer.id).then((data) => {})
+}
 const onSubmit = (isImport) => {
   ref_form.value
     .submit()
@@ -141,19 +147,27 @@ const onSubmit = (isImport) => {
         content: `请确认是否${titleCpt.value}?${isImport ? '创建成功后将自动跳转至文档上传页面!' : ''}`,
         onSubmit: () => {
           state.loading = true
-          ElMessage.success(`${titleCpt.value}成功!`)
-          if (isImport) {
-            router.push({
-              name: '18e6009c-a72c-4359-864b-e7725fccca69',
-              params: {
-                id: '知识库ID',
-              },
+          datasetsCreate(state.form)
+            .then(({ data }: any) => {
+              ElMessage.success(`${titleCpt.value}成功!`)
+              if (isImport) {
+                router.push({
+                  name: '18e6009c-a72c-4359-864b-e7725fccca69',
+                  params: {
+                    id: '知识库ID',
+                  },
+                })
+              } else {
+                emit('update:show', false)
+                emit('refresh')
+              }
+            })
+            .catch(({ message }: any) => {
+              ElMessage.error(message)
+            })
+            .finally(() => {
+              state.loading = false
             })
-          } else {
-            emit('update:show', false)
-            emit('refresh')
-          }
-          state.loading = false
         },
       })
     })
@@ -165,6 +179,7 @@ const onSubmit = (isImport) => {
       })
     })
 }
+const getModelConfig = (data) => {}
 </script>
 
 <style lang="scss" scoped></style>

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

@@ -27,7 +27,7 @@
             <CzrButton
               type="add"
               title="添加分段"
-              @click="state.detail.show = true"
+              @click="() => (state.detail.show = true)"
             />
             <CzrButton title="迁移" icon="move" @click="onKnowledge()" />
             <CzrButton title="归档" icon="cloud" />

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

@@ -13,7 +13,7 @@
         <div
           class="knowledge-item __hover"
           :class="{ active: item.id == state.active.id }"
-          @click="state.active = item"
+          @click="() => (state.active = item)"
         >
           <img src="@/assets/images/answer.png" />
           <div v-title>{{ item.name }}</div>

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

@@ -13,7 +13,7 @@
           <CzrButton
             type="normal"
             title="批量选择"
-            @click="state.isSelect = true"
+            @click="() => (state.isSelect = true)"
           />
         </template>
         <template v-else>

+ 1 - 1
src/views/manage/knowledge/documents/index.vue

@@ -11,7 +11,7 @@
           <div
             class="menu-item __hover"
             :class="{ active: state.menu === item.value }"
-            @click="state.menu = item.value"
+            @click="() => (state.menu = item.value)"
           >
             <SvgIcon :name="item.icon" :active="state.menu === item.value" />{{
               item.label

+ 4 - 2
src/views/manage/knowledge/index.vue

@@ -5,7 +5,9 @@
       <div class="ml-auto flex items-center gap-[var(--czr-gap)]">
         <div
           class="__hover flex items-center gap-[0.3rem] text-[0.88rem] text-[#576275]"
-          @click="state.query.form.isCreate = !state.query.form.isCreate"
+          @click="
+            () => (state.query.form.isCreate = !state.query.form.isCreate)
+          "
         >
           <SvgIcon
             name="czr_add1"
@@ -15,7 +17,7 @@
         </div>
         <div
           class="__hover flex items-center gap-[0.3rem] text-[0.88rem] text-[#576275]"
-          @click="state.query.form.isStar = !state.query.form.isStar"
+          @click="() => (state.query.form.isStar = !state.query.form.isStar)"
         >
           <SvgIcon
             name="star"

+ 203 - 48
src/views/manage/knowledge/model-config.vue

@@ -5,8 +5,8 @@
       <div
         class="__hover h-[8.38rem] flex-1 rounded-[var(--czr-gap)] bg-[#ffffff] px-[1.5rem] py-[1rem]"
         style="border: var(--czr-border); border-width: 0.13rem"
-        :class="{ 'index-method-active': state.indexMethod.value === 1 }"
-        @click="state.indexMethod.value = 1"
+        :class="{ 'index-method-active': state.indexMethod.value === '高质量' }"
+        @click="() => (state.indexMethod.value = '高质量')"
       >
         <div class="flex items-center">
           <img
@@ -26,29 +26,29 @@
           调用嵌入模型来处理文档以实现更精确的检索,可以帮助大语言模型生成高质量的回答。
         </div>
       </div>
-      <div
-        class="__hover h-[8.38rem] flex-1 rounded-[var(--czr-gap)] bg-[#ffffff] px-[1.5rem] py-[1rem]"
-        style="border: var(--czr-border); border-width: 0.13rem"
-        :class="{ 'index-method-active': state.indexMethod.value === 2 }"
-        @click="state.indexMethod.value = 2"
-      >
-        <div class="flex items-center">
-          <img
-            src="@/assets/images/model-icon-2.png"
-            class="mr-[var(--czr-gap)] h-[3.25rem] w-[3.25rem]"
-          />
-          <div class="text-[1.25rem] font-bold text-[#2E3238]">经济</div>
-        </div>
-        <div
-          class="mt-[0.5rem] text-[0.88rem] text-[#606266]"
-          style="line-height: 1.3rem"
-        >
-          每个块使用 10 个关键词进行检索,不消耗 tokens,但会降低检索准确性。
-        </div>
-      </div>
+      <!--      <div-->
+      <!--        class="__hover h-[8.38rem] flex-1 rounded-[var(&#45;&#45;czr-gap)] bg-[#ffffff] px-[1.5rem] py-[1rem]"-->
+      <!--        style="border: var(&#45;&#45;czr-border); border-width: 0.13rem"-->
+      <!--        :class="{ 'index-method-active': state.indexMethod.value === 2 }"-->
+      <!--        @click="() => state.indexMethod.value = 2"-->
+      <!--      >-->
+      <!--        <div class="flex items-center">-->
+      <!--          <img-->
+      <!--            src="@/assets/images/model-icon-2.png"-->
+      <!--            class="mr-[var(&#45;&#45;czr-gap)] h-[3.25rem] w-[3.25rem]"-->
+      <!--          />-->
+      <!--          <div class="text-[1.25rem] font-bold text-[#2E3238]">经济</div>-->
+      <!--        </div>-->
+      <!--        <div-->
+      <!--          class="mt-[0.5rem] text-[0.88rem] text-[#606266]"-->
+      <!--          style="line-height: 1.3rem"-->
+      <!--        >-->
+      <!--          每个块使用 10 个关键词进行检索,不消耗 tokens,但会降低检索准确性。-->
+      <!--        </div>-->
+      <!--      </div>-->
     </div>
     <div
-      v-if="state.indexMethod.value === 1"
+      v-if="state.indexMethod.value === '高质量'"
       class="mt-[var(--czr-gap)] flex h-[2.5rem] w-full items-center gap-[0.5rem] rounded-[0.25rem] px-[0.75rem] text-[0.8rem] text-[#666666]"
       style="
         border: var(--czr-border);
@@ -83,7 +83,7 @@
         'search-method-active':
           state.searchMethod.value === SearchMethodType.Vector,
       }"
-      @click="state.searchMethod.value = SearchMethodType.Vector"
+      @click="() => (state.searchMethod.value = SearchMethodType.Vector)"
     >
       <div class="h-full w-full px-[1.5rem] py-[1rem]">
         <div class="flex items-center">
@@ -194,7 +194,7 @@
         'search-method-active':
           state.searchMethod.value === SearchMethodType.Global,
       }"
-      @click="state.searchMethod.value = SearchMethodType.Global"
+      @click="() => (state.searchMethod.value = SearchMethodType.Global)"
     >
       <div class="h-full w-full px-[1.5rem] py-[1rem]">
         <div class="flex items-center">
@@ -308,7 +308,7 @@
         'search-method-active':
           state.searchMethod.value === SearchMethodType.Mix,
       }"
-      @click="state.searchMethod.value = SearchMethodType.Mix"
+      @click="() => (state.searchMethod.value = SearchMethodType.Mix)"
     >
       <div class="h-full w-full px-[1.5rem] py-[1rem]">
         <div class="flex items-center">
@@ -335,9 +335,14 @@
               style="border: var(--czr-border); border-width: 0.13rem"
               :class="{
                 'index-method-active':
-                  state.searchMethod[SearchMethodType.Mix].indexMethod === 1,
+                  state.searchMethod[SearchMethodType.Mix].indexMethod ===
+                  'weightSetting',
               }"
-              @click="state.searchMethod[SearchMethodType.Mix].indexMethod = 1"
+              @click="
+                () =>
+                  (state.searchMethod[SearchMethodType.Mix].indexMethod =
+                    'weightSetting')
+              "
             >
               <div class="flex items-center">
                 <img
@@ -364,9 +369,14 @@
               style="border: var(--czr-border); border-width: 0.13rem"
               :class="{
                 'index-method-active':
-                  state.searchMethod[SearchMethodType.Mix].indexMethod === 2,
+                  state.searchMethod[SearchMethodType.Mix].indexMethod ===
+                  'rerank',
               }"
-              @click="state.searchMethod[SearchMethodType.Mix].indexMethod = 2"
+              @click="
+                () =>
+                  (state.searchMethod[SearchMethodType.Mix].indexMethod =
+                    'rerank')
+              "
             >
               <div class="flex items-center">
                 <img
@@ -389,7 +399,10 @@
             class="mt-[1rem] flex flex-col gap-[0.5rem] rounded-[0.25rem] bg-[#ffffff] p-[var(--czr-gap)] text-[1rem] font-bold text-[#2E3238]"
           >
             <template
-              v-if="state.searchMethod[SearchMethodType.Mix].indexMethod === 1"
+              v-if="
+                state.searchMethod[SearchMethodType.Mix].indexMethod ===
+                'weightSetting'
+              "
             >
               <div>
                 <el-slider
@@ -416,7 +429,8 @@
             </template>
             <template
               v-else-if="
-                state.searchMethod[SearchMethodType.Mix].indexMethod === 2
+                state.searchMethod[SearchMethodType.Mix].indexMethod ===
+                'rerank'
               "
             >
               <CzrFormColumn
@@ -494,14 +508,12 @@
 import { getCurrentInstance, reactive, ref, watch } from 'vue'
 
 const emit = defineEmits([])
-const props = defineProps({
-  transfer: <any>{},
-})
+const props = defineProps({})
 const { proxy }: any = getCurrentInstance()
 enum SearchMethodType {
-  Vector = 'vector',
-  Global = 'global',
-  Mix = 'mix',
+  Vector = 'VECTOR',
+  Global = 'FULL_TEXT',
+  Mix = 'HYBRID',
 }
 const state: any = reactive({
   indexMethod: {
@@ -530,7 +542,6 @@ const state: any = reactive({
       score: 0.5,
     },
     mix: {
-      isRerank: true,
       indexMethod: 1,
       weight: 0.7,
       rerank: '',
@@ -540,15 +551,159 @@ const state: any = reactive({
     },
   },
 })
-watch(
-  () => props.transfer,
-  (n) => {
-    if (n) {
-      // 初始化
-    }
-  },
-  { immediate: true },
-)
+const reset = () => {
+  state.indexMethod = {
+    show: true,
+    value: 1,
+  }
+  state.embedding = {
+    show: true,
+    value: '',
+  }
+  state.searchMethod = {
+    show: true,
+    value: SearchMethodType.Vector,
+    [SearchMethodType.Vector]: {
+      isRerank: true,
+      rerank: '',
+      topK: 5,
+      isScore: true,
+      score: 0.5,
+    },
+    [SearchMethodType.Global]: {
+      isRerank: true,
+      rerank: '',
+      topK: 5,
+      isScore: true,
+      score: 0.5,
+    },
+    [SearchMethodType.Mix]: {
+      indexMethod: 1,
+      weight: 0.7,
+      rerank: '',
+      topK: 5,
+      isScore: true,
+      score: 0.5,
+    },
+  }
+}
+const getData = () => {
+  const result = {
+    indexingTechnique: state.indexMethod.value,
+    embeddingModelId: state.embedding.value,
+    indexConfig: {},
+  }
+  switch (state.searchMethod.value) {
+    case SearchMethodType.Vector:
+      {
+        result.indexConfig.isRerank = state.searchMethod[
+          SearchMethodType.Vector
+        ].isRerank
+          ? 1
+          : 0
+        result.indexConfig.rerankType =
+          state.searchMethod[SearchMethodType.Vector].rerank
+        result.indexConfig.topK =
+          state.searchMethod[SearchMethodType.Vector].topK
+        result.indexConfig.isScore = state.searchMethod[SearchMethodType.Vector]
+          .isScore
+          ? 1
+          : 0
+        result.indexConfig.score =
+          state.searchMethod[SearchMethodType.Vector].score
+      }
+      break
+    case SearchMethodType.Global:
+      {
+        result.indexConfig.isRerank = state.searchMethod[
+          SearchMethodType.Global
+        ].isRerank
+          ? 1
+          : 0
+        result.indexConfig.rerankType =
+          state.searchMethod[SearchMethodType.Global].rerank
+        result.indexConfig.topK =
+          state.searchMethod[SearchMethodType.Global].topK
+        result.indexConfig.isScore = state.searchMethod[SearchMethodType.Global]
+          .isScore
+          ? 1
+          : 0
+        result.indexConfig.score =
+          state.searchMethod[SearchMethodType.Global].score
+      }
+      break
+    case SearchMethodType.Mix:
+      {
+        result.indexConfig.weightRerank =
+          state.searchMethod[SearchMethodType.Mix].indexMethod
+        result.indexConfig.semantics =
+          state.searchMethod[SearchMethodType.Mix].weight
+        result.indexConfig.keyword =
+          1 - state.searchMethod[SearchMethodType.Mix].weight
+        result.indexConfig.rerankType =
+          state.searchMethod[SearchMethodType.Mix].rerank
+        result.indexConfig.topK = state.searchMethod[SearchMethodType.Mix].topK
+        result.indexConfig.isScore = state.searchMethod[SearchMethodType.Mix]
+          .isScore
+          ? 1
+          : 0
+        result.indexConfig.score =
+          state.searchMethod[SearchMethodType.Mix].score
+      }
+      break
+  }
+  return result
+}
+const init = ({ indexMethod, embedding, searchMethod }) => {
+  state.indexMethod.value = indexMethod
+  state.embedding.value = embedding
+  switch (searchMethod.type) {
+    case SearchMethodType.Vector:
+      {
+        state.searchMethod[SearchMethodType.Vector].isRerank =
+          searchMethod.isRerank == 1
+        state.searchMethod[SearchMethodType.Vector].rerank =
+          searchMethod.rerankType
+        state.searchMethod[SearchMethodType.Vector].topK = searchMethod.topK
+        state.searchMethod[SearchMethodType.Vector].isScore =
+          searchMethod.isScore == 1
+        state.searchMethod[SearchMethodType.Vector].score = searchMethod.score
+      }
+      break
+    case SearchMethodType.Global:
+      {
+        state.searchMethod[SearchMethodType.Global].isRerank =
+          searchMethod.isRerank == 1
+        state.searchMethod[SearchMethodType.Global].rerank =
+          searchMethod.rerankType
+        state.searchMethod[SearchMethodType.Global].topK = searchMethod.topK
+        state.searchMethod[SearchMethodType.Global].isScore =
+          searchMethod.isScore == 1
+        state.searchMethod[SearchMethodType.Global].score = searchMethod.score
+      }
+      break
+    case SearchMethodType.Mix:
+      {
+        state.searchMethod[SearchMethodType.Mix].indexMethod =
+          searchMethod.weightRerank
+        state.searchMethod[SearchMethodType.Mix].weight = Number(
+          searchMethod.semantics,
+        )
+        state.searchMethod[SearchMethodType.Mix].rerank =
+          searchMethod.rerankType
+        state.searchMethod[SearchMethodType.Mix].topK = searchMethod.topK
+        state.searchMethod[SearchMethodType.Mix].isScore =
+          searchMethod.isScore == 1
+        state.searchMethod[SearchMethodType.Mix].score = searchMethod.score
+      }
+      break
+  }
+}
+defineExpose({
+  reset,
+  getData,
+  init,
+})
 </script>
 
 <style lang="scss" scoped>

+ 3 - 3
src/views/manage/knowledge/upload/index.vue

@@ -137,7 +137,7 @@
                   <template v-if="file.hover__">
                     <div
                       class="__hover flex items-center gap-[0.25rem]"
-                      @click="state.uploadFiles.delete(id)"
+                      @click="() => state.uploadFiles.delete(id)"
                     >
                       <SvgIcon name="czr_del" size="14" class="mb-[2px]" />删除
                     </div>
@@ -203,12 +203,12 @@
                 title="返回上一步"
                 icon="czr_arrow"
                 :rotate="180"
-                @click="state.step = 1"
+                @click="() => (state.step = 1)"
               />
               <CzrButton
                 type="primary"
                 title="保存并处理"
-                @click="state.step = 3"
+                @click="() => (state.step = 3)"
               />
             </div>
           </div>

+ 4 - 4
src/views/manage/model/statistic/index.vue

@@ -82,28 +82,28 @@
                   state.statistic.table.dateType === 1 ? 'primary' : 'normal'
                 "
                 title="今日"
-                @click="state.statistic.table.dateType = 1"
+                @click="() => (state.statistic.table.dateType = 1)"
               />
               <CzrButton
                 :type="
                   state.statistic.table.dateType === 2 ? 'primary' : 'normal'
                 "
                 title="近7天"
-                @click="state.statistic.table.dateType = 2"
+                @click="() => (state.statistic.table.dateType = 2)"
               />
               <CzrButton
                 :type="
                   state.statistic.table.dateType === 3 ? 'primary' : 'normal'
                 "
                 title="近30天"
-                @click="state.statistic.table.dateType = 3"
+                @click="() => (state.statistic.table.dateType = 3)"
               />
               <CzrButton
                 :type="
                   state.statistic.table.dateType === 4 ? 'primary' : 'normal'
                 "
                 title="自定义"
-                @click="state.statistic.table.dateType = 4"
+                @click="() => (state.statistic.table.dateType = 4)"
               />
               <CzrFormColumn
                 v-if="state.statistic.table.dateType === 4"

+ 4 - 1
src/views/workflow/instance/component/select-popover/index.vue

@@ -11,7 +11,10 @@
       }"
     >
       <template #reference>
-        <div @click="state.show = !state.show" class="display __hover-bg">
+        <div
+          @click="() => (state.show = !state.show)"
+          class="display __hover-bg"
+        >
           <span>{{
             options.filter((v) => v.value === value)[0]?.label || ''
           }}</span>

+ 1 - 1
src/views/workflow/instance/component/vars/env-detail.vue

@@ -15,7 +15,7 @@
           <div
             class="__hover"
             :class="{ active: state.form.type === item.type }"
-            @click="state.form.type = item.type"
+            @click="() => (state.form.type = item.type)"
           >
             {{ item.label }}
           </div>

+ 1 - 1
src/views/workflow/instance/component/vars/vars-detail.vue

@@ -15,7 +15,7 @@
           <div
             class="__hover"
             :class="{ active: state.form.type === item.type }"
-            @click="state.form.type = item.type"
+            @click="() => (state.form.type = item.type)"
           >
             {{ item.label }}
           </div>

+ 1 - 1
src/views/workflow/instance/component/vars/vars-popover.vue

@@ -10,7 +10,7 @@
       }"
     >
       <template #reference>
-        <div @click="state.show = !state.show" class="__hover">
+        <div @click="() => (state.show = !state.show)" class="__hover">
           <slot name="default" />
         </div>
       </template>