Closed eemirtekin closed 1 week ago
Hi @eemirtekin! I'm here to help you with any bugs, questions, or contribution-related inquiries. Let me know how I can assist you!
To resolve the error "Error building Component CSVAgent: langchain.agents.agent.AgentExecutor() got multiple values for keyword argument 'max_iterations'", you need to ensure that the max_iterations
argument is not being passed multiple times. This can happen if max_iterations
is included both in the create_csv_agent
function call and in the self.get_agent_kwargs()
method.
Here's the corrected code snippet:
from langchain_experimental.agents.agent_toolkits.csv.base import create_csv_agent
from langflow.base.agents.agent import LCAgentComponent
from langflow.field_typing import AgentExecutor
from langflow.inputs import HandleInput, FileInput, DropdownInput
class CSVAgentComponent(LCAgentComponent):
display_name = "CSVAgent"
description = "Construct a CSV agent from a CSV and tools."
documentation = "https://python.langchain.com/docs/modules/agents/toolkits/csv"
name = "CSVAgent"
inputs = LCAgentComponent._base_inputs + [
HandleInput(name="llm", display_name="Language Model", input_types=["LanguageModel"], required=True),
FileInput(name="path", display_name="File Path", file_types=["csv"], required=True),
DropdownInput(
name="agent_type",
display_name="Agent Type",
advanced=True,
options=["zero-shot-react-description", "openai-functions", "openai-tools"],
value="openai-tools",
),
]
def build_agent(self) -> AgentExecutor:
agent_kwargs = self.get_agent_kwargs()
# Remove max_iterations if it exists in agent_kwargs to avoid conflict
agent_kwargs.pop('max_iterations', None)
return create_csv_agent(llm=self.llm, path=self.path, agent_type=self.agent_type, **agent_kwargs)
This ensures that max_iterations
is properly managed and not passed multiple times, thus resolving the error [1][2].
To continue talking to Dosu, mention @dosu.
@dosu It doesn't work.
@eemirtekin
Please try to use this component: CSV Agent.json
Please let me know if it works for you.
Thank you for your contribution! This issue will be closed. If you have any questions or encounter another problem, please open a new issue and we will be ready to assist you.
Bug Description
I am getting the error below.
Error Building Component Error building Component CSVAgent: langchain.agents.agent.AgentExecutor() got multiple values for keyword argument 'max_iterations'
Reproduction
Expected behavior
I want to have a conversation with the CSV file.
Who can help?
No response
Operating System
Ubuntu 22.04.4 LTS
Langflow Version
1.0.17
Python Version
3.10
Screenshot
Flow File
No response