diff --git a/web/containers/DropdownListSidebar/index.tsx b/web/containers/DropdownListSidebar/index.tsx index b0d64ff09..f8ac92d6f 100644 --- a/web/containers/DropdownListSidebar/index.tsx +++ b/web/containers/DropdownListSidebar/index.tsx @@ -15,16 +15,24 @@ import { SelectTrigger, SelectValue, Input, + Tooltip, + TooltipContent, + TooltipPortal, + TooltipTrigger, + TooltipArrow, + Badge, } from '@janhq/uikit' import { atom, useAtomValue, useSetAtom } from 'jotai' -import { MonitorIcon } from 'lucide-react' +import { MonitorIcon, InfoIcon } from 'lucide-react' import { twMerge } from 'tailwind-merge' import { MainViewState } from '@/constants/screens' +import { useActiveModel } from '@/hooks/useActiveModel' + import { useEngineSettings } from '@/hooks/useEngineSettings' import { useMainViewState } from '@/hooks/useMainViewState' @@ -33,6 +41,7 @@ import useRecommendedModel from '@/hooks/useRecommendedModel' import { toGibibytes } from '@/utils/converter' +import { totalRamAtom, usedRamAtom } from '@/helpers/atoms/SystemBar.atom' import { ModelParams, activeThreadAtom, @@ -49,6 +58,7 @@ export default function DropdownListSidebar() { const threadStates = useAtomValue(threadStatesAtom) const setSelectedModel = useSetAtom(selectedModelAtom) const setThreadModelParams = useSetAtom(setThreadModelParamsAtom) + const { activeModel } = useActiveModel() const [selected, setSelected] = useState() const { setMainViewState } = useMainViewState() @@ -56,6 +66,8 @@ export default function DropdownListSidebar() { { api_key: string } | undefined >(undefined) const { readOpenAISettings, saveOpenAISettings } = useEngineSettings() + const totalRam = useAtomValue(totalRamAtom) + const usedRam = useAtomValue(usedRamAtom) useEffect(() => { readOpenAISettings().then((settings) => { @@ -119,6 +131,71 @@ export default function DropdownListSidebar() { return null } + const getLabel = (size: number) => { + const minimumRamModel = size * 1.25 + const availableRam = totalRam - usedRam + (activeModel?.metadata.size ?? 0) + if (minimumRamModel > totalRam) { + return ( + + Not enough RAM + + + + + + + + {`This tag signals insufficient RAM for optimal model + performance. It's dynamic and may change with your system's + RAM availability.`} + + + + + + + ) + } + if (minimumRamModel < availableRam) { + return ( + + Recommended + + ) + } + if (minimumRamModel < totalRam && minimumRamModel > availableRam) { + return ( + + Slow on your device + + + + + + + + This tag indicates that your current RAM performance may + affect model speed. It can change based on other active apps. + To improve, consider closing unnecessary applications to free + up RAM. + + + + + + + ) + } + } + return ( <>