jan/web/screens/MyModels/index.tsx
Louis 96dba2690d feat: class-based plugin manager
chore: add facades

refactor: core module export

refactor: inference plugin - deprecate function registering (#537)

* refactor: revamp inference plugin as class - deprecate function registering

* refactor: monitoring plugin - deprecate service registering (#538)

refactor: revamp inference plugin as class - deprecate function registering

chore: update import

refactor: plugin revamp - model management

chore: update build steps and remove experimental plugins

refactor: remove pluggable electron

chore: add sorting for conversations

chore: build plugins for testing

chore: consistent plugin directory name

chore: docs

chore: fix CI

chore: update conversation prefix
2023-11-06 13:46:01 +07:00

86 lines
2.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React, { Fragment } from 'react'
import { useSetAtom } from 'jotai'
import { Button } from '@uikit'
import { modelDownloadStateAtom } from '@helpers/atoms/DownloadState.atom'
import DownloadedModelTable from '@/_components/DownloadedModelTable'
import { useAtomValue } from 'jotai'
import { useGetDownloadedModels } from '@hooks/useGetDownloadedModels'
import { formatDownloadPercentage } from '@utils/converter'
import { LayoutGrid } from 'lucide-react'
import {
setMainViewStateAtom,
MainViewState,
} from '@helpers/atoms/MainView.atom'
const MyModelsScreen = () => {
const { downloadedModels } = useGetDownloadedModels()
const setMainViewState = useSetAtom(setMainViewStateAtom)
const modelDownloadStates = useAtomValue(modelDownloadStateAtom)
const downloadStates: DownloadState[] = []
for (const [, value] of Object.entries(modelDownloadStates)) {
downloadStates.push(value)
}
const isDownloadingFirstModel = downloadStates.length > 0
if (!downloadedModels || downloadedModels.length === 0)
return (
<div className="flex h-full items-center justify-center px-4">
<div className="text-center">
<LayoutGrid size={32} className="mx-auto text-accent/50" />
<div className="mt-4">
{isDownloadingFirstModel ? (
<div className="relative">
<div className="mt-4">
<h1 className="text-2xl font-bold leading-snug">
Donwloading your first model
</h1>
<p className="mt-1 text-muted-foreground">
{downloadStates[0].fileName} -{' '}
{formatDownloadPercentage(downloadStates[0].percent)}
</p>
</div>
</div>
) : (
<Fragment>
<h1 className="text-2xl font-bold leading-snug">{`Ups, You don't have a model.`}</h1>
<p className="mt-1 text-base text-muted-foreground">{`lets download your first model`}</p>
<Button
className="mt-4"
themes="accent"
onClick={() => setMainViewState(MainViewState.ExploreModel)}
>
Explore Models
</Button>
</Fragment>
)}
</div>
</div>
</div>
)
return (
<div className="flex h-full w-full overflow-y-auto">
<div className="w-full p-5">
<h1
data-testid="testid-mymodels-header"
className="text-lg font-semibold"
>
My Models
</h1>
<p className="mt-2 text-gray-600 dark:text-gray-400">
You have <span>{downloadedModels.length}</span> models downloaded
</p>
<div>
{/* <ActiveModelTable /> */}
{/* <DownloadingModelTable /> */}
<DownloadedModelTable />
</div>
</div>
</div>
)
}
export default MyModelsScreen