Replies: 2 comments
-
The issue you're facing stems from the To resolve this, you'll need to ensure that the LLM you pass to from langchain_openai import ChatOpenAI
class CustomChatOpenAI(ChatOpenAI):
def bind_tools(self, tools):
# Custom logic to bind tools
self.tools = tools
# Ensure other necessary setups are also handled Use this custom class instead of the direct Remember, the key is to maintain the
|
Beta Was this translation helpful? Give feedback.
-
Same issue here |
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
Hi! I'm trying to use Langchain to create a negotiation agent that can call tools, and then output a final json of the negotiation decision.
I'm using
create_tool_calling_agent
, and I want the output to be structured like theOutput
object, and so I bind the llm usingwith_structured_output
.I get the following error:
ValueError: This function requires a .bind_tools method be implemented on the LLM.
The code works if I just use
.with_structured_output
but not thetool_calling_agent
, and it also works if I just usetool_calling_agent
but not.with_structured_output
. I can't get both to work.Please let me know how I can make this possible, or if there's another way to make this usage work!
In this thread #20343 (reply in thread), @baskaryan seems to say you shouldn't need to call both tools and structured output, but I don't know how to otherwise get the json output I want and also let the agent call tools.
System Info
System Information
Package Information
Beta Was this translation helpful? Give feedback.
All reactions