| Name | Type | Description |
|---|---|---|
func | Callable | None | Default: NoneThe function from which to create a tool. |
coroutine | Callable[..., Awaitable[Any]] | None | Default: NoneThe async function from which to create a tool. |
name | str | None | Default: None |
description | str | None | Default: None |
return_direct | bool | Default: False |
args_schema | ArgsSchema | None | Default: None |
infer_schema | bool | Default: True |
response_format | Literal['content', 'content_and_artifact'] | Default: 'content' |
parse_docstring | bool | Default: False |
error_on_invalid_docstring | bool | Default: False |
**kwargs | Any | Default: {} |
Create tool from a given function.
A classmethod that helps to create a tool from a function.
The name of the tool.
Defaults to the function name.
The description of the tool.
Defaults to the function docstring.
Whether to return the result directly or as a callback.
The schema of the tool's input arguments.
Whether to infer the schema from the function's signature.
The tool response format.
If 'content' then the output of the tool is interpreted as the
contents of a ToolMessage. If 'content_and_artifact' then the output
is expected to be a two-tuple corresponding to the (content, artifact)
of a ToolMessage.
If infer_schema and parse_docstring, will attempt
to parse parameter descriptions from Google Style function docstrings.
if parse_docstring is provided, configure
whether to raise ValueError on invalid Google Style docstrings.
Additional arguments to pass to the tool