on_chain_start() — langchain Function Reference
Architecture documentation for the on_chain_start() function in event_stream.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 6afc0657_d493_6ec0_9f7e_76a8658ef71c["on_chain_start()"] 33d093c4_1ed0_fc6a_17c6_762d4c5cfa04["_AstreamEventsCallbackHandler"] 6afc0657_d493_6ec0_9f7e_76a8658ef71c -->|defined in| 33d093c4_1ed0_fc6a_17c6_762d4c5cfa04 411fc9b2_d611_6b33_d19f_de0162e13d29["_write_run_start_info()"] 6afc0657_d493_6ec0_9f7e_76a8658ef71c -->|calls| 411fc9b2_d611_6b33_d19f_de0162e13d29 87f79bee_f9c5_8262_1829_62f633c4f870["_send()"] 6afc0657_d493_6ec0_9f7e_76a8658ef71c -->|calls| 87f79bee_f9c5_8262_1829_62f633c4f870 9aed8e4f_9d4c_016f_aa43_c5908015cf8d["_get_parent_ids()"] 6afc0657_d493_6ec0_9f7e_76a8658ef71c -->|calls| 9aed8e4f_9d4c_016f_aa43_c5908015cf8d 8d2c2f35_3238_0aa3_4695_e986bf2b36bd["_assign_name()"] 6afc0657_d493_6ec0_9f7e_76a8658ef71c -->|calls| 8d2c2f35_3238_0aa3_4695_e986bf2b36bd style 6afc0657_d493_6ec0_9f7e_76a8658ef71c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/tracers/event_stream.py lines 549–595
async def on_chain_start(
self,
serialized: dict[str, Any],
inputs: dict[str, Any],
*,
run_id: UUID,
tags: list[str] | None = None,
parent_run_id: UUID | None = None,
metadata: dict[str, Any] | None = None,
run_type: str | None = None,
name: str | None = None,
**kwargs: Any,
) -> None:
"""Start a trace for a chain run."""
name_ = _assign_name(name, serialized)
run_type_ = run_type or "chain"
data: EventData = {}
# Work-around Runnable core code not sending input in some
# cases.
if inputs != {"input": ""}:
data["input"] = inputs
kwargs["inputs"] = inputs
self._write_run_start_info(
run_id,
tags=tags,
metadata=metadata,
parent_run_id=parent_run_id,
name_=name_,
run_type=run_type_,
**kwargs,
)
self._send(
{
"event": f"on_{run_type_}_start",
"data": data,
"name": name_,
"tags": tags or [],
"run_id": str(run_id),
"metadata": metadata or {},
"parent_ids": self._get_parent_ids(run_id),
},
run_type_,
)
Domain
Subdomains
Source
Frequently Asked Questions
What does on_chain_start() do?
on_chain_start() is a function in the langchain codebase, defined in libs/core/langchain_core/tracers/event_stream.py.
Where is on_chain_start() defined?
on_chain_start() is defined in libs/core/langchain_core/tracers/event_stream.py at line 549.
What does on_chain_start() call?
on_chain_start() calls 4 function(s): _assign_name, _get_parent_ids, _send, _write_run_start_info.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free