-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebLLM Example Code does not Work in Google Chrome #5771
Comments
To resolve the issue with the WebLLM example code in Google Chrome, where the code throws an exception indicating that the model is not loaded before calling Here is an example of how you can modify the code to ensure the model is loaded: import { ChatWebLLM } from "@langchain/community/chat_models/webllm";
import { HumanMessage } from "@langchain/core/messages";
const model = new ChatWebLLM({
model: "Phi-3-mini-4k-instruct-q4f16_1-MLC",
chatOptions: {
temperature: 0.5,
},
});
await model.engine.reload(model.model); // Ensure the model is loaded
const response = await model.invoke([
new HumanMessage({ content: "What is 1 + 1?" }),
]);
console.log(response);
/*
AIMessage {
content: ' 2\n',
} In this example, the Additionally, ensure that you are running the code in a web environment, such as a web worker, as shown in the example above. |
I suspect related to #5776 We will lock the peer dep to a specific version from here on out |
@jacoblee93 Actually for this specific issue it's not related to webllm version, but wrong sample code in the documentation. As suggested by the Dosubot above, either |
Ah I see - thank you! That PR should fix the example as well then. |
Thank you all. I will make all the updates described here and try again. |
Checked other resources
Example Code
Tried the example code from langchain and it throws exception in Google chrome.
web-llm 0.2.46
Error Message and Stack Trace (if applicable)
Description
WebLLM Example Code does not Work in Google Chrome
System Info
[email protected] | MIT | deps: 16 | versions: 277
Typescript bindings for langchain
https://github.com/langchain-ai/langchainjs/tree/main/langchain/
keywords: llm, ai, gpt3, chain, prompt, prompt engineering, chatgpt, machine learning, ml, openai, embeddings, vectorstores
dist
.tarball: https://registry.npmjs.org/langchain/-/langchain-0.2.5.tgz
.shasum: fc23848c20244a1d0a3dd5dd4663af9a41017ccb
.integrity: sha512-H5WL0NanCdQ+tzoeEt7Fyz9YGdR3wbfDvfQrJvxAO95istKo5JraRh24dzyvqxM9439xwRMNaMIpMwsyqtWDtQ==
.unpackedSize: 4.0 MB
dependencies:
@langchain/core: ~0.2.0
@langchain/openai: ~0.1.0
@langchain/textsplitters: ~0.0.0
binary-extensions: ^2.2.0
js-tiktoken: ^1.0.12
js-yaml: ^4.1.0
jsonpointer: ^5.0.1
langchainhub: ~0.0.8
langsmith: ~0.1.30
ml-distance: ^4.0.0
openapi-types: ^12.1.3
p-retry: 4
uuid: ^9.0.0
yaml: ^2.2.1
zod-to-json-schema: ^3.22.3
zod: ^3.22.4
maintainers:
dist-tags:
latest: 0.2.5
next: 0.2.3-rc.0
published a week ago by jacoblee93 [email protected]
The text was updated successfully, but these errors were encountered: