fix: adjust calculation hub labels using total RAM instead remaining RAM
This commit is contained in:
parent
120e52e39f
commit
1513158902
@ -14,7 +14,6 @@ import ModalCancelDownload from '@/containers/ModalCancelDownload'
|
|||||||
|
|
||||||
import { MainViewState } from '@/constants/screens'
|
import { MainViewState } from '@/constants/screens'
|
||||||
|
|
||||||
import { useActiveModel } from '@/hooks/useActiveModel'
|
|
||||||
import { useCreateNewThread } from '@/hooks/useCreateNewThread'
|
import { useCreateNewThread } from '@/hooks/useCreateNewThread'
|
||||||
import useDownloadModel from '@/hooks/useDownloadModel'
|
import useDownloadModel from '@/hooks/useDownloadModel'
|
||||||
import { useDownloadState } from '@/hooks/useDownloadState'
|
import { useDownloadState } from '@/hooks/useDownloadState'
|
||||||
@ -24,7 +23,7 @@ import { useMainViewState } from '@/hooks/useMainViewState'
|
|||||||
|
|
||||||
import { toGibibytes } from '@/utils/converter'
|
import { toGibibytes } from '@/utils/converter'
|
||||||
|
|
||||||
import { totalRamAtom, usedRamAtom } from '@/helpers/atoms/SystemBar.atom'
|
import { totalRamAtom } from '@/helpers/atoms/SystemBar.atom'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
model: Model
|
model: Model
|
||||||
@ -38,7 +37,6 @@ const ExploreModelItemHeader: React.FC<Props> = ({ model, onClick, open }) => {
|
|||||||
const { modelDownloadStateAtom, downloadStates } = useDownloadState()
|
const { modelDownloadStateAtom, downloadStates } = useDownloadState()
|
||||||
const { requestCreateNewThread } = useCreateNewThread()
|
const { requestCreateNewThread } = useCreateNewThread()
|
||||||
const totalRam = useAtomValue(totalRamAtom)
|
const totalRam = useAtomValue(totalRamAtom)
|
||||||
const usedRam = useAtomValue(usedRamAtom)
|
|
||||||
|
|
||||||
const downloadAtom = useMemo(
|
const downloadAtom = useMemo(
|
||||||
() => atom((get) => get(modelDownloadStateAtom)[model.id]),
|
() => atom((get) => get(modelDownloadStateAtom)[model.id]),
|
||||||
@ -84,33 +82,20 @@ const ExploreModelItemHeader: React.FC<Props> = ({ model, onClick, open }) => {
|
|||||||
downloadButton = <ModalCancelDownload model={model} />
|
downloadButton = <ModalCancelDownload model={model} />
|
||||||
}
|
}
|
||||||
|
|
||||||
const { activeModel } = useActiveModel()
|
|
||||||
|
|
||||||
const getLabel = (size: number) => {
|
const getLabel = (size: number) => {
|
||||||
const minimumRamModel = size * 1.25
|
if (size * 1.25 >= totalRam) {
|
||||||
const availableRam = totalRam - usedRam + (activeModel?.metadata.size ?? 0)
|
|
||||||
|
|
||||||
if (minimumRamModel > totalRam) {
|
|
||||||
return (
|
return (
|
||||||
<Badge className="rounded-md" themes="danger">
|
<Badge className="rounded-md" themes="danger">
|
||||||
Not enough RAM
|
Not enough RAM
|
||||||
</Badge>
|
</Badge>
|
||||||
)
|
)
|
||||||
}
|
} else {
|
||||||
if (minimumRamModel < availableRam) {
|
|
||||||
return (
|
return (
|
||||||
<Badge className="rounded-md" themes="success">
|
<Badge className="rounded-md" themes="success">
|
||||||
Recommended
|
Recommended
|
||||||
</Badge>
|
</Badge>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (minimumRamModel < totalRam && minimumRamModel > availableRam) {
|
|
||||||
return (
|
|
||||||
<Badge className="rounded-md" themes="warning">
|
|
||||||
Slow on your device
|
|
||||||
</Badge>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user