CallbackManagerForRetrieverRun#
- class langchain_core.callbacks.manager.CallbackManagerForRetrieverRun(
- *,
- 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,
Callback manager for retriever 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. 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_child
([tag])Get a child callback 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_retriever_end
(documents, **kwargs)Run when retriever ends running.
on_retriever_error
(error, **kwargs)Run when retriever errors.
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,
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
- get_child(
- tag: str | None = None,
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:
- classmethod get_noop_manager() Self #
Return a manager that doesnβt perform any operations.
- Returns:
The noop manager.
- Return type:
- on_custom_event(
- name: str,
- data: Any,
- *,
- run_id: UUID,
- tags: list[str] | None = None,
- metadata: dict[str, Any] | None = None,
- **kwargs: 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 (Optional[list[str]]) β The tags associated with the custom event (includes inherited tags).
metadata (Optional[dict[str, Any]]) β The metadata associated with the custom event (includes inherited metadata).
kwargs (Any)
- Return type:
Any
Added in version 0.2.15.
- on_retriever_end(
- documents: Sequence[Document],
- **kwargs: Any,
Run when retriever ends running.
- Parameters:
documents (Sequence[Document]) β The retrieved documents.
**kwargs (Any) β Additional keyword arguments.
- Return type:
None
- on_retriever_error(
- error: BaseException,
- **kwargs: Any,
Run when retriever errors.
- Parameters:
error (BaseException) β The error.
**kwargs (Any) β Additional keyword arguments.
- Return type:
None
- on_retry(
- retry_state: RetryCallState,
- **kwargs: Any,
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,
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
Examples using CallbackManagerForRetrieverRun