Tasks
__all__ = ['BaseTask', 'BaseTextInputTask', 'BaseMultiTextInputTask', 'PromptTask', 'ActionsSubtask', 'ToolkitTask', 'TextSummaryTask', 'ToolTask', 'TextQueryTask', 'ExtractionTask', 'CsvExtractionTask', 'JsonExtractionTask', 'BaseImageGenerationTask', 'CodeExecutionTask', 'PromptImageGenerationTask', 'VariationImageGenerationTask', 'InpaintingImageGenerationTask', 'OutpaintingImageGenerationTask', 'ImageQueryTask', 'StructureRunTask']
module-attribute
ActionsSubtask
Bases: BaseTextInputTask
Source code in griptape/tasks/actions_subtask.py
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 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 |
|
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[Action] = field(factory=list, kw_only=True)
class-attribute
instance-attribute
children: list[BaseTask]
property
input: TextArtifact
property
writable
origin_task: BaseTask
property
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
Action
Source code in griptape/tasks/actions_subtask.py
input: dict = field()
class-attribute
instance-attribute
name: str = field()
class-attribute
instance-attribute
path: Optional[str] = field(default=None)
class-attribute
instance-attribute
tag: str = field()
class-attribute
instance-attribute
tool: Optional[BaseTool] = field(default=None)
class-attribute
instance-attribute
__error_to_action(error)
__init_from_prompt(value)
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)
before_run()
Source code in griptape/tasks/actions_subtask.py
execute_action(action)
Source code in griptape/tasks/actions_subtask.py
execute_actions(actions)
Source code in griptape/tasks/actions_subtask.py
run()
Source code in griptape/tasks/actions_subtask.py
BaseImageGenerationTask
Bases: ImageArtifactFileOutputMixin
, 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: tuple[TextArtifact, ...]
property
writable
after_run()
BaseTask
Bases: ABC
Source code in griptape/tasks/base_task.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 |
|
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
futures_executor: futures.Executor = field(default=Factory(lambda: futures.ThreadPoolExecutor()), kw_only=True)
class-attribute
instance-attribute
id: str = field(default=Factory(lambda: uuid.uuid4().hex), kw_only=True)
class-attribute
instance-attribute
input: BaseArtifact | tuple[BaseArtifact, ...] | tuple[BaseArtifact, Sequence[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
parents: list[BaseTask]
property
state: State = field(default=State.PENDING, kw_only=True)
class-attribute
instance-attribute
structure: Optional[Structure] = field(default=None, init=False)
class-attribute
instance-attribute
State
__str__()
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
run_fn: Callable[[CodeExecutionTask], BaseArtifact] = field(kw_only=True)
class-attribute
instance-attribute
CsvExtractionTask
Bases: ExtractionTask
Source code in griptape/tasks/csv_extraction_task.py
extraction_engine: CsvExtractionEngine
property
writable
ExtractionTask
Bases: BaseTextInputTask
Source code in griptape/tasks/extraction_task.py
args: dict = field(kw_only=True)
class-attribute
instance-attribute
extraction_engine: BaseExtractionEngine
property
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
property
writable
input: tuple[TextArtifact, list[ImageArtifact]]
property
writable
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
property
writable
input: tuple[TextArtifact, ImageArtifact, ImageArtifact]
property
writable
run()
Source code in griptape/tasks/inpainting_image_generation_task.py
JsonExtractionTask
Bases: ExtractionTask
Source code in griptape/tasks/json_extraction_task.py
extraction_engine: JsonExtractionEngine
property
writable
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
property
writable
input: tuple[TextArtifact, ImageArtifact, ImageArtifact]
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
property
writable
input: TextArtifact
property
writable
run()
Source code in griptape/tasks/prompt_image_generation_task.py
PromptTask
Bases: BaseTextInputTask
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
output: Optional[BaseArtifact] = field(default=None, init=False)
class-attribute
instance-attribute
prompt_driver: BasePromptDriver
property
prompt_stack: PromptStack
property
default_system_template_generator(_)
preprocess(structure)
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
TextQueryTask
Bases: BaseTextInputTask
Source code in griptape/tasks/text_query_task.py
loader: TextLoader = field(default=Factory(lambda: TextLoader()), kw_only=True)
class-attribute
instance-attribute
namespace: Optional[str] = field(default=None, kw_only=True)
class-attribute
instance-attribute
query_engine: BaseQueryEngine
property
writable
top_n: Optional[int] = field(default=None, kw_only=True)
class-attribute
instance-attribute
TextSummaryTask
Bases: BaseTextInputTask
Source code in griptape/tasks/text_summary_task.py
ToolTask
Bases: PromptTask
, ActionsSubtaskOriginMixin
Source code in griptape/tasks/tool_task.py
ACTION_PATTERN = '(?s)[^{]*({.*})'
class-attribute
instance-attribute
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
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 |
|
DEFAULT_MAX_STEPS = 20
class-attribute
instance-attribute
generate_assistant_subtask_template: Callable[[ActionsSubtask], str] = field(default=Factory(lambda self: self.default_assistant_subtask_template_generator, takes_self=True), kw_only=True)
class-attribute
instance-attribute
generate_user_subtask_template: Callable[[ActionsSubtask], str] = field(default=Factory(lambda self: self.default_user_subtask_template_generator, takes_self=True), kw_only=True)
class-attribute
instance-attribute
max_subtasks: int = field(default=DEFAULT_MAX_STEPS, kw_only=True)
class-attribute
instance-attribute
prompt_stack: PromptStack
property
subtasks: list[ActionsSubtask] = field(factory=list)
class-attribute
instance-attribute
task_memory: Optional[TaskMemory] = field(default=None, kw_only=True)
class-attribute
instance-attribute
tool_output_memory: list[TaskMemory]
property
tools: list[BaseTool] = field(factory=list, kw_only=True)
class-attribute
instance-attribute
__attrs_post_init__()
actions_schema()
add_subtask(subtask)
default_assistant_subtask_template_generator(subtask)
default_system_template_generator(_)
Source code in griptape/tasks/toolkit_task.py
default_user_subtask_template_generator(subtask)
find_memory(memory_name)
find_subtask(subtask_id)
find_tool(tool_name)
preprocess(structure)
run()
Source code in griptape/tasks/toolkit_task.py
set_default_tools_memory(memory)
Source code in griptape/tasks/toolkit_task.py
validate_tools(_, tools)
VariationImageGenerationTask
Bases: BaseImageGenerationTask
A task that generates a variation of an image using a prompt. Accepts a text prompt and image as input in one of the following formats: - tuple of (template string, ImageArtifact) - tuple of (TextArtifact, ImageArtifact) - Callable that returns a tuple of (TextArtifact, ImageArtifact)
Attributes:
Name | Type | Description |
---|---|---|
image_generation_engine |
VariationImageGenerationEngine
|
The engine used to generate the image. |
negative_rulesets |
VariationImageGenerationEngine
|
List of negatively-weighted rulesets applied to the text prompt, if supported by the driver. |
negative_rules |
VariationImageGenerationEngine
|
List of negatively-weighted rules applied to the text prompt, if supported by the driver. |
output_dir |
VariationImageGenerationEngine
|
If provided, the generated image will be written to disk in output_dir. |
output_file |
VariationImageGenerationEngine
|
If provided, the generated image will be written to disk as output_file. |