jan/web/app/_hooks/useDeleteModel.ts
Louis 5fc1ba7067
feature: @janhq/plugin-core module & plugins update (#321)
* @janhq/plugin-core module

* refactor web to use exported services from module

* refactor data-plugin to provide DAL & move model logics to model management plugin

* model-management in TS

* add ci auto package, increate version, and publish to npm repository

* chore: storage operations

* chore: hybrid data-plugin esm & cjs module

* chore: PouchDB Driver

* chore: documentation

---------

Co-authored-by: Hien To <hien@jan.ai>
Co-authored-by: Service Account <service@jan.ai>
2023-10-14 15:59:28 +07:00

22 lines
827 B
TypeScript

import { execute, executeSerial } from "@/_services/pluginService";
import { ModelManagementService } from "@janhq/plugin-core";
import { useSetAtom } from "jotai";
import { downloadedModelAtom } from "@/_helpers/atoms/DownloadedModel.atom";
import { getDownloadedModels } from "./useGetDownloadedModels";
import { AssistantModel } from "@/_models/AssistantModel";
export default function useDeleteModel() {
const setDownloadedModels = useSetAtom(downloadedModelAtom);
const deleteModel = async (model: AssistantModel) => {
execute(ModelManagementService.DeleteDownloadModel, model._id);
await executeSerial(ModelManagementService.DeleteModel, model._id);
// reload models
const downloadedModels = await getDownloadedModels();
setDownloadedModels(downloadedModels);
};
return { deleteModel };
}