Home / Function/ test_structured_tool_from_function_with_run_manager() — langchain Function Reference

test_structured_tool_from_function_with_run_manager() — langchain Function Reference

Architecture documentation for the test_structured_tool_from_function_with_run_manager() function in test_tools.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  2e783401_9cd8_4c77_0e54_84f64f732623["test_structured_tool_from_function_with_run_manager()"]
  8e7836ae_e72c_f670_72a5_4ca6d46e3555["test_tools.py"]
  2e783401_9cd8_4c77_0e54_84f64f732623 -->|defined in| 8e7836ae_e72c_f670_72a5_4ca6d46e3555
  b621c544_d6db_7e8d_7240_9ce08870d71a["foo()"]
  2e783401_9cd8_4c77_0e54_84f64f732623 -->|calls| b621c544_d6db_7e8d_7240_9ce08870d71a
  style 2e783401_9cd8_4c77_0e54_84f64f732623 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/test_tools.py lines 588–627

def test_structured_tool_from_function_with_run_manager() -> None:
    """Test args and schema of structured tool when using callbacks."""

    def foo(  # noqa: D417
        bar: int, baz: str, callbacks: CallbackManagerForToolRun | None = None
    ) -> str:
        """Docstring.

        Args:
            bar: int
            baz: str
        """
        assert callbacks is not None
        return str(bar) + baz

    handler = FakeCallbackHandler()
    structured_tool = StructuredTool.from_function(foo)

    assert structured_tool.args == {
        "bar": {"title": "Bar", "type": "integer"},
        "baz": {"title": "Baz", "type": "string"},
    }

    assert _schema(structured_tool.args_schema) == {
        "properties": {
            "bar": {"title": "Bar", "type": "integer"},
            "baz": {"title": "Baz", "type": "string"},
        },
        "description": inspect.getdoc(foo),
        "title": "foo",
        "type": "object",
        "required": ["bar", "baz"],
    }

    assert (
        structured_tool.run(
            tool_input={"bar": "10", "baz": "baz"}, run_manger=[handler]
        )
        == "10baz"
    )

Domain

Subdomains

Calls

Frequently Asked Questions

What does test_structured_tool_from_function_with_run_manager() do?
test_structured_tool_from_function_with_run_manager() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/test_tools.py.
Where is test_structured_tool_from_function_with_run_manager() defined?
test_structured_tool_from_function_with_run_manager() is defined in libs/core/tests/unit_tests/test_tools.py at line 588.
What does test_structured_tool_from_function_with_run_manager() call?
test_structured_tool_from_function_with_run_manager() calls 1 function(s): foo.

Analyze Your Own Codebase

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

Try Supermodel Free