* feat: adding create bot functionality Signed-off-by: James <james@jan.ai> * update the temperature progress bar Signed-off-by: James <james@jan.ai> * chore: remove tgz Signed-off-by: James <james@jan.ai> * update core dependency Signed-off-by: James <james@jan.ai> * fix e2e test Signed-off-by: James <james@jan.ai> --------- Signed-off-by: James <james@jan.ai> Co-authored-by: James <james@jan.ai>
30 lines
827 B
TypeScript
30 lines
827 B
TypeScript
import { Bot } from "@/_models/Bot";
|
|
import { executeSerial } from "../../../electron/core/plugin-manager/execution/extension-manager";
|
|
import { DataService } from "@janhq/core";
|
|
|
|
export default function useGetBots() {
|
|
const getAllBots = async (): Promise<Bot[]> => {
|
|
try {
|
|
const bots = await executeSerial(DataService.GetBots);
|
|
return bots;
|
|
} catch (err) {
|
|
alert(`Failed to get bots: ${err}`);
|
|
console.error(err);
|
|
return [];
|
|
}
|
|
};
|
|
|
|
const getBotById = async (botId: string): Promise<Bot | undefined> => {
|
|
try {
|
|
const bot: Bot = await executeSerial(DataService.GetBotById, botId);
|
|
return bot;
|
|
} catch (err) {
|
|
alert(`Failed to get bot ${botId}: ${err}`);
|
|
console.error(err);
|
|
return undefined;
|
|
}
|
|
};
|
|
|
|
return { getBotById, getAllBots };
|
|
}
|