langchain_core.callbacks.manager.AsyncCallbackManagerForToolRun¶

class langchain_core.callbacks.manager.AsyncCallbackManagerForToolRun(*, run_id: UUID, handlers: List[BaseCallbackHandler], inheritable_handlers: List[BaseCallbackHandler], parent_run_id: Optional[UUID] = None, tags: Optional[List[str]] = None, inheritable_tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, inheritable_metadata: Optional[Dict[str, Any]] = None)[source]¶

Async callback manager for tool run.

Initialize the run manager.

Parameters
  • run_id (UUID) – The ID of the run.

  • handlers (List[BaseCallbackHandler]) – The list of handlers.

  • inheritable_handlers (List[BaseCallbackHandler]) – The list of inheritable handlers.

  • parent_run_id (UUID, optional) – The ID of the parent run. Defaults to None.

  • tags (Optional[List[str]]) – The list of tags.

  • inheritable_tags (Optional[List[str]]) – The list of inheritable tags.

  • metadata (Optional[Dict[str, Any]]) – The metadata.

  • inheritable_metadata (Optional[Dict[str, Any]]) – The inheritable metadata.

Methods

__init__(*, run_id, handlers, ...[, ...])

Initialize the run manager.

get_child([tag])

Get a child callback manager.

get_noop_manager()

Return a manager that doesn't perform any operations.

get_sync()

Get the equivalent sync RunManager.

on_retry(retry_state, **kwargs)

Run on a retry event.

on_text(text, **kwargs)

Run when text is received.

on_tool_end(output, **kwargs)

Run when tool ends running.

on_tool_error(error, **kwargs)

Run when tool errors.

__init__(*, run_id: UUID, handlers: List[BaseCallbackHandler], inheritable_handlers: List[BaseCallbackHandler], parent_run_id: Optional[UUID] = None, tags: Optional[List[str]] = None, inheritable_tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, inheritable_metadata: Optional[Dict[str, Any]] = None) None¶

Initialize the run manager.

Parameters
  • run_id (UUID) – The ID of the run.

  • handlers (List[BaseCallbackHandler]) – The list of handlers.

  • inheritable_handlers (List[BaseCallbackHandler]) – The list of inheritable handlers.

  • parent_run_id (UUID, optional) – The ID of the parent run. Defaults to None.

  • tags (Optional[List[str]]) – The list of tags.

  • inheritable_tags (Optional[List[str]]) – The list of inheritable tags.

  • metadata (Optional[Dict[str, Any]]) – The metadata.

  • inheritable_metadata (Optional[Dict[str, Any]]) – The inheritable metadata.

Return type

None

get_child(tag: Optional[str] = None) AsyncCallbackManager¶

Get a child callback manager.

Parameters

tag (str, optional) – The tag for the child callback manager. Defaults to None.

Returns

The child callback manager.

Return type

AsyncCallbackManager

classmethod get_noop_manager() BRM¶

Return a manager that doesn’t perform any operations.

Returns

The noop manager.

Return type

BaseRunManager

get_sync() CallbackManagerForToolRun[source]¶

Get the equivalent sync RunManager.

Returns

The sync RunManager.

Return type

CallbackManagerForToolRun

async on_retry(retry_state: RetryCallState, **kwargs: Any) None¶

Run on a retry event.

Parameters
  • retry_state (RetryCallState) –

  • kwargs (Any) –

Return type

None

async on_text(text: str, **kwargs: Any) Any¶

Run when text is received.

Parameters
  • text (str) – The received text.

  • kwargs (Any) –

Returns

The result of the callback.

Return type

Any

async on_tool_end(output: Any, **kwargs: Any) None[source]¶

Run when tool ends running.

Parameters
  • output (Any) – The output of the tool.

  • kwargs (Any) –

Return type

None

async on_tool_error(error: BaseException, **kwargs: Any) None[source]¶

Run when tool errors.

Parameters
  • error (Exception or KeyboardInterrupt) – The error.

  • kwargs (Any) –

Return type

None

Examples using AsyncCallbackManagerForToolRun¶