Replies: 3 comments 5 replies
-
Hey @jakowenko! I'm a bot designed to help you with bugs, questions, and contributions. I'm here to assist you while you wait for a human maintainer. To overcome the issue of Bedrock not supporting the Here is the relevant part of the code that checks for the if (llm.bindTools === undefined) {
throw new Error(
`This agent requires that the "bind_tools()" method be implemented on the input model.`
);
} To resolve this, you can either:
Here is an example of how you might implement a wrapper around a model to add the class MyModelWithTools extends BaseChatModel {
constructor(model) {
super();
this.model = model;
}
bindTools(tools) {
// Implement the logic to bind tools to your model
this.tools = tools;
return this;
}
// Implement other necessary methods from BaseChatModel
}
// Usage
const myModel = new MyModelWithTools(existingModel);
const agent = createToolCallingAgent({ llm: myModel, tools, prompt }); By ensuring that your model has the |
Beta Was this translation helpful? Give feedback.
-
I've been playing with this locally and managed to bend the BedrockChat class and utils to do this - use the new tools API with Claude 3 (claude-3-sonnet-20240229). I also managed to make it work properly only for non-streamed messages; somehow it's not de-serializing tool argument json well with streamed mode. @jakowenko FYI the changes needed are happening in the message formatting and parsing logic, where this behavior for tool call is completely missing, e.g. here: As you can see, no "tools" array is being passed here to the model, so the fact that model doesn't implement "bind_tools" it at the very top of this, but even with it, it wouldn't send the tools to the API. If anyone finds this idea useful and willing to help, pls let me know, happy to make the PR today (after some polish). |
Beta Was this translation helpful? Give feedback.
-
Hey team, I'm reading through this issue, but I have similar request, can I have sagemaker chat model which can support function/tool calling? The SageMakerEndpoint llm from the langchain does not support the bind_tools and tool calling as far as I tested. |
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
I'm trying to use the langchain library to create an agent using Bedrock and it seems like Bedrock doesn't support the bind_tools function and I was looking to see if there is a way to overcome this. I did find this langchain-aws pull request that seemed to support it when using an Anthropic model.
I'm able to invoke the retriever directly, but when I try to use this as a tool within the agent I get the following error.
Error: This agent requires that the "bind_tools()" method be implemented on the input model.
System Info
[email protected]
@langchain/[email protected]
@langchain/[email protected]
OS: macOS 14.5
npm version: 10.5.0
node version: 20.12.2
Beta Was this translation helpful? Give feedback.
All reactions