import { Fragment } from 'react' import { InferenceEngine } from '@janhq/core' import { CommandModal, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, Badge, } from '@janhq/uikit' import { useAtom } from 'jotai' import { DatabaseIcon, CpuIcon } from 'lucide-react' import { showSelectModelModalAtom } from '@/containers/Providers/KeyListener' import { MainViewState } from '@/constants/screens' import { useActiveModel } from '@/hooks/useActiveModel' import { useGetDownloadedModels } from '@/hooks/useGetDownloadedModels' import { useMainViewState } from '@/hooks/useMainViewState' export default function CommandListDownloadedModel() { const { setMainViewState } = useMainViewState() const { downloadedModels } = useGetDownloadedModels() const { activeModel, startModel, stopModel } = useActiveModel() const [showSelectModelModal, setShowSelectModelModal] = useAtom( showSelectModelModalAtom ) const onModelActionClick = (modelId: string) => { if (activeModel && activeModel.id === modelId) { stopModel() } else { startModel(modelId) } } const isNotDownloadedModel = downloadedModels.length === 0 if (isNotDownloadedModel) return null return ( No Model found. {!isNotDownloadedModel && ( {downloadedModels .filter((model) => model.engine === InferenceEngine.nitro) .map((model) => ( { onModelActionClick(model.id) setShowSelectModelModal(false) }} >
{model.id} {activeModel && activeModel.id === model.id && ( Active )}
))}
)} { setMainViewState(MainViewState.Hub) setShowSelectModelModal(false) }} > Explore The Hub
) }