_infer_arg_descriptions() — langchain Function Reference
Architecture documentation for the _infer_arg_descriptions() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 1a23ba05_08c6_e278_462c_5ad74643f2c9["_infer_arg_descriptions()"] 80cebff4_efbd_4311_85e9_de0dc81a7eee["base.py"] 1a23ba05_08c6_e278_462c_5ad74643f2c9 -->|defined in| 80cebff4_efbd_4311_85e9_de0dc81a7eee ce65f72d_5a31_1cf5_28d0_0114514b29b5["create_schema_from_function()"] ce65f72d_5a31_1cf5_28d0_0114514b29b5 -->|calls| 1a23ba05_08c6_e278_462c_5ad74643f2c9 8d8fb0ce_9186_8b62_ef81_625850eda075["_parse_python_function_docstring()"] 1a23ba05_08c6_e278_462c_5ad74643f2c9 -->|calls| 8d8fb0ce_9186_8b62_ef81_625850eda075 fb3bc5b8_42ae_d4d9_5379_496d34d8490f["_validate_docstring_args_against_annotations()"] 1a23ba05_08c6_e278_462c_5ad74643f2c9 -->|calls| fb3bc5b8_42ae_d4d9_5379_496d34d8490f 9844b114_d1bc_aba8_a452_29f3abc0d0a8["_get_annotation_description()"] 1a23ba05_08c6_e278_462c_5ad74643f2c9 -->|calls| 9844b114_d1bc_aba8_a452_29f3abc0d0a8 style 1a23ba05_08c6_e278_462c_5ad74643f2c9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/tools/base.py lines 196–227
def _infer_arg_descriptions(
fn: Callable,
*,
parse_docstring: bool = False,
error_on_invalid_docstring: bool = False,
) -> tuple[str, dict]:
"""Infer argument descriptions from function docstring and annotations.
Args:
fn: The function to infer descriptions from.
parse_docstring: Whether to parse the docstring for descriptions.
error_on_invalid_docstring: Whether to raise error on invalid docstring.
Returns:
A tuple containing the function description and argument descriptions.
"""
annotations = typing.get_type_hints(fn, include_extras=True)
if parse_docstring:
description, arg_descriptions = _parse_python_function_docstring(
fn, annotations, error_on_invalid_docstring=error_on_invalid_docstring
)
else:
description = inspect.getdoc(fn) or ""
arg_descriptions = {}
if parse_docstring:
_validate_docstring_args_against_annotations(arg_descriptions, annotations)
for arg, arg_type in annotations.items():
if arg in arg_descriptions:
continue
if desc := _get_annotation_description(arg_type):
arg_descriptions[arg] = desc
return description, arg_descriptions
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does _infer_arg_descriptions() do?
_infer_arg_descriptions() is a function in the langchain codebase, defined in libs/core/langchain_core/tools/base.py.
Where is _infer_arg_descriptions() defined?
_infer_arg_descriptions() is defined in libs/core/langchain_core/tools/base.py at line 196.
What does _infer_arg_descriptions() call?
_infer_arg_descriptions() calls 3 function(s): _get_annotation_description, _parse_python_function_docstring, _validate_docstring_args_against_annotations.
What calls _infer_arg_descriptions()?
_infer_arg_descriptions() is called by 1 function(s): create_schema_from_function.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free