dspy.Tool
dspy.Tool(func: Callable, name: Optional[str] = None, desc: Optional[str] = None, args: Optional[dict[str, Any]] = None, arg_types: Optional[dict[str, Any]] = None, arg_desc: Optional[dict[str, str]] = None)
Tool class.
This class is used to simplify the creation of tools for tool calling (function calling) in LLMs. Only supports functions for now.
Initialize the Tool class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func
|
Callable
|
The actual function that is being wrapped by the tool. |
required |
name
|
Optional[str]
|
The name of the tool. Defaults to None. |
None
|
desc
|
Optional[str]
|
The description of the tool. Defaults to None. |
None
|
args
|
Optional[dict[str, Any]]
|
The args of the tool, represented as a dictionary from arg name to arg's json schema. Defaults to None. |
None
|
arg_types
|
Optional[dict[str, Any]]
|
The argument types of the tool, represented as a dictionary from arg name to the type of the argument. Defaults to None. |
None
|
arg_desc
|
Optional[dict[str, str]]
|
Descriptions for each arg, represented as a dictionary from arg name to description string. Defaults to None. |
None
|