feat(agent-editor): support multi-select model field
parent
604d549a79
commit
46875d6337
|
|
@ -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 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 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() {
|
export default function AgentEditor() {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
|
|
@ -481,11 +488,18 @@ export default function AgentEditor() {
|
||||||
name="model"
|
name="model"
|
||||||
label="模型"
|
label="模型"
|
||||||
className="mb-0"
|
className="mb-0"
|
||||||
|
getValueProps={(value) => ({ value: parseModelSelections(value) })}
|
||||||
|
normalize={(value) =>
|
||||||
|
Array.isArray(value) ? value.map((item) => String(item).trim()).filter(Boolean).join(', ') : ''
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<Select
|
<Select
|
||||||
|
mode="multiple"
|
||||||
placeholder="选择模型"
|
placeholder="选择模型"
|
||||||
style={{ height: 42 }}
|
style={{ height: 42 }}
|
||||||
dropdownStyle={{ borderRadius: 12 }}
|
dropdownStyle={{ borderRadius: 12 }}
|
||||||
|
maxTagCount="responsive"
|
||||||
|
optionFilterProp="value"
|
||||||
options={models.map((m) => {
|
options={models.map((m) => {
|
||||||
const inputPrice = 2 * m.model_ratio;
|
const inputPrice = 2 * m.model_ratio;
|
||||||
const outputPrice = inputPrice * m.completion_ratio;
|
const outputPrice = inputPrice * m.completion_ratio;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue