Elemental | Documentation
Instruction

Instruction

The instruction module includes set of classes to augment the message that is passed to the language model by additional information in a consistent form. It includes several specialized classes dedicated to particular step in the agent workflows, however, all of them follow the generic class Instruction in their interface

class Instruction:
    """
    Definition of the instruction which in addition 
    to task includes potential context and memories 
    retrieved from the long memory.
    """

    def __init__(
            self,
            task: Task, 
            memories: Optional[List[str]] = None
        ) -> None:
        """
        Initialize the instruction with the task and 
        optional memories.
        """

        self._description = task.description
        self._context = task.context
        self._memories = memories

    def render(self) -> str:
        """
        Create full string representation of the 
        instruction including task description, context, 
        and memories. Last two are optional.
        """
        ...

In the example above, the Instruction class is initialized with a Task object and an optional list of memories. The render method creates a string representation of the instruction including task description, context, and memories.

Several version of this functionalities are provided with some focusing on specialized agent's role in a generic multi-agent workflow:

  • BasicInstruction - Definition of the instruction which is done outside of the TaskQueue (i.e. direct interaction with the agent).
  • Instruction - Definition of the instruction which in addition to task includes potential context and memories retrieved from the long memory.
  • ReplanningInstruction - Definition of the replanning step instruction which instead of a single task takes the current TaskQueue (completed and pending tasks) and based on the progress (represented by the results of the completed tasks) performs the replanning - potential change of the pending tasks (done tasks are not changed).
  • ComposerInstruction - Definition of the composer instruction which instead of a single task takes the current TaskQueue (completed and pending tasks) and based on the progress (represented by the results of the completed tasks) performs the composition of the final response.