def test_query_pipeline_multi_intermediate_output() -> None:
    """Test query pipeline showing intermediate outputs."""
    # try run run_multi_with_intermediates
    # link both qc1_0 and qc1_1 to qc2
    qc1_0 = QueryComponent1()
    qc1_1 = QueryComponent1()
    qc2 = QueryComponent2()
    p = QueryPipeline()
    p.add_modules({"qc1_0": qc1_0, "qc1_1": qc1_1, "qc2": qc2})
    p.add_link("qc1_0", "qc2", dest_key="input1")
    p.add_link("qc1_1", "qc2", dest_key="input2")
    outputs, intermediates = p.run_multi_with_intermediates(
        {"qc1_0": {"input1": 1, "input2": 2}, "qc1_1": {"input1": 3, "input2": 4}}
    )

    assert outputs == {"qc2": {"output": "3:7"}}

    assert intermediates["qc1_0"].inputs == {"input1": 1, "input2": 2}
    assert intermediates["qc1_0"].outputs == {"output": 3}

    assert intermediates["qc1_1"].inputs == {"input1": 3, "input2": 4}
    assert intermediates["qc1_1"].outputs == {"output": 7}

    assert intermediates["qc2"].inputs == {"input1": 3, "input2": 7}
    assert intermediates["qc2"].outputs == {"output": "3:7"}
Test query pipeline showing intermediate outputs.
llama-index-core/tests/query_pipeline/test_query.py