Skip to content
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

Failed to pull hub prompt with anthropic model #7328

Open
5 tasks done
yowpark opened this issue Dec 6, 2024 · 2 comments
Open
5 tasks done

Failed to pull hub prompt with anthropic model #7328

yowpark opened this issue Dec 6, 2024 · 2 comments
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@yowpark
Copy link

yowpark commented Dec 6, 2024

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

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) {

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

image

System Info

platform mac
node v18.19.0
npm 10.2.3

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label Dec 6, 2024
Copy link

dosubot bot commented Dec 6, 2024

Hey @yowpark! I'm here to assist you with any bugs, questions, or contributions. Let's work on solving this issue together.

I found a similar unsolved discussion titled "How can I use Claude 3 models with ChatAnthropic?" which might be related to your issue [1].

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.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@jacoblee93
Copy link
Collaborator

Thanks for reporting - will dig in and patch, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants