From a7f6a6cc16ba629c9151e75323c88a13e46419d0 Mon Sep 17 00:00:00 2001 From: CGD <3030332422@qq.com> Date: Mon, 7 Apr 2025 16:57:31 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=AE=8C=E5=96=84=E2=80=9C=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E2=80=9D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/manager-web/src/views/ModelConfig.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main/manager-web/src/views/ModelConfig.vue b/main/manager-web/src/views/ModelConfig.vue index 01d149bd..83774639 100644 --- a/main/manager-web/src/views/ModelConfig.vue +++ b/main/manager-web/src/views/ModelConfig.vue @@ -53,7 +53,7 @@
- + 查询 @@ -212,8 +212,8 @@ export default { this.loadData(); }, handleSearch() { - // TODO: 查询 - console.log('查询:', this.search); + this.currentPage = 1; + this.loadData(); }, // 批量删除 batchDelete() { From d901b0ed34034a60a17fd91d9e1088774b34b323 Mon Sep 17 00:00:00 2001 From: CGD <3030332422@qq.com> Date: Mon, 7 Apr 2025 20:52:11 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E2=80=9C?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=A8=A1=E5=9E=8B=E9=85=8D=E7=BD=AE=E2=80=9D?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/manager-web/src/components/ModelEditDialog.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/main/manager-web/src/components/ModelEditDialog.vue b/main/manager-web/src/components/ModelEditDialog.vue index 594efb17..3d545918 100644 --- a/main/manager-web/src/components/ModelEditDialog.vue +++ b/main/manager-web/src/components/ModelEditDialog.vue @@ -38,7 +38,7 @@
- @@ -184,7 +184,6 @@ export default { if (data.code === 0 && data.data) { const model = data.data; - this.loadProviders(); let configJson = model.configJson || {}; if (typeof configJson !== 'object' || Array.isArray(configJson)) { From f4218b032a927b49e32fb93f0bb7ff56ef16aa7d Mon Sep 17 00:00:00 2001 From: CGD <3030332422@qq.com> Date: Tue, 8 Apr 2025 09:09:05 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E2=80=9C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A8=A1=E5=9E=8B=E2=80=9D=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E4=BA=86=E2=80=9C=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E9=85=8D=E7=BD=AE=E2=80=9D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/ModelEditDialog.vue | 136 +++++++++++++----- 1 file changed, 100 insertions(+), 36 deletions(-) diff --git a/main/manager-web/src/components/ModelEditDialog.vue b/main/manager-web/src/components/ModelEditDialog.vue index 3d545918..45a4c94e 100644 --- a/main/manager-web/src/components/ModelEditDialog.vue +++ b/main/manager-web/src/components/ModelEditDialog.vue @@ -15,11 +15,11 @@
是否启用 - +
设为默认 - +
@@ -59,21 +59,26 @@
调用信息
-
+
- -
- - - - - - -
- - - - + +
@@ -111,7 +116,7 @@ const DEFAULT_CONFIG_JSON = { export default { name: "ModelEditDialog", - props: { + props: { visible: { type: Boolean, default: false }, modelData: { type: Object, @@ -135,12 +140,56 @@ export default { docLink: "", remark: "", sort: 0, - apiKey: "", - apiUrl: "", configJson: JSON.parse(JSON.stringify(DEFAULT_CONFIG_JSON)) } }; }, + computed: { + callInfoFields() { + const fieldsMap = { + llm: [ + { label: '模型名称', prop: 'model_name', placeholder: '请输入model_name' }, + { label: '接口地址', prop: 'base_url', placeholder: '请输入base_url' }, + { label: '秘钥信息', prop: 'api_key', placeholder: '请输入api_key', type: 'password' } + ], + vad: [ + { label: '模型目录', prop: 'model_dir', placeholder: '请输入model_dir' }, + { label: '阈值', prop: 'threshold', placeholder: '请输入threshold' }, + { label: '静音时长', prop: 'min_silence_duration_ms', placeholder: '请输入min_silence_duration_ms' } + ], + asr: [ + { label: 'App ID', prop: 'appid', placeholder: '请输入appid' }, + { label: '集群', prop: 'cluster', placeholder: '请输入cluster' }, + { label: '访问令牌', prop: 'access_token', placeholder: '请输入access_token', type: 'password' }, + { label: '输出目录', prop: 'output_dir', placeholder: '请输入output_dir' } + ], + intent: [ + { label: '模型', prop: 'llm', placeholder: '请输入model' }, + { label: '类型', prop: 'type', placeholder: '请输入类型' } + ], + tts: [ + { label: '模型', prop: 'model', placeholder: '请输入model' }, + { label: '语音ID', prop: 'voice_id', placeholder: '请输入voice_id' }, + { label: 'Group ID', prop: 'group_id', placeholder: '请输入group_id' }, + { label: 'API Key', prop: 'api_key', placeholder: '请输入api_key', type: 'password' }, + ], + memory: [ + { label: 'API Key', prop: 'api_key', placeholder: '请输入api_key', type: 'password' }, + { label: '类型', prop: 'type', placeholder: '请输入类型' } + ] + }; + + return fieldsMap[this.modelType] || []; + }, + chunkedCallInfoFields() { + const chunkSize = 2; + const result = []; + for (let i = 0; i < this.callInfoFields.length; i += chunkSize) { + result.push(this.callInfoFields.slice(i, i + chunkSize)); + } + return result; + }, + }, watch: { modelType() { this.resetProviders() @@ -169,8 +218,6 @@ export default { docLink: "", remark: "", sort: 0, - apiKey: "", - apiUrl: "", configJson: JSON.parse(JSON.stringify(DEFAULT_CONFIG_JSON)) }; }, @@ -184,13 +231,18 @@ export default { if (data.code === 0 && data.data) { const model = data.data; - let configJson = model.configJson || {}; if (typeof configJson !== 'object' || Array.isArray(configJson)) { console.warn('Invalid configJson format, using default'); configJson = {}; } + this.callInfoFields.forEach(field => { + if (!configJson.hasOwnProperty(field.prop)) { + configJson[field.prop] = ''; + } + }); + this.form = { id: model.id || "", modelType: model.modelType || "", @@ -201,9 +253,6 @@ export default { docLink: model.docLink || "", remark: model.remark || "", sort: model.sort || 0, - apiKey: configJson.api_key || "", - apiUrl: configJson.base_url || "", - name:configJson.model_name, configJson: { ...JSON.parse(JSON.stringify(DEFAULT_CONFIG_JSON)), ...configJson, @@ -219,21 +268,19 @@ export default { }, handleSave() { const formData = { - modelCode: this.form.code, - modelName: this.form.name, - supplier: this.form.supplier, + modelCode: this.form.modelCode, + modelName: this.form.modelName, isDefault: this.form.isDefault ? 1 : 0, - isEnabled: this.form.isEnable ? 1 : 0, - docLink: this.form.docUrl, - sort: this.form.sort, + isEnabled: this.form.isEnabled ? 1 : 0, + docLink: this.form.docLink, remark: this.form.remark, + sort: this.form.sort || 0, configJson: { - provider: this.form.supplier, - modelName: this.form.modelName, - apiUrl: this.form.apiUrl, - apiKey: this.form.apiKey + ...this.form.configJson, + type: this.form.configJson.type || this.modelType } }; + this.$emit("save", formData); this.dialogVisible = false; }, @@ -248,7 +295,6 @@ export default { this.providersLoaded = true; }); }, - } }; @@ -413,4 +459,22 @@ export default { .custom-input-bg .el-input__inner { height: 32px; } + + +.custom-form .el-form-item { + margin-bottom: 20px; +} + + +.custom-input-bg .el-input__inner { + height: 32px; +} + + +.custom-form .el-form-item__label { + color: #3d4566; + font-weight: normal; + text-align: right; + padding-right: 20px; +} From 024468adbdcc3ba59ca8bb4bfbb5fcc67ab71feb Mon Sep 17 00:00:00 2001 From: CGD <3030332422@qq.com> Date: Tue, 8 Apr 2025 09:38:31 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E2=80=9C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A8=A1=E5=9E=8B=E2=80=9D=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E4=BA=86=E2=80=9C=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E9=85=8D=E7=BD=AE=E2=80=9D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/AddModelDialog.vue | 149 ++++++++++++++---- 1 file changed, 115 insertions(+), 34 deletions(-) diff --git a/main/manager-web/src/components/AddModelDialog.vue b/main/manager-web/src/components/AddModelDialog.vue index 3e6022cd..32bc9c4c 100644 --- a/main/manager-web/src/components/AddModelDialog.vue +++ b/main/manager-web/src/components/AddModelDialog.vue @@ -5,8 +5,7 @@
添加模型
- - + @@ -61,23 +60,28 @@
调用信息
-
+
- -
- - - - - - -
- - - - + +
@@ -110,14 +114,62 @@ export default { remark: '', isEnabled: true, isDefault: true, - configJson: { - param1: '', - param2: '', - apiKey: '' - } + configJson: {} } } }, + watch: { + visible(val) { + if(val) { + this.initConfigJson(); + } + } + }, + computed: { + callInfoFields() { + const fieldsMap = { + llm: [ + { label: '模型名称', prop: 'model_name', placeholder: '请输入model_name' }, + { label: '接口地址', prop: 'base_url', placeholder: '请输入base_url' }, + { label: '秘钥信息', prop: 'api_key', placeholder: '请输入api_key', type: 'password' } + ], + vad: [ + { label: '模型目录', prop: 'model_dir', placeholder: '请输入model_dir' }, + { label: '阈值', prop: 'threshold', placeholder: '请输入threshold' }, + { label: '静音时长', prop: 'min_silence_duration_ms', placeholder: '请输入min_silence_duration_ms' } + ], + asr: [ + { label: 'App ID', prop: 'appid', placeholder: '请输入appid' }, + { label: '集群', prop: 'cluster', placeholder: '请输入cluster' }, + { label: '访问令牌', prop: 'access_token', placeholder: '请输入access_token', type: 'password' }, + { label: '输出目录', prop: 'output_dir', placeholder: '请输入output_dir' } + ], + intent: [ + { label: '模型', prop: 'llm', placeholder: '请输入model' }, + { label: '类型', prop: 'type', placeholder: '请输入类型' } + ], + tts: [ + { label: '模型', prop: 'model', placeholder: '请输入model' }, + { label: '语音ID', prop: 'voice_id', placeholder: '请输入voice_id' }, + { label: 'Group ID', prop: 'group_id', placeholder: '请输入group_id' }, + { label: 'API Key', prop: 'api_key', placeholder: '请输入api_key', type: 'password' }, + ], + memory: [ + { label: 'API Key', prop: 'api_key', placeholder: '请输入api_key', type: 'password' }, + { label: '类型', prop: 'type', placeholder: '请输入类型' } + ] + }; + return fieldsMap[this.modelType] || []; + }, + chunkedCallInfoFields() { + const chunkSize = 2; + const result = []; + for (let i = 0; i < this.callInfoFields.length; i += chunkSize) { + result.push(this.callInfoFields.slice(i, i + chunkSize)); + } + return result; + } + }, methods: { loadProviders() { if (this.providersLoaded) @@ -131,18 +183,51 @@ export default { this.providersLoaded = true }) }, + // 初始化配置 + initConfigJson() { + const defaultConfig = {}; + this.callInfoFields.forEach(field => { + defaultConfig[field.prop] = ''; + }); + this.formData.configJson = { ...defaultConfig }; + }, confirm() { - if (!this.formData.modelName || !this.formData.modelCode || !this.formData.supplier || - !this.formData.configJson.param1 || !this.formData.configJson.param2 || !this.formData.configJson.apiKey) { + + const baseRequiredFields = [ + this.formData.modelName, + this.formData.modelCode, + this.formData.supplier + ]; + + const callInfoRequiredFields = this.callInfoFields.map( + field => this.formData.configJson[field.prop] + ); + + const allRequiredFields = [...baseRequiredFields, ...callInfoRequiredFields]; + + if (allRequiredFields.some(field => !field)) { this.$message.error('请填写所有必填字段'); return; } - this.$emit('confirm', { - ...this.formData, + const submitData = { + modelName: this.formData.modelName, + modelCode: this.formData.modelCode, + supplier: this.formData.supplier, + sort: this.formData.sort, + docLink: this.formData.docLink, + remark: this.formData.remark, + isEnabled: this.formData.isEnabled ? 1 : 0, + isDefault: this.formData.isDefault ? 1 : 0, provideCode: this.formData.supplier, - configJson: this.formData.configJson - }); + configJson: { + ...this.formData.configJson, + type: this.formData.supplier + } + }; + + this.$emit('confirm', submitData); + this.$emit('update:visible', false); this.resetForm(); }, @@ -156,11 +241,7 @@ export default { remark: '', isEnabled: true, isDefault: true, - configJson: { - param1: '', - param2: '', - apiKey: '' - } + configJson: {} }; // 重置加载状态 this.providers = []; From 710b338e6db3400213918ea6f01c8387bf19b8d5 Mon Sep 17 00:00:00 2001 From: CGD <3030332422@qq.com> Date: Tue, 8 Apr 2025 10:53:59 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=AE=8C=E6=88=90=E2=80=9C=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E6=A8=A1=E5=9E=8B=E9=85=8D=E7=BD=AE=E2=80=9D=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/manager-web/src/apis/module/model.js | 20 ++++++++++++++++++- .../src/components/AddModelDialog.vue | 2 +- .../src/components/ModelEditDialog.vue | 19 +++++++++++------- main/manager-web/src/views/ModelConfig.vue | 18 ++++++++++++++--- 4 files changed, 47 insertions(+), 12 deletions(-) diff --git a/main/manager-web/src/apis/module/model.js b/main/manager-web/src/apis/module/model.js index e27c69ad..38cc946e 100644 --- a/main/manager-web/src/apis/module/model.js +++ b/main/manager-web/src/apis/module/model.js @@ -159,5 +159,23 @@ export default { }) }).send() }, - + // 更新模型配置 + updateModel(params, callback) { + const { modelType, provideCode, id, formData } = params; + RequestService.sendRequest() + .url(`${getServiceUrl()}/models/${modelType}/${provideCode}/${id}`) + .method('PUT') + .data(formData) + .success((res) => { + RequestService.clearRequestTime(); + callback(res); + }) + .fail((err) => { + console.error('更新模型失败:', err); + this.$message.error(err.msg || '更新模型失败'); + RequestService.reAjaxFun(() => { + this.updateModel(params, callback); + }); + }).send(); + }, } diff --git a/main/manager-web/src/components/AddModelDialog.vue b/main/manager-web/src/components/AddModelDialog.vue index 32bc9c4c..04e184a0 100644 --- a/main/manager-web/src/components/AddModelDialog.vue +++ b/main/manager-web/src/components/AddModelDialog.vue @@ -5,7 +5,7 @@
添加模型
- + diff --git a/main/manager-web/src/components/ModelEditDialog.vue b/main/manager-web/src/components/ModelEditDialog.vue index 45a4c94e..5e311704 100644 --- a/main/manager-web/src/components/ModelEditDialog.vue +++ b/main/manager-web/src/components/ModelEditDialog.vue @@ -94,7 +94,6 @@ import Api from '@/apis/api'; const DEFAULT_CONFIG_JSON = { - provider: "", type: "", base_url: "", model_name: "", @@ -102,8 +101,8 @@ const DEFAULT_CONFIG_JSON = { raw: {}, config: { keyComparator: {}, - ignoreError: 0, - ignoreCase: 0, + ignoreError: false, + ignoreCase: false, dateFormat: "", ignoreNullValue: false, transientSupport: false, @@ -267,7 +266,10 @@ export default { } }, handleSave() { + const provideCode = this.form.configJson.type; + const { provider, ...restConfigJson } = this.form.configJson; const formData = { + id: this.form.id, modelCode: this.form.modelCode, modelName: this.form.modelName, isDefault: this.form.isDefault ? 1 : 0, @@ -276,12 +278,15 @@ export default { remark: this.form.remark, sort: this.form.sort || 0, configJson: { - ...this.form.configJson, - type: this.form.configJson.type || this.modelType + ...restConfigJson, + config: { + ...restConfigJson.config, + ignoreError: !!restConfigJson.config?.ignoreError, + ignoreCase: !!restConfigJson.config?.ignoreCase, + } } }; - - this.$emit("save", formData); + this.$emit("save", { provideCode, formData }); this.dialogVisible = false; }, loadProviders() { diff --git a/main/manager-web/src/views/ModelConfig.vue b/main/manager-web/src/views/ModelConfig.vue index 83774639..71df5d2d 100644 --- a/main/manager-web/src/views/ModelConfig.vue +++ b/main/manager-web/src/views/ModelConfig.vue @@ -301,9 +301,21 @@ export default { // TODO: 导出配置 console.log('导出配置'); }, - handleModelSave(formData) { - // TODO: 保存模型数据 - console.log('保存的模型数据:', formData); + handleModelSave({ provideCode, formData }) { + const modelType = this.activeTab; + const id = formData.id; + Api.model.updateModel( + { modelType, provideCode, id, formData }, + ({ data }) => { + if (data.code === 0) { + this.$message.success('保存成功'); + this.loadData(); + this.editDialogVisible = false; + } else { + this.$message.error(data.msg || '保存失败'); + } + } + ); }, selectAll() { if (this.isAllSelected) { From 625c9c2e40484b0e0d0950dfa1cbfefb5fdc757e Mon Sep 17 00:00:00 2001 From: CGD <3030332422@qq.com> Date: Tue, 8 Apr 2025 16:17:56 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E2=80=9C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A8=A1=E5=9E=8B=E2=80=9D=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=EF=BC=8C=E4=BD=BF=E5=85=B6=E8=83=BD=E6=A0=B9=E6=8D=AE=E4=BE=9B?= =?UTF-8?q?=E5=BA=94=E5=99=A8=E5=8A=A8=E6=80=81=E8=8E=B7=E5=8F=96=E5=88=B0?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/AddModelDialog.vue | 104 +++++++----------- .../src/components/ModelEditDialog.vue | 42 ++++--- 2 files changed, 64 insertions(+), 82 deletions(-) diff --git a/main/manager-web/src/components/AddModelDialog.vue b/main/manager-web/src/components/AddModelDialog.vue index 04e184a0..5c119da1 100644 --- a/main/manager-web/src/components/AddModelDialog.vue +++ b/main/manager-web/src/components/AddModelDialog.vue @@ -6,6 +6,7 @@ 添加模型 + @@ -70,15 +71,14 @@ :key="field.prop" :label="field.label" :prop="field.prop" - style="flex: 1;" - > + style="flex: 1;"> + :show-password="field.type === 'password'"> + @@ -105,6 +105,8 @@ export default { return { providers: [], providersLoaded: false, + providerFields: [], + currentProvider: null, formData: { modelName: '', modelCode: '', @@ -123,49 +125,22 @@ export default { if(val) { this.initConfigJson(); } + }, + 'formData.supplier'(newVal) { + this.currentProvider = this.providers.find(p => p.value === newVal); + this.providerFields = this.currentProvider?.fields || []; + this.initDynamicConfig(); } }, computed: { - callInfoFields() { - const fieldsMap = { - llm: [ - { label: '模型名称', prop: 'model_name', placeholder: '请输入model_name' }, - { label: '接口地址', prop: 'base_url', placeholder: '请输入base_url' }, - { label: '秘钥信息', prop: 'api_key', placeholder: '请输入api_key', type: 'password' } - ], - vad: [ - { label: '模型目录', prop: 'model_dir', placeholder: '请输入model_dir' }, - { label: '阈值', prop: 'threshold', placeholder: '请输入threshold' }, - { label: '静音时长', prop: 'min_silence_duration_ms', placeholder: '请输入min_silence_duration_ms' } - ], - asr: [ - { label: 'App ID', prop: 'appid', placeholder: '请输入appid' }, - { label: '集群', prop: 'cluster', placeholder: '请输入cluster' }, - { label: '访问令牌', prop: 'access_token', placeholder: '请输入access_token', type: 'password' }, - { label: '输出目录', prop: 'output_dir', placeholder: '请输入output_dir' } - ], - intent: [ - { label: '模型', prop: 'llm', placeholder: '请输入model' }, - { label: '类型', prop: 'type', placeholder: '请输入类型' } - ], - tts: [ - { label: '模型', prop: 'model', placeholder: '请输入model' }, - { label: '语音ID', prop: 'voice_id', placeholder: '请输入voice_id' }, - { label: 'Group ID', prop: 'group_id', placeholder: '请输入group_id' }, - { label: 'API Key', prop: 'api_key', placeholder: '请输入api_key', type: 'password' }, - ], - memory: [ - { label: 'API Key', prop: 'api_key', placeholder: '请输入api_key', type: 'password' }, - { label: '类型', prop: 'type', placeholder: '请输入类型' } - ] - }; - return fieldsMap[this.modelType] || []; + dynamicCallInfoFields() { + return this.providerFields; }, chunkedCallInfoFields() { const chunkSize = 2; const result = []; - for (let i = 0; i < this.callInfoFields.length; i += chunkSize) { - result.push(this.callInfoFields.slice(i, i + chunkSize)); + for (let i = 0; i < this.dynamicCallInfoFields.length; i += chunkSize) { + result.push(this.dynamicCallInfoFields.slice(i, i + chunkSize)); } return result; } @@ -178,45 +153,44 @@ export default { Api.model.getModelProviders(this.modelType, (data) => { this.providers = data.map(item => ({ label: item.name, - value: item.providerCode + value: item.providerCode, + fields: JSON.parse(item.fields || '[]').map(f => ({ + label: f.label, + prop: f.key, + type: f.type === 'password' ? 'password' : 'text', + placeholder: `请输入${f.label}` + })) })) this.providersLoaded = true }) }, - // 初始化配置 initConfigJson() { const defaultConfig = {}; - this.callInfoFields.forEach(field => { + this.providerFields.forEach(field => { defaultConfig[field.prop] = ''; }); this.formData.configJson = { ...defaultConfig }; }, + initDynamicConfig() { + const newConfig = {}; + this.providerFields.forEach(field => { + newConfig[field.prop] = this.formData.configJson[field.prop] || ''; + }); + this.formData.configJson = newConfig; + }, confirm() { - - const baseRequiredFields = [ - this.formData.modelName, - this.formData.modelCode, - this.formData.supplier - ]; - - const callInfoRequiredFields = this.callInfoFields.map( - field => this.formData.configJson[field.prop] - ); - - const allRequiredFields = [...baseRequiredFields, ...callInfoRequiredFields]; - - if (allRequiredFields.some(field => !field)) { - this.$message.error('请填写所有必填字段'); + if (!this.formData.supplier) { + this.$message.error('请选择供应器'); return; } const submitData = { - modelName: this.formData.modelName, - modelCode: this.formData.modelCode, + modelName: this.formData.modelName || '', + modelCode: this.formData.modelCode || '', supplier: this.formData.supplier, - sort: this.formData.sort, - docLink: this.formData.docLink, - remark: this.formData.remark, + sort: this.formData.sort || 1, + docLink: this.formData.docLink || '', + remark: this.formData.remark || '', isEnabled: this.formData.isEnabled ? 1 : 0, isDefault: this.formData.isDefault ? 1 : 0, provideCode: this.formData.supplier, @@ -227,7 +201,6 @@ export default { }; this.$emit('confirm', submitData); - this.$emit('update:visible', false); this.resetForm(); }, @@ -246,6 +219,9 @@ export default { // 重置加载状态 this.providers = []; this.providersLoaded = false; + // 重置字段配置 + this.providerFields = []; + this.currentProvider = null; }, handleClose() { this.resetForm(); diff --git a/main/manager-web/src/components/ModelEditDialog.vue b/main/manager-web/src/components/ModelEditDialog.vue index 5e311704..a6a71a6d 100644 --- a/main/manager-web/src/components/ModelEditDialog.vue +++ b/main/manager-web/src/components/ModelEditDialog.vue @@ -147,34 +147,40 @@ export default { callInfoFields() { const fieldsMap = { llm: [ - { label: '模型名称', prop: 'model_name', placeholder: '请输入model_name' }, - { label: '接口地址', prop: 'base_url', placeholder: '请输入base_url' }, - { label: '秘钥信息', prop: 'api_key', placeholder: '请输入api_key', type: 'password' } + { label: '模型名称', prop: 'model_name', placeholder: '请输入model_name' }, + { label: '接口地址', prop: 'base_url', placeholder: '请输入base_url' }, + { label: '秘钥信息', prop: 'api_key', placeholder: '请输入api_key', type: 'password' } ], vad: [ - { label: '模型目录', prop: 'model_dir', placeholder: '请输入model_dir' }, - { label: '阈值', prop: 'threshold', placeholder: '请输入threshold' }, - { label: '静音时长', prop: 'min_silence_duration_ms', placeholder: '请输入min_silence_duration_ms' } + { label: '模型名称', prop: 'model_name', placeholder: '请输入model_name' }, + { label: '模型目录', prop: 'model_dir', placeholder: '请输入model_dir' }, + { label: '阈值', prop: 'threshold', placeholder: '请输入threshold' }, + { label: '静音时长', prop: 'min_silence_duration_ms', placeholder: '请输入min_silence_duration_ms' }, + { label: '接口地址', prop: 'base_url', placeholder: '请输入base_url' }, + { label: '秘钥信息', prop: 'api_key', placeholder: '请输入api_key', type: 'password' } ], asr: [ - { label: 'App ID', prop: 'appid', placeholder: '请输入appid' }, - { label: '集群', prop: 'cluster', placeholder: '请输入cluster' }, - { label: '访问令牌', prop: 'access_token', placeholder: '请输入access_token', type: 'password' }, - { label: '输出目录', prop: 'output_dir', placeholder: '请输入output_dir' } + { label: '模型名称', prop: 'model_name', placeholder: '请输入model_name' }, + { label: '集群', prop: 'cluster', placeholder: '请输入cluster' }, + { label: '接口地址', prop: 'base_url', placeholder: '请输入base_url' }, + { label: '秘钥信息', prop: 'api_key', placeholder: '请输入api_key', type: 'password' } ], intent: [ - { label: '模型', prop: 'llm', placeholder: '请输入model' }, - { label: '类型', prop: 'type', placeholder: '请输入类型' } + { label: '模型名称', prop: 'model_name', placeholder: '请输入model_name' }, + { label: 'LLM模型', prop: 'llm', placeholder: '请输入llm' }, + { label: '接口地址', prop: 'base_url', placeholder: '请输入base_url' }, + { label: '秘钥信息', prop: 'api_key', placeholder: '请输入api_key', type: 'password' } ], tts: [ - { label: '模型', prop: 'model', placeholder: '请输入model' }, - { label: '语音ID', prop: 'voice_id', placeholder: '请输入voice_id' }, - { label: 'Group ID', prop: 'group_id', placeholder: '请输入group_id' }, - { label: 'API Key', prop: 'api_key', placeholder: '请输入api_key', type: 'password' }, + { label: '模型名称', prop: 'model_name', placeholder: '请输入model_name' }, + { label: '语音ID', prop: 'voice_id', placeholder: '请输入voice_id' }, + { label: '接口地址', prop: 'base_url', placeholder: '请输入base_url' }, + { label: '秘钥信息', prop: 'api_key', placeholder: '请输入api_key', type: 'password' } ], memory: [ - { label: 'API Key', prop: 'api_key', placeholder: '请输入api_key', type: 'password' }, - { label: '类型', prop: 'type', placeholder: '请输入类型' } + { label: '模型名称', prop: 'model_name', placeholder: '请输入model_name' }, + { label: '接口地址', prop: 'base_url', placeholder: '请输入base_url' }, + { label: '秘钥信息', prop: 'api_key', placeholder: '请输入api_key', type: 'password' } ] };