tasks
__all__ = ['BaseTask', 'BaseTextInputTask', 'BaseMultiTextInputTask', 'PromptTask', 'ActionsSubtask', 'ToolkitTask', 'TextSummaryTask', 'ToolTask', 'RagTask', 'ExtractionTask', 'BaseImageGenerationTask', 'CodeExecutionTask', 'PromptImageGenerationTask', 'VariationImageGenerationTask', 'InpaintingImageGenerationTask', 'OutpaintingImageGenerationTask', 'ImageQueryTask', 'BaseAudioGenerationTask', 'TextToSpeechTask', 'StructureRunTask', 'AudioTranscriptionTask']
module-attribute
ActionsSubtask
Bases: BaseTask
Source code in griptape/tasks/actions_subtask.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 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 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
|
ACTIONS_PATTERN = '(?s)Actions:[^\\[]*(\\[.*\\])'
class-attribute
instance-attribute
ANSWER_PATTERN = '(?s)^Answer:\\s?([\\s\\S]*)$'
class-attribute
instance-attribute
THOUGHT_PATTERN = '(?s)^Thought:\\s*(.*?)$'
class-attribute
instance-attribute
actions: list[ToolAction] = field(factory=list, kw_only=True)
class-attribute
instance-attribute
children: list[BaseTask]
property
input: TextArtifact | ListArtifact
property
writable
origin_task: BaseTask
property
output: Optional[BaseArtifact] = field(default=None, init=False)
class-attribute
instance-attribute
parent_task_id: Optional[str] = field(default=None, kw_only=True)
class-attribute
instance-attribute
parents: list[BaseTask]
property
thought: Optional[str] = field(default=None, kw_only=True)
class-attribute
instance-attribute
__init_from_artifacts(artifacts)
Parses the input Artifacts to extract the thought and actions.
Text Artifacts are used to extract the thought, and ToolAction Artifacts are used to extract the actions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
artifacts |
ListArtifact
|
The input Artifacts. |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in griptape/tasks/actions_subtask.py
__init_from_prompt(value)
Source code in griptape/tasks/actions_subtask.py
__parse_actions(actions_matches)
Source code in griptape/tasks/actions_subtask.py
__process_action_object(action_object)
Source code in griptape/tasks/actions_subtask.py
__validate_action(action)
Source code in griptape/tasks/actions_subtask.py
actions_to_dicts()
Source code in griptape/tasks/actions_subtask.py
actions_to_json()
add_child(child)
add_parent(parent)
after_run()
Source code in griptape/tasks/actions_subtask.py
attach_to(parent_task)
Source code in griptape/tasks/actions_subtask.py
before_run()
Source code in griptape/tasks/actions_subtask.py
execute_action(action)
Source code in griptape/tasks/actions_subtask.py
execute_actions(actions)
run()
Source code in griptape/tasks/actions_subtask.py
AudioTranscriptionTask
Bases: BaseAudioInputTask
Source code in griptape/tasks/audio_transcription_task.py
audio_transcription_engine: AudioTranscriptionEngine = field(default=Factory(lambda: AudioTranscriptionEngine()), kw_only=True)
class-attribute
instance-attribute
BaseAudioGenerationTask
Bases: ArtifactFileOutputMixin
, RuleMixin
, BaseTask
, ABC
Source code in griptape/tasks/base_audio_generation_task.py
after_run()
BaseImageGenerationTask
Bases: ArtifactFileOutputMixin
, RuleMixin
, BaseTask
, ABC
Provides a base class for image generation-related tasks.
Attributes:
Name | Type | Description |
---|---|---|
negative_rulesets |
list[Ruleset]
|
List of negatively-weighted rulesets applied to the text prompt, if supported by the driver. |
negative_rules |
list[Rule]
|
List of negatively-weighted rules applied to the text prompt, if supported by the driver. |
output_dir |
list[Rule]
|
If provided, the generated image will be written to disk in output_dir. |
output_file |
list[Rule]
|
If provided, the generated image will be written to disk as output_file. |
Source code in griptape/tasks/base_image_generation_task.py
NEGATIVE_RULESET_NAME = 'Negative Ruleset'
class-attribute
instance-attribute
all_negative_rulesets: list[Ruleset]
property
negative_rules: list[Rule] = field(factory=list, kw_only=True)
class-attribute
instance-attribute
negative_rulesets: list[Ruleset] = field(factory=list, kw_only=True)
class-attribute
instance-attribute
validate_negative_rules(_, negative_rules)
Source code in griptape/tasks/base_image_generation_task.py
validate_negative_rulesets(_, negative_rulesets)
Source code in griptape/tasks/base_image_generation_task.py
BaseMultiTextInputTask
Bases: RuleMixin
, BaseTask
, ABC
Source code in griptape/tasks/base_multi_text_input_task.py
DEFAULT_INPUT_TEMPLATE = '{{ args[0] }}'
class-attribute
instance-attribute
input: ListArtifact
property
writable
after_run()
BaseTask
Bases: FuturesExecutorMixin
, ABC
Source code in griptape/tasks/base_task.py
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 |
|
child_ids: list[str] = field(factory=list, kw_only=True)
class-attribute
instance-attribute
children: list[BaseTask]
property
context: dict[str, Any] = field(factory=dict, kw_only=True)
class-attribute
instance-attribute
full_context: dict[str, Any]
property
id: str = field(default=Factory(lambda: uuid.uuid4().hex), kw_only=True)
class-attribute
instance-attribute
input: BaseArtifact
abstractmethod
property
max_meta_memory_entries: Optional[int] = field(default=20, kw_only=True)
class-attribute
instance-attribute
meta_memories: list[BaseMetaEntry]
property
output: Optional[BaseArtifact] = field(default=None, init=False)
class-attribute
instance-attribute
parent_ids: list[str] = field(factory=list, kw_only=True)
class-attribute
instance-attribute
parent_outputs: dict[str, str]
property
parents: list[BaseTask]
property
parents_output_text: str
property
state: State = field(default=State.PENDING, kw_only=True)
class-attribute
instance-attribute
structure: Optional[Structure] = field(default=None, kw_only=True)
class-attribute
instance-attribute
State
__attrs_post_init__()
__lshift__(other)
__rshift__(other)
__str__()
add_child(child)
Source code in griptape/tasks/base_task.py
add_children(children)
add_parent(parent)
Source code in griptape/tasks/base_task.py
add_parents(parents)
after_run()
Source code in griptape/tasks/base_task.py
before_run()
Source code in griptape/tasks/base_task.py
can_execute()
execute()
Source code in griptape/tasks/base_task.py
is_executing()
is_finished()
is_pending()
preprocess(structure)
reset()
BaseTextInputTask
Bases: RuleMixin
, BaseTask
, ABC
Source code in griptape/tasks/base_text_input_task.py
DEFAULT_INPUT_TEMPLATE = '{{ args[0] }}'
class-attribute
instance-attribute
input: TextArtifact
property
writable
after_run()
CodeExecutionTask
Bases: BaseTextInputTask
Source code in griptape/tasks/code_execution_task.py
ExtractionTask
Bases: BaseTextInputTask
Source code in griptape/tasks/extraction_task.py
args: dict = field(kw_only=True, factory=dict)
class-attribute
instance-attribute
extraction_engine: BaseExtractionEngine = field(kw_only=True)
class-attribute
instance-attribute
ImageQueryTask
Bases: BaseTask
A task that executes a natural language query on one or more input images.
Accepts a text prompt and a list of images as input in one of the following formats: - tuple of (template string, list[ImageArtifact]) - tuple of (TextArtifact, list[ImageArtifact]) - Callable that returns a tuple of (TextArtifact, list[ImageArtifact]).
Attributes:
Name | Type | Description |
---|---|---|
image_query_engine |
ImageQueryEngine
|
The engine used to execute the query. |
Source code in griptape/tasks/image_query_task.py
image_query_engine: ImageQueryEngine = field(default=Factory(lambda: ImageQueryEngine()), kw_only=True)
class-attribute
instance-attribute
input: ListArtifact
property
writable
run()
Source code in griptape/tasks/image_query_task.py
InpaintingImageGenerationTask
Bases: BaseImageGenerationTask
A task that modifies a select region within an image using a mask.
Accepts a text prompt, image, and mask as input in one of the following formats: - tuple of (template string, ImageArtifact, ImageArtifact) - tuple of (TextArtifact, ImageArtifact, ImageArtifact) - Callable that returns a tuple of (TextArtifact, ImageArtifact, ImageArtifact).
Attributes:
Name | Type | Description |
---|---|---|
image_generation_engine |
InpaintingImageGenerationEngine
|
The engine used to generate the image. |
negative_rulesets |
InpaintingImageGenerationEngine
|
List of negatively-weighted rulesets applied to the text prompt, if supported by the driver. |
negative_rules |
InpaintingImageGenerationEngine
|
List of negatively-weighted rules applied to the text prompt, if supported by the driver. |
output_dir |
InpaintingImageGenerationEngine
|
If provided, the generated image will be written to disk in output_dir. |
output_file |
InpaintingImageGenerationEngine
|
If provided, the generated image will be written to disk as output_file. |
Source code in griptape/tasks/inpainting_image_generation_task.py
image_generation_engine: InpaintingImageGenerationEngine = field(default=Factory(lambda: InpaintingImageGenerationEngine()), kw_only=True)
class-attribute
instance-attribute
input: ListArtifact
property
writable
run()
Source code in griptape/tasks/inpainting_image_generation_task.py
OutpaintingImageGenerationTask
Bases: BaseImageGenerationTask
A task that modifies an image outside the bounds of a mask.
Accepts a text prompt, image, and mask as input in one of the following formats: - tuple of (template string, ImageArtifact, ImageArtifact) - tuple of (TextArtifact, ImageArtifact, ImageArtifact) - Callable that returns a tuple of (TextArtifact, ImageArtifact, ImageArtifact).
Attributes:
Name | Type | Description |
---|---|---|
image_generation_engine |
OutpaintingImageGenerationEngine
|
The engine used to generate the image. |
negative_rulesets |
OutpaintingImageGenerationEngine
|
List of negatively-weighted rulesets applied to the text prompt, if supported by the driver. |
negative_rules |
OutpaintingImageGenerationEngine
|
List of negatively-weighted rules applied to the text prompt, if supported by the driver. |
output_dir |
OutpaintingImageGenerationEngine
|
If provided, the generated image will be written to disk in output_dir. |
output_file |
OutpaintingImageGenerationEngine
|
If provided, the generated image will be written to disk as output_file. |
Source code in griptape/tasks/outpainting_image_generation_task.py
image_generation_engine: OutpaintingImageGenerationEngine = field(default=Factory(lambda: OutpaintingImageGenerationEngine()), kw_only=True)
class-attribute
instance-attribute
input: ListArtifact
property
writable
run()
Source code in griptape/tasks/outpainting_image_generation_task.py
PromptImageGenerationTask
Bases: BaseImageGenerationTask
Used to generate an image from a text prompt.
Accepts prompt as input in one of the following formats: - template string - TextArtifact - Callable that returns a TextArtifact.
Attributes:
Name | Type | Description |
---|---|---|
image_generation_engine |
PromptImageGenerationEngine
|
The engine used to generate the image. |
negative_rulesets |
PromptImageGenerationEngine
|
List of negatively-weighted rulesets applied to the text prompt, if supported by the driver. |
negative_rules |
PromptImageGenerationEngine
|
List of negatively-weighted rules applied to the text prompt, if supported by the driver. |
output_dir |
PromptImageGenerationEngine
|
If provided, the generated image will be written to disk in output_dir. |
output_file |
PromptImageGenerationEngine
|
If provided, the generated image will be written to disk as output_file. |
Source code in griptape/tasks/prompt_image_generation_task.py
DEFAULT_INPUT_TEMPLATE = '{{ args[0] }}'
class-attribute
instance-attribute
image_generation_engine: PromptImageGenerationEngine = field(default=Factory(lambda: PromptImageGenerationEngine()), kw_only=True)
class-attribute
instance-attribute
input: TextArtifact
property
writable
run()
Source code in griptape/tasks/prompt_image_generation_task.py
PromptTask
Source code in griptape/tasks/prompt_task.py
generate_system_template: Callable[[PromptTask], str] = field(default=Factory(lambda self: self.default_system_template_generator, takes_self=True), kw_only=True)
class-attribute
instance-attribute
input: BaseArtifact
property
writable
output: Optional[BaseArtifact] = field(default=None, init=False)
class-attribute
instance-attribute
prompt_driver: BasePromptDriver = field(default=Factory(lambda: Defaults.drivers_config.prompt_driver), kw_only=True)
class-attribute
instance-attribute
prompt_stack: PromptStack
property
after_run()
before_run()
default_system_template_generator(_)
RagTask
Bases: BaseTextInputTask
Source code in griptape/tasks/rag_task.py
rag_engine: RagEngine = field(kw_only=True, default=Factory(lambda: RagEngine()))
class-attribute
instance-attribute
StructureRunTask
Bases: BaseMultiTextInputTask
Task to run a Structure.
Attributes:
Name | Type | Description |
---|---|---|
driver |
BaseStructureRunDriver
|
Driver to run the Structure. |
Source code in griptape/tasks/structure_run_task.py
TextSummaryTask
Bases: BaseTextInputTask
Source code in griptape/tasks/text_summary_task.py
summary_engine: BaseSummaryEngine = field(default=Factory(lambda: PromptSummaryEngine()), kw_only=True)
class-attribute
instance-attribute
TextToSpeechTask
Bases: BaseAudioGenerationTask
Source code in griptape/tasks/text_to_speech_task.py
DEFAULT_INPUT_TEMPLATE = '{{ args[0] }}'
class-attribute
instance-attribute
input: TextArtifact
property
writable
text_to_speech_engine: TextToSpeechEngine = field(default=Factory(lambda: TextToSpeechEngine()), kw_only=True)
class-attribute
instance-attribute
run()
Source code in griptape/tasks/text_to_speech_task.py
ToolTask
Bases: PromptTask
, ActionsSubtaskOriginMixin
Source code in griptape/tasks/tool_task.py
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 |
|
ACTION_PATTERN = '(?s)[^{]*({.*})'
class-attribute
instance-attribute
prompt_stack: PromptStack
property
subtask: Optional[ActionsSubtask] = field(default=None, kw_only=True)
class-attribute
instance-attribute
task_memory: Optional[TaskMemory] = field(default=None, kw_only=True)
class-attribute
instance-attribute
tool: BaseTool = field(kw_only=True)
class-attribute
instance-attribute
__attrs_post_init__()
actions_schema()
add_subtask(subtask)
default_system_template_generator(_)
Source code in griptape/tasks/tool_task.py
find_memory(memory_name)
find_subtask(subtask_id)
find_tool(tool_name)
preprocess(structure)
run()
Source code in griptape/tasks/tool_task.py
set_default_tools_memory(memory)
Source code in griptape/tasks/tool_task.py
ToolkitTask
Bases: PromptTask
, ActionsSubtaskOriginMixin
Source code in griptape/tasks/toolkit_task.py
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 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 |
|