diff --git a/web/screens/ExploreModels/ExploreModelItemHeader/index.tsx b/web/screens/ExploreModels/ExploreModelItemHeader/index.tsx index 2f871b170..851e5bada 100644 --- a/web/screens/ExploreModels/ExploreModelItemHeader/index.tsx +++ b/web/screens/ExploreModels/ExploreModelItemHeader/index.tsx @@ -23,6 +23,8 @@ import { useMainViewState } from '@/hooks/useMainViewState' import { toGibibytes } from '@/utils/converter' +import { totalRamAtom, usedRamAtom } from '@/helpers/atoms/SystemBar.atom' + type Props = { model: Model onClick: () => void @@ -34,6 +36,8 @@ const ExploreModelItemHeader: React.FC = ({ model, onClick, open }) => { const { downloadedModels } = useGetDownloadedModels() const { modelDownloadStateAtom, downloadStates } = useDownloadState() const { requestCreateNewThread } = useCreateNewThread() + const totalRam = useAtomValue(totalRamAtom) + const usedRam = useAtomValue(usedRamAtom) const downloadAtom = useMemo( () => atom((get) => get(modelDownloadStateAtom)[model.id]), @@ -79,6 +83,33 @@ const ExploreModelItemHeader: React.FC = ({ model, onClick, open }) => { downloadButton = } + const getLabel = (size: number) => { + const minimumRamModel = size * 1.25 + const availableRam = totalRam - usedRam + + if (minimumRamModel > totalRam) { + return ( + + Not enough RAM + + ) + } + if (minimumRamModel < availableRam) { + return ( + + Recommended + + ) + } + if (minimumRamModel < totalRam && minimumRamModel > availableRam) { + return ( + + Slow on your device + + ) + } + } + return (
= ({ model, onClick, open }) => { {toGibibytes(model.metadata.size)} - {model.metadata.size && ( - <> - - Recommended - - - Slow on your device - - - Not enough RAM - - - )} + {getLabel(model.metadata.size)} + {downloadButton}