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
28 lines
863 B
TypeScript
28 lines
863 B
TypeScript
import { useEffect } from 'react'
|
|
import { PluginType } from '@janhq/core'
|
|
import { useAtom } from 'jotai'
|
|
import { downloadedModelAtom } from '@helpers/atoms/DownloadedModel.atom'
|
|
import { pluginManager } from '@plugin/PluginManager'
|
|
import { ModelPlugin } from '@janhq/core/lib/plugins'
|
|
import { Model } from '@janhq/core/lib/types'
|
|
|
|
export function useGetDownloadedModels() {
|
|
const [downloadedModels, setDownloadedModels] = useAtom(downloadedModelAtom)
|
|
|
|
useEffect(() => {
|
|
getDownloadedModels().then((downloadedModels) => {
|
|
setDownloadedModels(downloadedModels)
|
|
})
|
|
}, [setDownloadedModels])
|
|
|
|
return { downloadedModels }
|
|
}
|
|
|
|
export async function getDownloadedModels(): Promise<Model[]> {
|
|
const models =
|
|
((await pluginManager
|
|
.get<ModelPlugin>(PluginType.Model)
|
|
?.getDownloadedModels()) as Model[]) ?? []
|
|
return models
|
|
}
|