mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-29 03:03:56 +08:00
优化了“修改模型”页面,使其能够动态获取到调用信息
This commit is contained in:
@@ -61,10 +61,11 @@
|
|||||||
<div style="font-size: 20px; font-weight: bold; color: #3d4566; margin-bottom: 15px;">调用信息</div>
|
<div style="font-size: 20px; font-weight: bold; color: #3d4566; margin-bottom: 15px;">调用信息</div>
|
||||||
<div style="height: 2px; background: #e9e9e9; margin-bottom: 22px;"></div>
|
<div style="height: 2px; background: #e9e9e9; margin-bottom: 22px;"></div>
|
||||||
|
|
||||||
<el-form :model="form.configJson" ref="callInfoForm" label-width="100px" label-position="left" class="custom-form">
|
<el-form :model="form.configJson" ref="callInfoForm" label-width="100px" class="custom-form">
|
||||||
<template v-for="(row, rowIndex) in chunkedCallInfoFields">
|
<template v-for="(row, rowIndex) in chunkedCallInfoFields">
|
||||||
<div :key="rowIndex" style="display: flex; gap: 20px; margin-bottom: 0;">
|
<div :key="rowIndex" style="display: flex; gap: 20px; margin-bottom: 0;">
|
||||||
<el-form-item v-for="field in row"
|
<el-form-item
|
||||||
|
v-for="field in row"
|
||||||
:key="field.prop"
|
:key="field.prop"
|
||||||
:label="field.label"
|
:label="field.label"
|
||||||
:prop="field.prop"
|
:prop="field.prop"
|
||||||
@@ -72,7 +73,7 @@
|
|||||||
<el-input
|
<el-input
|
||||||
v-model="form.configJson[field.prop]"
|
v-model="form.configJson[field.prop]"
|
||||||
:placeholder="field.placeholder"
|
:placeholder="field.placeholder"
|
||||||
:type="field.type || 'text'"
|
:type="field.type"
|
||||||
class="custom-input-bg"
|
class="custom-input-bg"
|
||||||
:show-password="field.type === 'password'">
|
:show-password="field.type === 'password'">
|
||||||
</el-input>
|
</el-input>
|
||||||
@@ -129,6 +130,7 @@ export default {
|
|||||||
dialogVisible: this.visible,
|
dialogVisible: this.visible,
|
||||||
providers: [],
|
providers: [],
|
||||||
providersLoaded: false,
|
providersLoaded: false,
|
||||||
|
dynamicCallInfoFields: [],
|
||||||
form: {
|
form: {
|
||||||
id: "",
|
id: "",
|
||||||
modelType: "",
|
modelType: "",
|
||||||
@@ -144,53 +146,11 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
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() {
|
chunkedCallInfoFields() {
|
||||||
const chunkSize = 2;
|
const chunkSize = 2;
|
||||||
const result = [];
|
const result = [];
|
||||||
for (let i = 0; i < this.callInfoFields.length; i += chunkSize) {
|
for (let i = 0; i < this.dynamicCallInfoFields.length; i += chunkSize) {
|
||||||
result.push(this.callInfoFields.slice(i, i + chunkSize));
|
result.push(this.dynamicCallInfoFields.slice(i, i + chunkSize));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
@@ -209,7 +169,12 @@ export default {
|
|||||||
},
|
},
|
||||||
visible(val) {
|
visible(val) {
|
||||||
this.dialogVisible = val;
|
this.dialogVisible = val;
|
||||||
|
},
|
||||||
|
'form.configJson.type'(newVal) {
|
||||||
|
if (newVal) {
|
||||||
|
this.loadProviderFields(newVal);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
resetForm() {
|
resetForm() {
|
||||||
@@ -230,19 +195,18 @@ export default {
|
|||||||
this.providers = [];
|
this.providers = [];
|
||||||
this.providersLoaded = false;
|
this.providersLoaded = false;
|
||||||
},
|
},
|
||||||
loadModelData() {
|
async loadModelData() {
|
||||||
if (this.modelData.id) {
|
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) {
|
if (data.code === 0 && data.data) {
|
||||||
const model = data.data;
|
const model = data.data;
|
||||||
|
|
||||||
let configJson = model.configJson || {};
|
// 获取供应器字段配置
|
||||||
if (typeof configJson !== 'object' || Array.isArray(configJson)) {
|
await this.loadProviderFields(model.configJson.type);
|
||||||
console.warn('Invalid configJson format, using default');
|
|
||||||
configJson = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
this.callInfoFields.forEach(field => {
|
// 初始化configJson
|
||||||
|
let configJson = model.configJson || {};
|
||||||
|
this.dynamicCallInfoFields.forEach(field => {
|
||||||
if (!configJson.hasOwnProperty(field.prop)) {
|
if (!configJson.hasOwnProperty(field.prop)) {
|
||||||
configJson[field.prop] = '';
|
configJson[field.prop] = '';
|
||||||
}
|
}
|
||||||
@@ -306,6 +270,19 @@ export default {
|
|||||||
this.providersLoaded = true;
|
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}`
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -69,7 +69,7 @@
|
|||||||
<el-table-column label="模型编码" prop="modelCode" align="center"></el-table-column>
|
<el-table-column label="模型编码" prop="modelCode" align="center"></el-table-column>
|
||||||
<el-table-column label="提供商" align="center">
|
<el-table-column label="提供商" align="center">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
{{ scope.row.configJson?.provider || '未知' }}
|
{{ scope.row.configJson.type || '未知' }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="是否启用" align="center">
|
<el-table-column label="是否启用" align="center">
|
||||||
|
|||||||
Reference in New Issue
Block a user