root_listeners.py — langchain Source File
Architecture documentation for root_listeners.py, a python file in the langchain codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR cc8ba568_e178_2f0e_b70b_f9448e561f12["root_listeners.py"] 2bf6d401_816d_d011_3b05_a6114f55ff58["collections.abc"] cc8ba568_e178_2f0e_b70b_f9448e561f12 --> 2bf6d401_816d_d011_3b05_a6114f55ff58 feec1ec4_6917_867b_d228_b134d0ff8099["typing"] cc8ba568_e178_2f0e_b70b_f9448e561f12 --> feec1ec4_6917_867b_d228_b134d0ff8099 a8ec7563_2814_99b3_c6da_61c599efc542["langchain_core.runnables.config"] cc8ba568_e178_2f0e_b70b_f9448e561f12 --> a8ec7563_2814_99b3_c6da_61c599efc542 f7666125_c605_123c_e624_6364530e64e7["langchain_core.tracers.base"] cc8ba568_e178_2f0e_b70b_f9448e561f12 --> f7666125_c605_123c_e624_6364530e64e7 36cb50e1_bcef_f6a3_9561_cc46faff8973["langchain_core.tracers.schemas"] cc8ba568_e178_2f0e_b70b_f9448e561f12 --> 36cb50e1_bcef_f6a3_9561_cc46faff8973 02f66451_d2a9_e7c3_9765_c3a7594721ad["uuid"] cc8ba568_e178_2f0e_b70b_f9448e561f12 --> 02f66451_d2a9_e7c3_9765_c3a7594721ad style cc8ba568_e178_2f0e_b70b_f9448e561f12 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Tracers that call listeners."""
from collections.abc import Awaitable, Callable
from typing import TYPE_CHECKING
from langchain_core.runnables.config import (
RunnableConfig,
acall_func_with_variable_args,
call_func_with_variable_args,
)
from langchain_core.tracers.base import AsyncBaseTracer, BaseTracer
from langchain_core.tracers.schemas import Run
if TYPE_CHECKING:
from uuid import UUID
Listener = Callable[[Run], None] | Callable[[Run, RunnableConfig], None]
AsyncListener = (
Callable[[Run], Awaitable[None]] | Callable[[Run, RunnableConfig], Awaitable[None]]
)
class RootListenersTracer(BaseTracer):
"""Tracer that calls listeners on run start, end, and error."""
log_missing_parent = False
"""Whether to log a warning if the parent is missing."""
def __init__(
self,
*,
config: RunnableConfig,
on_start: Listener | None,
on_end: Listener | None,
on_error: Listener | None,
) -> None:
"""Initialize the tracer.
Args:
config: The runnable config.
on_start: The listener to call on run start.
on_end: The listener to call on run end.
on_error: The listener to call on run error
"""
super().__init__(_schema_format="original+chat")
self.config = config
self._arg_on_start = on_start
self._arg_on_end = on_end
self._arg_on_error = on_error
self.root_id: UUID | None = None
def _persist_run(self, run: Run) -> None:
# This is a legacy method only called once for an entire run tree
# therefore not useful here
pass
def _on_run_create(self, run: Run) -> None:
if self.root_id is not None:
return
// ... (71 more lines)
Domain
Subdomains
Functions
Dependencies
- collections.abc
- langchain_core.runnables.config
- langchain_core.tracers.base
- langchain_core.tracers.schemas
- typing
- uuid
Source
Frequently Asked Questions
What does root_listeners.py do?
root_listeners.py is a source file in the langchain codebase, written in python. It belongs to the Observability domain, Tracers subdomain.
What functions are defined in root_listeners.py?
root_listeners.py defines 1 function(s): uuid.
What does root_listeners.py depend on?
root_listeners.py imports 6 module(s): collections.abc, langchain_core.runnables.config, langchain_core.tracers.base, langchain_core.tracers.schemas, typing, uuid.
Where is root_listeners.py in the architecture?
root_listeners.py is located at libs/core/langchain_core/tracers/root_listeners.py (domain: Observability, subdomain: Tracers, directory: libs/core/langchain_core/tracers).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free