tools
__all__ = ['BaseTool', 'BaseImageGenerationTool', 'CalculatorTool', 'WebSearchTool', 'WebScraperTool', 'SqlTool', 'EmailTool', 'RestApiTool', 'FileManagerTool', 'VectorStoreTool', 'DateTimeTool', 'ComputerTool', 'PromptImageGenerationTool', 'VariationImageGenerationTool', 'InpaintingImageGenerationTool', 'OutpaintingImageGenerationTool', 'GriptapeCloudToolTool', 'StructureRunTool', 'ImageQueryTool', 'RagTool', 'TextToSpeechTool', 'AudioTranscriptionTool', 'ExtractionTool', 'PromptSummaryTool', 'QueryTool', 'StructuredOutputTool']
module-attribute
AudioTranscriptionTool
Bases: BaseTool
A tool that can be used to generate transcriptions from input audio.
Source code in griptape/tools/audio_transcription/tool.py
audio_loader: AudioLoader = field(default=Factory(lambda: AudioLoader()), kw_only=True)
class-attribute
instance-attribute
audio_transcription_driver: BaseAudioTranscriptionDriver = field(kw_only=True)
class-attribute
instance-attribute
transcribe_audio_from_disk(params)
Source code in griptape/tools/audio_transcription/tool.py
transcribe_audio_from_memory(params)
Source code in griptape/tools/audio_transcription/tool.py
BaseImageGenerationTool
Bases: ArtifactFileOutputMixin
, BaseTool
A base class for tools that generate images from text prompts.
Source code in griptape/tools/base_image_generation_tool.py
NEGATIVE_PROMPT_DESCRIPTION = "Features and qualities to avoid in the generated image. Affirmatively describe what to avoid, for example: to avoid the color red, include 'red' rather than 'no red'."
class-attribute
instance-attribute
PROMPT_DESCRIPTION = 'Features and qualities to include in the generated image, descriptive and succinct.'
class-attribute
instance-attribute
BaseTool
Bases: ActivityMixin
, SerializableMixin
, RunnableMixin['BaseTool']
, 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
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 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
|
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, metadata={'serializable': True})
class-attribute
instance-attribute
has_requirements: bool
property
input_memory: Optional[list[TaskMemory]] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
install_dependencies_on_init: bool = field(default=True, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
name: str = field(default=Factory(lambda self: self.__class__.__name__, takes_self=True), kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
off_prompt: bool = field(default=False, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
output_memory: Optional[dict[str, list[TaskMemory]]] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
requirements_path: str
property
verbose: bool = field(default=False, kw_only=True, metadata={'serializable': 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
are_requirements_met(requirements_path)
Source code in griptape/tools/base_tool.py
before_run(activity, subtask, action)
find_input_memory(memory_name)
install_dependencies(env=None)
Source code in griptape/tools/base_tool.py
run(activity, subtask, action)
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. |
Source code in griptape/tools/base_tool.py
tool_dir()
try_run(activity, subtask, action, value)
Source code in griptape/tools/base_tool.py
validate()
validate_output_memory(_, output_memory)
Source code in griptape/tools/base_tool.py
CalculatorTool
Bases: BaseTool
Source code in griptape/tools/calculator/tool.py
calculate(params)
Source code in griptape/tools/calculator/tool.py
ComputerTool
Bases: BaseTool
Source code in griptape/tools/computer/tool.py
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 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 |
|
container_workdir: str = field(default='/griptape', kw_only=True)
class-attribute
instance-attribute
docker_client: DockerClient = field(default=Factory(lambda self: self.default_docker_client(), takes_self=True), kw_only=True)
class-attribute
instance-attribute
dockerfile_path: str = field(default=Factory(lambda self: f'{os.path.join(self.tool_dir(), 'resources/Dockerfile')}', takes_self=True), kw_only=True)
class-attribute
instance-attribute
env_vars: dict = field(factory=dict, kw_only=True)
class-attribute
instance-attribute
local_workdir: Optional[str] = field(default=None, kw_only=True)
class-attribute
instance-attribute
requirements_txt_path: str = field(default=Factory(lambda self: f'{os.path.join(self.tool_dir(), 'resources/requirements.txt')}', takes_self=True), kw_only=True)
class-attribute
instance-attribute
__attrs_post_init__()
Source code in griptape/tools/computer/tool.py
__del__()
build_image(tool)
Source code in griptape/tools/computer/tool.py
container_name(tool)
default_docker_client()
dependencies()
execute_code(params)
Source code in griptape/tools/computer/tool.py
execute_code_in_container(filename, code)
Source code in griptape/tools/computer/tool.py
execute_command(params)
Source code in griptape/tools/computer/tool.py
execute_command_in_container(command)
Source code in griptape/tools/computer/tool.py
image_name(tool)
install_dependencies(env=None)
remove_existing_container(name)
Source code in griptape/tools/computer/tool.py
validate_docker_client(_, docker_client)
Source code in griptape/tools/computer/tool.py
DateTimeTool
Bases: BaseTool
Source code in griptape/tools/date_time/tool.py
get_current_datetime()
Source code in griptape/tools/date_time/tool.py
get_relative_datetime(params)
Source code in griptape/tools/date_time/tool.py
EmailTool
Bases: BaseTool
Tool for working with email.
Attributes:
Name | Type | Description |
---|---|---|
username |
Optional[str]
|
Username/email address used to send email via the SMTP protocol and retrieve email via the IMAP protocol. Example: bender@futurama.com. |
password |
Optional[str]
|
Password used to send email via the SMTP protocol and retrieve email via the IMAP protocol. If using gmail, this would be an App Password. |
email_max_retrieve_count |
Optional[int]
|
Used to limit the number of messages retrieved during any given activities. |
smtp_host |
Optional[str]
|
Hostname or url of the SMTP server. Example: smtp.gmail.com. Required when using the |
smtp_port |
Optional[int]
|
Port of the SMTP server. Example: 465. Required when using the |
smtp_use_ssl |
bool
|
Whether to use SSL when sending email via the SMTP protocol. |
smtp_user |
Optional[str]
|
Username/email address used to send email via the SMTP protocol. Overrides username for SMTP only. Required when using the |
smtp_password |
Optional[str]
|
Password to send email via the SMTP protocol. Overrides password for SMTP only. Required when using the |
imap_url |
Optional[str]
|
Hostname or url of the IMAP server. Example: imap.gmail.com. Required when using the |
imap_user |
Optional[str]
|
Username/email address used to retrieve email via the IMAP protocol. Overrides username for IMAP only. Required when using the |
imap_password |
Optional[str]
|
Password to retrieve email via the IMAP protocol. Overrides password for IMAP only. Required when using the |
mailboxes |
dict[str, Optional[str]]
|
Descriptions of mailboxes available for retrieving email via the IMAP protocol. Required when using the |
email_loader |
EmailLoader
|
Instance of |
Source code in griptape/tools/email/tool.py
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 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
email_loader: EmailLoader = field(default=Factory(lambda self: EmailLoader(imap_url=self.imap_url, username=self.imap_user, password=self.imap_password), takes_self=True), kw_only=True)
class-attribute
instance-attribute
email_max_retrieve_count: Optional[int] = field(default=None, kw_only=True)
class-attribute
instance-attribute
imap_password: Optional[str] = field(default=Factory(lambda self: self.password, takes_self=True), kw_only=True)
class-attribute
instance-attribute
imap_url: Optional[str] = field(default=None, kw_only=True)
class-attribute
instance-attribute
imap_user: Optional[str] = field(default=Factory(lambda self: self.username, takes_self=True), kw_only=True)
class-attribute
instance-attribute
mailboxes: dict[str, Optional[str]] = field(default=None, kw_only=True)
class-attribute
instance-attribute
password: Optional[str] = field(default=None, kw_only=True)
class-attribute
instance-attribute
smtp_host: Optional[str] = field(default=None, kw_only=True)
class-attribute
instance-attribute
smtp_password: Optional[str] = field(default=Factory(lambda self: self.password, takes_self=True), kw_only=True)
class-attribute
instance-attribute
smtp_port: Optional[int] = field(default=None, kw_only=True)
class-attribute
instance-attribute
smtp_use_ssl: bool = field(default=True, kw_only=True)
class-attribute
instance-attribute
smtp_user: Optional[str] = field(default=Factory(lambda self: self.username, takes_self=True), kw_only=True)
class-attribute
instance-attribute
username: Optional[str] = field(default=None, kw_only=True)
class-attribute
instance-attribute
retrieve(params)
Source code in griptape/tools/email/tool.py
send(params)
Source code in griptape/tools/email/tool.py
ExtractionTool
Tool for using an Extraction Engine.
Attributes:
Name | Type | Description |
---|---|---|
extraction_engine |
BaseExtractionEngine
|
|
Source code in griptape/tools/extraction/tool.py
extraction_engine: BaseExtractionEngine = field()
class-attribute
instance-attribute
extract(params)
Source code in griptape/tools/extraction/tool.py
FileManagerTool
Bases: BaseTool
FileManagerTool is a tool that can be used to list, load, and save files.
Attributes:
Name | Type | Description |
---|---|---|
file_manager_driver |
BaseFileManagerDriver
|
File Manager Driver to use to list, load, and save files. |
Source code in griptape/tools/file_manager/tool.py
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 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 |
|
file_manager_driver: BaseFileManagerDriver = field(default=Factory(lambda: LocalFileManagerDriver()), kw_only=True)
class-attribute
instance-attribute
loaders: dict[str, loaders.BaseLoader] = field(default=Factory(lambda self: {'application/pdf': loaders.PdfLoader(file_manager_driver=self.file_manager_driver), 'text/csv': loaders.CsvLoader(file_manager_driver=self.file_manager_driver), 'text': loaders.TextLoader(file_manager_driver=self.file_manager_driver), 'image': loaders.ImageLoader(file_manager_driver=self.file_manager_driver), 'application/octet-stream': BlobLoader(file_manager_driver=self.file_manager_driver)}, takes_self=True), kw_only=True)
class-attribute
instance-attribute
list_files_from_disk(params)
Source code in griptape/tools/file_manager/tool.py
load_files_from_disk(params)
Source code in griptape/tools/file_manager/tool.py
save_content_to_file(params)
Source code in griptape/tools/file_manager/tool.py
save_memory_artifacts_to_disk(params)
Source code in griptape/tools/file_manager/tool.py
GriptapeCloudToolTool
Bases: BaseGriptapeCloudTool
Runs a Griptape Cloud hosted Tool.
Attributes:
Name | Type | Description |
---|---|---|
tool_id |
str
|
The ID of the tool to run. |
Source code in griptape/tools/griptape_cloud_tool/tool.py
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 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
tool_id: str = field(kw_only=True)
class-attribute
instance-attribute
__attrs_post_init__()
__extract_schema_from_ref(schema, schema_ref)
Extracts a schema from a $ref if present, resolving it into native schema properties.
Source code in griptape/tools/griptape_cloud_tool/tool.py
ImageQueryTool
Bases: BaseTool
Source code in griptape/tools/image_query/tool.py
image_loader: ImageLoader = field(default=Factory(lambda: ImageLoader()), kw_only=True)
class-attribute
instance-attribute
prompt_driver: BasePromptDriver = field(kw_only=True)
class-attribute
instance-attribute
query_image_from_disk(params)
Source code in griptape/tools/image_query/tool.py
query_images_from_memory(params)
Source code in griptape/tools/image_query/tool.py
InpaintingImageGenerationTool
Bases: BaseImageGenerationTool
A tool that can be used to generate prompted inpaintings of an image.
Attributes:
Name | Type | Description |
---|---|---|
image_generation_driver |
BaseImageGenerationDriver
|
The image generation driver used to generate the image. |
output_dir |
BaseImageGenerationDriver
|
If provided, the generated image will be written to disk in output_dir. |
output_file |
BaseImageGenerationDriver
|
If provided, the generated image will be written to disk as output_file. |
Source code in griptape/tools/inpainting_image_generation/tool.py
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 115 116 117 118 |
|
image_generation_driver: BaseImageGenerationDriver = field(kw_only=True)
class-attribute
instance-attribute
image_loader: ImageLoader = field(default=ImageLoader(), kw_only=True)
class-attribute
instance-attribute
image_inpainting_from_file(params)
Source code in griptape/tools/inpainting_image_generation/tool.py
image_inpainting_from_memory(params)
Source code in griptape/tools/inpainting_image_generation/tool.py
OutpaintingImageGenerationTool
Bases: BaseImageGenerationTool
A tool that can be used to generate prompted outpaintings of an image.
Attributes:
Name | Type | Description |
---|---|---|
image_generation_driver |
BaseImageGenerationDriver
|
The image generation driver used to generate the image. |
output_dir |
BaseImageGenerationDriver
|
If provided, the generated image will be written to disk in output_dir. |
output_file |
BaseImageGenerationDriver
|
If provided, the generated image will be written to disk as output_file. |
Source code in griptape/tools/outpainting_image_generation/tool.py
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 |
|