test_event_stream_on_chain_with_tool() — langchain Function Reference
Architecture documentation for the test_event_stream_on_chain_with_tool() function in test_runnable_events_v1.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 27442f0d_99fb_ef73_02c6_ca9504b43c9d["test_event_stream_on_chain_with_tool()"] 8ff41f3c_f250_f8de_8094_4f24860a10e0["test_runnable_events_v1.py"] 27442f0d_99fb_ef73_02c6_ca9504b43c9d -->|defined in| 8ff41f3c_f250_f8de_8094_4f24860a10e0 aac0453e_34cd_4dce_c7fa_f176ab20140b["_collect_events()"] 27442f0d_99fb_ef73_02c6_ca9504b43c9d -->|calls| aac0453e_34cd_4dce_c7fa_f176ab20140b 6ebe7fde_6e8f_dae5_d42f_9cea181617f5["_assert_events_equal_allow_superset_metadata()"] 27442f0d_99fb_ef73_02c6_ca9504b43c9d -->|calls| 6ebe7fde_6e8f_dae5_d42f_9cea181617f5 style 27442f0d_99fb_ef73_02c6_ca9504b43c9d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/runnables/test_runnable_events_v1.py lines 1429–1524
async def test_event_stream_on_chain_with_tool() -> None:
"""Test the event stream with a tool."""
@tool
def concat(a: str, b: str) -> str:
"""A tool that does nothing."""
return a + b
def reverse(s: str) -> str:
"""Reverse a string."""
return s[::-1]
# For whatever reason type annotations fail here because reverse
# does not appear to be a runnable
chain = concat | reverse
events = await _collect_events(
chain.astream_events({"a": "hello", "b": "world"}, version="v1")
)
_assert_events_equal_allow_superset_metadata(
events,
[
{
"data": {"input": {"a": "hello", "b": "world"}},
"event": "on_chain_start",
"metadata": {},
"name": "RunnableSequence",
"run_id": "",
"parent_ids": [],
"tags": [],
},
{
"data": {"input": {"a": "hello", "b": "world"}},
"event": "on_tool_start",
"metadata": {},
"name": "concat",
"run_id": "",
"parent_ids": [],
"tags": ["seq:step:1"],
},
{
"data": {"input": {"a": "hello", "b": "world"}, "output": "helloworld"},
"event": "on_tool_end",
"metadata": {},
"name": "concat",
"run_id": "",
"parent_ids": [],
"tags": ["seq:step:1"],
},
{
"data": {},
"event": "on_chain_start",
"metadata": {},
"name": "reverse",
"run_id": "",
"parent_ids": [],
"tags": ["seq:step:2"],
},
{
"data": {"chunk": "dlrowolleh"},
"event": "on_chain_stream",
"metadata": {},
"name": "reverse",
"run_id": "",
"parent_ids": [],
"tags": ["seq:step:2"],
},
{
"data": {"chunk": "dlrowolleh"},
"event": "on_chain_stream",
"metadata": {},
"name": "RunnableSequence",
"run_id": "",
"parent_ids": [],
"tags": [],
},
{
"data": {"input": "helloworld", "output": "dlrowolleh"},
"event": "on_chain_end",
"metadata": {},
"name": "reverse",
Domain
Subdomains
Source
Frequently Asked Questions
What does test_event_stream_on_chain_with_tool() do?
test_event_stream_on_chain_with_tool() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/runnables/test_runnable_events_v1.py.
Where is test_event_stream_on_chain_with_tool() defined?
test_event_stream_on_chain_with_tool() is defined in libs/core/tests/unit_tests/runnables/test_runnable_events_v1.py at line 1429.
What does test_event_stream_on_chain_with_tool() call?
test_event_stream_on_chain_with_tool() calls 2 function(s): _assert_events_equal_allow_superset_metadata, _collect_events.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free