model-list.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import React from 'react'
  2. import { useTranslation } from 'react-i18next'
  3. import ModelIcon from '@/app/components/header/account-setting/model-provider-page/model-icon'
  4. import ModelName from '@/app/components/header/account-setting/model-provider-page/model-name'
  5. import { useModelProviderModelList } from '@/service/use-models'
  6. import type { PluginDetail } from '@/app/components/plugins/types'
  7. type Props = {
  8. detail: PluginDetail
  9. }
  10. const ModelList = ({
  11. detail,
  12. }: Props) => {
  13. const { t } = useTranslation()
  14. const { data: res } = useModelProviderModelList(`${detail.plugin_id}/${detail.name === 'gemini' ? 'google' : detail.name}`)
  15. if (!res)
  16. return null
  17. return (
  18. <div className='px-4 py-2'>
  19. <div className='mb-1 h-6 flex items-center text-text-secondary system-sm-semibold-uppercase'>{t('plugin.detailPanel.modelNum', { num: res.data.length })}</div>
  20. <div className='flex flex-col'>
  21. {res.data.map(model => (
  22. <div key={model.model} className='h-6 py-1 flex items-center'>
  23. <ModelIcon
  24. className='shrink-0 mr-2'
  25. provider={(model as any).provider}
  26. modelName={model.model}
  27. />
  28. <ModelName
  29. className='grow text-text-secondary system-md-regular'
  30. modelItem={model}
  31. showModelType
  32. showMode
  33. showContextSize
  34. />
  35. </div>
  36. ))}
  37. </div>
  38. </div>
  39. )
  40. }
  41. export default ModelList