index.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import type { FC } from 'react'
  2. import type {
  3. Model,
  4. ModelProvider,
  5. } from '../declarations'
  6. import { useLanguage } from '../hooks'
  7. import { CubeOutline } from '@/app/components/base/icons/src/vender/line/shapes'
  8. import { OpenaiViolet } from '@/app/components/base/icons/src/public/llm'
  9. type ModelIconProps = {
  10. provider?: Model | ModelProvider
  11. modelName?: string
  12. className?: string
  13. }
  14. const ModelIcon: FC<ModelIconProps> = ({
  15. provider,
  16. className,
  17. modelName,
  18. }) => {
  19. const language = useLanguage()
  20. if (provider?.provider === 'openai' && (modelName?.startsWith('gpt-4') || modelName?.includes('4o')))
  21. return <OpenaiViolet className={`w-4 h-4 ${className}`}/>
  22. if (provider?.icon_small) {
  23. return (
  24. <img
  25. alt='model-icon'
  26. src={`${provider.icon_small[language] || provider.icon_small.en_US}`}
  27. className={`w-4 h-4 ${className}`}
  28. />
  29. )
  30. }
  31. return (
  32. <div className={`
  33. flex items-center justify-center w-6 h-6 rounded border-[0.5px] border-black/5 bg-gray-50
  34. ${className}
  35. `}>
  36. <CubeOutline className='w-4 h-4 text-gray-400' />
  37. </div>
  38. )
  39. }
  40. export default ModelIcon