_on_run_create() — langchain Function Reference
Architecture documentation for the _on_run_create() function in log_stream.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 79906bae_a315_8c6a_0f74_2bca8c58615c["_on_run_create()"] 78fc514f_5439_00c6_7e00_021af9ce4e07["LogStreamCallbackHandler"] 79906bae_a315_8c6a_0f74_2bca8c58615c -->|defined in| 78fc514f_5439_00c6_7e00_021af9ce4e07 c5f1fbd2_23b6_75cb_1f29_b9e028c332a0["send()"] 79906bae_a315_8c6a_0f74_2bca8c58615c -->|calls| c5f1fbd2_23b6_75cb_1f29_b9e028c332a0 98bcd7e4_7b8f_2694_2f03_85ddc533e9b2["include_run()"] 79906bae_a315_8c6a_0f74_2bca8c58615c -->|calls| 98bcd7e4_7b8f_2694_2f03_85ddc533e9b2 999c00c5_f6b7_32ae_2290_ef3266811aab["_get_standardized_inputs()"] 79906bae_a315_8c6a_0f74_2bca8c58615c -->|calls| 999c00c5_f6b7_32ae_2290_ef3266811aab style 79906bae_a315_8c6a_0f74_2bca8c58615c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/tracers/log_stream.py lines 433–488
def _on_run_create(self, run: Run) -> None:
"""Start a run."""
if self.root_id is None:
self.root_id = run.id
if not self.send(
{
"op": "replace",
"path": "",
"value": RunState(
id=str(run.id),
streamed_output=[],
final_output=None,
logs={},
name=run.name,
type=run.run_type,
),
}
):
return
if not self.include_run(run):
return
# Determine previous index, increment by 1
with self.lock:
self._counter_map_by_name[run.name] += 1
count = self._counter_map_by_name[run.name]
self._key_map_by_run_id[run.id] = (
run.name if count == 1 else f"{run.name}:{count}"
)
entry = LogEntry(
id=str(run.id),
name=run.name,
type=run.run_type,
tags=run.tags or [],
metadata=(run.extra or {}).get("metadata", {}),
start_time=run.start_time.isoformat(timespec="milliseconds"),
streamed_output=[],
streamed_output_str=[],
final_output=None,
end_time=None,
)
if self._schema_format == "streaming_events":
# If using streaming events let's add inputs as well
entry["inputs"] = _get_standardized_inputs(run, self._schema_format)
# Add the run to the stream
self.send(
{
"op": "add",
"path": f"/logs/{self._key_map_by_run_id[run.id]}",
"value": entry,
}
)
Domain
Subdomains
Source
Frequently Asked Questions
What does _on_run_create() do?
_on_run_create() is a function in the langchain codebase, defined in libs/core/langchain_core/tracers/log_stream.py.
Where is _on_run_create() defined?
_on_run_create() is defined in libs/core/langchain_core/tracers/log_stream.py at line 433.
What does _on_run_create() call?
_on_run_create() calls 3 function(s): _get_standardized_inputs, include_run, send.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free