langchain_core.callbacks.base.BaseCallbackManager

class langchain_core.callbacks.base.BaseCallbackManager(handlers: List[BaseCallbackHandler], inheritable_handlers: Optional[List[BaseCallbackHandler]] = None, parent_run_id: Optional[UUID] = None, *, tags: Optional[List[str]] = None, inheritable_tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, inheritable_metadata: Optional[Dict[str, Any]] = None)[source]

Base callback manager that handles callbacks from LangChain.

Initialize callback manager.

Attributes

is_async

Whether the callback manager is async.

Methods

__init__(handlers[, inheritable_handlers, ...])

Initialize callback manager.

add_handler(handler[, inherit])

Add a handler to the callback manager.

add_metadata(metadata[, inherit])

add_tags(tags[, inherit])

copy()

Copy the callback manager.

on_chain_start(serialized, inputs, *, run_id)

Run when 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 Retriever starts running.

on_tool_start(serialized, input_str, *, run_id)

Run when tool starts running.

remove_handler(handler)

Remove a handler from the callback manager.

remove_metadata(keys)

remove_tags(tags)

set_handler(handler[, inherit])

Set handler as the only handler on the callback manager.

set_handlers(handlers[, inherit])

Set handlers as the only handlers on the callback manager.

__init__(handlers: List[BaseCallbackHandler], inheritable_handlers: Optional[List[BaseCallbackHandler]] = None, parent_run_id: Optional[UUID] = None, *, tags: Optional[List[str]] = None, inheritable_tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, inheritable_metadata: Optional[Dict[str, Any]] = None) None[source]

Initialize callback manager.

add_handler(handler: BaseCallbackHandler, inherit: bool = True) None[source]

Add a handler to the callback manager.

add_metadata(metadata: Dict[str, Any], inherit: bool = True) None[source]
add_tags(tags: List[str], inherit: bool = True) None[source]
copy() T[source]

Copy the callback manager.

on_chain_start(serialized: Dict[str, Any], inputs: Dict[str, Any], *, run_id: UUID, parent_run_id: Optional[UUID] = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) Any

Run when chain starts running.

on_chat_model_start(serialized: Dict[str, Any], messages: List[List[BaseMessage]], *, run_id: UUID, parent_run_id: Optional[UUID] = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) Any

Run when a chat model starts running.

on_llm_start(serialized: Dict[str, Any], prompts: List[str], *, run_id: UUID, parent_run_id: Optional[UUID] = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) Any

Run when LLM starts running.

on_retriever_start(serialized: Dict[str, Any], query: str, *, run_id: UUID, parent_run_id: Optional[UUID] = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) Any

Run when Retriever starts running.

on_tool_start(serialized: Dict[str, Any], input_str: str, *, run_id: UUID, parent_run_id: Optional[UUID] = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) Any

Run when tool starts running.

remove_handler(handler: BaseCallbackHandler) None[source]

Remove a handler from the callback manager.

remove_metadata(keys: List[str]) None[source]
remove_tags(tags: List[str]) None[source]
set_handler(handler: BaseCallbackHandler, inherit: bool = True) None[source]

Set handler as the only handler on the callback manager.

set_handlers(handlers: List[BaseCallbackHandler], inherit: bool = True) None[source]

Set handlers as the only handlers on the callback manager.