-
@@ -129,6 +130,7 @@ export default {
dialogVisible: this.visible,
providers: [],
providersLoaded: false,
+ dynamicCallInfoFields: [],
form: {
id: "",
modelType: "",
@@ -144,53 +146,11 @@ export default {
};
},
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_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: '模型名称', 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: '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_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: '模型名称', prop: 'model_name', placeholder: '请输入model_name' },
- { label: '接口地址', prop: 'base_url', placeholder: '请输入base_url' },
- { label: '秘钥信息', prop: 'api_key', placeholder: '请输入api_key', type: 'password' }
- ]
- };
-
- 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));
+ for (let i = 0; i < this.dynamicCallInfoFields.length; i += chunkSize) {
+ result.push(this.dynamicCallInfoFields.slice(i, i + chunkSize));
}
return result;
},
@@ -209,7 +169,12 @@ export default {
},
visible(val) {
this.dialogVisible = val;
+ },
+ 'form.configJson.type'(newVal) {
+ if (newVal) {
+ this.loadProviderFields(newVal);
}
+ }
},
methods: {
resetForm() {
@@ -230,19 +195,18 @@ export default {
this.providers = [];
this.providersLoaded = false;
},
- loadModelData() {
+ async loadModelData() {
if (this.modelData.id) {
- Api.model.getModelConfig(this.modelData.id, ({ data }) => {
+ Api.model.getModelConfig(this.modelData.id, async ({ data }) => {
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 = {};
- }
+ // 获取供应器字段配置
+ await this.loadProviderFields(model.configJson.type);
- this.callInfoFields.forEach(field => {
+ // 初始化configJson
+ let configJson = model.configJson || {};
+ this.dynamicCallInfoFields.forEach(field => {
if (!configJson.hasOwnProperty(field.prop)) {
configJson[field.prop] = '';
}
@@ -306,6 +270,19 @@ export default {
this.providersLoaded = true;
});
},
+ async loadProviderFields(providerCode) {
+ Api.model.getModelProviders(this.modelType, (data) => {
+ const provider = data.find(p => p.providerCode === providerCode);
+ if (provider) {
+ this.dynamicCallInfoFields = JSON.parse(provider.fields || '[]').map(f => ({
+ label: f.label,
+ prop: f.key,
+ type: f.type === 'password' ? 'password' : 'text',
+ placeholder: `请输入${f.label}`
+ }));
+ }
+ });
+ }
}
};
diff --git a/main/manager-web/src/views/ModelConfig.vue b/main/manager-web/src/views/ModelConfig.vue
index 71df5d2d..af60fef7 100644
--- a/main/manager-web/src/views/ModelConfig.vue
+++ b/main/manager-web/src/views/ModelConfig.vue
@@ -69,7 +69,7 @@
- {{ scope.row.configJson?.provider || '未知' }}
+ {{ scope.row.configJson.type || '未知' }}