import { Plugin, GPTIcon, AnthropicIcon } from '~/components/svg'; import { useAuthContext } from '~/hooks/AuthContext'; import { cn } from '~/utils'; const getIcon = (props) => { const { size = 30, isCreatedByUser, button, model, message = true } = props; // eslint-disable-next-line react-hooks/rules-of-hooks const { user } = useAuthContext(); if (isCreatedByUser) { return (
avatar
); } else if (!isCreatedByUser) { const { endpoint, error } = props; let icon, bg, name; if (endpoint === 'azureOpenAI') { const { chatGptLabel } = props; icon = ; bg = 'linear-gradient(0.375turn, #61bde2, #4389d0)'; name = chatGptLabel || 'ChatGPT'; } else if (endpoint === 'openAI' || (endpoint === 'gptPlugins' && message)) { const { chatGptLabel } = props; icon = ; bg = model && model.toLowerCase().startsWith('gpt-4') ? '#AB68FF' : chatGptLabel ? `rgba(16, 163, 127, ${button ? 0.75 : 1})` : `rgba(16, 163, 127, ${button ? 0.75 : 1})`; name = chatGptLabel || 'ChatGPT'; } else if (endpoint === 'gptPlugins' && !message) { icon = ; bg = `rgba(69, 89, 164, ${button ? 0.75 : 1})`; name = 'Plugins'; } else if (endpoint === 'google') { const { modelLabel } = props; icon = Palm Icon; name = modelLabel || 'PaLM2'; } else if (endpoint === 'anthropic') { const { modelLabel } = props; icon = ; bg = '#d09a74'; name = modelLabel || 'Claude'; } else if (endpoint === 'bingAI') { const { jailbreak } = props; if (jailbreak) { icon = Bing Icon; name = 'Sydney'; } else { icon = Sydney Icon; name = 'BingAI'; } } else if (endpoint === 'chatGPTBrowser') { icon = ; bg = model && model.toLowerCase().startsWith('gpt-4') ? '#AB68FF' : `rgba(0, 163, 255, ${button ? 0.75 : 1})`; name = 'ChatGPT'; } else if (endpoint === null) { icon = ; bg = 'grey'; name = 'N/A'; } else { icon = ; bg = 'grey'; name = 'UNKNOWN'; } return (
{icon} {error && ( ! )}
); } }; export default getIcon;