index.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import { useTranslation } from 'react-i18next'
  5. import ModelSelector from '@/app/components/header/account-setting/model-provider-page/model-selector'
  6. import { useProviderContext } from '@/context/provider-context'
  7. export type IModelConfigProps = {
  8. modelId: string
  9. providerName: string
  10. onChange?: (modelId: string, providerName: string) => void
  11. readonly?: boolean
  12. }
  13. const ModelConfig: FC<IModelConfigProps> = ({
  14. modelId,
  15. providerName,
  16. onChange,
  17. readonly,
  18. }) => {
  19. const { t } = useTranslation()
  20. const { agentThoughtModelList } = useProviderContext()
  21. return (
  22. <div className='flex items-center justify-between h-[52px] px-3 rounded-xl bg-gray-50'>
  23. <div className='text-sm font-semibold text-gray-800'>{t('explore.universalChat.model')}</div>
  24. <ModelSelector
  25. triggerClassName={`${readonly && '!cursor-not-allowed !opacity-60'}`}
  26. defaultModel={{ provider: providerName, model: modelId }}
  27. modelList={agentThoughtModelList}
  28. onSelect={(model) => {
  29. onChange?.(model.model, model.provider)
  30. }}
  31. readonly={readonly}
  32. />
  33. </div>
  34. )
  35. }
  36. export default React.memo(ModelConfig)