Skip to content

Commit

Permalink
fix: handle Message in path input in CSVAgentComponent (#4784)
Browse files Browse the repository at this point in the history
* fixing problem handling path type

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

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>
  • Loading branch information
mieslep and ogabrielluiz authored Nov 22, 2024
1 parent 4ee53f2 commit 68a0b7d
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 68a0b7d

Please sign in to comment.