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
35 lines
1020 B
TypeScript
35 lines
1020 B
TypeScript
import { atom } from 'jotai'
|
|
|
|
// download states
|
|
export const modelDownloadStateAtom = atom<Record<string, DownloadState>>({})
|
|
|
|
export const setDownloadStateAtom = atom(
|
|
null,
|
|
(get, set, state: DownloadState) => {
|
|
const currentState = { ...get(modelDownloadStateAtom) }
|
|
console.debug(
|
|
`current download state for ${state.fileName} is ${JSON.stringify(state)}`
|
|
)
|
|
state.fileName = state.fileName.replace('models/', '')
|
|
// TODO: Need somehow to not depend on filename
|
|
currentState[state.fileName] = state
|
|
set(modelDownloadStateAtom, currentState)
|
|
}
|
|
)
|
|
|
|
export const setDownloadStateSuccessAtom = atom(
|
|
null,
|
|
(get, set, fileName: string) => {
|
|
const currentState = { ...get(modelDownloadStateAtom) }
|
|
fileName = fileName.replace('models/', '')
|
|
const state = currentState[fileName]
|
|
if (!state) {
|
|
console.error(`Cannot find download state for ${fileName}`)
|
|
return
|
|
}
|
|
|
|
delete currentState[fileName]
|
|
set(modelDownloadStateAtom, currentState)
|
|
}
|
|
)
|