You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
import * as hub from "langchain/hub";
import { ChatAnthropic } from "@langchain/anthropic";
const prompt = await hub.pull("blahblah", { includeModel: true }); // this prompt has anthropic model
Error Message and Stack Trace (if applicable)
[1] > Exception occurs: Error: Invalid namespace: $.kwargs.last.kwargs.bound -> {"lc":1,"type":"constructor","id":["langchain","chat_models","anthropic","ChatAnthropic"],"kwargs":{"temperature":0.5,"max_tokens":1024,"top_p":1,"top_k":-1,"anthropic_api_key":{"id":["ANTHROPIC_API_KEY"],"lc":1,"type":"secret"},"model":"claude-3-5-haiku-20241022"}}
[1] > at Object.reviver (file:///some-directory/node_modules/@langchain/core/dist/load/index.js:117:19)
[1] > at file:///some-directory/node_modules/@langchain/core/dist/load/index.js:153:31
[1] > at Array.map (<anonymous>)
[1] > at Object.reviver (file:///some-directory/node_modules/@langchain/core/dist/load/index.js:151:79)
[1] > at Object.reviver (file:///some-directory/node_modules/@langchain/core/dist/load/index.js:131:38)
[1] > at file:///some-directory/node_modules/@langchain/core/dist/load/index.js:153:31
[1] > at Array.map (<anonymous>)
[1] > at Object.reviver (file:///some-directory/node_modules/@langchain/core/dist/load/index.js:151:79)
[1] > at Object.reviver (file:///some-directory/node_modules/@langchain/core/dist/load/index.js:131:38)
[1] > at load (file:///some-directory/node_modules/@langchain/core/dist/load/index.js:161:20) {
Regarding the error you're encountering, it seems to be related to the namespace handling for the ChatAnthropic model in the import_map.ts file. The error message indicates an "Invalid namespace," which suggests that the namespace for ChatAnthropic might not be correctly defined or exported.
The reviver function in the load/index.js file is responsible for handling namespaces during deserialization. It processes serialized objects and reconstructs them based on their type and associated metadata. If the namespace is not correctly defined in the import_map.ts file, it could lead to the error you're seeing [2].
To resolve this, you should verify that the ChatAnthropic model is correctly defined and exported in the import_map.ts file. Ensure that its namespace follows the expected naming convention and matches the structure used for other models like ChatOpenAI. If there are discrepancies, updating the export definitions to align with the correct structure should help resolve the issue.
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
Description
This appears to be an issue that chat_models__anthropic isn't exported at import_map.ts, unlike openai.
https://github.com/langchain-ai/langchainjs/blob/main/langchain/src/load/import_map.ts#L126
System Info
platform mac
node v18.19.0
npm 10.2.3
The text was updated successfully, but these errors were encountered: