mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 01:10:14 +01:00
* fix: Ensure safe access to agent capabilities in AgentConfig * fix: don't show agent builder if agents endpoint is not enabled * fix: Improve error logging for MCP tool calls * fix: Enhance error message for MCP tool failures * feat: Add optional spec and iconURL properties to TEndpointOption type * chore: Update condition to use constant for new conversation parameter * feat: Enhance abort error handling with additional endpoint options to properly render error message fields * fix: Throw error instead of returning message for failed MCP tool calls * refactor: separate logic to generate new S3 URLs for expired links * feat: Implement S3 URL refresh for user avatars with error handling * fix: authcontext error in chats where agent chain is used * refactor: streamline balance configuration logic in getBalanceConfig function * fix: enhance icon resolution logic in SpecIcon component * fix: allow null values for spec and iconURL in TEndpointOption type * fix: update balance check to allow null tokenCredits
76 lines
2 KiB
TypeScript
76 lines
2 KiB
TypeScript
import { memo, useMemo } from 'react';
|
|
import type { IconMapProps } from '~/common';
|
|
import { URLIcon } from '~/components/Endpoints/URLIcon';
|
|
import { icons } from '~/hooks/Endpoint/Icons';
|
|
|
|
interface ConvoIconURLProps {
|
|
iconURL?: string;
|
|
modelLabel?: string | null;
|
|
endpointIconURL?: string;
|
|
assistantName?: string;
|
|
agentName?: string;
|
|
context?: 'landing' | 'menu-item' | 'nav' | 'message';
|
|
assistantAvatar?: string;
|
|
agentAvatar?: string;
|
|
}
|
|
|
|
const classMap = {
|
|
'menu-item': 'relative flex h-full items-center justify-center overflow-hidden rounded-full',
|
|
message: 'icon-md',
|
|
default: 'icon-xl relative flex h-full overflow-hidden rounded-full',
|
|
};
|
|
|
|
const styleMap = {
|
|
'menu-item': { width: '20px', height: '20px' },
|
|
default: { width: '100%', height: '100%' },
|
|
};
|
|
|
|
const styleImageMap = {
|
|
default: { width: '100%', height: '100%' },
|
|
};
|
|
|
|
const ConvoIconURL: React.FC<ConvoIconURLProps> = ({
|
|
iconURL = '',
|
|
modelLabel = '',
|
|
endpointIconURL,
|
|
assistantAvatar,
|
|
assistantName,
|
|
agentAvatar,
|
|
agentName,
|
|
context,
|
|
}) => {
|
|
const Icon = useMemo(() => icons[iconURL] ?? icons.unknown, [iconURL]);
|
|
const isURL = useMemo(
|
|
() => !!(iconURL && (iconURL.includes('http') || iconURL.startsWith('/images/'))),
|
|
[iconURL],
|
|
);
|
|
if (isURL) {
|
|
return (
|
|
<URLIcon
|
|
iconURL={iconURL}
|
|
altName={modelLabel}
|
|
className={classMap[context ?? 'default'] ?? classMap.default}
|
|
containerStyle={styleMap[context ?? 'default'] ?? styleMap.default}
|
|
imageStyle={styleImageMap[context ?? 'default'] ?? styleImageMap.default}
|
|
/>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div className="shadow-stroke relative flex h-full items-center justify-center rounded-full bg-white text-black">
|
|
{Icon && (
|
|
<Icon
|
|
size={41}
|
|
context={context}
|
|
className="h-2/3 w-2/3"
|
|
agentName={agentName}
|
|
iconURL={endpointIconURL}
|
|
assistantName={assistantName}
|
|
avatar={assistantAvatar || agentAvatar}
|
|
/>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default memo(ConvoIconURL);
|