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] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E2=80=9C=E6=B7=BB?=
=?UTF-8?q?=E5=8A=A0=E6=A8=A1=E5=9E=8B=E2=80=9D=E9=A1=B5=E9=9D=A2=EF=BC=8C?=
=?UTF-8?q?=E4=BD=BF=E5=85=B6=E8=83=BD=E6=A0=B9=E6=8D=AE=E4=BE=9B=E5=BA=94?=
=?UTF-8?q?=E5=99=A8=E5=8A=A8=E6=80=81=E8=8E=B7=E5=8F=96=E5=88=B0=E8=B0=83?=
=?UTF-8?q?=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' }
]
};