on_chat_model_start() — langchain Function Reference
Architecture documentation for the on_chat_model_start() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 35c09138_3b53_5201_8c40_89d52f296f61["on_chat_model_start()"] 64513429_d001_87b1_5f19_cc17a3f3577b["AsyncCallbackHandler"] 35c09138_3b53_5201_8c40_89d52f296f61 -->|defined in| 64513429_d001_87b1_5f19_cc17a3f3577b b9be6f40_94bd_92e4_7492_1e042c297746["on_chat_model_start()"] b9be6f40_94bd_92e4_7492_1e042c297746 -->|calls| 35c09138_3b53_5201_8c40_89d52f296f61 b9be6f40_94bd_92e4_7492_1e042c297746["on_chat_model_start()"] 35c09138_3b53_5201_8c40_89d52f296f61 -->|calls| b9be6f40_94bd_92e4_7492_1e042c297746 style 35c09138_3b53_5201_8c40_89d52f296f61 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/callbacks/base.py lines 519–549
async def on_chat_model_start(
self,
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:
"""Run when a chat model starts running.
!!! warning
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.
Args:
serialized: The serialized chat model.
messages: The messages.
run_id: The ID of the current run.
parent_run_id: The ID of the parent run.
tags: The tags.
metadata: The metadata.
**kwargs: Additional keyword arguments.
"""
# NotImplementedError is thrown intentionally
# Callback handler will fall back to on_llm_start if this is exception is thrown
msg = f"{self.__class__.__name__} does not implement `on_chat_model_start`"
raise NotImplementedError(msg)
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does on_chat_model_start() do?
on_chat_model_start() is a function in the langchain codebase, defined in libs/core/langchain_core/callbacks/base.py.
Where is on_chat_model_start() defined?
on_chat_model_start() is defined in libs/core/langchain_core/callbacks/base.py at line 519.
What does on_chat_model_start() call?
on_chat_model_start() calls 1 function(s): on_chat_model_start.
What calls on_chat_model_start()?
on_chat_model_start() is called by 1 function(s): on_chat_model_start.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free