fix: handle Message in path input in CSVAgentComponent (#4784)

* fixing problem handling path type

* Add type check for 'path.text' in CSV utility function

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
This commit is contained in:
Phil Miesle 2024-11-22 17:51:39 +00:00 committed by GitHub
commit 68a0b7d6c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -51,6 +51,11 @@ class CSVAgentComponent(LCAgentComponent):
Output(display_name="Agent", name="agent", method="build_agent"),
]
def _path(self) -> str:
if isinstance(self.path, Message) and isinstance(self.path.text, str):
return self.path.text
return self.path
def build_agent_response(self) -> Message:
agent_kwargs = {
"verbose": self.verbose,
@ -59,7 +64,7 @@ class CSVAgentComponent(LCAgentComponent):
agent_csv = create_csv_agent(
llm=self.llm,
path=self.path,
path=self._path(),
agent_type=self.agent_type,
handle_parsing_errors=self.handle_parsing_errors,
**agent_kwargs,
@ -76,7 +81,7 @@ class CSVAgentComponent(LCAgentComponent):
agent_csv = create_csv_agent(
llm=self.llm,
path=self.path,
path=self._path(),
agent_type=self.agent_type,
handle_parsing_errors=self.handle_parsing_errors,
**agent_kwargs,