πŸ—‚ Planner

What is Planner?

Planner is one of the important component of any Agent framework, which enables the agent to divide a task into multiple subtasks based on the requirement. We call this step as Task Decomposition.

The Planner in the OpenAGI contains essential modules and components that handle task planning and decomposition. These components are designed to work together to break down complex tasks into manageable sub-tasks, which are then executed by Admin.

Below is a detailed explanation of the attributes and functionality of the modules within the Planner.

Attributes

ParameterOptional ParameterDescription

human_intervene

No

It indicates the framework that after generating output, it should ask human for feedback and make changes to output based on that.

autonomous

No

Autonomous will self assign role and instructions and divide it among the workers. The default is `False`

input_action

Yes

It shows how user can provide feedback to the Admin during execution.

prompt

Yes

An optional prompt to be used for task planning.

workers

Yes

Workers can represent different agents or processes that handle specific subtasks, enabling parallel execution and improving efficiency. If no workers are specified, the planner will operate without additional parallel processing capabilities.

llm

Yes

This parameter allows the user to specify the Large Language Model (LLM) that will be used for generating responses and planning tasks.

retry_threshold

Yes

This parameter defines the maximum number of times the planner will attempt to retry a task if it fails to execute successfully. The default value is 3.

Code Snippet

The primary component, TaskPlanner, allows for the decomposition of tasks into smaller sub-tasks and the planning of their execution. This modular approach facilitates efficient task management and execution within the OpenAGI framework.

from openagi.planner.task_decomposer import TaskPlanner

planner = TaskPlanner(human_intervene=False)
# make TaskPlanner autonomous = True for auto creating workers
# Autonomous Multi Agent Architecture
# plan = TaskPlanner(autonomous=True,human_intervene=True)

Below we have shown how one can initiate and run using query.

# imports
from openagi.agent import Admin
from openagi.llms.openai import OpenAIModel
from openagi.planner.task_decomposer import TaskPlanner
from openagi.actions.tools.ddg_search import DuckDuckGoSearch

# Define LLM
config = OpenAIModel.load_from_env_config()
llm = OpenAIModel(config=config)

# Planner Usage
admin = Admin(
    llm=llm,
    actions=[DuckDuckGoSearch],
    planner=TaskPlanner(human_intervene=False),
)

# Run Admin
res = admin.run(
            query="sample query",
            description="sample description",
            )

Last updated