Skip to content

ChatWebLLM Initialization Failure Due To @mlc-ai/web-llm Refactoring #5648

@kaiwinut

Description

@kaiwinut

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

The following code:

import { ChatWebLLM } from '@langchain/community/chat_models/webllm';

webllmModel = new ChatWebLLM({
	model: 'Phi2-q4f32_1',
	chatOptions: {
		temperature: 0.1
	}
});
await webllmModel.initialize();

Error Message and Stack Trace (if applicable)

Uncaught (in promise) TypeError: (void 0) is not a constructor
at ChatWebLLM.initialize (@langchain_community_chat_models_webllm.js?v=b8d3d037:13507:19)
at worker.ts:156:22

Description

I'm trying to use ChatWebLLM via web workers following the documentation and the end-to-end example referenced in the docs.

I expect the web llm engine to be initialized when I call ChatWebLLM.initialize; however, the error above occurs instead.

After studying the source code, I figured that in a recent commit, the developers of web-llm renamed the Engine class to MLCEngine. This results in a failed constructor call on this line:

this.engine = new webllm.Engine();

Fixing the web-llm version to 0.2.35 (where the class was not renamed yet) works for now.

System Info

Node version: v22.1.0
langchain version: 0.2.4
@langchain/community version: 0.2.5
@mlc-ai/web-llm version: 0.2.41

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions