import { memo } from 'react'; import { Feather } from 'lucide-react'; import { EModelEndpoint, isAssistantsEndpoint, alternateName } from 'librechat-data-provider'; import { Plugin, GPTIcon, PaLMIcon, CodeyIcon, GeminiIcon, BedrockIcon, AssistantIcon, AnthropicIcon, AzureMinimalIcon, CustomMinimalIcon, } from '~/components/svg'; import UnknownIcon from '~/components/Chat/Menus/Endpoints/UnknownIcon'; import { IconProps } from '~/common'; import { cn } from '~/utils'; type EndpointIcon = { icon: React.ReactNode | React.JSX.Element; bg?: string; name?: string | null; }; function getOpenAIColor(_model: string | null | undefined) { const model = _model?.toLowerCase() ?? ''; if (model && /\bo1\b/i.test(model)) { return '#000000'; } return model.includes('gpt-4') ? '#AB68FF' : '#19C37D'; } function getGoogleIcon(model: string | null | undefined, size: number) { if (model?.toLowerCase().includes('code') === true) { return ; } else if (model?.toLowerCase().includes('gemini') === true) { return ; } else { return ; } } function getGoogleModelName(model: string | null | undefined) { if (model?.toLowerCase().includes('code') === true) { return 'Codey'; } else if (model?.toLowerCase().includes('gemini') === true) { return 'Gemini'; } else { return 'PaLM2'; } } const MessageEndpointIcon: React.FC = (props) => { const { error, button, iconURL = '', endpoint, jailbreak, size = 30, model = '', assistantName, agentName, } = props; const assistantsIcon = { icon: iconURL ? (
{assistantName}
) : (
), name: endpoint, }; const agentsIcon = { icon: iconURL ? (
{agentName}
) : (
), name: endpoint, }; const endpointIcons: { [key: string]: EndpointIcon | undefined; } = { [EModelEndpoint.assistants]: assistantsIcon, [EModelEndpoint.agents]: agentsIcon, [EModelEndpoint.azureAssistants]: assistantsIcon, [EModelEndpoint.azureOpenAI]: { icon: , bg: 'linear-gradient(0.375turn, #61bde2, #4389d0)', name: 'ChatGPT', }, [EModelEndpoint.openAI]: { icon: , bg: getOpenAIColor(model), name: 'ChatGPT', }, [EModelEndpoint.gptPlugins]: { icon: , bg: `rgba(69, 89, 164, ${button === true ? 0.75 : 1})`, name: 'Plugins', }, [EModelEndpoint.google]: { icon: getGoogleIcon(model, size), name: getGoogleModelName(model), }, [EModelEndpoint.anthropic]: { icon: , bg: '#d09a74', name: 'Claude', }, [EModelEndpoint.bedrock]: { icon: , bg: '#268672', name: alternateName[EModelEndpoint.bedrock], }, [EModelEndpoint.bingAI]: { icon: jailbreak === true ? ( Bing Icon ) : ( Sydney Icon ), name: jailbreak === true ? 'Sydney' : 'BingAI', }, [EModelEndpoint.chatGPTBrowser]: { icon: , bg: typeof model === 'string' && model.toLowerCase().includes('gpt-4') ? '#AB68FF' : `rgba(0, 163, 255, ${button === true ? 0.75 : 1})`, name: 'ChatGPT', }, [EModelEndpoint.custom]: { icon: , name: 'Custom', }, null: { icon: , bg: 'grey', name: 'N/A' }, default: { icon: (
), name: endpoint, }, }; let { icon, bg, name } = endpoint != null && endpoint && endpointIcons[endpoint] ? endpointIcons[endpoint] ?? {} : (endpointIcons.default as EndpointIcon); if (iconURL && endpointIcons[iconURL]) { ({ icon, bg, name } = endpointIcons[iconURL]); } if (isAssistantsEndpoint(endpoint)) { return icon; } return (
{icon} {error === true && ( ! )}
); }; export default memo(MessageEndpointIcon);