Skip to content

azad.predefined_tools.task_entry Module

azad.predefined_tools.task_entry

Predefined Task Entry Tool Schema and Metadata.

Attributes

TASK_ENTRY_TOOL_METADATA module-attribute

TASK_ENTRY_TOOL_METADATA = {'name': 'task_entry', 'description': 'Creates a new nested task in the mindmap structure', 'requires_approval': True, 'parameters': {'initial_task_config': {'description': 'Configuration for the new nested task', 'streamable': False}, 'task_description': {'description': 'Description of the task and initial context', 'streamable': False}}, 'required_parameters': ['initial_task_config', 'task_description'], 'examples': [{'explanation': 'Create a nested task with a specific configuration', 'parameters': {'initial_task_config': {'model_name': 'gpt-4', 'tool_metadata': [], 'dialect_name': 'xml', 'dialect_options': {}}, 'task_description': [{'type': 'text', 'text': 'Analyze this code snippet'}]}}], 'is_task_entry': True, 'is_task_exit': False, 'task_lifecycle_output_keypairs': {'initial_task_config': TASK_CONFIG, 'task_description': TASK_DESCRIPTION}}

Classes

TaskEntryToolSchema

Bases: BaseModel

Input schema for the Task Entry tool.

This defines the required parameters when creating a new nested task.

Attributes
initial_task_config class-attribute instance-attribute
initial_task_config: TaskConfigPart = Field(..., description='Configuration for the new nested task including model, tools, and dialect')
task_description class-attribute instance-attribute
task_description: List[Union[TextPart, ImagePart, InformationalPart]] = Field(..., description='Description of the task and initial context to be provided to the nested task')
model_config class-attribute instance-attribute
model_config = {'populate_by_name': True, 'extra': 'forbid'}
Functions
validate_task_description
validate_task_description() -> TaskEntryToolSchema

Validate that task_description contains at least one content part.

Source code in azad/predefined_tools/task_entry.py
@model_validator(mode='after') # type: ignore
def validate_task_description(self) -> TaskEntryToolSchema:
    """Validate that task_description contains at least one content part."""
    if not self.task_description:
        raise ValueError("task_description must contain at least one content part")
    return self
to_tool_result
to_tool_result() -> Dict[str, Any]

Convert to format expected by mindmap's add_task_entry method.

Source code in azad/predefined_tools/task_entry.py
def to_tool_result(self) -> Dict[str, Any]:
    """Convert to format expected by mindmap's add_task_entry method."""
    return {
        "task_description": self.task_description,
        "initial_task_config": self.initial_task_config
    }
from_task_config classmethod
from_task_config(task_config: TaskConfigPart, task_description: List[Union[TextPart, ImagePart, InformationalPart]]) -> TaskEntryToolSchema

Create a TaskEntryToolSchema from a TaskConfigPart and task description.

Source code in azad/predefined_tools/task_entry.py
@classmethod
def from_task_config(cls, task_config: TaskConfigPart, task_description: List[Union[TextPart, ImagePart, InformationalPart]]) -> TaskEntryToolSchema:
    """Create a TaskEntryToolSchema from a TaskConfigPart and task description."""
    return cls(
        initial_task_config=task_config,
        task_description=task_description
    )
apply_to_task
apply_to_task(task: Task) -> None

Apply this task entry to a Task object.

Source code in azad/predefined_tools/task_entry.py
def apply_to_task(self, task: Task) -> None:
    """Apply this task entry to a Task object."""
    task.add_task_entry(
        task_description=self.task_description,
        initial_task_config=self.initial_task_config
    )

TaskEntryOutputSchema

Bases: BaseModel

Output schema for the Task Entry tool.

This defines the structure of the result returned when a nested task is created.

Attributes
task_description class-attribute instance-attribute
task_description: List[Union[TextPart, ImagePart, InformationalPart]] = Field(..., description='The task description that was used to create the nested task')
initial_task_config class-attribute instance-attribute
initial_task_config: TaskConfigPart = Field(..., description='The configuration that was used for the nested task')
task_id class-attribute instance-attribute
task_id: str = Field(..., description='ID of the newly created subtask')
status class-attribute instance-attribute
status: Literal['created', 'error'] = Field(..., description='Status of the task creation')
message class-attribute instance-attribute
message: Optional[str] = Field(None, description='Additional information about the task creation')
model_config class-attribute instance-attribute
model_config = {'populate_by_name': True, 'extra': 'forbid'}