* chore: update core services and module export * Correct version of plugins (#374) Co-authored-by: Hien To <tominhhien97@gmail.com> * janhq/jan: Update tag build 1.0.2 for data-plugin * janhq/jan: Update tag build 1.0.2 for inference-plugin * janhq/jan: Update tag build 1.0.2 for model-management-plugin * janhq/jan: Update tag build 1.0.2 for monitoring-plugin * janhq/jan: Update tag build 1.0.2 for openai-plugin * chore: update web to use @janhq/core module --------- Co-authored-by: hiento09 <136591877+hiento09@users.noreply.github.com> Co-authored-by: Hien To <tominhhien97@gmail.com> Co-authored-by: Service Account <service@jan.ai>
27 lines
907 B
TypeScript
27 lines
907 B
TypeScript
import { executeSerial } from "@/_services/pluginService";
|
|
import { ModelManagementService, InferenceService } from "@janhq/core";
|
|
import useInitModel from "./useInitModel";
|
|
import { useSetAtom } from "jotai";
|
|
import { activeAssistantModelAtom } from "@/_helpers/atoms/Model.atom";
|
|
|
|
export default function useStartStopModel() {
|
|
const { initModel } = useInitModel();
|
|
const setActiveModel = useSetAtom(activeAssistantModelAtom);
|
|
|
|
const startModel = async (modelId: string) => {
|
|
const model = await executeSerial(ModelManagementService.GetModelById, modelId);
|
|
if (!model) {
|
|
alert(`Model ${modelId} not found! Please re-download the model first.`);
|
|
} else {
|
|
await initModel(model);
|
|
}
|
|
};
|
|
|
|
const stopModel = async (modelId: string) => {
|
|
await executeSerial(InferenceService.StopModel, modelId);
|
|
setActiveModel(undefined);
|
|
};
|
|
|
|
return { startModel, stopModel };
|
|
}
|