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,