Tasks are our smallest functioning unit/node that helps you define what do you want to get done by the agent. It combines agent & tools.

Description

The Task object initialization configures a specific operation or activity to be performed within the system, encompassing a broad spectrum of functionalities from content generation to data processing. This configuration includes defining the task’s name, assigning an agent with a specific role or capability, setting input and output types, and specifying operational details such as instructions and default inputs. Additional settings may control logging and feature enhancements.

Parameter Table

name
str

The unique identifier or descriptive name for the task, highlighting its primary focus or objective.

agent
Agent

The agent instance responsible for carrying out the task, equipped with the necessary skills or functionalities. Instance of Agent class.

output_type
str

Specifies the format or type of the task’s output, ensuring compatibility with subsequent operations or requirements. Accepts (OutputType.TEXT / OutputType.IMAGE).

input_type
str

Defines the expected format or type of input the task requires, aligning with the nature of the data being processed. (InputType.TEXT / InputType.IMAGE).

model
AIModel

(Optional) A reference to a the llm model. Instance of AIModel (OpenAIModel/PerplexityModel) class.

instructions
str

Detailed guidance or commands that the agent follows to execute the task, potentially including objectives and constraints.

log_output
bool

A boolean value indicating whether the task’s outputs should be streamed to logger.

enhance_prompt
bool

A boolean flag enabling additional processing or modification of the initial instructions to optimize task performance. (Automatically enhances prompts based on https://arxiv.org/pdf/2312.16171.pdf paper).

default_input
any

A predefined input value used when actual input is unavailable or incomplete, ensuring task continuity.

tool
Tool

Tool is an instance of Tool class to do external software actions using llm flow. For example, an email sending tool.

input_tasks
List[Task]

Input tasks instances of Task class. It is for explicitly mentioning which tasks output to be used as input for the current task.

Let’s look at an example, on how you can define a task

from  lyzr_automata  import  Task
from lyzr_automata.tasks.task_literals import InputType, OutputType
    
linkedin_content_writing_task = Task(
        name="linkedin content writing",
        agent=linkedin_content_writer_agent,
        output_type=OutputType.TEXT,
        input_type=InputType.TEXT,
        model=open_ai_text_completion_model,
        instructions="Write a linkedin post on gene editing using CRISPR",
        log_output=True,
        enhance_prompt=False,
)

Let’s look at an example, on how you can create a tool task

linkedin_post_task  = Task(
        name="upload post to linkedin",
        model=open_ai_model_text,
        tool=linkedin_post_tool,
        instructions="Post on Linkedin",
	)