mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-26 21:28:50 +01:00
* WIP: end session endpoint * refactor: move useGetBannerQuery outside of package * refactor: add queriesEnabled and move useGetEndpointsConfigQuery to data-provider (local) * refactor: move useGetEndpointsQuery import to data-provider * refactor: relocate useGetEndpointsQuery import to improve module organization * refactor: move `useGetStartupConfig` from package to `~/data-provider` * refactor: move useGetUserBalance to data-provider and update imports * refactor: update query enabled conditions to include config check * refactor: remove unused useConfigOverride import from useAppStartup * refactor: integrate queriesEnabled state into file and search queries and move useGetSearchEnabledQuery to data-provider (local) * refactor: move useGetUserQuery to data-provider and update imports * refactor: enhance loginUser mutation with success and error handling as pass in options to hook * refactor: update enabled condition in queries to handle undefined config * refactor: enhance authentication mutations with queriesEnabled state management * refactor: improve conditional rendering for error messages and feature flags in Login component * refactor: remove unused queriesEnabled state from AuthContextProvider * refactor: implement queriesEnabled state management in LoginLayout with timeout handling * refactor: add conditional check for end session endpoint in OpenID strategy * ci: fix tests after changes * refactor: remove endSessionEndpoint from user schema and update logoutController to use OpenID issuer's end_session_endpoint * refactor: update logoutController to use end_session_endpoint from issuer metadata
79 lines
2.4 KiB
TypeScript
79 lines
2.4 KiB
TypeScript
import React, { useMemo, memo } from 'react';
|
|
import type { Assistant, Agent } from 'librechat-data-provider';
|
|
import type { TMessageIcon } from '~/common';
|
|
import { getEndpointField, getIconEndpoint, logger } from '~/utils';
|
|
import ConvoIconURL from '~/components/Endpoints/ConvoIconURL';
|
|
import { useGetEndpointsQuery } from '~/data-provider';
|
|
import Icon from '~/components/Endpoints/Icon';
|
|
|
|
const MessageIcon = memo(
|
|
({
|
|
iconData,
|
|
assistant,
|
|
agent,
|
|
}: {
|
|
iconData?: TMessageIcon;
|
|
assistant?: Assistant;
|
|
agent?: Agent;
|
|
}) => {
|
|
logger.log('icon_data', iconData, assistant, agent);
|
|
const { data: endpointsConfig } = useGetEndpointsQuery();
|
|
|
|
const agentName = useMemo(() => agent?.name ?? '', [agent]);
|
|
const agentAvatar = useMemo(() => agent?.avatar?.filepath ?? '', [agent]);
|
|
const assistantName = useMemo(() => assistant?.name ?? '', [assistant]);
|
|
const assistantAvatar = useMemo(() => assistant?.metadata?.avatar ?? '', [assistant]);
|
|
|
|
const avatarURL = useMemo(() => {
|
|
let result = '';
|
|
if (assistant) {
|
|
result = assistantAvatar;
|
|
} else if (agent) {
|
|
result = agentAvatar;
|
|
}
|
|
return result;
|
|
}, [assistant, agent, assistantAvatar, agentAvatar]);
|
|
|
|
const iconURL = iconData?.iconURL;
|
|
const endpoint = useMemo(
|
|
() => getIconEndpoint({ endpointsConfig, iconURL, endpoint: iconData?.endpoint }),
|
|
[endpointsConfig, iconURL, iconData?.endpoint],
|
|
);
|
|
|
|
const endpointIconURL = useMemo(
|
|
() => getEndpointField(endpointsConfig, endpoint, 'iconURL'),
|
|
[endpointsConfig, endpoint],
|
|
);
|
|
|
|
if (iconData?.isCreatedByUser !== true && iconURL != null && iconURL.includes('http')) {
|
|
return (
|
|
<ConvoIconURL
|
|
iconURL={iconURL}
|
|
modelLabel={iconData?.modelLabel}
|
|
context="message"
|
|
assistantAvatar={assistantAvatar}
|
|
agentAvatar={agentAvatar}
|
|
endpointIconURL={endpointIconURL}
|
|
assistantName={assistantName}
|
|
agentName={agentName}
|
|
/>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Icon
|
|
isCreatedByUser={iconData?.isCreatedByUser ?? false}
|
|
endpoint={endpoint}
|
|
iconURL={avatarURL || endpointIconURL}
|
|
model={iconData?.model}
|
|
assistantName={assistantName}
|
|
agentName={agentName}
|
|
size={28.8}
|
|
/>
|
|
);
|
|
},
|
|
);
|
|
|
|
MessageIcon.displayName = 'MessageIcon';
|
|
|
|
export default MessageIcon;
|