StatefulAsyncCallbackHandler Class — langchain Architecture
Architecture documentation for the StatefulAsyncCallbackHandler class in test_async_callback_manager.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 4c7911c3_3a1d_f829_848f_5f683cc90bc9["StatefulAsyncCallbackHandler"] 64513429_d001_87b1_5f19_cc17a3f3577b["AsyncCallbackHandler"] 4c7911c3_3a1d_f829_848f_5f683cc90bc9 -->|extends| 64513429_d001_87b1_5f19_cc17a3f3577b f1a09d1e_2693_1456_76d6_3f34ca061a65["test_async_callback_manager.py"] 4c7911c3_3a1d_f829_848f_5f683cc90bc9 -->|defined in| f1a09d1e_2693_1456_76d6_3f34ca061a65 dfac0c64_07e2_1787_b14a_98ac7ded0851["__init__()"] 4c7911c3_3a1d_f829_848f_5f683cc90bc9 -->|method| dfac0c64_07e2_1787_b14a_98ac7ded0851 2916e273_7429_5c51_38d6_6936f07ce55b["on_llm_start()"] 4c7911c3_3a1d_f829_848f_5f683cc90bc9 -->|method| 2916e273_7429_5c51_38d6_6936f07ce55b
Relationship Graph
Source Code
libs/core/tests/unit_tests/callbacks/test_async_callback_manager.py lines 96–127
class StatefulAsyncCallbackHandler(AsyncCallbackHandler):
def __init__(self, name: str, *, run_inline: bool = True):
self.name = name
self.run_inline = run_inline
async def on_llm_start(
self,
serialized: dict[str, Any],
prompts: list[str],
*,
run_id: UUID,
parent_run_id: UUID | None = None,
**kwargs: Any,
) -> None:
if self.name == "StateModifier":
current_counter = counter_var.get()
counter_var.set(current_counter + 1)
state = counter_var.get()
elif self.name == "StateReader":
state = counter_var.get()
else:
state = None
shared_stack.append(state)
await super().on_llm_start(
serialized,
prompts,
run_id=run_id,
parent_run_id=parent_run_id,
**kwargs,
)
Extends
Source
Frequently Asked Questions
What is the StatefulAsyncCallbackHandler class?
StatefulAsyncCallbackHandler is a class in the langchain codebase, defined in libs/core/tests/unit_tests/callbacks/test_async_callback_manager.py.
Where is StatefulAsyncCallbackHandler defined?
StatefulAsyncCallbackHandler is defined in libs/core/tests/unit_tests/callbacks/test_async_callback_manager.py at line 96.
What does StatefulAsyncCallbackHandler extend?
StatefulAsyncCallbackHandler extends AsyncCallbackHandler.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free