From 027fdde5d52bad83acf4dfe62461cbe81155cec0 Mon Sep 17 00:00:00 2001 From: 2814109 <2814109k@gmail.com> Date: Sun, 20 Oct 2024 14:43:08 +0900 Subject: [PATCH] chore --- src/functions/initialize-engine.ts | 25 +++++++++++-------------- src/hooks/use-llm-engine.ts | 2 +- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/functions/initialize-engine.ts b/src/functions/initialize-engine.ts index 77d6147..d187b9c 100644 --- a/src/functions/initialize-engine.ts +++ b/src/functions/initialize-engine.ts @@ -2,18 +2,15 @@ import { CreateMLCEngine } from "@mlc-ai/web-llm"; import { initProgressCallback } from "../helpers/initProgressCallback"; import type { useLlmEngine } from "../hooks/use-llm-engine"; -export const initializeEngine = - ( - hooksProps: Pick< - ReturnType, - "setEngine" | "withLoadingHasDispatch" - >, - ) => - async () => - await hooksProps.withLoadingHasDispatch(async (setResponse) => { - const engine = await CreateMLCEngine( - "Qwen2.5-1.5B-Instruct-q4f16_1-MLC", - { initProgressCallback: initProgressCallback(setResponse) }, - ); - hooksProps.setEngine(engine); +export const initializeEngine = async ( + hooksProps: Pick< + ReturnType, + "setEngine" | "withLoadingHasDispatch" + >, +) => + await hooksProps.withLoadingHasDispatch(async (setResponse) => { + const engine = await CreateMLCEngine("Qwen2.5-1.5B-Instruct-q4f16_1-MLC", { + initProgressCallback: initProgressCallback(setResponse), }); + hooksProps.setEngine(engine); + }); diff --git a/src/hooks/use-llm-engine.ts b/src/hooks/use-llm-engine.ts index 7c949c2..6aff31d 100644 --- a/src/hooks/use-llm-engine.ts +++ b/src/hooks/use-llm-engine.ts @@ -32,7 +32,7 @@ export const useLlmEngine = () => { // biome-ignore lint/correctness/useExhaustiveDependencies: useEffect(() => { (async () => { - await initializeEngine({ withLoadingHasDispatch, setEngine })(); + await initializeEngine({ withLoadingHasDispatch, setEngine }); })(); }, []);