.with_structured_output throwing error with create_react_agent #24904
Replies: 1 comment 7 replies
-
Hey @Sachin-Deloitte! I'm a bot here to help you with bug fixes, answer your questions, and guide you on becoming a contributor. Let's get that bug squashed! 🤖 The error To resolve this, ensure that the model you pass to from langgraph.prebuilt import create_react_agent
from langchain_core.pydantic_v1 import BaseModel, Field
from langchain_openai import ChatOpenAI
from langchain_community.agent_toolkits.sql.toolkit import SQLDatabaseToolkit
class OutputFormat(BaseModel):
AImessage: str = Field(description="Detailed answer of the user question")
FinalSqlQuery: str = Field(description="Final SQL query which was executed")
TableNames: str = Field(description="Name of all the tables accessed during to reach the final SQL query")
# Initialize the language model
llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0)
# Use the `with_structured_output` method
struct_llm = llm.with_structured_output(OutputFormat)
# Initialize the SQLDatabaseToolkit
toolkit = SQLDatabaseToolkit(db=db, llm=llm)
# Get the tools from the toolkit
tools = toolkit.get_tools()
# Create the agent
agent_executor = create_react_agent(struct_llm, tools, state_modifier=system_message) In this example, |
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
I am trying to format the response of LLM using .with_structured_output however getting the below error:
in create_react_agent
model = model.bind_tools(tool_classes)
AttributeError: 'RunnableSequence' object has no attribute 'bind_tools'
System Info
System Information
Package Information
Beta Was this translation helpful? Give feedback.
All reactions