Home / Function/ test_passthrough_assign_schema() — langchain Function Reference

test_passthrough_assign_schema() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  985786c8_c735_6ca0_986f_47ee5ae6ecdf["test_passthrough_assign_schema()"]
  26df6ad8_0189_51d0_c3c1_6c3248893ff5["test_runnable.py"]
  985786c8_c735_6ca0_986f_47ee5ae6ecdf -->|defined in| 26df6ad8_0189_51d0_c3c1_6c3248893ff5
  style 985786c8_c735_6ca0_986f_47ee5ae6ecdf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/runnables/test_runnable.py lines 509–543

def test_passthrough_assign_schema() -> None:
    retriever = FakeRetriever()  # str -> list[Document]
    prompt = PromptTemplate.from_template("{context} {question}")
    fake_llm = FakeListLLM(responses=["a"])  # str -> list[list[str]]

    seq_w_assign = (
        RunnablePassthrough.assign(context=itemgetter("question") | retriever)
        | prompt
        | fake_llm
    )

    assert seq_w_assign.get_input_jsonschema() == {
        "properties": {"question": {"title": "Question", "type": "string"}},
        "title": "RunnableSequenceInput",
        "type": "object",
        "required": ["question"],
    }
    assert seq_w_assign.get_output_jsonschema() == {
        "title": "FakeListLLMOutput",
        "type": "string",
    }

    invalid_seq_w_assign = (
        RunnablePassthrough.assign(context=itemgetter("question") | retriever)
        | fake_llm
    )

    # fallback to RunnableAssign.input_schema if next runnable doesn't have
    # expected dict input_schema
    assert invalid_seq_w_assign.get_input_jsonschema() == {
        "properties": {"question": {"title": "Question"}},
        "title": "RunnableParallel<context>Input",
        "type": "object",
        "required": ["question"],
    }

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free