You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.tsx 1.6KB

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