mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-11 13:08:51 +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
93 lines
2.7 KiB
TypeScript
93 lines
2.7 KiB
TypeScript
import { useMemo } from 'react';
|
|
import type { TMessage, Assistant, Agent } from 'librechat-data-provider';
|
|
import type { TMessageProps } from '~/common';
|
|
import MessageEndpointIcon from '../Endpoints/MessageEndpointIcon';
|
|
import ConvoIconURL from '~/components/Endpoints/ConvoIconURL';
|
|
import { getIconEndpoint } from '~/utils';
|
|
import { UserIcon } from '../svg';
|
|
|
|
export default function MessageIcon(
|
|
props: Pick<TMessageProps, 'message' | 'conversation'> & {
|
|
assistant?: false | Assistant;
|
|
agent?: false | Agent;
|
|
},
|
|
) {
|
|
const { message, conversation, assistant, agent } = props;
|
|
|
|
const messageSettings = useMemo(
|
|
() => ({
|
|
...(conversation ?? {}),
|
|
...({
|
|
...message,
|
|
iconURL: message?.iconURL ?? '',
|
|
} as TMessage),
|
|
}),
|
|
[conversation, message],
|
|
);
|
|
|
|
const iconURL = messageSettings.iconURL ?? '';
|
|
let endpoint = messageSettings.endpoint;
|
|
endpoint = getIconEndpoint({ endpointsConfig: undefined, iconURL, endpoint });
|
|
const assistantName = (assistant ? assistant.name : '') ?? '';
|
|
const assistantAvatar = (assistant ? assistant.metadata?.avatar : '') ?? '';
|
|
const agentName = (agent ? agent.name : '') ?? '';
|
|
const agentAvatar = (agent ? agent?.avatar?.filepath : '') ?? '';
|
|
const avatarURL = useMemo(() => {
|
|
let result = '';
|
|
if (assistant) {
|
|
result = assistantAvatar;
|
|
} else if (agent) {
|
|
result = agentAvatar;
|
|
}
|
|
return result;
|
|
}, [assistant, agent, assistantAvatar, agentAvatar]);
|
|
console.log('MessageIcon', {
|
|
endpoint,
|
|
iconURL,
|
|
assistantName,
|
|
assistantAvatar,
|
|
agentName,
|
|
agentAvatar,
|
|
});
|
|
if (message?.isCreatedByUser !== true && iconURL && iconURL.includes('http')) {
|
|
return (
|
|
<ConvoIconURL
|
|
iconURL={iconURL}
|
|
modelLabel={messageSettings.chatGptLabel ?? messageSettings.modelLabel ?? ''}
|
|
context="message"
|
|
assistantAvatar={assistantAvatar}
|
|
assistantName={assistantName}
|
|
agentAvatar={agentAvatar}
|
|
agentName={agentName}
|
|
/>
|
|
);
|
|
}
|
|
|
|
if (message?.isCreatedByUser === true) {
|
|
return (
|
|
<div
|
|
style={{
|
|
backgroundColor: 'rgb(121, 137, 255)',
|
|
width: '20px',
|
|
height: '20px',
|
|
boxShadow: 'rgba(240, 246, 252, 0.1) 0px 0px 0px 1px',
|
|
}}
|
|
className="relative flex h-9 w-9 items-center justify-center rounded-sm p-1 text-white"
|
|
>
|
|
<UserIcon />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<MessageEndpointIcon
|
|
{...messageSettings}
|
|
endpoint={endpoint}
|
|
iconURL={avatarURL}
|
|
model={message?.model ?? conversation?.model}
|
|
assistantName={assistantName}
|
|
agentName={agentName}
|
|
size={28.8}
|
|
/>
|
|
);
|
|
}
|