Skip to content

Commit

Permalink
fix: catch exceptions when executing tools
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Oct 10, 2024
1 parent 771734c commit 9560660
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gptme/tools/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ def execute(self, ask: bool) -> Generator[Message, None, None]:

tool = get_tool(self.tool)
if tool and tool.execute:
yield from tool.execute(self.content, ask, self.args)
try:
yield from tool.execute(self.content, ask, self.args)
except Exception as e:
yield Message("system", f"Error executing tool '{self.tool}': {e}")
else:
logger.warning(f"Tool '{self.tool}' is not available for execution.")

Expand Down

0 comments on commit 9560660

Please sign in to comment.