mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-21 21:50:49 +02:00

* chore: typing * chore: typing * fix: enhance message scrolling logic to handle empty messages tree and ref checks * fix: optimize message selection logic with useCallback for better performance * chore: typing * refactor: optimize icon rendering * refactor: further optimize chat props * fix: remove unnecessary console log in useQueryParams cleanup * refactor: add queryClient to reset message data on new conversation initiation * refactor: update data-testid attributes for consistency and improve code readability * refactor: integrate queryClient to reset message data on new conversation initiation
70 lines
2.1 KiB
TypeScript
70 lines
2.1 KiB
TypeScript
import { isAssistantsEndpoint } from 'librechat-data-provider';
|
|
import type {
|
|
TConversation,
|
|
TEndpointsConfig,
|
|
TPreset,
|
|
TAssistantsMap,
|
|
} from 'librechat-data-provider';
|
|
import ConvoIconURL from '~/components/Endpoints/ConvoIconURL';
|
|
import MinimalIcon from '~/components/Endpoints/MinimalIcon';
|
|
import { getEndpointField, 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}
|
|
jailbreak={undefined}
|
|
/>
|
|
);
|
|
}
|
|
}
|