From 68a0b7d6c69fa163adb371ace7f4bbb8a157b0a6 Mon Sep 17 00:00:00 2001 From: Phil Miesle Date: Fri, 22 Nov 2024 17:51:39 +0000 Subject: [PATCH] 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 --- .../base/langflow/components/langchain_utilities/csv.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/backend/base/langflow/components/langchain_utilities/csv.py b/src/backend/base/langflow/components/langchain_utilities/csv.py index 8fcb49278438..0bd4b7e6df0e 100644 --- a/src/backend/base/langflow/components/langchain_utilities/csv.py +++ b/src/backend/base/langflow/components/langchain_utilities/csv.py @@ -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 @@ def build_agent_response(self) -> Message: 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 @@ def build_agent(self) -> AgentExecutor: 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,