|
@@ -71,7 +71,7 @@
|
|
|
label="模型类型"
|
|
|
v-model:param="state.embedding.value"
|
|
|
link="select"
|
|
|
- :options="DictionaryStore.embeddingModels.list"
|
|
|
+ :options="state.optionsEmbedding"
|
|
|
:clearable="false"
|
|
|
/>
|
|
|
</template>
|
|
@@ -131,7 +131,7 @@
|
|
|
state.searchMethod[SearchMethodType.Vector].rerank
|
|
|
"
|
|
|
link="select"
|
|
|
- :options="DictionaryStore.rerankModels.list"
|
|
|
+ :options="state.optionsRerank"
|
|
|
:clearable="false"
|
|
|
default-error-msg="请选择Rerank模型"
|
|
|
/>
|
|
@@ -247,7 +247,7 @@
|
|
|
state.searchMethod[SearchMethodType.Global].rerank
|
|
|
"
|
|
|
link="select"
|
|
|
- :options="DictionaryStore.rerankModels.list"
|
|
|
+ :options="state.optionsRerank"
|
|
|
:clearable="false"
|
|
|
default-error-msg="请选择Rerank模型"
|
|
|
/>
|
|
@@ -451,7 +451,7 @@
|
|
|
label-width="0px"
|
|
|
v-model:param="state.searchMethod[SearchMethodType.Mix].rerank"
|
|
|
link="select"
|
|
|
- :options="DictionaryStore.rerankModels.list"
|
|
|
+ :options="state.optionsRerank"
|
|
|
:clearable="false"
|
|
|
default-error-msg="请选择Rerank模型"
|
|
|
/>
|
|
@@ -520,8 +520,17 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { getCurrentInstance, onMounted, reactive, ref, watch } from 'vue'
|
|
|
+import {
|
|
|
+ computed,
|
|
|
+ getCurrentInstance,
|
|
|
+ onMounted,
|
|
|
+ reactive,
|
|
|
+ ref,
|
|
|
+ watch,
|
|
|
+} from 'vue'
|
|
|
import { useDictionaryStore } from '@/stores'
|
|
|
+import { pluginGetListByType, pluginInstanceByType } from '@/api/modules/model'
|
|
|
+import { ElMessage } from 'element-plus'
|
|
|
|
|
|
const DictionaryStore = useDictionaryStore()
|
|
|
const emit = defineEmits([])
|
|
@@ -533,6 +542,8 @@ enum SearchMethodType {
|
|
|
Mix = 'HYBRID',
|
|
|
}
|
|
|
const state: any = reactive({
|
|
|
+ optionsEmbedding: [],
|
|
|
+ optionsRerank: [],
|
|
|
indexMethod: {
|
|
|
show: true,
|
|
|
value: '高质量',
|
|
@@ -568,6 +579,20 @@ const state: any = reactive({
|
|
|
},
|
|
|
},
|
|
|
})
|
|
|
+const optionsEmbeddingMapCpt = computed(() => {
|
|
|
+ const map = new Map()
|
|
|
+ state.optionsEmbedding.forEach((v) => {
|
|
|
+ map.set(v.value, v)
|
|
|
+ })
|
|
|
+ return map
|
|
|
+})
|
|
|
+const optionsRerankMapCpt = computed(() => {
|
|
|
+ const map = new Map()
|
|
|
+ state.optionsRerank.forEach((v) => {
|
|
|
+ map.set(v.value, v)
|
|
|
+ })
|
|
|
+ return map
|
|
|
+})
|
|
|
const reset = () => {
|
|
|
state.indexMethod = {
|
|
|
show: true,
|
|
@@ -608,9 +633,8 @@ const getData = () => {
|
|
|
const result = {
|
|
|
indexingTechnique: state.indexMethod.value,
|
|
|
embeddingModelId: state.embedding.value,
|
|
|
- embeddingModel: DictionaryStore.embeddingModels.map.get(
|
|
|
- state.embedding.value,
|
|
|
- ),
|
|
|
+ embeddingModel: optionsEmbeddingMapCpt.value.get(state.embedding.value)
|
|
|
+ .label,
|
|
|
indexConfig: {
|
|
|
type: state.searchMethod.value,
|
|
|
},
|
|
@@ -620,8 +644,11 @@ const getData = () => {
|
|
|
{
|
|
|
result.indexConfig.isRerank =
|
|
|
state.searchMethod[SearchMethodType.Vector].isRerank
|
|
|
- result.indexConfig.rerankType =
|
|
|
+ result.indexConfig.rerankTypeId =
|
|
|
state.searchMethod[SearchMethodType.Vector].rerank
|
|
|
+ result.indexConfig.rerankType = optionsRerankMapCpt.value.get(
|
|
|
+ state.searchMethod[SearchMethodType.Vector].rerank,
|
|
|
+ ).label
|
|
|
result.indexConfig.topK =
|
|
|
state.searchMethod[SearchMethodType.Vector].topK
|
|
|
result.indexConfig.isScore =
|
|
@@ -634,8 +661,11 @@ const getData = () => {
|
|
|
{
|
|
|
result.indexConfig.isRerank =
|
|
|
state.searchMethod[SearchMethodType.Global].isRerank
|
|
|
- result.indexConfig.rerankType =
|
|
|
+ result.indexConfig.rerankTypeId =
|
|
|
state.searchMethod[SearchMethodType.Global].rerank
|
|
|
+ result.indexConfig.rerankType = optionsRerankMapCpt.value.get(
|
|
|
+ state.searchMethod[SearchMethodType.Global].rerank,
|
|
|
+ ).label
|
|
|
result.indexConfig.topK =
|
|
|
state.searchMethod[SearchMethodType.Global].topK
|
|
|
result.indexConfig.isScore =
|
|
@@ -652,8 +682,11 @@ const getData = () => {
|
|
|
state.searchMethod[SearchMethodType.Mix].weight
|
|
|
result.indexConfig.keyword =
|
|
|
1 - state.searchMethod[SearchMethodType.Mix].weight
|
|
|
- result.indexConfig.rerankType =
|
|
|
+ result.indexConfig.rerankTypeId =
|
|
|
state.searchMethod[SearchMethodType.Mix].rerank
|
|
|
+ result.indexConfig.rerankType = optionsRerankMapCpt.value.get(
|
|
|
+ state.searchMethod[SearchMethodType.Mix].rerank,
|
|
|
+ ).label
|
|
|
result.indexConfig.topK = state.searchMethod[SearchMethodType.Mix].topK
|
|
|
result.indexConfig.isScore =
|
|
|
state.searchMethod[SearchMethodType.Mix].isScore
|
|
@@ -676,7 +709,7 @@ const init = ({ indexingTechnique, embeddingModelId, indexConfig }) => {
|
|
|
indexConfig.isRerank,
|
|
|
)
|
|
|
state.searchMethod[SearchMethodType.Vector].rerank =
|
|
|
- indexConfig.rerankType
|
|
|
+ indexConfig.rerankTypeId
|
|
|
state.searchMethod[SearchMethodType.Vector].topK = Number(
|
|
|
indexConfig.topK,
|
|
|
)
|
|
@@ -694,7 +727,7 @@ const init = ({ indexingTechnique, embeddingModelId, indexConfig }) => {
|
|
|
indexConfig.isRerank,
|
|
|
)
|
|
|
state.searchMethod[SearchMethodType.Global].rerank =
|
|
|
- indexConfig.rerankType
|
|
|
+ indexConfig.rerankTypeId
|
|
|
state.searchMethod[SearchMethodType.Global].topK = Number(
|
|
|
indexConfig.topK,
|
|
|
)
|
|
@@ -713,7 +746,8 @@ const init = ({ indexingTechnique, embeddingModelId, indexConfig }) => {
|
|
|
state.searchMethod[SearchMethodType.Mix].weight = Number(
|
|
|
indexConfig.semantics,
|
|
|
)
|
|
|
- state.searchMethod[SearchMethodType.Mix].rerank = indexConfig.rerankType
|
|
|
+ state.searchMethod[SearchMethodType.Mix].rerank =
|
|
|
+ indexConfig.rerankTypeId
|
|
|
state.searchMethod[SearchMethodType.Mix].topK = Number(indexConfig.topK)
|
|
|
state.searchMethod[SearchMethodType.Mix].isScore = Number(
|
|
|
indexConfig.isScore,
|
|
@@ -726,14 +760,37 @@ const init = ({ indexingTechnique, embeddingModelId, indexConfig }) => {
|
|
|
}
|
|
|
}
|
|
|
onMounted(() => {
|
|
|
- DictionaryStore.initRerankModels()
|
|
|
- DictionaryStore.initEmbeddingModels()
|
|
|
+ initDictionary()
|
|
|
})
|
|
|
defineExpose({
|
|
|
reset,
|
|
|
getData,
|
|
|
init,
|
|
|
})
|
|
|
+const initDictionary = () => {
|
|
|
+ pluginGetListByType({ type: 'EMBEDDING' })
|
|
|
+ .then(({ data }: any) => {
|
|
|
+ state.optionsEmbedding = data.map((v) => {
|
|
|
+ v.label = v.name
|
|
|
+ v.value = v.id
|
|
|
+ return v
|
|
|
+ })
|
|
|
+ })
|
|
|
+ .catch(({ message }: any) => {
|
|
|
+ ElMessage.error(message)
|
|
|
+ })
|
|
|
+ pluginGetListByType({ type: 'RERANK' })
|
|
|
+ .then(({ data }: any) => {
|
|
|
+ state.optionsRerank = data.map((v) => {
|
|
|
+ v.label = v.name
|
|
|
+ v.value = v.id
|
|
|
+ return v
|
|
|
+ })
|
|
|
+ })
|
|
|
+ .catch(({ message }: any) => {
|
|
|
+ ElMessage.error(message)
|
|
|
+ })
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|