Pandas agent: Pass forward callback manager (#3518)

The Pandas agent fails to pass callback_manager forward, making it
impossible to use custom callbacks with it. Fix that.

Co-authored-by: Sami Liedes <sami.liedes@rocket-science.ch>
This commit is contained in:
Sami Liedes 2023-04-25 19:58:56 +03:00 committed by GitHub
parent a08e9a3109
commit 61da2bb742
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,7 +42,12 @@ def create_pandas_dataframe_agent(
callback_manager=callback_manager,
)
tool_names = [tool.name for tool in tools]
agent = ZeroShotAgent(llm_chain=llm_chain, allowed_tools=tool_names, **kwargs)
agent = ZeroShotAgent(
llm_chain=llm_chain,
allowed_tools=tool_names,
callback_manager=callback_manager,
**kwargs,
)
return AgentExecutor.from_agent_and_tools(
agent=agent,
tools=tools,
@ -51,4 +56,5 @@ def create_pandas_dataframe_agent(
max_iterations=max_iterations,
max_execution_time=max_execution_time,
early_stopping_method=early_stopping_method,
callback_manager=callback_manager,
)