Home / Function/ on_chat_model_start() — langchain Function Reference

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
  b9be6f40_94bd_92e4_7492_1e042c297746["on_chat_model_start()"]
  3b53de05_0697_704a_50e8_c5f9aaeba5ae["CallbackManagerMixin"]
  b9be6f40_94bd_92e4_7492_1e042c297746 -->|defined in| 3b53de05_0697_704a_50e8_c5f9aaeba5ae
  35c09138_3b53_5201_8c40_89d52f296f61["on_chat_model_start()"]
  35c09138_3b53_5201_8c40_89d52f296f61 -->|calls| b9be6f40_94bd_92e4_7492_1e042c297746
  35c09138_3b53_5201_8c40_89d52f296f61["on_chat_model_start()"]
  b9be6f40_94bd_92e4_7492_1e042c297746 -->|calls| 35c09138_3b53_5201_8c40_89d52f296f61
  style b9be6f40_94bd_92e4_7492_1e042c297746 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/callbacks/base.py lines 270–300

    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

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