test_router_runnable_async() — langchain Function Reference
Architecture documentation for the test_router_runnable_async() function in test_runnable.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 0220d3ab_db8c_f784_31f0_cfee558a3902["test_router_runnable_async()"] 26df6ad8_0189_51d0_c3c1_6c3248893ff5["test_runnable.py"] 0220d3ab_db8c_f784_31f0_cfee558a3902 -->|defined in| 26df6ad8_0189_51d0_c3c1_6c3248893ff5 8652094c_ec57_c551_fc44_9566d00cf872["abatch()"] 0220d3ab_db8c_f784_31f0_cfee558a3902 -->|calls| 8652094c_ec57_c551_fc44_9566d00cf872 style 0220d3ab_db8c_f784_31f0_cfee558a3902 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/runnables/test_runnable.py lines 2909–2931
async def test_router_runnable_async() -> None:
chain1 = ChatPromptTemplate.from_template(
"You are a math genius. Answer the question: {question}"
) | FakeListLLM(responses=["4"])
chain2 = ChatPromptTemplate.from_template(
"You are an english major. Answer the question: {question}"
) | FakeListLLM(responses=["2"])
router = RouterRunnable({"math": chain1, "english": chain2})
chain: Runnable = {
"key": lambda x: x["key"],
"input": {"question": lambda x: x["question"]},
} | router
result = await chain.ainvoke({"key": "math", "question": "2 + 2"})
assert result == "4"
result2 = await chain.abatch(
[
{"key": "math", "question": "2 + 2"},
{"key": "english", "question": "2 + 2"},
]
)
assert result2 == ["4", "2"]
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does test_router_runnable_async() do?
test_router_runnable_async() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/runnables/test_runnable.py.
Where is test_router_runnable_async() defined?
test_router_runnable_async() is defined in libs/core/tests/unit_tests/runnables/test_runnable.py at line 2909.
What does test_router_runnable_async() call?
test_router_runnable_async() calls 1 function(s): abatch.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free