Home / Function/ test_graph_sequence_map() — langchain Function Reference

test_graph_sequence_map() — langchain Function Reference

Architecture documentation for the test_graph_sequence_map() function in test_graph.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  27e088ce_ed7a_b6d3_19ac_763242f5190e["test_graph_sequence_map()"]
  972d89eb_abd0_b940_67b4_eff75c775ace["test_graph.py"]
  27e088ce_ed7a_b6d3_19ac_763242f5190e -->|defined in| 972d89eb_abd0_b940_67b4_eff75c775ace
  style 27e088ce_ed7a_b6d3_19ac_763242f5190e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/runnables/test_graph.py lines 222–252

def test_graph_sequence_map(snapshot: SnapshotAssertion) -> None:
    fake_llm = FakeListLLM(responses=["a"])
    prompt = PromptTemplate.from_template("Hello, {name}!")
    list_parser = CommaSeparatedListOutputParser()
    str_parser = StrOutputParser()
    xml_parser = XMLOutputParser()

    def conditional_str_parser(value: str) -> Runnable[BaseMessage | str, str]:
        if value == "a":
            return str_parser
        return xml_parser

    sequence: Runnable = (
        prompt
        | fake_llm
        | {
            "as_list": list_parser,
            "as_str": conditional_str_parser,
        }
    )
    graph = sequence.get_graph()

    if version.parse("2.10") <= PYDANTIC_VERSION:
        assert _normalize_schema(graph.to_json(with_schemas=True)) == snapshot(
            name="graph_with_schema"
        )
        assert _normalize_schema(graph.to_json()) == snapshot(name="graph_no_schemas")

    assert graph.draw_ascii() == snapshot(name="ascii")
    assert graph.draw_mermaid() == snapshot(name="mermaid")
    assert graph.draw_mermaid(with_styles=False) == snapshot(name="mermaid-simple")

Subdomains

Frequently Asked Questions

What does test_graph_sequence_map() do?
test_graph_sequence_map() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/runnables/test_graph.py.
Where is test_graph_sequence_map() defined?
test_graph_sequence_map() is defined in libs/core/tests/unit_tests/runnables/test_graph.py at line 222.

Analyze Your Own Codebase

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

Try Supermodel Free