base_subtask
Adapted from the Griptape AI Framework documentation.
T = TypeVar('T', bound=BaseArtifact)
module-attributelogger = logging.getLogger(Defaults.logging_config.logger_name)
module-attribute
Bases:
BaseTask[T]
Source Code in griptape/tasks/base_subtask.py
@define class BaseSubtask(BaseTask[T]): @property def origin_task(self) -> BaseTask: if self._origin_task is not None: return self._origin_task raise Exception("ActionSubtask has no origin task.") @property def parents(self) -> list[BaseTask]: if isinstance(self.origin_task, ActionsSubtaskOriginMixin): return [self.origin_task.find_subtask(parent_id) for parent_id in self.parent_ids] raise Exception("ActionSubtask must be attached to a Task that implements ActionSubtaskOriginMixin.") @property def children(self) -> list[BaseTask]: if isinstance(self.origin_task, ActionsSubtaskOriginMixin): return [self.origin_task.find_subtask(child_id) for child_id in self.child_ids] raise Exception("ActionSubtask must be attached to a Task that implements ActionSubtaskOriginMixin.") def add_child(self, child: BaseTask) -> BaseTask: if child.id not in self.child_ids: self.child_ids.append(child.id) return child def add_parent(self, parent: BaseTask) -> BaseTask: if parent.id not in self.parent_ids: self.parent_ids.append(parent.id) return parent def attach_to(self, parent_task: BaseTask) -> None: self._origin_task = parent_task @abstractmethod def add_to_prompt_stack(self, stack: PromptStack) -> None: ...
children
propertyorigin_task
propertyparents
property
add_child(child)
Source Code in griptape/tasks/base_subtask.py
def add_child(self, child: BaseTask) -> BaseTask: if child.id not in self.child_ids: self.child_ids.append(child.id) return child
add_parent(parent)
Source Code in griptape/tasks/base_subtask.py
def add_parent(self, parent: BaseTask) -> BaseTask: if parent.id not in self.parent_ids: self.parent_ids.append(parent.id) return parent
add_to_prompt_stack(stack)abstractmethod
Source Code in griptape/tasks/base_subtask.py
@abstractmethod def add_to_prompt_stack(self, stack: PromptStack) -> None: ...
attach_to(parent_task)
Source Code in griptape/tasks/base_subtask.py
def attach_to(self, parent_task: BaseTask) -> None: self._origin_task = parent_task
Could this page be better? Report a problem or suggest an addition!