import DownloadModelContent from '../DownloadModelContent' import ModelDownloadButton from '../ModelDownloadButton' import ModelDownloadingButton from '../ModelDownloadingButton' import { useAtomValue } from 'jotai' import { modelDownloadStateAtom } from '@/_helpers/atoms/DownloadState.atom' import { AssistantModel } from '@/_models/AssistantModel' type Props = { model: AssistantModel isRecommend: boolean required?: string onDownloadClick?: (model: AssistantModel) => void } const AvailableModelCard: React.FC = ({ model, isRecommend, required, onDownloadClick, }) => { const downloadState = useAtomValue(modelDownloadStateAtom) let isDownloading = false let total = 0 let transferred = 0 if (model._id && downloadState[model._id]) { isDownloading = downloadState[model._id].error == null && downloadState[model._id].percent < 1 if (isDownloading) { total = downloadState[model._id].size.total transferred = downloadState[model._id].size.transferred } } const downloadButton = isDownloading ? (
) : (
onDownloadClick?.(model)} />
) return (
{downloadButton}
{/* */}
) } export default AvailableModelCard