File size: 2,762 Bytes
aa2e6af | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | import { EModelEndpoint } from 'librechat-data-provider';
import UnknownIcon from '~/components/Chat/Menus/Endpoints/UnknownIcon';
import {
AzureMinimalIcon,
OpenAIMinimalIcon,
LightningIcon,
MinimalPlugin,
BingAIMinimalIcon,
GoogleMinimalIcon,
CustomMinimalIcon,
AnthropicIcon,
Sparkles,
} from '~/components/svg';
import { cn } from '~/utils';
import { IconProps } from '~/common';
const MinimalIcon: React.FC<IconProps> = (props) => {
const { size = 30, iconClassName, error } = props;
let endpoint = 'default'; // Default value for endpoint
if (typeof props.endpoint === 'string') {
endpoint = props.endpoint;
}
const endpointIcons = {
[EModelEndpoint.azureOpenAI]: {
icon: <AzureMinimalIcon className={iconClassName} />,
name: props.chatGptLabel || 'ChatGPT',
},
[EModelEndpoint.openAI]: {
icon: <OpenAIMinimalIcon className={iconClassName} />,
name: props.chatGptLabel || 'ChatGPT',
},
[EModelEndpoint.gptPlugins]: { icon: <MinimalPlugin />, name: 'Plugins' },
[EModelEndpoint.google]: { icon: <GoogleMinimalIcon />, name: props.modelLabel || 'Google' },
[EModelEndpoint.anthropic]: {
icon: <AnthropicIcon className="icon-md shrink-0 dark:text-white" />,
name: props.modelLabel || 'Claude',
},
[EModelEndpoint.custom]: {
icon: <CustomMinimalIcon />,
name: 'Custom',
},
[EModelEndpoint.bingAI]: { icon: <BingAIMinimalIcon />, name: 'BingAI' },
[EModelEndpoint.chatGPTBrowser]: { icon: <LightningIcon />, name: 'ChatGPT' },
[EModelEndpoint.assistants]: { icon: <Sparkles className="icon-sm" />, name: 'Assistant' },
[EModelEndpoint.azureAssistants]: { icon: <Sparkles className="icon-sm" />, name: 'Assistant' },
default: {
icon: (
<UnknownIcon
iconURL={props.iconURL}
endpoint={endpoint}
className="icon-sm"
context="nav"
/>
),
name: endpoint,
},
};
let { icon, name } = endpointIcons[endpoint] ?? endpointIcons.default;
if (props.iconURL && endpointIcons[props.iconURL]) {
({ icon, name } = endpointIcons[props.iconURL]);
}
return (
<div
data-testid="convo-icon"
title={name}
style={{
width: size,
height: size,
}}
className={cn(
'relative flex items-center justify-center rounded-sm text-black dark:text-white',
props.className || '',
)}
>
{icon}
{error && (
<span className="absolute right-0 top-[20px] -mr-2 flex h-4 w-4 items-center justify-center rounded-full border border-white bg-red-500 text-[10px] text-black dark:text-white">
!
</span>
)}
</div>
);
};
export default MinimalIcon;
|