diff --git a/ui/src/api/model/model.ts b/ui/src/api/model/model.ts index a88faca13..dcdcdb1a4 100644 --- a/ui/src/api/model/model.ts +++ b/ui/src/api/model/model.ts @@ -22,62 +22,24 @@ Object.defineProperty(prefix, 'value', { * 获得模型列表 * @params 参数 name, model_type, model_name */ -const getModel: ( +const getModelList: ( data?: ListModelRequest, loading?: Ref, ) => Promise>> = (data, loading) => { - return get(`${prefix.value}`, data, loading) -} -/** - * 获取工作空间下重排模型列表 - * @param loading 加载器 - * @returns 重排模型列表 - */ -const getRerankerModel: (loading?: Ref) => Promise>> = (loading) => { - return get(`${prefix.value}`, { model_type: 'RERANKER' }, loading) + return get(`${prefix.value}/model`, data, loading) } /** - * 获取语音转文本模型列表 - * @param loading - * @returns 语音转文本模型列表 + * 获得下拉选择框模型列表 + * @params 参数 name, model_type, model_name */ -const getSTTModel: (loading?: Ref) => Promise>> = (loading) => { - return get(`${prefix.value}`, { model_type: 'STT' }, loading) +const getSelectModelList: ( + data?: ListModelRequest, + loading?: Ref, +) => Promise>> = (data, loading) => { + return get(`${prefix.value}/model_list`, data, loading) } -/** - * 获取文本转语音模型列表 - * @param loading - * @returns - */ -const getTTSModel: (loading?: Ref) => Promise>> = (loading) => { - return get(`${prefix.value}`, { model_type: 'TTS' }, loading) -} -/** - * 获取图片理解模型列表 - * @param loading - * @returns 图片理解模型列表 - */ -const getImageModel: (loading?: Ref) => Promise>> = (loading) => { - return get(`${prefix.value}`, { model_type: 'IMAGE' }, loading) -} -/** - * 获取图片生成模型列表 - * @param loading - * @returns 图片生成模型列表 - */ -const getTTIModel: (loading?: Ref) => Promise>> = (loading) => { - return get(`${prefix.value}`, { model_type: 'TTI' }, loading) -} -/** - * 获取大语言模型列表 - * @param loading - * @returns 大语言模型列表 - */ -const getLLMModel: (loading?: Ref) => Promise>> = (loading) => { - return get(`${prefix.value}`, { model_type: 'LLM' }, loading) -} /** * 获取模型参数表单 * @param model_id 模型id @@ -88,7 +50,7 @@ const getModelParamsForm: ( model_id: string, loading?: Ref, ) => Promise>> = (model_id, loading) => { - return get(`${prefix.value}/${model_id}/model_params_form`, {}, loading) + return get(`${prefix.value}/model/${model_id}/model_params_form`, {}, loading) } /** @@ -101,7 +63,7 @@ const createModel: ( request: CreateModelRequest, loading?: Ref, ) => Promise> = (request, loading) => { - return post(`${prefix.value}`, request, {}, loading) + return post(`${prefix.value}/model`, request, {}, loading) } /** @@ -115,7 +77,7 @@ const updateModel: ( request: EditModelRequest, loading?: Ref, ) => Promise> = (model_id, request, loading) => { - return put(`${prefix.value}/${model_id}`, request, {}, loading) + return put(`${prefix.value}/model/${model_id}`, request, {}, loading) } /** @@ -129,7 +91,7 @@ const updateModelParamsForm: ( request: any[], loading?: Ref, ) => Promise> = (model_id, request, loading) => { - return put(`${prefix.value}/${model_id}/model_params_form`, request, {}, loading) + return put(`${prefix.value}/model/${model_id}/model_params_form`, request, {}, loading) } /** @@ -142,7 +104,7 @@ const getModelById: (model_id: string, loading?: Ref) => Promise { - return get(`${prefix.value}/${model_id}`, {}, loading) + return get(`${prefix.value}/model/${model_id}`, {}, loading) } /** * 获取模型信息不包括认证信息根据模型id @@ -154,7 +116,7 @@ const getModelMetaById: (model_id: string, loading?: Ref) => Promise { - return get(`${prefix.value}/${model_id}/meta`, {}, loading) + return get(`${prefix.value}/model/${model_id}/meta`, {}, loading) } /** * 暂停下载 @@ -166,16 +128,16 @@ const pauseDownload: (model_id: string, loading?: Ref) => Promise { - return put(`${prefix.value}/${model_id}/pause_download`, undefined, {}, loading) + return put(`${prefix.value}/model/${model_id}/pause_download`, undefined, {}, loading) } const deleteModel: (model_id: string, loading?: Ref) => Promise> = ( model_id, loading, ) => { - return del(`${prefix.value}/${model_id}`, undefined, {}, loading) + return del(`${prefix.value}/model/${model_id}`, undefined, {}, loading) } export default { - getModel, + getModelList, createModel, updateModel, deleteModel, @@ -184,10 +146,5 @@ export default { pauseDownload, getModelParamsForm, updateModelParamsForm, - getRerankerModel, - getSTTModel, - getTTSModel, - getImageModel, - getTTIModel, - getLLMModel, + getSelectModelList, } diff --git a/ui/src/api/resource-management/model.ts b/ui/src/api/resource-management/model.ts index 6d20c92bb..554d1c864 100644 --- a/ui/src/api/resource-management/model.ts +++ b/ui/src/api/resource-management/model.ts @@ -16,7 +16,7 @@ const workspace_id = localStorage.getItem('workspace_id') || 'default' * 获得模型列表 * @params 参数 name, model_type, model_name */ -const getModel: ( +const getModelList: ( request?: ListModelRequest, loading?: Ref, ) => Promise>> = (data, loading) => { @@ -121,7 +121,7 @@ const deleteModel: (model_id: string, loading?: Ref) => Promise, ) => Promise>> = (param: any, loading) => { @@ -57,7 +57,7 @@ const getToolListPage: ( export default { getKnowledgeList, getKnowledgeListPage, - getModel, + getModelList, getToolList, getToolListPage } diff --git a/ui/src/api/system-shared/model.ts b/ui/src/api/system-shared/model.ts index 6d56ea4d5..2a0466d3d 100644 --- a/ui/src/api/system-shared/model.ts +++ b/ui/src/api/system-shared/model.ts @@ -15,13 +15,24 @@ const prefix = '/system/shared/model' * 获得模型列表 * @params 参数 name, model_type, model_name */ -const getModel: ( +const getModelList: ( request?: ListModelRequest, loading?: Ref, ) => Promise>> = (data, loading) => { return get(`${prefix}`, data, loading) } +/** + * 获得下拉选择框模型列表 + * @params 参数 name, model_type, model_name + */ +const getSelectModelList: ( + data?: ListModelRequest, + loading?: Ref, +) => Promise>> = (data, loading) => { + return get(`${prefix}`, data, loading) +} + /** * 获取模型参数表单 * @param model_id 模型id @@ -120,7 +131,7 @@ const deleteModel: (model_id: string, loading?: Ref) => Promise { const open = (ids: string[], type: string, _knowledgeId?: string) => { knowledgeId.value = _knowledgeId - getModel() + getModelFn() idList.value = ids apiSubmitType.value = type dialogVisible.value = true @@ -188,7 +188,7 @@ const submitHandle = async (formEl: FormInstance) => { }) } -function getModel() { +function getModelFn() { loading.value = true loadSharedApi({ type: 'knowledge', systemType: props.apiType }) .getKnowledgeModel() diff --git a/ui/src/components/generate-related-resource-dialog/index.vue b/ui/src/components/generate-related-resource-dialog/index.vue index bab3e6bd8..909df4438 100644 --- a/ui/src/components/generate-related-resource-dialog/index.vue +++ b/ui/src/components/generate-related-resource-dialog/index.vue @@ -137,7 +137,7 @@ watch(dialogVisible, (bool) => { const open = (ids: string[], type: string, _knowledgeId?: string) => { knowledgeId.value = _knowledgeId - getModel() + getModelFn() idList.value = ids apiType.value = type dialogVisible.value = true @@ -186,7 +186,7 @@ const submitHandle = async (formEl: FormInstance) => { }) } -function getModel() { +function getModelFn() { loading.value = true knowledgeApi .getKnowledgeModel() diff --git a/ui/src/stores/modules-resource-management/model.ts b/ui/src/stores/modules-resource-management/model.ts index 678d34462..fbf6657d3 100644 --- a/ui/src/stores/modules-resource-management/model.ts +++ b/ui/src/stores/modules-resource-management/model.ts @@ -7,9 +7,9 @@ import type {ListModelRequest} from '@/api/type/model' const useModelStore = defineStore('mod', { state: () => ({}), actions: { - async asyncGetModel(data?: ListModelRequest, loading?: Ref) { + async asyncGetSelectModel(data?: ListModelRequest, loading?: Ref) { return new Promise((resolve, reject) => { - ModelApi.getModel(data, loading) + ModelApi.getModelList(data, loading) .then((res) => { resolve(res) }) diff --git a/ui/src/stores/modules/model.ts b/ui/src/stores/modules/model.ts index 6af103ee9..20f3f0ada 100644 --- a/ui/src/stores/modules/model.ts +++ b/ui/src/stores/modules/model.ts @@ -7,14 +7,14 @@ import { loadSharedApi } from '@/utils/dynamics-api/shared-api' const useModelStore = defineStore('model', { state: () => ({}), actions: { - async asyncGetModel( - data?: ListModelRequest, + async asyncGetSelectModel( systemType: 'systemShare' | 'workspace' | 'systemManage' = 'workspace', + data?: ListModelRequest, loading?: Ref, ) { return new Promise((resolve, reject) => { loadSharedApi({ type: 'model', systemType }) - .getModel(data, loading) + .getSelectModelList(data, loading) .then((res: any) => { resolve(res) }) diff --git a/ui/src/styles/component.scss b/ui/src/styles/component.scss index 1219445a5..b14b76728 100644 --- a/ui/src/styles/component.scss +++ b/ui/src/styles/component.scss @@ -90,7 +90,6 @@ width: 280px; .el-dropdown-menu__item { padding: 8px 12px; - width: 100%; &:hover { background: var(--app-text-color-light-1); } diff --git a/ui/src/views/application/ApplicationSetting.vue b/ui/src/views/application/ApplicationSetting.vue index 0ad6e316c..6dd75f5a0 100644 --- a/ui/src/views/application/ApplicationSetting.vue +++ b/ui/src/views/application/ApplicationSetting.vue @@ -85,7 +85,7 @@ :placeholder="$t('views.application.form.aiModel.placeholder')" :options="modelOptions" @change="model_change" - @submitModel="getModel" + @submitModel="getSelectModel" showFooter :model-type="'LLM'" > @@ -645,10 +645,10 @@ function getKnowledge() { }) } -function getModel() { +function getSelectModel() { loading.value = true modelAPI - .getLLMModel() + .getSelectModelList({ model_type: 'LLM' }) .then((res: any) => { modelOptions.value = groupBy(res?.data, 'provider') loading.value = false @@ -661,7 +661,7 @@ function getModel() { function getSTTModel() { loading.value = true modelAPI - .getSTTModel() + .getSelectModelList({ model_type: 'STT' }) .then((res: any) => { sttModelOptions.value = groupBy(res?.data, 'provider') loading.value = false @@ -674,7 +674,7 @@ function getSTTModel() { function getTTSModel() { loading.value = true modelAPI - .getTTSModel() + .getSelectModelList({ model_type: 'TTS' }) .then((res: any) => { ttsModelOptions.value = groupBy(res?.data, 'provider') loading.value = false @@ -717,7 +717,7 @@ function refresh() { } onMounted(() => { - getModel() + getSelectModel() getKnowledge() getDetail() getSTTModel() diff --git a/ui/src/views/knowledge/component/BaseForm.vue b/ui/src/views/knowledge/component/BaseForm.vue index 75acd819c..fe85b787a 100644 --- a/ui/src/views/knowledge/component/BaseForm.vue +++ b/ui/src/views/knowledge/component/BaseForm.vue @@ -49,7 +49,7 @@ import type { knowledgeData } from '@/api/type/knowledge' import { t } from '@/locales' const props = defineProps<{ - data: { + data?: { type: Object default: () => {} } @@ -114,11 +114,13 @@ function validate() { }) } -function getModel() { +function getSelectModel() { loading.value = true + model - .asyncGetModel({ model_type: 'EMBEDDING' }, props.apiType) + .asyncGetSelectModel(props.apiType, { model_type: 'EMBEDDING' }) .then((res: any) => { + modelOptions.value = groupBy(res?.data, 'provider') loading.value = false }) @@ -128,7 +130,7 @@ function getModel() { } onMounted(() => { - getModel() + getSelectModel() }) onUnmounted(() => { form.value = { diff --git a/ui/src/views/model/index.vue b/ui/src/views/model/index.vue index 283e9d31c..0b5c2a812 100644 --- a/ui/src/views/model/index.vue +++ b/ui/src/views/model/index.vue @@ -203,7 +203,7 @@ const openCreateModel = (provider?: Provider, model_type?: string) => { const list_model = () => { const params = active_provider.value?.provider ? { provider: active_provider.value.provider } : {} loadSharedApi({ type: 'model', isShared: isShared.value, systemType: apiType.value }) - .getModel({ ...model_search_form.value, ...params }, list_model_loading) + .getModelList({ ...model_search_form.value, ...params }, list_model_loading) .then((ok: any) => { model_list.value = ok.data const v = model_list.value.map((m) => ({ id: m.user_id, username: m.username })) diff --git a/ui/src/views/resource-management/knowledge/component/BaseForm.vue b/ui/src/views/resource-management/knowledge/component/BaseForm.vue index 9d9d3e84a..c451f8173 100644 --- a/ui/src/views/resource-management/knowledge/component/BaseForm.vue +++ b/ui/src/views/resource-management/knowledge/component/BaseForm.vue @@ -114,10 +114,10 @@ function validate() { }) } -function getModel() { +function getSelectModel() { loading.value = true model - .asyncGetModel({model_type: 'EMBEDDING'}) + .asyncGetSelectModel({model_type: 'EMBEDDING'}) .then((res: any) => { modelOptions.value = groupBy(res?.data, 'provider') loading.value = false @@ -128,7 +128,7 @@ function getModel() { } onMounted(() => { - getModel() + getSelectModel() }) onUnmounted(() => { form.value = { diff --git a/ui/src/workflow/nodes/ai-chat-node/index.vue b/ui/src/workflow/nodes/ai-chat-node/index.vue index 4bab2f0b3..bc34cae3d 100644 --- a/ui/src/workflow/nodes/ai-chat-node/index.vue +++ b/ui/src/workflow/nodes/ai-chat-node/index.vue @@ -47,7 +47,7 @@ v-model="chat_data.model_id" :placeholder="$t('views.application.form.aiModel.placeholder')" :options="modelOptions" - @submitModel="getModel" + @submitModel="getSelectModel" showFooter :model-type="'LLM'" > @@ -270,13 +270,13 @@ const validate = () => { }) } -function getModel() { +function getSelectModel() { if (id) { - modelAPI.getLLMModel().then((res: any) => { + modelAPI.getSelectModelList({ model_type: 'LLM' }).then((res: any) => { modelOptions.value = groupBy(res?.data, 'provider') }) } else { - model.asyncGetModel().then((res: any) => { + model.asyncGetSelectModel('workspace').then((res: any) => { modelOptions.value = groupBy(res?.data, 'provider') }) } @@ -321,7 +321,7 @@ function submitMcpServersDialog(config: any) { } onMounted(() => { - getModel() + getSelectModel() if (typeof props.nodeModel.properties.node_data?.is_result === 'undefined') { if (isLastNode(props.nodeModel)) { set(props.nodeModel.properties.node_data, 'is_result', true) diff --git a/ui/src/workflow/nodes/base-node/index.vue b/ui/src/workflow/nodes/base-node/index.vue index 1c531c062..8cb8e92ff 100644 --- a/ui/src/workflow/nodes/base-node/index.vue +++ b/ui/src/workflow/nodes/base-node/index.vue @@ -253,13 +253,13 @@ const validate = () => { } function getSTTModel() { - modelAPI.getSTTModel().then((res: any) => { + modelAPI.getSelectModelList({ model_type: 'STT' }).then((res: any) => { sttModelOptions.value = groupBy(res?.data, 'provider') }) } function getTTSModel() { - modelAPI.getTTSModel().then((res: any) => { + modelAPI.getSelectModelList({ model_type: 'TTS' }).then((res: any) => { ttsModelOptions.value = groupBy(res?.data, 'provider') }) } diff --git a/ui/src/workflow/nodes/image-generate/index.vue b/ui/src/workflow/nodes/image-generate/index.vue index df405f204..0b2741976 100644 --- a/ui/src/workflow/nodes/image-generate/index.vue +++ b/ui/src/workflow/nodes/image-generate/index.vue @@ -219,14 +219,14 @@ const form_data = computed({ }, }) -function getModel() { +function getSelectModel() { if (id) { // todo - // applicationApi.getApplicationTTIModel(id).then((res: any) => { - // modelOptions.value = groupBy(res?.data, 'provider') - // }) + applicationApi.getApplicationTTIModel(id).then((res: any) => { + modelOptions.value = groupBy(res?.data, 'provider') + }) } else { - model.asyncGetModel().then((res: any) => { + model.asyncGetSelectModel('workspace').then((res: any) => { modelOptions.value = groupBy(res?.data, 'provider') }) } @@ -259,7 +259,7 @@ function submitNegativeDialog(val: string) { } onMounted(() => { - getModel() + getSelectModel() set(props.nodeModel, 'validate', validate) }) diff --git a/ui/src/workflow/nodes/image-understand/index.vue b/ui/src/workflow/nodes/image-understand/index.vue index c1add63f1..2a050be8d 100644 --- a/ui/src/workflow/nodes/image-understand/index.vue +++ b/ui/src/workflow/nodes/image-understand/index.vue @@ -239,14 +239,14 @@ const form_data = computed({ }, }) -function getModel() { +function getSelectModel() { if (id) { //todo - // applicationApi.getApplicationImageModel(id).then((res: any) => { - // modelOptions.value = groupBy(res?.data, 'provider') - // }) + applicationApi.getApplicationImageModel(id).then((res: any) => { + modelOptions.value = groupBy(res?.data, 'provider') + }) } else { - model.asyncGetModel().then((res: any) => { + model.asyncGetSelectModel('workspace').then((res: any) => { modelOptions.value = groupBy(res?.data, 'provider') }) } @@ -271,7 +271,7 @@ function refreshParam(data: any) { } onMounted(() => { - getModel() + getSelectModel() set(props.nodeModel, 'validate', validate) }) diff --git a/ui/src/workflow/nodes/question-node/index.vue b/ui/src/workflow/nodes/question-node/index.vue index 76b2eaaab..64b87060d 100644 --- a/ui/src/workflow/nodes/question-node/index.vue +++ b/ui/src/workflow/nodes/question-node/index.vue @@ -47,7 +47,7 @@ v-model="form_data.model_id" :placeholder="$t('views.application.form.aiModel.placeholder')" :options="modelOptions" - @submitModel="getModel" + @submitModel="getSelectModel" showFooter :model-type="'LLM'" > @@ -220,21 +220,21 @@ const validate = () => { }) } -function getModel() { +function getSelectModel() { if (id) { //todo - // applicationApi.getApplicationModel(id).then((res: any) => { - // modelOptions.value = groupBy(res?.data, 'provider') - // }) + applicationApi.getApplicationModel(id).then((res: any) => { + modelOptions.value = groupBy(res?.data, 'provider') + }) } else { - model.asyncGetModel().then((res: any) => { + model.asyncGetSelectModel('workspace').then((res: any) => { modelOptions.value = groupBy(res?.data, 'provider') }) } } onMounted(() => { - getModel() + getSelectModel() if (typeof props.nodeModel.properties.node_data?.is_result === 'undefined') { if (isLastNode(props.nodeModel)) { set(props.nodeModel.properties.node_data, 'is_result', true) diff --git a/ui/src/workflow/nodes/reranker-node/index.vue b/ui/src/workflow/nodes/reranker-node/index.vue index db7931485..b81546446 100644 --- a/ui/src/workflow/nodes/reranker-node/index.vue +++ b/ui/src/workflow/nodes/reranker-node/index.vue @@ -160,7 +160,7 @@ $t('views.applicationWorkflow.nodes.rerankerNode.reranker_model.placeholder') " :options="modelOptions" - @submitModel="getModel" + @submitModel="getSelectModel" showFooter :model-type="'RERANKER'" > @@ -235,14 +235,14 @@ const form_data = computed({ function refreshParam(data: any) { set(props.nodeModel.properties.node_data, 'reranker_setting', data) } -function getModel() { +function getSelectModel() { if (id) { //todo - // applicationApi.getApplicationRerankerModel(id).then((res: any) => { - // modelOptions.value = groupBy(res?.data, 'provider') - // }) + applicationApi.getApplicationRerankerModel(id).then((res: any) => { + modelOptions.value = groupBy(res?.data, 'provider') + }) } else { - model.asyncGetModel({ model_type: 'RERANKER' }).then((res: any) => { + model.asyncGetSelectModel('workspace', { model_type: 'RERANKER' }).then((res: any) => { modelOptions.value = groupBy(res?.data, 'provider') }) } @@ -265,7 +265,7 @@ const validate = () => { } onMounted(() => { - getModel() + getSelectModel() set(props.nodeModel, 'validate', validate) }) diff --git a/ui/src/workflow/nodes/speech-to-text-node/index.vue b/ui/src/workflow/nodes/speech-to-text-node/index.vue index 18954c744..381c7c2c7 100644 --- a/ui/src/workflow/nodes/speech-to-text-node/index.vue +++ b/ui/src/workflow/nodes/speech-to-text-node/index.vue @@ -154,21 +154,21 @@ const form_data = computed({ }, }) -function getModel() { +function getSelectModel() { if (id) { //todo - // applicationApi.getApplicationSTTModel(id).then((res: any) => { - // modelOptions.value = groupBy(res?.data, 'provider') - // }) + applicationApi.getApplicationSTTModel(id).then((res: any) => { + modelOptions.value = groupBy(res?.data, 'provider') + }) } else { - model.asyncGetModel().then((res: any) => { + model.asyncGetSelectModel('workspace').then((res: any) => { modelOptions.value = groupBy(res?.data, 'provider') }) } } onMounted(() => { - getModel() + getSelectModel() set(props.nodeModel, 'validate', validate) }) diff --git a/ui/src/workflow/nodes/text-to-speech-node/index.vue b/ui/src/workflow/nodes/text-to-speech-node/index.vue index e68718260..16cb3a700 100644 --- a/ui/src/workflow/nodes/text-to-speech-node/index.vue +++ b/ui/src/workflow/nodes/text-to-speech-node/index.vue @@ -170,17 +170,17 @@ const form_data = computed({ }) // todo -// function getModel() { -// if (id) { -// applicationApi.getApplicationTTSModel(id).then((res: any) => { -// modelOptions.value = groupBy(res?.data, 'provider') -// }) -// } else { -// model.asyncGetModel().then((res: any) => { -// modelOptions.value = groupBy(res?.data, 'provider') -// }) -// } -// } +function getSelectModel() { + if (id) { + applicationApi.getApplicationTTSModel(id).then((res: any) => { + modelOptions.value = groupBy(res?.data, 'provider') + }) + } else { + model.asyncGetSelectModel('workspace').then((res: any) => { + modelOptions.value = groupBy(res?.data, 'provider') + }) + } +} const openTTSParamSettingDialog = () => { const model_id = form_data.value.tts_model_id @@ -195,7 +195,7 @@ const refreshTTSForm = (data: any) => { } onMounted(() => { - // getModel() + getSelectModel() set(props.nodeModel, 'validate', validate) })