create_schema_from_function#
- langchain_core.tools.base.create_schema_from_function(model_name: str, func: Callable, *, filter_args: Sequence[str] | None = None, parse_docstring: bool = False, error_on_invalid_docstring: bool = False, include_injected: bool = True) Type[BaseModel] [source]#
Create a pydantic schema from a functionโs signature.
- Parameters:
model_name (str) โ Name to assign to the generated pydantic schema.
func (Callable) โ Function to generate the schema from.
filter_args (Sequence[str] | None) โ Optional list of arguments to exclude from the schema. Defaults to FILTERED_ARGS.
parse_docstring (bool) โ Whether to parse the functionโs docstring for descriptions for each argument. Defaults to False.
error_on_invalid_docstring (bool) โ if
parse_docstring
is provided, configure whether to raise ValueError on invalid Google Style docstrings. Defaults to False.include_injected (bool) โ Whether to include injected arguments in the schema. Defaults to True, since we want to include them in the schema when validating tool inputs.
- Returns:
A pydantic model with the same arguments as the function.
- Return type:
Type[BaseModel]