Home / Function/ test_structured_tool_from_function_docstring() — langchain Function Reference

test_structured_tool_from_function_docstring() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/core/tests/unit_tests/test_tools.py lines 448–479

def test_structured_tool_from_function_docstring() -> None:
    """Test that structured tools can be created from functions."""

    def foo(bar: int, baz: str) -> str:
        """Docstring.

        Args:
            bar: the bar value
            baz: the baz value
        """
        raise NotImplementedError

    structured_tool = StructuredTool.from_function(foo)
    assert structured_tool.name == "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 foo.__doc__ is not None
    assert structured_tool.description == textwrap.dedent(foo.__doc__.strip())

Domain

Subdomains

Calls

Frequently Asked Questions

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