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 manager.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  a6207573_f43a_6004_ebfd_c9da6a0f2d8f["on_chat_model_start()"]
  f2c19eb2_a092_16e7_b693_b7ae35a0bc8c["CallbackManager"]
  a6207573_f43a_6004_ebfd_c9da6a0f2d8f -->|defined in| f2c19eb2_a092_16e7_b693_b7ae35a0bc8c
  fd9cf5b0_df49_0a9e_1f92_c0f24cb802a3["on_chat_model_start()"]
  fd9cf5b0_df49_0a9e_1f92_c0f24cb802a3 -->|calls| a6207573_f43a_6004_ebfd_c9da6a0f2d8f
  fd9cf5b0_df49_0a9e_1f92_c0f24cb802a3["on_chat_model_start()"]
  a6207573_f43a_6004_ebfd_c9da6a0f2d8f -->|calls| fd9cf5b0_df49_0a9e_1f92_c0f24cb802a3
  8964b4e9_440e_18a7_2a15_a54a0b2b733c["handle_event()"]
  a6207573_f43a_6004_ebfd_c9da6a0f2d8f -->|calls| 8964b4e9_440e_18a7_2a15_a54a0b2b733c
  style a6207573_f43a_6004_ebfd_c9da6a0f2d8f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/callbacks/manager.py lines 1358–1410

    def on_chat_model_start(
        self,
        serialized: dict[str, Any],
        messages: list[list[BaseMessage]],
        run_id: UUID | None = None,
        **kwargs: Any,
    ) -> list[CallbackManagerForLLMRun]:
        """Run when chat model starts running.

        Args:
            serialized: The serialized LLM.
            messages: The list of messages.
            run_id: The ID of the run.
            **kwargs: Additional keyword arguments.

        Returns:
            A callback manager for each list of messages as an LLM run.

        """
        managers = []
        for message_list in messages:
            if run_id is not None:
                run_id_ = run_id
                run_id = None
            else:
                run_id_ = uuid7()
            handle_event(
                self.handlers,
                "on_chat_model_start",
                "ignore_chat_model",
                serialized,
                [message_list],
                run_id=run_id_,
                parent_run_id=self.parent_run_id,
                tags=self.tags,
                metadata=self.metadata,
                **kwargs,
            )

            managers.append(
                CallbackManagerForLLMRun(
                    run_id=run_id_,
                    handlers=self.handlers,
                    inheritable_handlers=self.inheritable_handlers,
                    parent_run_id=self.parent_run_id,
                    tags=self.tags,
                    inheritable_tags=self.inheritable_tags,
                    metadata=self.metadata,
                    inheritable_metadata=self.inheritable_metadata,
                )
            )

        return managers

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/manager.py.
Where is on_chat_model_start() defined?
on_chat_model_start() is defined in libs/core/langchain_core/callbacks/manager.py at line 1358.
What does on_chat_model_start() call?
on_chat_model_start() calls 2 function(s): handle_event, 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