RunManager#

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

Sync Run Manager.

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. Defaults to None.

  • inheritable_tags (Optional[List[str]]) โ€“ The list of inheritable tags. Defaults to None.

  • metadata (Optional[Dict[str, Any]]) โ€“ The metadata. Defaults to None.

  • inheritable_metadata (Optional[Dict[str, Any]]) โ€“ The inheritable metadata. Defaults to None.

Methods

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

Initialize the run manager.

get_noop_manager()

Return a manager that doesn't perform any operations.

on_custom_event(name,ย data,ย *,ย run_id[,ย ...])

Override to define a handler for a custom event.

on_retry(retry_state,ย **kwargs)

Run when a retry is received.

on_text(text,ย **kwargs)

Run when a text is received.

__init__(*, run_id: UUID, handlers: List[BaseCallbackHandler], inheritable_handlers: List[BaseCallbackHandler], parent_run_id: UUID | None = None, tags: List[str] | None = None, inheritable_tags: List[str] | None = None, metadata: Dict[str, Any] | None = None, inheritable_metadata: Dict[str, Any] | None = 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. Defaults to None.

  • inheritable_tags (Optional[List[str]]) โ€“ The list of inheritable tags. Defaults to None.

  • metadata (Optional[Dict[str, Any]]) โ€“ The metadata. Defaults to None.

  • inheritable_metadata (Optional[Dict[str, Any]]) โ€“ The inheritable metadata. Defaults to None.

Return type:

None

classmethod get_noop_manager() BRM#

Return a manager that doesnโ€™t perform any operations.

Returns:

The noop manager.

Return type:

BaseRunManager

on_custom_event(name: str, data: Any, *, run_id: UUID, tags: List[str] | None = None, metadata: Dict[str, Any] | None = None, **kwargs: Any) Any#

Override to define a handler for a custom event.

Parameters:
  • name (str) โ€“ The name of the custom event.

  • data (Any) โ€“ The data for the custom event. Format will match the format specified by the user.

  • run_id (UUID) โ€“ The ID of the run.

  • tags (List[str] | None) โ€“ The tags associated with the custom event (includes inherited tags).

  • metadata (Dict[str, Any] | None) โ€“ The metadata associated with the custom event (includes inherited metadata).

  • kwargs (Any)

Return type:

Any

Added in version 0.2.15.

on_retry(retry_state: RetryCallState, **kwargs: Any) None[source]#

Run when a retry is received.

Parameters:
  • retry_state (RetryCallState) โ€“ The retry state.

  • **kwargs (Any) โ€“ Additional keyword arguments.

Return type:

None

on_text(text: str, **kwargs: Any) Any[source]#

Run when a text is received.

Parameters:
  • text (str) โ€“ The received text.

  • **kwargs (Any) โ€“ Additional keyword arguments.

Returns:

The result of the callback.

Return type:

Any