diff --git a/client/src/components/Endpoints/Settings/Assistants.tsx b/client/src/components/Endpoints/Settings/Assistants.tsx index f8b2e51fd7..135a2a93ea 100644 --- a/client/src/components/Endpoints/Settings/Assistants.tsx +++ b/client/src/components/Endpoints/Settings/Assistants.tsx @@ -1,6 +1,6 @@ import { useState, useMemo, useEffect } from 'react'; import TextareaAutosize from 'react-textarea-autosize'; -import type { TPreset } from 'librechat-data-provider'; +import type { Assistant, TPreset } from 'librechat-data-provider'; import type { TModelSelectProps, Option } from '~/common'; import { Label, HoverCard, SelectDropDown, HoverCardTrigger } from '~/components/ui'; import { cn, defaultTextProps, removeFocusOutlines, mapAssistants } from '~/utils'; @@ -20,15 +20,19 @@ export default function Settings({ conversation, setOption, models, readonly }: const { model, endpoint, assistant_id, endpointType, promptPrefix, instructions } = conversation ?? {}; + const currentList = useMemo( + () => Object.values(assistantListMap?.[endpoint ?? ''] ?? {}) as Assistant[], + [assistantListMap, endpoint], + ); + const assistants = useMemo(() => { - return [ - defaultOption, - ...(assistantListMap[endpoint ?? ''] ?? []).map(({ id, name }) => ({ - label: name, - value: id, - })), - ].filter(Boolean); - }, [assistantListMap, endpoint, defaultOption]); + const currentAssistants = (currentList ?? []).map(({ id, name }) => ({ + label: name, + value: id, + })); + + return [defaultOption, ...currentAssistants].filter(Boolean); + }, [currentList, defaultOption]); const [onPromptPrefixChange, promptPrefixValue] = useDebouncedInput({ setOption, @@ -96,6 +100,9 @@ export default function Settings({ conversation, setOption, models, readonly }: value: assistant.id ?? '', }); setOption('assistant_id')(assistant.id); + if (assistant.model) { + setModel(assistant.model); + } }; const optionEndpoint = endpointType ?? endpoint; @@ -141,7 +148,7 @@ export default function Settings({ conversation, setOption, models, readonly }: