Skip to content

Commit

Permalink
chore: update to webllm v0.2.35 and fix build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Neet-Nestor committed Jul 3, 2024
1 parent 6582694 commit 13dbed6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/get-started/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"url": "^0.11.3"
},
"dependencies": {
"@mlc-ai/web-agent-interface": "file:../.."
"@mlc-ai/web-agent-interface": "file:../../lib"
}
}
2 changes: 1 addition & 1 deletion examples/get-started/src/get_started.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function main() {
[
wai.AbilityTypeEnum.Editing,
{
modelId: "Llama-2-7b-chat-hf-q4f16_1-1k",
modelId: "Llama-3-8B-Instruct-q4f16_1-MLC",
worker: new Worker(new URL("./worker.ts", import.meta.url), {
type: "module",
}),
Expand Down
6 changes: 2 additions & 4 deletions examples/get-started/src/worker.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { EngineWorkerHandler, Engine } from "@mlc-ai/web-llm";
import { WebWorkerMLCEngineHandler } from "@mlc-ai/web-llm";

// Hookup an engine to a worker handler
const engine = new Engine();
const handler = new EngineWorkerHandler(engine);
const handler = new WebWorkerMLCEngineHandler();
self.onmessage = (msg: MessageEvent) => {
handler.onmessage(msg);
};
11 changes: 5 additions & 6 deletions src/environment/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { Environment, EnvironmentTypeEnum } from "./environment";
import { ActionType } from "../action";
import {
ChatCompletionRequest,
CreateWebWorkerEngine,
EngineInterface,
CreateWebWorkerMLCEngine,
MLCEngineInterface,
ChatOptions,
InitProgressCallback,
} from "@mlc-ai/web-llm";

export class ChatEnvironment extends Environment {
engine?: EngineInterface;
engine?: MLCEngineInterface;

constructor() {
super(EnvironmentTypeEnum.Chat);
Expand All @@ -29,10 +29,9 @@ export class ChatEnvironment extends Environment {
if (this.engine) {
return;
}
this.engine = await CreateWebWorkerEngine(worker, modelId, {
chatOpts: chatOpts,
this.engine = await CreateWebWorkerMLCEngine(worker, modelId, {
initProgressCallback: initProgressCallback,
});
}, chatOpts);
console.log("Engine initialized");
},
);
Expand Down

0 comments on commit 13dbed6

Please sign in to comment.