From fd0d631f3965e72eab92b4d808565bd5f87e06f7 Mon Sep 17 00:00:00 2001 From: MohammedAlhajji <91945586+MohammedAlhajji@users.noreply.github.com> Date: Tue, 4 Apr 2023 00:26:03 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20missing=20kwargs=20in=20f?= =?UTF-8?q?rom=5Fagent=5Fand=5Ftools=20in=20dataframe=20agent=20(#2285)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hello! I've noticed a bug in `create_pandas_dataframe_agent`. When calling it with argument `return_intermediate_steps=True`, it doesn't return the intermediate step. I think the issue is that `kwargs` was not passed where it needed to be passed. It should be passed into `AgentExecutor.from_agent_and_tools` Please correct me if my solution isn't appropriate and I will fix with the appropriate approach. Co-authored-by: alhajji --- langchain/agents/agent_toolkits/pandas/base.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/langchain/agents/agent_toolkits/pandas/base.py b/langchain/agents/agent_toolkits/pandas/base.py index 43bdf90519..40d0c329ea 100644 --- a/langchain/agents/agent_toolkits/pandas/base.py +++ b/langchain/agents/agent_toolkits/pandas/base.py @@ -18,6 +18,9 @@ def create_pandas_dataframe_agent( suffix: str = SUFFIX, input_variables: Optional[List[str]] = None, verbose: bool = False, + return_intermediate_steps: bool = False, + max_iterations: Optional[int] = 15, + early_stopping_method: str = "force", **kwargs: Any, ) -> AgentExecutor: """Construct a pandas agent from an LLM and dataframe.""" @@ -39,4 +42,11 @@ def create_pandas_dataframe_agent( ) tool_names = [tool.name for tool in tools] agent = ZeroShotAgent(llm_chain=llm_chain, allowed_tools=tool_names, **kwargs) - return AgentExecutor.from_agent_and_tools(agent=agent, tools=tools, verbose=verbose) + return AgentExecutor.from_agent_and_tools( + agent=agent, + tools=tools, + verbose=verbose, + return_intermediate_steps=return_intermediate_steps, + max_iterations=max_iterations, + early_stopping_method=early_stopping_method, + )