Home / Function/ test_tool_from_runnable() — langchain Function Reference

test_tool_from_runnable() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  00bf6d91_c711_639b_a43b_dc7c8dc9d174["test_tool_from_runnable()"]
  26df6ad8_0189_51d0_c3c1_6c3248893ff5["test_runnable.py"]
  00bf6d91_c711_639b_a43b_dc7c8dc9d174 -->|defined in| 26df6ad8_0189_51d0_c3c1_6c3248893ff5
  fb618d44_c03b_ea8b_385b_2278dfb173d4["invoke()"]
  00bf6d91_c711_639b_a43b_dc7c8dc9d174 -->|calls| fb618d44_c03b_ea8b_385b_2278dfb173d4
  style 00bf6d91_c711_639b_a43b_dc7c8dc9d174 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/runnables/test_runnable.py lines 4833–4859

async def test_tool_from_runnable() -> None:
    prompt = (
        SystemMessagePromptTemplate.from_template("You are a nice assistant.")
        + "{question}"
    )
    llm = FakeStreamingListLLM(responses=["foo-lish"])

    chain = prompt | llm | StrOutputParser()

    chain_tool = tool("chain_tool", chain)

    assert isinstance(chain_tool, BaseTool)
    assert chain_tool.name == "chain_tool"
    assert chain_tool.run({"question": "What up"}) == chain.invoke(
        {"question": "What up"}
    )
    assert await chain_tool.arun({"question": "What up"}) == await chain.ainvoke(
        {"question": "What up"}
    )
    assert chain_tool.description.endswith(repr(chain))
    assert _schema(chain_tool.args_schema) == chain.get_input_jsonschema()
    assert _schema(chain_tool.args_schema) == {
        "properties": {"question": {"title": "Question", "type": "string"}},
        "title": "PromptInput",
        "type": "object",
        "required": ["question"],
    }

Domain

Subdomains

Calls

Frequently Asked Questions

What does test_tool_from_runnable() do?
test_tool_from_runnable() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/runnables/test_runnable.py.
Where is test_tool_from_runnable() defined?
test_tool_from_runnable() is defined in libs/core/tests/unit_tests/runnables/test_runnable.py at line 4833.
What does test_tool_from_runnable() call?
test_tool_from_runnable() 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