知识库功能增强,支持Milvus,并优化相关逻辑

This commit is contained in:
2026-02-24 11:19:53 +08:00
parent 148a08a3f1
commit 094b185c49
10 changed files with 196 additions and 59 deletions

View File

@@ -1,9 +1,5 @@
<script setup lang="ts">
import type { FormInstance } from 'element-plus';
import { onMounted, ref } from 'vue';
import { InfoFilled } from '@element-plus/icons-vue';
import type {FormInstance} from 'element-plus';
import {
ElButton,
ElDialog,
@@ -18,10 +14,14 @@ import {
ElTooltip,
} from 'element-plus';
import { api } from '#/api/request';
import {onMounted, ref} from 'vue';
import {InfoFilled} from '@element-plus/icons-vue';
import {api} from '#/api/request';
import DictSelect from '#/components/dict/DictSelect.vue';
import UploadAvatar from '#/components/upload/UploadAvatar.vue';
import { $t } from '#/locales';
import {$t} from '#/locales';
const emit = defineEmits(['reload']);
const embeddingLlmList = ref<any>([]);
@@ -83,12 +83,28 @@ const defaultEntity = {
dimensionOfVectorModel: undefined,
options: {
canUpdateEmbeddingModel: true,
rerankEnable: false,
},
rerankModelId: '',
searchEngineEnable: '',
englishName: '',
};
const entity = ref<any>({ ...defaultEntity });
const normalizeEntity = (raw: any = {}) => {
const options = {
canUpdateEmbeddingModel: true,
...(raw.options || {}),
};
if (options.rerankEnable === undefined || options.rerankEnable === null) {
options.rerankEnable = !!raw.rerankModelId;
}
return {
...defaultEntity,
...raw,
options,
};
};
const entity = ref<any>(normalizeEntity(defaultEntity));
const btnLoading = ref(false);
const rules = ref({
@@ -119,14 +135,10 @@ const rules = ref({
function openDialog(row: any = {}) {
if (row.id) {
isAdd.value = false;
entity.value = {
...defaultEntity,
...row,
options: { ...defaultEntity.options, ...row.options },
};
entity.value = normalizeEntity(row);
} else {
isAdd.value = true;
entity.value = { ...defaultEntity };
entity.value = normalizeEntity(defaultEntity);
}
dialogVisible.value = true;
}
@@ -136,6 +148,11 @@ async function save() {
const valid = await saveForm.value?.validate();
if (!valid) return;
if (!entity.value.options) {
entity.value.options = {};
}
entity.value.options.rerankEnable = !!entity.value.options.rerankEnable;
btnLoading.value = true;
const res = await api.post(
isAdd.value
@@ -162,7 +179,7 @@ async function save() {
function closeDialog() {
saveForm.value?.resetFields();
isAdd.value = true;
entity.value = { ...defaultEntity };
entity.value = normalizeEntity(defaultEntity);
dialogVisible.value = false;
}
@@ -339,12 +356,19 @@ defineExpose({
type="number"
/>
</ElFormItem>
<ElFormItem
prop="options.rerankEnable"
:label="$t('documentCollection.rerankEnable')"
>
<ElSwitch v-model="entity.options.rerankEnable" />
</ElFormItem>
<ElFormItem
prop="rerankModelId"
:label="$t('documentCollection.rerankLlmId')"
>
<ElSelect
v-model="entity.rerankModelId"
clearable
:placeholder="$t('documentCollection.placeholder.rerankLlm')"
>
<ElOption