test_tool_arg_descriptions() — langchain Function Reference
Architecture documentation for the test_tool_arg_descriptions() function in test_tools.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD a8b84669_346c_2c04_405f_4c6eb1f1e470["test_tool_arg_descriptions()"] 8e7836ae_e72c_f670_72a5_4ca6d46e3555["test_tools.py"] a8b84669_346c_2c04_405f_4c6eb1f1e470 -->|defined in| 8e7836ae_e72c_f670_72a5_4ca6d46e3555 b621c544_d6db_7e8d_7240_9ce08870d71a["foo()"] a8b84669_346c_2c04_405f_4c6eb1f1e470 -->|calls| b621c544_d6db_7e8d_7240_9ce08870d71a style a8b84669_346c_2c04_405f_4c6eb1f1e470 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/test_tools.py lines 1192–1275
def test_tool_arg_descriptions() -> None:
def foo(bar: str, baz: int) -> str:
"""The foo.
Args:
bar: The bar.
baz: The baz.
"""
return bar
foo1 = tool(foo)
args_schema = _schema(foo1.args_schema)
assert args_schema == {
"title": "foo",
"type": "object",
"description": inspect.getdoc(foo),
"properties": {
"bar": {"title": "Bar", "type": "string"},
"baz": {"title": "Baz", "type": "integer"},
},
"required": ["bar", "baz"],
}
# Test parses docstring
foo2 = tool(foo, parse_docstring=True)
args_schema = _schema(foo2.args_schema)
expected = {
"title": "foo",
"description": "The foo.",
"type": "object",
"properties": {
"bar": {"title": "Bar", "description": "The bar.", "type": "string"},
"baz": {"title": "Baz", "description": "The baz.", "type": "integer"},
},
"required": ["bar", "baz"],
}
assert args_schema == expected
# Test parsing with run_manager does not raise error
def foo3( # noqa: D417
bar: str, baz: int, run_manager: CallbackManagerForToolRun | None = None
) -> str:
"""The foo.
Args:
bar: The bar.
baz: The baz.
"""
return bar
as_tool = tool(foo3, parse_docstring=True)
args_schema = _schema(as_tool.args_schema)
assert args_schema["description"] == expected["description"]
assert args_schema["properties"] == expected["properties"]
# Test parsing with runtime does not raise error
def foo3_runtime(bar: str, baz: int, runtime: Any) -> str: # noqa: D417
"""The foo.
Args:
bar: The bar.
baz: The baz.
"""
return bar
_ = tool(foo3_runtime, parse_docstring=True)
# Test parameterless tool does not raise error for missing Args section
# in docstring.
def foo4() -> str:
"""The foo."""
return "bar"
as_tool = tool(foo4, parse_docstring=True)
args_schema = _schema(as_tool.args_schema)
assert args_schema["description"] == expected["description"]
def foo5(run_manager: CallbackManagerForToolRun | None = None) -> str:
"""The foo."""
return "bar"
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does test_tool_arg_descriptions() do?
test_tool_arg_descriptions() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/test_tools.py.
Where is test_tool_arg_descriptions() defined?
test_tool_arg_descriptions() is defined in libs/core/tests/unit_tests/test_tools.py at line 1192.
What does test_tool_arg_descriptions() call?
test_tool_arg_descriptions() 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