AsyncCallbackManagerForChainRun#
- class langchain_core.callbacks.manager.AsyncCallbackManagerForChainRun(*, 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]#
Async callback manager for chain 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.
get_sync
()Get the equivalent sync RunManager.
on_agent_action
(action,Β **kwargs)Run when agent action is received.
on_agent_finish
(finish,Β **kwargs)Run when agent finish is received.
on_chain_end
(outputs,Β **kwargs)Run when a chain ends running.
on_chain_error
(error,Β **kwargs)Run when chain errors.
on_custom_event
(name,Β data,Β *,Β run_id[,Β ...])Override to define a handler for a custom event.
on_retry
(retry_state,Β **kwargs)Async 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
- get_child(tag: str | None = 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:
- classmethod get_noop_manager() BRM #
Return a manager that doesnβt perform any operations.
- Returns:
The noop manager.
- Return type:
- get_sync() CallbackManagerForChainRun [source]#
Get the equivalent sync RunManager.
- Returns:
The sync RunManager.
- Return type:
- async on_agent_action(action: AgentAction, **kwargs: Any) Any [source]#
Run when agent action is received.
- Parameters:
action (AgentAction) β The agent action.
**kwargs (Any) β Additional keyword arguments.
- Returns:
The result of the callback.
- Return type:
Any
- async on_agent_finish(finish: AgentFinish, **kwargs: Any) Any [source]#
Run when agent finish is received.
- Parameters:
finish (AgentFinish) β The agent finish.
**kwargs (Any) β Additional keyword arguments.
- Returns:
The result of the callback.
- Return type:
Any
- async on_chain_end(outputs: Dict[str, Any] | Any, **kwargs: Any) None [source]#
Run when a chain ends running.
- Parameters:
outputs (Union[Dict[str, Any], Any]) β The outputs of the chain.
**kwargs (Any) β Additional keyword arguments.
- Return type:
None
- async on_chain_error(error: BaseException, **kwargs: Any) None [source]#
Run when chain errors.
- Parameters:
error (Exception or KeyboardInterrupt) β The error.
**kwargs (Any) β Additional keyword arguments.
- Return type:
None
- 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
New in version 0.2.15.
- async on_retry(retry_state: RetryCallState, **kwargs: Any) None #
Async run when a retry is received.
- Parameters:
retry_state (RetryCallState) β The retry state.
**kwargs (Any) β Additional keyword arguments.
- Return type:
None
- async on_text(text: str, **kwargs: Any) 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