Home / Function/ chain() — langchain Function Reference

chain() — langchain Function Reference

Architecture documentation for the chain() function in test_fallbacks.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  552a7e6a_d1f9_1ea8_1c20_b9324779691c["chain()"]
  d62d478e_a330_c328_7da4_58e88d780807["test_fallbacks.py"]
  552a7e6a_d1f9_1ea8_1c20_b9324779691c -->|defined in| d62d478e_a330_c328_7da4_58e88d780807
  style 552a7e6a_d1f9_1ea8_1c20_b9324779691c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/runnables/test_fallbacks.py lines 51–58

def chain() -> Runnable[Any, str]:
    error_llm = FakeListLLM(responses=["foo"], i=1)
    pass_llm = FakeListLLM(responses=["bar"])

    prompt = PromptTemplate.from_template("what did baz say to {buz}")
    return RunnableParallel({"buz": lambda x: x}) | (prompt | error_llm).with_fallbacks(
        [prompt | pass_llm]
    )

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free