* feat: better hardware setting * chore: update layout * feat: better hardware setting * chore: fix title section * chore: added hardware engine management * chore: integrate gpus and enable set gpu activate * chore: update calculate ram and vram * chore: update calulate vram and ram used * fix: set active gpus * chore: fix progress bar spacing * chore: always update cache vram gpu * chore: update cpu usage percentage * chore: fix type usage cpu * chore: update ram cpus usage getsystemmonitor from new api harware engine management system * test: update test case data using hardware management extension * chore: resolve conflict lock json * chore: cleanup app services * chore: update type OperationSystemInfo * chore: update app service * chore: show list gpus on system monitor * chore: remove monitoring extension * chore: update test case app service * chore: remove unused hooks useGpusSetting * chore: remove monitor from shource index * chore: fix test core * chore: update gpu and cpu info on engine management ext * chore: fix app service test * chore: update test appService include cpu info * chore: filter gpus show or hide on system monitor based activated gpu * chore: remove unused run_mode * chore: remove tensort * chore: update check gpu run_mode * chore: handle undefined gpus * chore: cleanup PR * chore: cleanup process node error * chore: fix type
69 lines
1.7 KiB
TypeScript
69 lines
1.7 KiB
TypeScript
import React from 'react'
|
|
|
|
import { ModelMetadata } from '@janhq/core'
|
|
import { Badge } from '@janhq/joi'
|
|
import { useAtomValue } from 'jotai'
|
|
|
|
import { useActiveModel } from '@/hooks/useActiveModel'
|
|
|
|
import { useSettings } from '@/hooks/useSettings'
|
|
|
|
import NotEnoughMemoryLabel from './NotEnoughMemoryLabel'
|
|
|
|
import SlowOnYourDeviceLabel from './SlowOnYourDeviceLabel'
|
|
|
|
import {
|
|
availableVramAtom,
|
|
totalRamAtom,
|
|
usedRamAtom,
|
|
} from '@/helpers/atoms/SystemBar.atom'
|
|
|
|
type Props = {
|
|
metadata: ModelMetadata
|
|
compact?: boolean
|
|
}
|
|
const UnsupportedModel = () => {
|
|
return (
|
|
<Badge className="space-x-1 rounded-md" theme="warning">
|
|
<span>Coming Soon</span>
|
|
</Badge>
|
|
)
|
|
}
|
|
|
|
const ModelLabel = ({ metadata, compact }: Props) => {
|
|
const { activeModel } = useActiveModel()
|
|
const totalRam = useAtomValue(totalRamAtom)
|
|
const usedRam = useAtomValue(usedRamAtom)
|
|
const availableVram = useAtomValue(availableVramAtom)
|
|
const { settings } = useSettings()
|
|
|
|
const getLabel = (size: number) => {
|
|
const minimumRamModel = size * 1.25
|
|
const availableRam = settings?.gpus?.some((gpu) => gpu.activated)
|
|
? availableVram * 1000000 // MB to bytes
|
|
: totalRam - usedRam + (activeModel?.metadata?.size ?? 0)
|
|
if (minimumRamModel > totalRam) {
|
|
return (
|
|
<NotEnoughMemoryLabel
|
|
unit={settings?.gpus?.some((gpu) => gpu.activated) ? 'VRAM' : 'RAM'}
|
|
compact={compact}
|
|
/>
|
|
)
|
|
}
|
|
|
|
if (minimumRamModel < totalRam && minimumRamModel > availableRam) {
|
|
return <SlowOnYourDeviceLabel compact={compact} />
|
|
}
|
|
|
|
return null
|
|
}
|
|
|
|
return metadata?.tags?.includes('Coming Soon') ? (
|
|
<UnsupportedModel />
|
|
) : (
|
|
getLabel(metadata?.size ?? 0)
|
|
)
|
|
}
|
|
|
|
export default React.memo(ModelLabel)
|