feat(agent-editor): support multi-select model field

main
sp mac bookpro 2605 2026-05-29 13:45:01 +08:00
parent 604d549a79
commit 46875d6337
1 changed files with 14 additions and 0 deletions

View File

@ -27,6 +27,13 @@ const DEFAULT_AVATAR = '/default_bot_icon.jpg';
const PRESET_AVATARS: string[] = Array.from({ length: 12 }, (_, index) => `/avatars/avatar-${String(index + 1).padStart(2, '0')}.png`);
const isImageUrl = (url: string) => url?.startsWith('http') || url?.startsWith('/');
const parseModelSelections = (value?: string | string[]) =>
Array.isArray(value)
? value
: String(value || '')
.split(',')
.map((item) => item.trim())
.filter(Boolean);
export default function AgentEditor() {
const { id } = useParams();
@ -481,11 +488,18 @@ export default function AgentEditor() {
name="model"
label="模型"
className="mb-0"
getValueProps={(value) => ({ value: parseModelSelections(value) })}
normalize={(value) =>
Array.isArray(value) ? value.map((item) => String(item).trim()).filter(Boolean).join(', ') : ''
}
>
<Select
mode="multiple"
placeholder="选择模型"
style={{ height: 42 }}
dropdownStyle={{ borderRadius: 12 }}
maxTagCount="responsive"
optionFilterProp="value"
options={models.map((m) => {
const inputPrice = 2 * m.model_ratio;
const outputPrice = inputPrice * m.completion_ratio;