Skip to content

Agent

Data Structures for LLM Agent.

Task

Bases: BaseModel

Represents a single task with an instruction.

Attributes:

Name Type Description
id_ str

Identifier for task.

instruction str

The instruction for the task.

Source code in src/llm_agents_from_scratch/data_structures/agent.py
class Task(BaseModel):
    """Represents a single task with an instruction.

    Attributes:
        id_: Identifier for task.
        instruction: The instruction for the task.
    """

    id_: str = Field(default_factory=lambda: str(uuid.uuid4()))
    instruction: str

    def __str__(self) -> str:
        """String representation of Task."""
        return self.instruction

__str__

__str__()

String representation of Task.

Source code in src/llm_agents_from_scratch/data_structures/agent.py
def __str__(self) -> str:
    """String representation of Task."""
    return self.instruction

TaskStep

Bases: BaseModel

Represents a step within a task and its own instruction.

Attributes:

Name Type Description
id_ str

Identifier for task step.

task_id str

ID of associated task.

instruction str

The instruction for the task.

Source code in src/llm_agents_from_scratch/data_structures/agent.py
class TaskStep(BaseModel):
    """Represents a step within a task and its own instruction.

    Attributes:
        id_: Identifier for task step.
        task_id: ID of associated task.
        instruction: The instruction for the task.
    """

    id_: str = Field(default_factory=lambda: str(uuid.uuid4()))
    task_id: str
    instruction: str = Field(
        description="The instruction for this step in the task.",
    )

    def __str__(self) -> str:
        """String representation of TaskStep."""
        return self.instruction

__str__

__str__()

String representation of TaskStep.

Source code in src/llm_agents_from_scratch/data_structures/agent.py
def __str__(self) -> str:
    """String representation of TaskStep."""
    return self.instruction

TaskStepResult

Bases: BaseModel

The result of a task step execution.

Attributes:

Name Type Description
task_step_id str

The ID of the TaskStep that was executed.

content str

The content results of the execution.

Source code in src/llm_agents_from_scratch/data_structures/agent.py
class TaskStepResult(BaseModel):
    """The result of a task step execution.

    Attributes:
        task_step_id: The ID of the `TaskStep` that was executed.
        content: The content results of the execution.
    """

    task_step_id: str
    content: str

    def __str__(self) -> str:
        """String representation of TaskStepResult."""
        return self.content

__str__

__str__()

String representation of TaskStepResult.

Source code in src/llm_agents_from_scratch/data_structures/agent.py
def __str__(self) -> str:
    """String representation of TaskStepResult."""
    return self.content

TaskResult

Bases: BaseModel

The result of the task execution.

Attributes:

Name Type Description
task_id str

The ID Task that was executed.

content str

The content results of the task execution.

Source code in src/llm_agents_from_scratch/data_structures/agent.py
class TaskResult(BaseModel):
    """The result of the task execution.

    Attributes:
        task_id: The ID `Task` that was executed.
        content: The content results of the task execution.
    """

    task_id: str
    content: str

    def __str__(self) -> str:
        """String representation of TaskResult."""
        return self.content

__str__

__str__()

String representation of TaskResult.

Source code in src/llm_agents_from_scratch/data_structures/agent.py
def __str__(self) -> str:
    """String representation of TaskResult."""
    return self.content

NextStepDecision

Bases: BaseModel

Structured output used within TaskHandler.get_next_step().

Source code in src/llm_agents_from_scratch/data_structures/agent.py
class NextStepDecision(BaseModel):
    """Structured output used within TaskHandler.get_next_step()."""

    kind: Literal["next_step", "final_result"]
    content: str = Field(
        description=(
            "If kind='next_step': describe the next tool call to make. "
            "If kind='final_result': the final answer (ONLY when task "
            "objective is fully achieved)."
        ),
    )