Home / Function/ test_from_chains() — langchain Function Reference

test_from_chains() — langchain Function Reference

Architecture documentation for the test_from_chains() function in test_mrkl.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  40b06066_5bc2_a3ad_dccb_b108a16eb779["test_from_chains()"]
  11e4d0ce_1ab2_b50d_7115_96011ca80049["test_mrkl.py"]
  40b06066_5bc2_a3ad_dccb_b108a16eb779 -->|defined in| 11e4d0ce_1ab2_b50d_7115_96011ca80049
  style 40b06066_5bc2_a3ad_dccb_b108a16eb779 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/tests/unit_tests/agents/test_mrkl.py lines 145–164

def test_from_chains() -> None:
    """Test initializing from chains."""
    chain_configs = [
        Tool(name="foo", func=lambda _x: "foo", description="foobar1"),
        Tool(name="bar", func=lambda _x: "bar", description="foobar2"),
    ]
    agent = ZeroShotAgent.from_llm_and_tools(FakeLLM(), chain_configs)
    expected_tools_prompt = "foo(_x) - foobar1\nbar(_x) - foobar2"
    expected_tool_names = "foo, bar"
    expected_template = "\n\n".join(
        [
            PREFIX,
            expected_tools_prompt,
            FORMAT_INSTRUCTIONS.format(tool_names=expected_tool_names),
            SUFFIX,
        ],
    )
    prompt = agent.llm_chain.prompt
    assert isinstance(prompt, PromptTemplate)
    assert prompt.template == expected_template

Domain

Subdomains

Frequently Asked Questions

What does test_from_chains() do?
test_from_chains() is a function in the langchain codebase, defined in libs/langchain/tests/unit_tests/agents/test_mrkl.py.
Where is test_from_chains() defined?
test_from_chains() is defined in libs/langchain/tests/unit_tests/agents/test_mrkl.py at line 145.

Analyze Your Own Codebase

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

Try Supermodel Free