mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-08 04:25:46 +00:00
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:
parent
226fe645f1
commit
5de59f9236
@ -312,7 +312,6 @@ class ChildTool(BaseTool):
|
|||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> Any:
|
) -> Any:
|
||||||
"""Run the tool."""
|
"""Run the tool."""
|
||||||
parsed_input = self._parse_input(tool_input)
|
|
||||||
if not self.verbose and verbose is not None:
|
if not self.verbose and verbose is not None:
|
||||||
verbose_ = verbose
|
verbose_ = verbose
|
||||||
else:
|
else:
|
||||||
@ -341,6 +340,7 @@ class ChildTool(BaseTool):
|
|||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
|
parsed_input = self._parse_input(tool_input)
|
||||||
tool_args, tool_kwargs = self._to_args_and_kwargs(parsed_input)
|
tool_args, tool_kwargs = self._to_args_and_kwargs(parsed_input)
|
||||||
observation = (
|
observation = (
|
||||||
self._run(*tool_args, run_manager=run_manager, **tool_kwargs)
|
self._run(*tool_args, run_manager=run_manager, **tool_kwargs)
|
||||||
@ -392,7 +392,6 @@ class ChildTool(BaseTool):
|
|||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> Any:
|
) -> Any:
|
||||||
"""Run the tool asynchronously."""
|
"""Run the tool asynchronously."""
|
||||||
parsed_input = self._parse_input(tool_input)
|
|
||||||
if not self.verbose and verbose is not None:
|
if not self.verbose and verbose is not None:
|
||||||
verbose_ = verbose
|
verbose_ = verbose
|
||||||
else:
|
else:
|
||||||
@ -416,6 +415,7 @@ class ChildTool(BaseTool):
|
|||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
|
parsed_input = self._parse_input(tool_input)
|
||||||
# We then call the tool on the tool input to get an observation
|
# We then call the tool on the tool input to get an observation
|
||||||
tool_args, tool_kwargs = self._to_args_and_kwargs(parsed_input)
|
tool_args, tool_kwargs = self._to_args_and_kwargs(parsed_input)
|
||||||
observation = (
|
observation = (
|
||||||
|
Loading…
Reference in New Issue
Block a user