Skip to content

Commit d56c457

Browse files
committed
Merge branch 'Danny/main' into lijing/merge_base_danny
2 parents ee0b5cc + 7984076 commit d56c457

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

client/src/components/Endpoints/Settings/Assistants.tsx

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState, useMemo, useEffect } from 'react';
22
import TextareaAutosize from 'react-textarea-autosize';
3-
import type { TPreset } from 'librechat-data-provider';
3+
import type { Assistant, TPreset } from 'librechat-data-provider';
44
import type { TModelSelectProps, Option } from '~/common';
55
import { Label, HoverCard, SelectDropDown, HoverCardTrigger } from '~/components/ui';
66
import { cn, defaultTextProps, removeFocusOutlines, mapAssistants } from '~/utils';
@@ -20,15 +20,19 @@ export default function Settings({ conversation, setOption, models, readonly }:
2020
const { model, endpoint, assistant_id, endpointType, promptPrefix, instructions } =
2121
conversation ?? {};
2222

23+
const currentList = useMemo(
24+
() => Object.values(assistantListMap?.[endpoint ?? ''] ?? {}) as Assistant[],
25+
[assistantListMap, endpoint],
26+
);
27+
2328
const assistants = useMemo(() => {
24-
return [
25-
defaultOption,
26-
...(assistantListMap[endpoint ?? ''] ?? []).map(({ id, name }) => ({
27-
label: name,
28-
value: id,
29-
})),
30-
].filter(Boolean);
31-
}, [assistantListMap, endpoint, defaultOption]);
29+
const currentAssistants = (currentList ?? []).map(({ id, name }) => ({
30+
label: name,
31+
value: id,
32+
}));
33+
34+
return [defaultOption, ...currentAssistants].filter(Boolean);
35+
}, [currentList, defaultOption]);
3236

3337
const [onPromptPrefixChange, promptPrefixValue] = useDebouncedInput({
3438
setOption,
@@ -96,6 +100,9 @@ export default function Settings({ conversation, setOption, models, readonly }:
96100
value: assistant.id ?? '',
97101
});
98102
setOption('assistant_id')(assistant.id);
103+
if (assistant.model) {
104+
setModel(assistant.model);
105+
}
99106
};
100107

101108
const optionEndpoint = endpointType ?? endpoint;
@@ -141,7 +148,7 @@ export default function Settings({ conversation, setOption, models, readonly }:
141148
<TextareaAutosize
142149
id="promptPrefix"
143150
disabled={readonly}
144-
value={promptPrefixValue as string | undefined}
151+
value={(promptPrefixValue as string | null | undefined) ?? ''}
145152
onChange={onPromptPrefixChange}
146153
placeholder={localize('com_endpoint_prompt_prefix_assistants_placeholder')}
147154
className={cn(
@@ -158,7 +165,7 @@ export default function Settings({ conversation, setOption, models, readonly }:
158165
<TextareaAutosize
159166
id="instructions"
160167
disabled={readonly}
161-
value={instructionsValue as string | undefined}
168+
value={(instructionsValue as string | null | undefined) ?? ''}
162169
onChange={onInstructionsChange}
163170
placeholder={localize('com_endpoint_instructions_assistants_placeholder')}
164171
className={cn(

0 commit comments

Comments
 (0)