mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 07:03:53 +08:00
fix:修复了"模型配置"问题
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { getServiceUrl } from '../api';
|
||||
import RequestService from '../httpRequest';
|
||||
|
||||
|
||||
export default {
|
||||
// 获取模型配置列表
|
||||
getModelList(params, callback) {
|
||||
@@ -162,21 +161,25 @@ export default {
|
||||
// 更新模型配置
|
||||
updateModel(params, callback) {
|
||||
const { modelType, provideCode, id, formData } = params;
|
||||
const payload = {
|
||||
...formData,
|
||||
configJson: formData.configJson
|
||||
};
|
||||
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();
|
||||
.url(`${getServiceUrl()}/models/${modelType}/${provideCode}/${id}`)
|
||||
.method('PUT')
|
||||
.data(payload)
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime();
|
||||
callback(res);
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('更新模型失败:', err);
|
||||
this.$message.error(err.msg || '更新模型失败');
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.updateModel(params, callback);
|
||||
});
|
||||
}).send();
|
||||
},
|
||||
// 设置默认模型
|
||||
setDefaultModel(id, callback) {
|
||||
|
||||
@@ -94,14 +94,6 @@
|
||||
<script>
|
||||
import Api from '@/apis/api';
|
||||
|
||||
const DEFAULT_CONFIG_JSON = {
|
||||
type: "",
|
||||
base_url: "",
|
||||
model_name: "",
|
||||
api_key: "",
|
||||
empty: false
|
||||
};
|
||||
|
||||
export default {
|
||||
name: "ModelEditDialog",
|
||||
props: {
|
||||
@@ -132,7 +124,7 @@ export default {
|
||||
docLink: "",
|
||||
remark: "",
|
||||
sort: 0,
|
||||
configJson: JSON.parse(JSON.stringify(DEFAULT_CONFIG_JSON))
|
||||
configJson: {}
|
||||
}
|
||||
};
|
||||
},
|
||||
@@ -183,8 +175,11 @@ export default {
|
||||
docLink: "",
|
||||
remark: "",
|
||||
sort: 0,
|
||||
configJson: JSON.parse(JSON.stringify(DEFAULT_CONFIG_JSON))
|
||||
configJson: {}
|
||||
};
|
||||
this.dynamicCallInfoFields.forEach(field => {
|
||||
this.$set(this.form.configJson, field.prop, '');
|
||||
});
|
||||
},
|
||||
resetProviders() {
|
||||
this.providers = [];
|
||||
@@ -266,6 +261,8 @@ export default {
|
||||
this.dynamicCallInfoFields.forEach(field => {
|
||||
if (!configJson.hasOwnProperty(field.prop)) {
|
||||
configJson[field.prop] = '';
|
||||
} else if (typeof configJson[field.prop] !== 'string') {
|
||||
configJson[field.prop] = String(configJson[field.prop]);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -280,7 +277,6 @@ export default {
|
||||
remark: model.remark,
|
||||
sort: Number(model.sort) || 0,
|
||||
configJson: {
|
||||
...DEFAULT_CONFIG_JSON,
|
||||
...configJson
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user