mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-14 00:47:27 +00:00
include the tool name for on_tool_end callback (#2000)
This is useful if you rely on the `on_tool_end` callback to detect which tool has finished in a multi agents scenario. For example, I'm working on a project where I consume the `on_tool_end` event where the event could be emitted by many agents or tools. Right now the only way to know which tool has finished would be set a marker on the `on_tool_start` and catch it on `on_tool_end`. I didn't want to break the signature of the function, but what would have been cleaner would be to pass the same details as in `on_tool_start` Co-authored-by: blob42 <spike@w530>
This commit is contained in:
parent
e0331b55bb
commit
33ebb05251
@ -70,7 +70,7 @@ class BaseTool(BaseModel):
|
|||||||
self.callback_manager.on_tool_error(e, verbose=verbose)
|
self.callback_manager.on_tool_error(e, verbose=verbose)
|
||||||
raise e
|
raise e
|
||||||
self.callback_manager.on_tool_end(
|
self.callback_manager.on_tool_end(
|
||||||
observation, verbose=verbose, color=color, **kwargs
|
observation, verbose=verbose, color=color, name=self.name, **kwargs
|
||||||
)
|
)
|
||||||
return observation
|
return observation
|
||||||
|
|
||||||
@ -112,10 +112,10 @@ class BaseTool(BaseModel):
|
|||||||
raise e
|
raise e
|
||||||
if self.callback_manager.is_async:
|
if self.callback_manager.is_async:
|
||||||
await self.callback_manager.on_tool_end(
|
await self.callback_manager.on_tool_end(
|
||||||
observation, verbose=verbose, color=color, **kwargs
|
observation, verbose=verbose, color=color, name=self.name, **kwargs
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.callback_manager.on_tool_end(
|
self.callback_manager.on_tool_end(
|
||||||
observation, verbose=verbose, color=color, **kwargs
|
observation, verbose=verbose, color=color, name=self.name, **kwargs
|
||||||
)
|
)
|
||||||
return observation
|
return observation
|
||||||
|
Loading…
Reference in New Issue
Block a user