index.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import type { FC } from 'react'
  2. import type { ModelProvider } from '../declarations'
  3. import { useLanguage } from '../hooks'
  4. import { useAppContext } from '@/context/app-context'
  5. import { Openai } from '@/app/components/base/icons/src/vender/other'
  6. import { AnthropicDark, AnthropicLight } from '@/app/components/base/icons/src/public/llm'
  7. import { renderI18nObject } from '@/hooks/use-i18n'
  8. import { Theme } from '@/types/app'
  9. import cn from '@/utils/classnames'
  10. type ProviderIconProps = {
  11. provider: ModelProvider
  12. className?: string
  13. }
  14. const ProviderIcon: FC<ProviderIconProps> = ({
  15. provider,
  16. className,
  17. }) => {
  18. const { theme } = useAppContext()
  19. const language = useLanguage()
  20. if (provider.provider === 'langgenius/anthropic/anthropic') {
  21. return (
  22. <div className='mb-2 py-[7px]'>
  23. {theme === Theme.dark && <AnthropicLight className='w-[90px] h-2.5' />}
  24. {theme === Theme.light && <AnthropicDark className='w-[90px] h-2.5' />}
  25. </div>
  26. )
  27. }
  28. if (provider.provider === 'langgenius/openai/openai') {
  29. return (
  30. <div className='mb-2'>
  31. <Openai className='w-auto h-6 text-text-inverted-dimmed' />
  32. </div>
  33. )
  34. }
  35. return (
  36. <div className={cn('inline-flex items-center gap-2', className)}>
  37. <img
  38. alt='provider-icon'
  39. src={renderI18nObject(provider.icon_small, language)}
  40. className='w-6 h-6'
  41. />
  42. <div className='system-md-semibold text-text-primary'>
  43. {renderI18nObject(provider.label, language)}
  44. </div>
  45. </div>
  46. )
  47. }
  48. export default ProviderIcon