Initialize tool from a function.
from_function(
cls,
func: Callable | None,
name: str,
description: str,
return_direct: bool = False,
args_schema: ArgsSchema | None = None,
coroutine: Callable[..., Awaitable[Any]] | None = None,
**kwargs: Any = {}
) -> Tool| Name | Type | Description |
|---|---|---|
func* | Callable | None | The function to create the tool from. |
name* | str | The name of the tool. |
description* | str | The description of the tool. |
return_direct | bool | Default: FalseWhether to return the output directly. |
args_schema | ArgsSchema | None | Default: NoneThe schema of the tool's input arguments. |
coroutine | Callable[..., Awaitable[Any]] | None | Default: NoneThe asynchronous version of the function. |
**kwargs | Any | Default: {}Additional arguments to pass to the tool. |