on_llm_start() — langchain Function Reference
Architecture documentation for the on_llm_start() function in manager.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 082e343b_042a_f645_ef5e_35d66aa78bc3["on_llm_start()"] f2c19eb2_a092_16e7_b693_b7ae35a0bc8c["CallbackManager"] 082e343b_042a_f645_ef5e_35d66aa78bc3 -->|defined in| f2c19eb2_a092_16e7_b693_b7ae35a0bc8c aff29c00_eb3e_fd6a_1d26_af2c7296121e["on_llm_start()"] aff29c00_eb3e_fd6a_1d26_af2c7296121e -->|calls| 082e343b_042a_f645_ef5e_35d66aa78bc3 aff29c00_eb3e_fd6a_1d26_af2c7296121e["on_llm_start()"] 082e343b_042a_f645_ef5e_35d66aa78bc3 -->|calls| aff29c00_eb3e_fd6a_1d26_af2c7296121e 8964b4e9_440e_18a7_2a15_a54a0b2b733c["handle_event()"] 082e343b_042a_f645_ef5e_35d66aa78bc3 -->|calls| 8964b4e9_440e_18a7_2a15_a54a0b2b733c style 082e343b_042a_f645_ef5e_35d66aa78bc3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/callbacks/manager.py lines 1307–1356
def on_llm_start(
self,
serialized: dict[str, Any],
prompts: list[str],
run_id: UUID | None = None,
**kwargs: Any,
) -> list[CallbackManagerForLLMRun]:
"""Run when LLM starts running.
Args:
serialized: The serialized LLM.
prompts: The list of prompts.
run_id: The ID of the run.
**kwargs: Additional keyword arguments.
Returns:
A callback manager for each prompt as an LLM run.
"""
managers = []
for i, prompt in enumerate(prompts):
# Can't have duplicate runs with the same run ID (if provided)
run_id_ = run_id if i == 0 and run_id is not None else uuid7()
handle_event(
self.handlers,
"on_llm_start",
"ignore_llm",
serialized,
[prompt],
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
Called By
Source
Frequently Asked Questions
What does on_llm_start() do?
on_llm_start() is a function in the langchain codebase, defined in libs/core/langchain_core/callbacks/manager.py.
Where is on_llm_start() defined?
on_llm_start() is defined in libs/core/langchain_core/callbacks/manager.py at line 1307.
What does on_llm_start() call?
on_llm_start() calls 2 function(s): handle_event, on_llm_start.
What calls on_llm_start()?
on_llm_start() is called by 1 function(s): on_llm_start.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free