tool_specs¶
The Tool Specs module provides definitions and implementations of tool specifications.
This module contains various tool specification classes that support transforming "tool ingredients" such as Python functions and Automa workflows into LLM-callable tools, enabling callable objects to be seamlessly used in agentic systems.
ToolSpec ¶
Bases: Serializable
ToolSpec is an abstract class that represents a tool specification that describes all necessary information about a tool used by the LLM.
ToolSpec and its subclasses are responsible for providing four categories of interfaces: 1. Transformations to LLM Tool: to_tool. 2. Worker Creation: create_worker. 3. Serialization and Deserialization. 4. ToolSpec initialization from raw resources: from_raw.
Source code in bridgic/core/agentic/tool_specs/_base_tool_spec.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
to_tool ¶
abstractmethod Transform this ToolSpec to a Tool object used by LLM.
Returns:
| Type | Description |
|---|---|
Tool | A |
FunctionToolSpec ¶
Bases: ToolSpec
Source code in bridgic/core/agentic/tool_specs/_function_tool_spec.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
from_raw ¶
classmethod from_raw(
func: Callable,
tool_name: Optional[str] = None,
tool_description: Optional[str] = None,
tool_parameters: Optional[Dict[str, Any]] = None,
) -> FunctionToolSpec
Create a FunctionToolSpec from a python function. By default, the tool name, description and parameters' json schema will be extracted from the function's docstring and the parameters' type and description. However, these values can be customized by passing in the corresponding arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func | Callable | The python function to create a FunctionToolSpec from. | required |
tool_name | Optional[str] | The name of the tool. If not provided, the function name will be used. | None |
tool_description | Optional[str] | The description of the tool. If not provided, the function docstring will be used. | None |
tool_parameters | Optional[Dict[str, Any]] | The JSON schema of the tool's parameters. If not provided, the JSON schema will be constructed properly from the parameters' annotations, the function's signature and/or docstring. | None |
Returns:
| Type | Description |
|---|---|
FunctionToolSpec | A new |
Source code in bridgic/core/agentic/tool_specs/_function_tool_spec.py
to_tool ¶
Transform this FunctionToolSpec to a Tool object used by LLM.
Returns:
| Type | Description |
|---|---|
Tool | A |
Source code in bridgic/core/agentic/tool_specs/_function_tool_spec.py
create_worker ¶
create_worker() -> Worker
Create a Worker from the information included in this FunctionToolSpec.
Returns:
| Type | Description |
|---|---|
Worker | A new |
Source code in bridgic/core/agentic/tool_specs/_function_tool_spec.py
AutomaToolSpec ¶
Bases: ToolSpec
Source code in bridgic/core/agentic/tool_specs/_automa_tool_spec.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
from_raw ¶
classmethod from_raw(
automa_cls: Type[Automa],
tool_name: Optional[str] = None,
tool_description: Optional[str] = None,
tool_parameters: Optional[Dict[str, Any]] = None,
**automa_init_kwargs: Dict[str, Any]
) -> AutomaToolSpec
Create an AutomaToolSpec from an Automa class.
Source code in bridgic/core/agentic/tool_specs/_automa_tool_spec.py
to_tool ¶
Transform this AutomaToolSpec to a Tool object used by LLM.
Returns:
| Type | Description |
|---|---|
Tool | A |
Source code in bridgic/core/agentic/tool_specs/_automa_tool_spec.py
as_tool ¶
A decorator that transforms a class to a tool that may be used by LLM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec_func | Callable | The function used to declare the tool spec. Note that this function is not intended to be called directly. | required |