import type { FC } from 'react' import { useTranslation } from 'react-i18next' import Indicator from '../../../indicator' import Selector from '../selector' import type { Model, ProviderEnum } from '../declarations' import { ProviderEnum as ProviderEnumValue } from '../declarations' import Button from '@/app/components/base/button' type CardProps = { providerType: ProviderEnum models: Model[] onOpenModal: (v: Omit & Model['config']) => void onOperate: (v: Record) => void } const Card: FC = ({ providerType, models, onOpenModal, onOperate, }) => { const { t } = useTranslation() const renderDesc = (model: Model) => { if (providerType === ProviderEnumValue.azure_openai) return model.config.openai_api_base if (providerType === ProviderEnumValue.replicate) return `version: ${model.config.model_version}` if (providerType === ProviderEnumValue.huggingface_hub) return model.config.huggingfacehub_endpoint_url } return (
{ models.map(model => (
{model.model_name}
{model.model_type}
{renderDesc(model)}
onOperate({ ...v, value: model })} className={open => `${open && '!bg-gray-100 shadow-none'} flex justify-center items-center w-7 h-7 bg-white rounded-md border-[0.5px] border-gray-200 shadow-xs cursor-pointer hover:bg-gray-100`} deleteText={t('common.operation.remove') || ''} />
)) }
) } export default Card