Admin

The Admin serves as the master task executor within the OpenAGI framework, responsible for major configurations related to task planning, execution, and defining the cognitive architecture. It acts as the decision-maker, understanding task specifications, and executing them in a more human-like manner.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 from openagi.llms.openai import OpenAIModel from openagi.planner.task_decomposer import TaskPlanner from openagi.actions.tools.ddg_search import DuckDuckGoSearch from openagi.memory import Memory # Define LLM config = OpenAIModel.load_from_env_config() llm = OpenAIModel(config=config) # Instantiate the Admin admin = Admin( llm=llm, actions=[DuckDuckGoSearch], planner=TaskPlanner(human_intervene=False), memory=Memory(), ) # Execute the task res = admin.run( query="sample query", description="sample description", )

Planner


The Planner is a crucial component of any agent framework, enabling the agent to divide a task into multiple subtasks based on requirements, a process known as Task Decomposition. In OpenAGI, the Planner includes essential modules and components that manage task planning and decomposition, working together to break down complex tasks into manageable sub-tasks that are then executed by the Admin. The Planner takes the "human_intervene" parameter, which is very useful for decomposing tasks effectively. This parameter indicates that after generating output, the framework should ask for human feedback and make changes based on that.
1 2 3 from openagi.planner.task_decomposer import TaskPlanner planner=TaskPlanner(human_intervene=True)

Workers

Workers are specialized classes responsible for executing tasks assigned by the Admin. They utilize various tools such as internet search engines, Large Language Models (LLMs), and document writers to perform their tasks. The Admin can decompose large tasks into smaller subtasks, which are then assigned to Workers for execution.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 # Define Worker parameters role = "Researcher" instructions = "Research the topic and provide a summary." actions = [DuckDuckGoSearch] max_iterations = 3 force_output = False # Instantiate the Worker worker = Worker( role=role, instructions=instructions, actions=actions, llm=llm, max_iterations=max_iterations, force_output=force_output )

LLM

Large Language Models (LLMs) serve as the backbone for executing Agentic workflows. They excel at generating responses and, when combined with human-like planning, reasoning, and task decomposition, give rise to the concept of Agents. OpenAGI supports LLMs like OpenAI and Azure ChatOpenAI models, which are implemented within the Admin and utilize a Planner to execute tasks.

1 2 3 4 5 6 7 8 9 10 # Define LLM configuration config = OpenAIModel.load_from_env_config() # Instantiate the OpenAI Large Language Model llm = OpenAIModel(config=config) # Generate a response response = llm.generate_response("What are the core concepts of OpenAGI agents?") print(response)

Action

Actions provide predefined functionalities that the Agent can invoke to accomplish various tasks. They include fetching data from external sources, processing it, and storing the results for subsequent use. Agents invoke actions during runtime to execute specific tasks, such as gathering information from a user query.

1 2 3 4 5 6 7 # Instantiate an Action action = DuckDuckGoSearch() # Execute a predefined action results = action.search("OpenAGI agents") print(results)

Tools

Tools are functionalities that fetch data to the Agent for analysis and decision-making. They are cataloged in a tools database, supporting activities like internet searches, email dispatch, and interactions with Git repositories. Users can create custom tools and integrate them seamlessly into the framework's operations.

1 2 3 4 5 6 7 # Instantiate the DuckDuckGoSearch tool search_tool = DuckDuckGoSearch() # Use the tool to perform an internet search results = search_tool.search("OpenAGI agents") print(results)

Memory

Memory is a crucial component of the Agentic framework, providing agents with the ability to recall past tasks, observations, and feedback. It helps agents make informed decisions by learning from previous actions and experiences. Memory ensures that agents don't repeat mistakes and continuously improve user experience based on recalled information.

1 2 3 4 5 6 7 8 9 10 11 # Instantiate the Memory component memory = Memory() # Store an interaction interaction = {"user_query": "What are OpenAGI agents?", "response": "OpenAGI agents are autonomous human-like agents"} memory.store_interaction(interaction) # Retrieve past interactions past_interactions = memory.retrieve_past_interactions() print(past_interactions)

Reference

Check out the detailed documentation: https://openagi.aiplanet.com/