auto infer toolexception type

This commit is contained in:
isaac hershenson
2024-09-11 09:56:31 -07:00
parent ecd5a4b460
commit 5329b43bc1

View File

@@ -572,7 +572,6 @@ class ChildTool(BaseTool):
content = _handle_validation_error(e, flag=self.handle_validation_error) content = _handle_validation_error(e, flag=self.handle_validation_error)
status = "error" status = "error"
except Exception as e: except Exception as e:
e = ToolException(e)
if not self.handle_tool_error: if not self.handle_tool_error:
error_to_raise = e error_to_raise = e
else: else:
@@ -689,7 +688,6 @@ class ChildTool(BaseTool):
content = _handle_validation_error(e, flag=self.handle_validation_error) content = _handle_validation_error(e, flag=self.handle_validation_error)
status = "error" status = "error"
except Exception as e: except Exception as e:
e = ToolException(e)
if not self.handle_tool_error: if not self.handle_tool_error:
error_to_raise = e error_to_raise = e
else: else:
@@ -742,6 +740,7 @@ def _handle_tool_error(
flag: Optional[Union[Literal[True], str, Callable[[ToolException], str]]], flag: Optional[Union[Literal[True], str, Callable[[ToolException], str]]],
) -> str: ) -> str:
if isinstance(flag, bool): if isinstance(flag, bool):
print(e.args)
if e.args: if e.args:
content = e.args[0] content = e.args[0]
else: else: