BaseRunManager#

class langchain_core.callbacks.manager.BaseRunManager(*, 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]#

Base class for run manager (a bound callback 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, *, run_id[, parent_run_id])

Run on a retry event.

on_text(text, *, run_id[, parent_run_id])

Run on an arbitrary text.

__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[source]#

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[source]#

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, *, run_id: UUID, parent_run_id: UUID | None = None, **kwargs: Any) Any#

Run on a retry event.

Parameters:
  • retry_state (RetryCallState) – The retry state.

  • run_id (UUID) – The run ID. This is the ID of the current run.

  • parent_run_id (UUID) – The parent run ID. This is the ID of the parent run.

  • kwargs (Any) – Additional keyword arguments.

Return type:

Any

on_text(text: str, *, run_id: UUID, parent_run_id: UUID | None = None, **kwargs: Any) Any#

Run on an arbitrary text.

Parameters:
  • text (str) – The text.

  • run_id (UUID) – The run ID. This is the ID of the current run.

  • parent_run_id (UUID) – The parent run ID. This is the ID of the parent run.

  • kwargs (Any) – Additional keyword arguments.

Return type:

Any