Home / Function/ test_each() — langchain Function Reference

test_each() — langchain Function Reference

Architecture documentation for the test_each() function in test_runnable.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  d326dc3e_1e5f_f515_c1a6_e04361fbb238["test_each()"]
  26df6ad8_0189_51d0_c3c1_6c3248893ff5["test_runnable.py"]
  d326dc3e_1e5f_f515_c1a6_e04361fbb238 -->|defined in| 26df6ad8_0189_51d0_c3c1_6c3248893ff5
  f59d5b6a_111b_6895_b338_7e3d29e63896["invoke()"]
  d326dc3e_1e5f_f515_c1a6_e04361fbb238 -->|calls| f59d5b6a_111b_6895_b338_7e3d29e63896
  style d326dc3e_1e5f_f515_c1a6_e04361fbb238 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/runnables/test_runnable.py lines 3831–3849

def test_each(snapshot: SnapshotAssertion) -> None:
    prompt = (
        SystemMessagePromptTemplate.from_template("You are a nice assistant.")
        + "{question}"
    )
    first_llm = FakeStreamingListLLM(responses=["first item, second item, third item"])
    parser = FakeSplitIntoListParser()
    second_llm = FakeStreamingListLLM(responses=["this", "is", "a", "test"])

    chain = prompt | first_llm | parser | second_llm.map()

    assert dumps(chain, pretty=True) == snapshot
    output = chain.invoke({"question": "What up"})
    assert output == ["this", "is", "a"]

    assert (parser | second_llm.map()).invoke("first item, second item") == [
        "test",
        "this",
    ]

Domain

Subdomains

Calls

Frequently Asked Questions

What does test_each() do?
test_each() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/runnables/test_runnable.py.
Where is test_each() defined?
test_each() is defined in libs/core/tests/unit_tests/runnables/test_runnable.py at line 3831.
What does test_each() call?
test_each() calls 1 function(s): invoke.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free