feat: 更新Agent模型配置使用model_id
- AiModel接口新增model_id字段 - ModelCheckboxDropdown使用model_id作为checkbox的value - 保存时将model_id数组用逗号拼接成字符串提交 - 修改normalize函数,使用','作为分隔符(不带空格)main
parent
dfab0f6d43
commit
4fbb15f3d0
|
|
@ -119,6 +119,7 @@ export interface ChatHistoryResp {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AiModel {
|
export interface AiModel {
|
||||||
|
model_id: string;
|
||||||
model_name: string;
|
model_name: string;
|
||||||
icon: string;
|
icon: string;
|
||||||
model_ratio: number;
|
model_ratio: number;
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ export default function CapabilitySettings({
|
||||||
className="mb-0"
|
className="mb-0"
|
||||||
getValueProps={(value) => ({ value: parseModelSelections(value) })}
|
getValueProps={(value) => ({ value: parseModelSelections(value) })}
|
||||||
normalize={(value) =>
|
normalize={(value) =>
|
||||||
Array.isArray(value) ? value.map((item) => String(item).trim()).filter(Boolean).join(', ') : ''
|
Array.isArray(value) ? value.map((item) => String(item).trim()).filter(Boolean).join(',') : ''
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<ModelCheckboxDropdown models={models} />
|
<ModelCheckboxDropdown models={models} />
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ export default function ModelCheckboxDropdown({ value = [], onChange, models }:
|
||||||
const inputPrice = 2 * m.model_ratio;
|
const inputPrice = 2 * m.model_ratio;
|
||||||
const outputPrice = inputPrice * m.completion_ratio;
|
const outputPrice = inputPrice * m.completion_ratio;
|
||||||
return (
|
return (
|
||||||
<Checkbox key={m.model_name} value={m.model_name} className="agent-model-checkbox-item">
|
<Checkbox key={m.model_id} value={m.model_id} className="agent-model-checkbox-item">
|
||||||
<div className="agent-model-checkbox-content">
|
<div className="agent-model-checkbox-content">
|
||||||
<div className="agent-model-checkbox-meta">
|
<div className="agent-model-checkbox-meta">
|
||||||
<img
|
<img
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,10 @@ export function useAgentEditor({ id, isNew, form, message, navigate }: UseAgentE
|
||||||
Object.keys(values).forEach((key) => {
|
Object.keys(values).forEach((key) => {
|
||||||
const formValue = (values as any)[key];
|
const formValue = (values as any)[key];
|
||||||
const originalValue = (agent as any)?.[key];
|
const originalValue = (agent as any)?.[key];
|
||||||
if (formValue !== originalValue) {
|
// 特殊处理 model 字段:如果是数组,用逗号拼接成字符串
|
||||||
|
if (key === 'model' && Array.isArray(formValue)) {
|
||||||
|
changedFields[key] = formValue.join(',');
|
||||||
|
} else if (formValue !== originalValue) {
|
||||||
changedFields[key] = formValue;
|
changedFields[key] = formValue;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue