diff --git a/client/src/components/Chat/Menus/Endpoints/Icons.tsx b/client/src/components/Chat/Menus/Endpoints/Icons.tsx index 913fc5b3f8..b7a775b269 100644 --- a/client/src/components/Chat/Menus/Endpoints/Icons.tsx +++ b/client/src/components/Chat/Menus/Endpoints/Icons.tsx @@ -11,6 +11,7 @@ import { CustomMinimalIcon, AssistantIcon, LightningIcon, + BedrockIcon, Sparkles, } from '~/components/svg'; import UnknownIcon from './UnknownIcon'; @@ -52,6 +53,10 @@ const AgentAvatar = ({ className = '', agentName, avatar, size }: AgentIconMapPr return ; }; +const Bedrock = ({ className = '' }: IconMapProps) => { + return ; +}; + export const icons = { [EModelEndpoint.azureOpenAI]: AzureMinimalIcon, [EModelEndpoint.openAI]: GPTIcon, @@ -64,5 +69,6 @@ export const icons = { [EModelEndpoint.assistants]: AssistantAvatar, [EModelEndpoint.azureAssistants]: AssistantAvatar, [EModelEndpoint.agents]: AgentAvatar, + [EModelEndpoint.bedrock]: Bedrock, unknown: UnknownIcon, }; diff --git a/client/src/components/Endpoints/MessageEndpointIcon.tsx b/client/src/components/Endpoints/MessageEndpointIcon.tsx index fc084bbb55..ad204a7d4b 100644 --- a/client/src/components/Endpoints/MessageEndpointIcon.tsx +++ b/client/src/components/Endpoints/MessageEndpointIcon.tsx @@ -1,4 +1,4 @@ -import { EModelEndpoint, isAssistantsEndpoint } from 'librechat-data-provider'; +import { EModelEndpoint, isAssistantsEndpoint, alternateName } from 'librechat-data-provider'; import UnknownIcon from '~/components/Chat/Menus/Endpoints/UnknownIcon'; import { BrainCircuit } from 'lucide-react'; import { @@ -7,6 +7,7 @@ import { PaLMIcon, CodeyIcon, GeminiIcon, + BedrockIcon, AssistantIcon, AnthropicIcon, AzureMinimalIcon, @@ -16,11 +17,31 @@ import { import { IconProps } from '~/common'; import { cn } from '~/utils'; +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, + iconURL = '', endpoint, jailbreak, size = 30, @@ -30,7 +51,7 @@ const MessageEndpointIcon: React.FC = (props) => { } = props; const assistantsIcon = { - icon: props.iconURL ? ( + icon: iconURL ? (
= (props) => { > {assistantName} @@ -59,7 +80,7 @@ const MessageEndpointIcon: React.FC = (props) => { }; const agentsIcon = { - icon: props.iconURL ? ( + icon: iconURL ? (
= (props) => { > {agentName} @@ -104,42 +125,38 @@ const MessageEndpointIcon: React.FC = (props) => { }, [EModelEndpoint.gptPlugins]: { icon: , - bg: `rgba(69, 89, 164, ${button ? 0.75 : 1})`, + bg: `rgba(69, 89, 164, ${button === true ? 0.75 : 1})`, name: 'Plugins', }, [EModelEndpoint.google]: { - icon: model?.toLowerCase()?.includes('code') ? ( - - ) : model?.toLowerCase()?.includes('gemini') ? ( - - ) : ( - - ), - name: model?.toLowerCase()?.includes('code') - ? 'Codey' - : model?.toLowerCase()?.includes('gemini') - ? 'Gemini' - : 'PaLM2', + 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 ? ( - Bing Icon - ) : ( - Sydney Icon - ), - name: jailbreak ? 'Sydney' : '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 ? 0.75 : 1})`, + : `rgba(0, 163, 255, ${button === true ? 0.75 : 1})`, name: 'ChatGPT', }, [EModelEndpoint.custom]: { @@ -152,7 +169,7 @@ const MessageEndpointIcon: React.FC = (props) => {
= (props) => { }} className={cn( 'relative flex h-9 w-9 items-center justify-center rounded-sm p-1 text-white', - props.className || '', + props.className ?? '', )} > {icon} - {error && ( + {error === true && ( ! diff --git a/client/src/components/Endpoints/MinimalIcon.tsx b/client/src/components/Endpoints/MinimalIcon.tsx index 80ab657a83..1f008e263c 100644 --- a/client/src/components/Endpoints/MinimalIcon.tsx +++ b/client/src/components/Endpoints/MinimalIcon.tsx @@ -1,4 +1,4 @@ -import { EModelEndpoint } from 'librechat-data-provider'; +import { EModelEndpoint, alternateName } from 'librechat-data-provider'; import { BrainCircuit } from 'lucide-react'; import UnknownIcon from '~/components/Chat/Menus/Endpoints/UnknownIcon'; import { @@ -10,6 +10,7 @@ import { GoogleMinimalIcon, CustomMinimalIcon, AnthropicIcon, + BedrockIcon, Sparkles, } from '~/components/svg'; import { cn } from '~/utils'; @@ -27,17 +28,17 @@ const MinimalIcon: React.FC = (props) => { const endpointIcons = { [EModelEndpoint.azureOpenAI]: { icon: , - name: props.chatGptLabel || 'ChatGPT', + name: props.chatGptLabel ?? 'ChatGPT', }, [EModelEndpoint.openAI]: { icon: , - name: props.chatGptLabel || 'ChatGPT', + name: props.chatGptLabel ?? 'ChatGPT', }, [EModelEndpoint.gptPlugins]: { icon: , name: 'Plugins' }, - [EModelEndpoint.google]: { icon: , name: props.modelLabel || 'Google' }, + [EModelEndpoint.google]: { icon: , name: props.modelLabel ?? 'Google' }, [EModelEndpoint.anthropic]: { icon: , - name: props.modelLabel || 'Claude', + name: props.modelLabel ?? 'Claude', }, [EModelEndpoint.custom]: { icon: , @@ -47,7 +48,14 @@ const MinimalIcon: React.FC = (props) => { [EModelEndpoint.chatGPTBrowser]: { icon: , name: 'ChatGPT' }, [EModelEndpoint.assistants]: { icon: , name: 'Assistant' }, [EModelEndpoint.azureAssistants]: { icon: , name: 'Assistant' }, - [EModelEndpoint.agents]: { icon: , name: 'Agent' }, + [EModelEndpoint.agents]: { + icon: , + name: props.modelLabel ?? alternateName[EModelEndpoint.agents], + }, + [EModelEndpoint.bedrock]: { + icon: , + name: props.modelLabel ?? alternateName[EModelEndpoint.bedrock], + }, default: { icon: ( = (props) => { }} className={cn( 'relative flex items-center justify-center rounded-sm text-black dark:text-white', - props.className || '', + props.className ?? '', )} > {icon} - {error && ( + {error === true && ( ! diff --git a/packages/data-provider/src/config.ts b/packages/data-provider/src/config.ts index 7901339973..b6c2c0a03f 100644 --- a/packages/data-provider/src/config.ts +++ b/packages/data-provider/src/config.ts @@ -568,7 +568,7 @@ export const alternateName = { [EModelEndpoint.google]: 'Google', [EModelEndpoint.anthropic]: 'Anthropic', [EModelEndpoint.custom]: 'Custom', - [EModelEndpoint.bedrock]: 'Bedrock', + [EModelEndpoint.bedrock]: 'AWS Bedrock', }; const sharedOpenAIModels = [ diff --git a/packages/data-provider/src/parsers.ts b/packages/data-provider/src/parsers.ts index f41d197962..79b6a48fe1 100644 --- a/packages/data-provider/src/parsers.ts +++ b/packages/data-provider/src/parsers.ts @@ -190,7 +190,7 @@ export const parseConvo = ({ // TODO: POC for default schema // defaultSchema?: Partial, }) => { - let schema = endpointSchemas[endpoint]; + let schema = endpointSchemas[endpoint] as EndpointSchema | undefined; if (!schema && !endpointType) { throw new Error(`Unknown endpoint: ${endpoint}`); @@ -202,14 +202,14 @@ export const parseConvo = ({ // schema = schemaCreators[endpoint](defaultSchema); // } - const convo = schema.parse(conversation) as s.TConversation; + const convo = schema?.parse(conversation) as s.TConversation | undefined; const { models, secondaryModels } = possibleValues ?? {}; if (models && convo) { convo.model = getFirstDefinedValue(models) ?? convo.model; } - if (secondaryModels && convo.agentOptions) { + if (secondaryModels && convo?.agentOptions) { convo.agentOptions.model = getFirstDefinedValue(secondaryModels) ?? convo.agentOptions.model; } @@ -217,9 +217,17 @@ export const parseConvo = ({ }; export const getResponseSender = (endpointOption: t.TEndpointOption): string => { - const { model, endpoint, endpointType, modelDisplayLabel, chatGptLabel, modelLabel, jailbreak } = - endpointOption; + const { + model: _m, + endpoint, + endpointType, + modelDisplayLabel, + chatGptLabel, + modelLabel, + jailbreak, + } = endpointOption; + const model = _m ?? ''; if ( [ EModelEndpoint.openAI, @@ -232,14 +240,14 @@ export const getResponseSender = (endpointOption: t.TEndpointOption): string => return chatGptLabel; } else if (model && model.includes('gpt-3')) { return 'GPT-3.5'; - } else if (model && model.includes('gpt-4')) { - return 'GPT-4'; } else if (model && model.includes('gpt-4o')) { return 'GPT-4o'; + } else if (model && model.includes('gpt-4')) { + return 'GPT-4'; } else if (model && model.includes('mistral')) { return 'Mistral'; } - return alternateName[endpoint] ?? 'ChatGPT'; + return (alternateName[endpoint] as string | undefined) ?? 'ChatGPT'; } if (endpoint === EModelEndpoint.bingAI) { @@ -250,6 +258,10 @@ export const getResponseSender = (endpointOption: t.TEndpointOption): string => return modelLabel ?? 'Claude'; } + if (endpoint === EModelEndpoint.bedrock) { + return modelLabel ?? alternateName[endpoint]; + } + if (endpoint === EModelEndpoint.google) { if (modelLabel) { return modelLabel; @@ -271,6 +283,8 @@ export const getResponseSender = (endpointOption: t.TEndpointOption): string => return 'Mistral'; } else if (model && model.includes('gpt-3')) { return 'GPT-3.5'; + } else if (model && model.includes('gpt-4o')) { + return 'GPT-4o'; } else if (model && model.includes('gpt-4')) { return 'GPT-4'; } else if (modelDisplayLabel) {