From 18cdd44d753c75416930e22de27d20f8b6b18846 Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Wed, 17 Jul 2024 19:09:36 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E6=95=B0=E6=8D=AE=E5=BA=93=E7=9A=84=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/stores/modules/model.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/src/stores/modules/model.ts b/ui/src/stores/modules/model.ts index a68b1e54a..0875e200e 100644 --- a/ui/src/stores/modules/model.ts +++ b/ui/src/stores/modules/model.ts @@ -1,11 +1,11 @@ import { defineStore } from 'pinia' import modelApi from '@/api/model' -import type { modelRequest, Provider } from '@/api/type/model' +import type { ListModelRequest, Provider } from '@/api/type/model' const useModelStore = defineStore({ id: 'model', state: () => ({}), actions: { - async asyncGetModel(data?: modelRequest) { + async asyncGetModel(data?: ListModelRequest) { return new Promise((resolve, reject) => { modelApi .getModel(data) From 73937746f9a73bf62f79c5ac70a95938c261998b Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Thu, 18 Jul 2024 14:34:09 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=E7=9F=A5=E8=AF=86=E5=BA=93?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=A2=9E=E5=8A=A0embedding=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/api/dataset.ts | 11 +-- ui/src/views/dataset/DatasetSetting.vue | 43 +++++++--- ui/src/views/dataset/component/BaseForm.vue | 93 ++++++++++++++++++--- 3 files changed, 121 insertions(+), 26 deletions(-) diff --git a/ui/src/api/dataset.ts b/ui/src/api/dataset.ts index df06d2768..6e61db1df 100644 --- a/ui/src/api/dataset.ts +++ b/ui/src/api/dataset.ts @@ -129,11 +129,12 @@ const getDatasetDetail: (dataset_id: string, loading?: Ref) => Promise< "desc": true } */ -const putDataset: (dataset_id: string, data: any) => Promise> = ( - dataset_id, - data: any -) => { - return put(`${prefix}/${dataset_id}`, data) +const putDataset: ( + dataset_id: string, + data: any, + loading?: Ref +) => Promise> = (dataset_id, data, loading) => { + return put(`${prefix}/${dataset_id}`, data, undefined, loading) } /** * 获取知识库 可关联的应用列表 diff --git a/ui/src/views/dataset/DatasetSetting.vue b/ui/src/views/dataset/DatasetSetting.vue index 2ede13ba5..803508184 100644 --- a/ui/src/views/dataset/DatasetSetting.vue +++ b/ui/src/views/dataset/DatasetSetting.vue @@ -105,7 +105,7 @@ import { useRoute } from 'vue-router' import BaseForm from '@/views/dataset/component/BaseForm.vue' import datasetApi from '@/api/dataset' import type { ApplicationFormType } from '@/api/type/application' -import { MsgSuccess } from '@/utils/message' +import { MsgSuccess, MsgConfirm } from '@/utils/message' import { isAppIcon } from '@/utils/application' import useStore from '@/stores' const route = useRoute() @@ -120,6 +120,8 @@ const loading = ref(false) const detail = ref({}) const application_list = ref>([]) const application_id_list = ref([]) +const cloneModelId = ref('') + const form = ref({ source_url: '', selector: '' @@ -133,7 +135,6 @@ async function submit() { if (await BaseFormRef.value?.validate()) { await webFormRef.value.validate((valid: any) => { if (valid) { - loading.value = true const obj = detail.value.type === '1' ? { @@ -145,27 +146,49 @@ async function submit() { application_id_list: application_id_list.value, ...BaseFormRef.value.form } - datasetApi - .putDataset(id, obj) - .then((res) => { + + if (cloneModelId.value !== BaseFormRef.value.form.embedding_mode_id) { + MsgConfirm(`提示`, `修改知识库向量模型后,需要对知识库重新向量化,是否继续保存?`, { + confirmButtonText: '重新向量化', + confirmButtonClass: 'primary' + }) + .then(() => { + datasetApi.putDataset(id, obj, loading).then((res) => { + datasetApi.putReEmbeddingDataset(id).then(() => { + MsgSuccess('保存成功') + }) + }) + }) + .catch(() => {}) + } else { + datasetApi.putDataset(id, obj, loading).then((res) => { MsgSuccess('保存成功') - loading.value = false - }) - .catch(() => { - loading.value = false }) + } } }) } } +function reEmbeddingDataset(row: any) { + datasetApi.putReEmbeddingDataset(row.id).then(() => { + MsgSuccess('提交成功') + }) +} + +function saveDataset(data: any) { + datasetApi.putDataset(id, data, loading).then((res) => { + MsgSuccess('保存成功') + }) +} + function getDetail() { dataset.asyncGetDatasetDetail(id, loading).then((res: any) => { detail.value = res.data + cloneModelId.value = res.data?.embedding_mode_id if (detail.value.type === '1') { form.value = res.data.meta } - application_id_list.value = res.data?.application_id_list datasetApi.listUsableApplication(id, loading).then((ok) => { application_list.value = ok.data diff --git a/ui/src/views/dataset/component/BaseForm.vue b/ui/src/views/dataset/component/BaseForm.vue index 88b7d22dd..debe81d63 100644 --- a/ui/src/views/dataset/component/BaseForm.vue +++ b/ui/src/views/dataset/component/BaseForm.vue @@ -5,6 +5,7 @@ :rules="rules" label-position="top" require-asterisk-position="right" + v-loading="loading" > - + + +
+ + {{ item.name }} +
+ +
+ + +
+ + {{ item.name }} + {{ + $t('views.application.applicationForm.form.aiModel.unavailable') + }} +
+ +
+
+ diff --git a/ui/src/views/log/component/EditMarkDialog.vue b/ui/src/views/log/component/EditMarkDialog.vue index cae7155c5..29adb9282 100644 --- a/ui/src/views/log/component/EditMarkDialog.vue +++ b/ui/src/views/log/component/EditMarkDialog.vue @@ -141,4 +141,13 @@ const submit = async (formEl: FormInstance) => { defineExpose({ open }) - +