CallbackManagerMixin#

class langchain_core.callbacks.base.CallbackManagerMixin[source]#

Mixin for callback manager.

Methods

on_chain_start(serialized, inputs, *, run_id)

Run when a chain starts running.

on_chat_model_start(serialized, messages, *, ...)

Run when a chat model starts running.

on_llm_start(serialized, prompts, *, run_id)

Run when LLM starts running.

on_retriever_start(serialized, query, *, run_id)

Run when the Retriever starts running.

on_tool_start(serialized, input_str, *, run_id)

Run when the tool starts running.

on_chain_start(
serialized: dict[str, Any],
inputs: dict[str, Any],
*,
run_id: UUID,
parent_run_id: UUID | None = None,
tags: list[str] | None = None,
metadata: dict[str, Any] | None = None,
**kwargs: Any,
) Any[source]#

Run when a chain starts running.

Parameters:
  • serialized (dict[str, Any]) – The serialized chain.

  • inputs (dict[str, Any]) – The inputs.

  • 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.

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

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

  • kwargs (Any) – Additional keyword arguments.

Return type:

Any

on_chat_model_start(
serialized: dict[str, Any],
messages: list[list[BaseMessage]],
*,
run_id: UUID,
parent_run_id: UUID | None = None,
tags: list[str] | None = None,
metadata: dict[str, Any] | None = None,
**kwargs: Any,
) Any[source]#

Run when a chat model starts running.

ATTENTION: This method is called for chat models. If you’re implementing

a handler for a non-chat model, you should use on_llm_start instead.

Parameters:
  • serialized (dict[str, Any]) – The serialized chat model.

  • messages (list[list[BaseMessage]]) – The messages.

  • 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.

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

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

  • kwargs (Any) – Additional keyword arguments.

Return type:

Any

on_llm_start(
serialized: dict[str, Any],
prompts: list[str],
*,
run_id: UUID,
parent_run_id: UUID | None = None,
tags: list[str] | None = None,
metadata: dict[str, Any] | None = None,
**kwargs: Any,
) Any[source]#

Run when LLM starts running.

ATTENTION: This method is called for non-chat models (regular LLMs). If

you’re implementing a handler for a chat model, you should use on_chat_model_start instead.

Parameters:
  • serialized (dict[str, Any]) – The serialized LLM.

  • prompts (list[str]) – The prompts.

  • 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.

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

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

  • kwargs (Any) – Additional keyword arguments.

Return type:

Any

on_retriever_start(
serialized: dict[str, Any],
query: str,
*,
run_id: UUID,
parent_run_id: UUID | None = None,
tags: list[str] | None = None,
metadata: dict[str, Any] | None = None,
**kwargs: Any,
) Any[source]#

Run when the Retriever starts running.

Parameters:
  • serialized (dict[str, Any]) – The serialized Retriever.

  • query (str) – The query.

  • 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.

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

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

  • kwargs (Any) – Additional keyword arguments.

Return type:

Any

on_tool_start(
serialized: dict[str, Any],
input_str: str,
*,
run_id: UUID,
parent_run_id: UUID | None = None,
tags: list[str] | None = None,
metadata: dict[str, Any] | None = None,
inputs: dict[str, Any] | None = None,
**kwargs: Any,
) Any[source]#

Run when the tool starts running.

Parameters:
  • serialized (dict[str, Any]) – The serialized tool.

  • input_str (str) – The input string.

  • 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.

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

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

  • inputs (Optional[dict[str, Any]]) – The inputs.

  • kwargs (Any) – Additional keyword arguments.

Return type:

Any