chore: add stop model action
This commit is contained in:
parent
7171bde1d9
commit
d256f49d07
@ -19,9 +19,14 @@ const dispose = async () =>
|
||||
});
|
||||
const inferenceUrl = () => "http://localhost:3928/llama/chat_completion";
|
||||
|
||||
const stopModel = () => {
|
||||
window.electronAPI.invokePluginFunc(MODULE_PATH, "killSubprocess");
|
||||
};
|
||||
|
||||
// Register all the above functions and objects with the relevant extension points
|
||||
export function init({ register }) {
|
||||
register("initModel", "initModel", initModel);
|
||||
register("inferenceUrl", "inferenceUrl", inferenceUrl);
|
||||
register("dispose", "dispose", dispose);
|
||||
register("stopModel", "stopModel", stopModel);
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ type Props = {
|
||||
};
|
||||
|
||||
const ModelRow: React.FC<Props> = ({ model }) => {
|
||||
const { startModel } = useStartStopModel();
|
||||
const { startModel, stopModel } = useStartStopModel();
|
||||
const activeModel = useAtomValue(currentProductAtom);
|
||||
const { deleteModel } = useDeleteModel();
|
||||
|
||||
@ -31,6 +31,8 @@ const ModelRow: React.FC<Props> = ({ model }) => {
|
||||
const onModelActionClick = (action: ModelActionType) => {
|
||||
if (action === ModelActionType.Start) {
|
||||
startModel(model.id);
|
||||
} else {
|
||||
stopModel(model.id);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
import React, { useState } from "react";
|
||||
|
||||
export default function useGetModels() {
|
||||
const [models, setModels] = useState<any[]>()
|
||||
|
||||
return {
|
||||
models
|
||||
};
|
||||
}
|
||||
@ -1,9 +1,12 @@
|
||||
import { executeSerial } from "@/_services/pluginService";
|
||||
import { DataService } from "../../shared/coreService";
|
||||
import { DataService, InfereceService } from "../../shared/coreService";
|
||||
import useInitModel from "./useInitModel";
|
||||
import { useSetAtom } from "jotai";
|
||||
import { currentProductAtom } from "@/_helpers/atoms/Model.atom";
|
||||
|
||||
export default function useStartStopModel() {
|
||||
const { initModel } = useInitModel();
|
||||
const setActiveModel = useSetAtom(currentProductAtom);
|
||||
|
||||
const startModel = async (modelId: string) => {
|
||||
const model = await executeSerial(DataService.GET_MODEL_BY_ID, modelId);
|
||||
@ -14,7 +17,10 @@ export default function useStartStopModel() {
|
||||
}
|
||||
};
|
||||
|
||||
const stopModel = async (modelId: string) => {};
|
||||
const stopModel = async (modelId: string) => {
|
||||
await executeSerial(InfereceService.STOP_MODEL, modelId);
|
||||
setActiveModel(undefined);
|
||||
};
|
||||
|
||||
return { startModel, stopModel };
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@ export enum ModelService {
|
||||
export enum InfereceService {
|
||||
INFERENCE_URL = "inferenceUrl",
|
||||
INIT_MODEL = "initModel",
|
||||
STOP_MODEL = "stopModel",
|
||||
}
|
||||
|
||||
export enum ModelManagementService {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user