import { Plugin, GPTIcon, BingIcon } from '~/components/svg'; import { useAuthContext } from '~/hooks/AuthContext'; 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 === 'bingAI') { const { jailbreak } = props; icon = ; bg = jailbreak ? 'radial-gradient(circle at 90% 110%, #F0F0FA, #D0E0F9)' : 'transparent'; name = jailbreak ? 'Sydney' : '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;