Closed jarib closed 7 months ago
Based on the error message you're receiving, it seems that the model identifier you're using, "claude-3-sonnet-20240229", is not supported by the API you're trying to use. This is likely the root cause of the issue you're experiencing.
The BedrockChat
class in LangChain.js is designed to interact with specific language models. When you instantiate a new BedrockChat
object, you need to provide a model identifier that is supported by the API. In your case, the model identifier "claude-3-sonnet-20240229" seems to be unsupported, hence the error.
To resolve this issue, you should replace the unsupported model identifier with a supported one. Unfortunately, without the exact list of supported model identifiers, I cannot provide a direct code modification to resolve this issue. You might need to check the official documentation or contact support for LangChain.js or the Bedrock model to find the correct model identifier for Claude 3.
Here's a general example of how you might modify your code once you have the correct model identifier:
import { BedrockChat } from '@langchain/community/chat_models/bedrock'
async function main() {
try {
const model = new BedrockChat({
model: 'supported.model.identifier' // Replace with the correct model identifier
});
const result = await model.invoke('Tell me a story');
console.log(result);
} catch (error) {
console.error(error);
process.exit(1);
}
}
main()
Regarding the two Python issues you mentioned, it's possible that they are related to the issue you're experiencing. However, without more information, it's hard to say for sure. If the issues are indeed related, the solutions proposed in those issues might also apply to your case. However, since the issues are in Python and you're working with JavaScript, the solutions might not be directly applicable.
I hope this helps! If you have any more questions or need further clarification, feel free to ask.
Will patch this tonight! Thanks for flagging.
Hey so this is actually going to take me a bit longer as I don't have access to the model on Bedrock :(
Will aim to get it as soon as I can and then work on this.
It's definitely already available:
$ aws bedrock list-foundation-models --region 'us-east-1' | jq '.modelSummaries[].modelId' | grep claude-3-sonnet
"anthropic.claude-3-sonnet-20240229-v1:0"
But yes, you need to apply for access.
Finished a PR, will merge and ship shortly!
Really appreciate the turnaround on this!!!
@jacoblee93 Does your PR also fix this for using claude 3 with the Bedrock client (not the BedrockChat)? import { Bedrock } from 'langchain/llms/bedrock'
Claude-3 is messages only :( you'll need to use the chat model. It should be pretty interchangeable though?
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
Description
These two issues from Python also apply to the JS version:
https://github.com/langchain-ai/langchain/issues/18513 https://github.com/langchain-ai/langchain/issues/18514
System Info
Platform: Mac Node: v20.11.0 Yarn version: 1.22.19