feat: Add Pandas kwargs support for CSV Agent (#5372)

* ✨ (csv.py): Add support for passing Pandas kwargs to the CSV agent for more customization and flexibility.

* 📝 (csv.py): mark 'is_list' attribute as True for the 'Pandas Kwargs' parameter to indicate it can accept a list of values
This commit is contained in:
Cristhian Zanforlin Lousa 2024-12-19 16:17:26 -03:00 • committed by GitHub
commit b07bd173b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,7 +3,7 @@ from langchain_experimental.agents.agent_toolkits.csv.base import create_csv_age
from langflow.base.agents.agent import LCAgentComponent from langflow.base.agents.agent import LCAgentComponent
from langflow.field_typing import AgentExecutor from langflow.field_typing import AgentExecutor
from langflow.inputs import DropdownInput, FileInput, HandleInput from langflow.inputs import DropdownInput, FileInput, HandleInput
from langflow.inputs.inputs import MessageTextInput from langflow.inputs.inputs import DictInput, MessageTextInput
from langflow.schema.message import Message from langflow.schema.message import Message
from langflow.template.field.base import Output from langflow.template.field.base import Output
@ -44,6 +44,13 @@ class CSVAgentComponent(LCAgentComponent):
display_name="Text", display_name="Text",
info="Text to be passed as input and extract info from the CSV File.", info="Text to be passed as input and extract info from the CSV File.",
), ),
DictInput(
name="pandas_kwargs",
display_name="Pandas Kwargs",
info="Pandas Kwargs to be passed to the agent.",
advanced=True,
is_list=True,
),
] ]
outputs = [ outputs = [
@ -67,6 +74,7 @@ class CSVAgentComponent(LCAgentComponent):
path=self._path(), path=self._path(),
agent_type=self.agent_type, agent_type=self.agent_type,
handle_parsing_errors=self.handle_parsing_errors, handle_parsing_errors=self.handle_parsing_errors,
pandas_kwargs=self.pandas_kwargs,
**agent_kwargs, **agent_kwargs,
) )
@ -84,6 +92,7 @@ class CSVAgentComponent(LCAgentComponent):
path=self._path(), path=self._path(),
agent_type=self.agent_type, agent_type=self.agent_type,
handle_parsing_errors=self.handle_parsing_errors, handle_parsing_errors=self.handle_parsing_errors,
pandas_kwargs=self.pandas_kwargs,
**agent_kwargs, **agent_kwargs,
) )