Skip to content

Commit

Permalink
chore
Browse files Browse the repository at this point in the history
  • Loading branch information
k70suK3-k06a7ash1 committed Oct 20, 2024
1 parent ff237d7 commit 027fdde
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
25 changes: 11 additions & 14 deletions src/functions/initialize-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof useLlmEngine>,
"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<typeof useLlmEngine>,
"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);
});
2 changes: 1 addition & 1 deletion src/hooks/use-llm-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const useLlmEngine = () => {
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
useEffect(() => {
(async () => {
await initializeEngine({ withLoadingHasDispatch, setEngine })();
await initializeEngine({ withLoadingHasDispatch, setEngine });
})();
}, []);

Expand Down

0 comments on commit 027fdde

Please sign in to comment.