test_combining_sequences() — langchain Function Reference
Architecture documentation for the test_combining_sequences() function in test_runnable.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD e78f934c_45bc_7548_4bf3_365874598c22["test_combining_sequences()"] 26df6ad8_0189_51d0_c3c1_6c3248893ff5["test_runnable.py"] e78f934c_45bc_7548_4bf3_365874598c22 -->|defined in| 26df6ad8_0189_51d0_c3c1_6c3248893ff5 a3895c50_dab4_0c36_2d24_f63121e198a0["invoke()"] e78f934c_45bc_7548_4bf3_365874598c22 -->|calls| a3895c50_dab4_0c36_2d24_f63121e198a0 style e78f934c_45bc_7548_4bf3_365874598c22 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/runnables/test_runnable.py lines 2663–2719
def test_combining_sequences(
snapshot: SnapshotAssertion,
) -> None:
prompt = (
SystemMessagePromptTemplate.from_template("You are a nice assistant.")
+ "{question}"
)
chat = FakeListChatModel(responses=["foo, bar"])
parser = CommaSeparatedListOutputParser()
chain = prompt | chat | parser
assert isinstance(chain, RunnableSequence)
assert chain.first == prompt
assert chain.middle == [chat]
assert chain.last == parser
assert dumps(chain, pretty=True) == snapshot
prompt2 = (
SystemMessagePromptTemplate.from_template("You are a nicer assistant.")
+ "{question}"
)
chat2 = FakeListChatModel(responses=["baz, qux"])
parser2 = CommaSeparatedListOutputParser()
input_formatter = RunnableLambda[list[str], dict[str, Any]](
lambda x: {"question": x[0] + x[1]}
)
chain2 = input_formatter | prompt2 | chat2 | parser2
assert isinstance(chain2, RunnableSequence)
assert chain2.first == input_formatter
assert chain2.middle == [prompt2, chat2]
assert chain2.last == parser2
assert dumps(chain2, pretty=True) == snapshot
combined_chain = chain | chain2
assert isinstance(combined_chain, RunnableSequence)
assert combined_chain.first == prompt
assert combined_chain.middle == [
chat,
parser,
input_formatter,
prompt2,
chat2,
]
assert combined_chain.last == parser2
assert dumps(combined_chain, pretty=True) == snapshot
# Test invoke
tracer = FakeTracer()
assert combined_chain.invoke(
{"question": "What is your name?"}, {"callbacks": [tracer]}
) == ["baz", "qux"]
assert tracer.runs == snapshot
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does test_combining_sequences() do?
test_combining_sequences() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/runnables/test_runnable.py.
Where is test_combining_sequences() defined?
test_combining_sequences() is defined in libs/core/tests/unit_tests/runnables/test_runnable.py at line 2663.
What does test_combining_sequences() call?
test_combining_sequences() 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