with_listeners() — langchain Function Reference
Architecture documentation for the with_listeners() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 6606ea6b_af21_fc53_21ca_cf61d28c7999["with_listeners()"] a94c7f6a_b072_1738_b1c2_2565e759189f["RunnableEach"] 6606ea6b_af21_fc53_21ca_cf61d28c7999 -->|defined in| a94c7f6a_b072_1738_b1c2_2565e759189f c95b18f5_8485_9405_07af_f9e9f27e3fc6["with_listeners()"] 6606ea6b_af21_fc53_21ca_cf61d28c7999 -->|calls| c95b18f5_8485_9405_07af_f9e9f27e3fc6 style 6606ea6b_af21_fc53_21ca_cf61d28c7999 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/runnables/base.py lines 5459–5494
def with_listeners(
self,
*,
on_start: Callable[[Run], None]
| Callable[[Run, RunnableConfig], None]
| None = None,
on_end: Callable[[Run], None]
| Callable[[Run, RunnableConfig], None]
| None = None,
on_error: Callable[[Run], None]
| Callable[[Run, RunnableConfig], None]
| None = None,
) -> RunnableEach[Input, Output]:
"""Bind lifecycle listeners to a `Runnable`, returning a new `Runnable`.
The `Run` object contains information about the run, including its `id`,
`type`, `input`, `output`, `error`, `start_time`, `end_time`, and
any tags or metadata added to the run.
Args:
on_start: Called before the `Runnable` starts running, with the `Run`
object.
on_end: Called after the `Runnable` finishes running, with the `Run`
object.
on_error: Called if the `Runnable` throws an error, with the `Run`
object.
Returns:
A new `Runnable` with the listeners bound.
"""
return RunnableEach(
bound=self.bound.with_listeners(
on_start=on_start, on_end=on_end, on_error=on_error
)
)
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does with_listeners() do?
with_listeners() is a function in the langchain codebase, defined in libs/core/langchain_core/runnables/base.py.
Where is with_listeners() defined?
with_listeners() is defined in libs/core/langchain_core/runnables/base.py at line 5459.
What does with_listeners() call?
with_listeners() calls 1 function(s): with_listeners.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free