mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
🔧 fix: Assistants App Error on Parameters Render (#2805)
This commit is contained in:
parent
1a452121fa
commit
79840763e7
1 changed files with 18 additions and 11 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
import { useState, useMemo, useEffect } from 'react';
|
import { useState, useMemo, useEffect } from 'react';
|
||||||
import TextareaAutosize from 'react-textarea-autosize';
|
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 type { TModelSelectProps, Option } from '~/common';
|
||||||
import { Label, HoverCard, SelectDropDown, HoverCardTrigger } from '~/components/ui';
|
import { Label, HoverCard, SelectDropDown, HoverCardTrigger } from '~/components/ui';
|
||||||
import { cn, defaultTextProps, removeFocusOutlines, mapAssistants } from '~/utils';
|
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 } =
|
const { model, endpoint, assistant_id, endpointType, promptPrefix, instructions } =
|
||||||
conversation ?? {};
|
conversation ?? {};
|
||||||
|
|
||||||
|
const currentList = useMemo(
|
||||||
|
() => Object.values(assistantListMap?.[endpoint ?? ''] ?? {}) as Assistant[],
|
||||||
|
[assistantListMap, endpoint],
|
||||||
|
);
|
||||||
|
|
||||||
const assistants = useMemo(() => {
|
const assistants = useMemo(() => {
|
||||||
return [
|
const currentAssistants = (currentList ?? []).map(({ id, name }) => ({
|
||||||
defaultOption,
|
|
||||||
...(assistantListMap[endpoint ?? ''] ?? []).map(({ id, name }) => ({
|
|
||||||
label: name,
|
label: name,
|
||||||
value: id,
|
value: id,
|
||||||
})),
|
}));
|
||||||
].filter(Boolean);
|
|
||||||
}, [assistantListMap, endpoint, defaultOption]);
|
return [defaultOption, ...currentAssistants].filter(Boolean);
|
||||||
|
}, [currentList, defaultOption]);
|
||||||
|
|
||||||
const [onPromptPrefixChange, promptPrefixValue] = useDebouncedInput({
|
const [onPromptPrefixChange, promptPrefixValue] = useDebouncedInput({
|
||||||
setOption,
|
setOption,
|
||||||
|
|
@ -96,6 +100,9 @@ export default function Settings({ conversation, setOption, models, readonly }:
|
||||||
value: assistant.id ?? '',
|
value: assistant.id ?? '',
|
||||||
});
|
});
|
||||||
setOption('assistant_id')(assistant.id);
|
setOption('assistant_id')(assistant.id);
|
||||||
|
if (assistant.model) {
|
||||||
|
setModel(assistant.model);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const optionEndpoint = endpointType ?? endpoint;
|
const optionEndpoint = endpointType ?? endpoint;
|
||||||
|
|
@ -141,7 +148,7 @@ export default function Settings({ conversation, setOption, models, readonly }:
|
||||||
<TextareaAutosize
|
<TextareaAutosize
|
||||||
id="promptPrefix"
|
id="promptPrefix"
|
||||||
disabled={readonly}
|
disabled={readonly}
|
||||||
value={promptPrefixValue as string | undefined}
|
value={(promptPrefixValue as string | null | undefined) ?? ''}
|
||||||
onChange={onPromptPrefixChange}
|
onChange={onPromptPrefixChange}
|
||||||
placeholder={localize('com_endpoint_prompt_prefix_assistants_placeholder')}
|
placeholder={localize('com_endpoint_prompt_prefix_assistants_placeholder')}
|
||||||
className={cn(
|
className={cn(
|
||||||
|
|
@ -158,7 +165,7 @@ export default function Settings({ conversation, setOption, models, readonly }:
|
||||||
<TextareaAutosize
|
<TextareaAutosize
|
||||||
id="instructions"
|
id="instructions"
|
||||||
disabled={readonly}
|
disabled={readonly}
|
||||||
value={instructionsValue as string | undefined}
|
value={(instructionsValue as string | null | undefined) ?? ''}
|
||||||
onChange={onInstructionsChange}
|
onChange={onInstructionsChange}
|
||||||
placeholder={localize('com_endpoint_instructions_assistants_placeholder')}
|
placeholder={localize('com_endpoint_instructions_assistants_placeholder')}
|
||||||
className={cn(
|
className={cn(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue