Core[Patch] Parse tool input after on_start (#16430)

For tracing, if a validation error occurs, currently it is attributed to
the previous step of the chain. It would be nice to have the on_start
and on_error callbacks called for tools when there is a validation error
that occurs to more easily attribute the root-cause
This commit is contained in:
William FH 2024-01-23 07:54:47 -08:00 committed by GitHub
parent 226fe645f1
commit 5de59f9236
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -312,7 +312,6 @@ class ChildTool(BaseTool):
**kwargs: Any,
) -> Any:
"""Run the tool."""
parsed_input = self._parse_input(tool_input)
if not self.verbose and verbose is not None:
verbose_ = verbose
else:
@ -341,6 +340,7 @@ class ChildTool(BaseTool):
**kwargs,
)
try:
parsed_input = self._parse_input(tool_input)
tool_args, tool_kwargs = self._to_args_and_kwargs(parsed_input)
observation = (
self._run(*tool_args, run_manager=run_manager, **tool_kwargs)
@ -392,7 +392,6 @@ class ChildTool(BaseTool):
**kwargs: Any,
) -> Any:
"""Run the tool asynchronously."""
parsed_input = self._parse_input(tool_input)
if not self.verbose and verbose is not None:
verbose_ = verbose
else:
@ -416,6 +415,7 @@ class ChildTool(BaseTool):
**kwargs,
)
try:
parsed_input = self._parse_input(tool_input)
# We then call the tool on the tool input to get an observation
tool_args, tool_kwargs = self._to_args_and_kwargs(parsed_input)
observation = (