File size: 2,169 Bytes
f0743f4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | import { getEndpointField, isAssistantsEndpoint } from 'librechat-data-provider';
import type {
TPreset,
TConversation,
TAssistantsMap,
TEndpointsConfig,
} from 'librechat-data-provider';
import ConvoIconURL from '~/components/Endpoints/ConvoIconURL';
import MinimalIcon from '~/components/Endpoints/MinimalIcon';
import { getIconEndpoint } from '~/utils';
export default function EndpointIcon({
conversation,
endpointsConfig,
className = 'mr-0',
assistantMap,
context,
}: {
conversation: TConversation | TPreset | null;
endpointsConfig: TEndpointsConfig;
containerClassName?: string;
context?: 'message' | 'nav' | 'landing' | 'menu-item';
assistantMap?: TAssistantsMap;
className?: string;
size?: number;
}) {
const convoIconURL = conversation?.iconURL ?? '';
let endpoint = conversation?.endpoint;
endpoint = getIconEndpoint({ endpointsConfig, iconURL: convoIconURL, endpoint });
const endpointType = getEndpointField(endpointsConfig, endpoint, 'type');
const endpointIconURL = getEndpointField(endpointsConfig, endpoint, 'iconURL');
const assistant = isAssistantsEndpoint(endpoint)
? assistantMap?.[endpoint]?.[conversation?.assistant_id ?? '']
: null;
const assistantAvatar = (assistant && (assistant.metadata?.avatar as string)) || '';
const assistantName = assistant && (assistant.name ?? '');
const iconURL = assistantAvatar || convoIconURL;
if (iconURL && (iconURL.includes('http') || iconURL.startsWith('/images/'))) {
return (
<ConvoIconURL
iconURL={iconURL}
modelLabel={conversation?.chatGptLabel ?? conversation?.modelLabel ?? ''}
context={context}
endpointIconURL={endpointIconURL}
assistantAvatar={assistantAvatar}
assistantName={assistantName ?? ''}
/>
);
} else {
return (
<MinimalIcon
size={20}
iconURL={endpointIconURL}
endpoint={endpoint}
endpointType={endpointType}
model={conversation?.model}
error={false}
className={className}
isCreatedByUser={false}
chatGptLabel={undefined}
modelLabel={undefined}
/>
);
}
}
|