Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🔧 fix: Assistants App Error on Parameters Render (#2805)

Danny Avila79840763e79a
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 }:
<TextareaAutosize
id="promptPrefix"
disabled={readonly}
- value={promptPrefixValue as string | undefined}
+ value={(promptPrefixValue as string | null | undefined) ?? ''}
onChange={onPromptPrefixChange}
placeholder={localize('com_endpoint_prompt_prefix_assistants_placeholder')}
className={cn(
@@ -158,7 +165,7 @@ export default function Settings({ conversation, setOption, models, readonly }:
<TextareaAutosize
id="instructions"
disabled={readonly}
- value={instructionsValue as string | undefined}
+ value={(instructionsValue as string | null | undefined) ?? ''}
onChange={onInstructionsChange}
placeholder={localize('com_endpoint_instructions_assistants_placeholder')}
className={cn(