base_tool
BaseTool
Bases: ActivityMixin
, ABC
Abstract class for all tools to inherit from for.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Tool name. |
input_memory |
Optional[list[TaskMemory]]
|
TaskMemory available in tool activities. Gets automatically set if None. |
output_memory |
Optional[dict[str, list[TaskMemory]]]
|
TaskMemory that activities write to be default. Gets automatically set if None. |
install_dependencies_on_init |
bool
|
Determines whether dependencies from the tool requirements.txt file are installed in init. |
dependencies_install_directory |
Optional[str]
|
Custom dependency install directory. |
verbose |
bool
|
Determines whether tool operations (such as dependency installation) should be verbose. |
off_prompt |
bool
|
Determines whether tool activity output goes to the output memory. |
Source code in griptape/tools/base_tool.py
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 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 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
|
REQUIREMENTS_FILE = 'requirements.txt'
class-attribute
instance-attribute
abs_dir_path: str
property
abs_file_path: str
property
dependencies_install_directory: Optional[str] = field(default=None, kw_only=True)
class-attribute
instance-attribute
input_memory: Optional[list[TaskMemory]] = field(default=None, kw_only=True)
class-attribute
instance-attribute
install_dependencies_on_init: bool = field(default=True, kw_only=True)
class-attribute
instance-attribute
name: str = field(default=Factory(lambda self: self.__class__.__name__, takes_self=True), kw_only=True)
class-attribute
instance-attribute
off_prompt: bool = field(default=False, kw_only=True)
class-attribute
instance-attribute
output_memory: Optional[dict[str, list[TaskMemory]]] = field(default=None, kw_only=True)
class-attribute
instance-attribute
requirements_path: str
property
verbose: bool = field(default=False, kw_only=True)
class-attribute
instance-attribute
__attrs_post_init__()
activity_schemas()
Source code in griptape/tools/base_tool.py
after_run(activity, subtask, action, value)
Source code in griptape/tools/base_tool.py
before_run(activity, subtask, action)
execute(activity, subtask, action)
Source code in griptape/tools/base_tool.py
find_input_memory(memory_name)
install_dependencies(env=None)
Source code in griptape/tools/base_tool.py
run(activity, subtask, action, value)
Source code in griptape/tools/base_tool.py
schema()
to_native_tool_name(activity)
Converts a Tool's name and an Activity into to a native tool name.
The native tool name is a combination of the Tool's name and the Activity's name. The Tool's name may only contain letters and numbers, and the Activity's name may only contain letters, numbers, and underscores.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
activity |
Callable
|
Activity to convert |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Native tool name. |