BabyAGI is an AI-powered task management system (Python script) created using OpenAI and Pinecone API, which prioritizes, organizes, and executes tasks. The main idea behind the system is to create tasks based on the results of previous tasks and predefined goals. The script then uses OpenAI’s natural language processing (NLP) capabilities to create new tasks based on the goals and uses Pinecone to store and retrieve task results for context. This is a simplified version of the original task-driven self-driving agent (March 28, 2023).
1. How BabyAGI Works
The overall principle of BabyAGI is shown in the figure below:
BabyAGI works by running an infinite loop that executes the following steps:
-
Extract the first task from the task list;
-
Send the task to the execution agent, which uses the OpenAI API to complete the task based on context;
-
Organize the results and store them in Pinecone;
-
Create new tasks based on the goals and the results of the previous task, and prioritize the task list.
execution_agent() function uses the OpenAI API. It accepts two parameters: the goal and the task, and then sends a prompt to OpenAI’s API (including a description of the AI system’s task, the goal, and the task itself), which returns the result as a string.
task_creation_agent() function uses the OpenAI API to create new tasks based on the goals and the results of the previous task. This function accepts four parameters: the goal, the result of the previous task, the task description, and the current task list. It then sends a prompt to OpenAI’s API, which returns a string list of new tasks. The function then returns the new tasks as a list of dictionaries, where each dictionary contains the name of the task.
prioritization_agent() function uses the OpenAI API to reorder the task list. This function accepts one parameter, which is the ID of the current task. It sends a prompt to OpenAI’s API, which returns a reordered task list (numbered).
Finally, the script uses Pinecone to store and retrieve task results for context. The script creates a Pinecone index based on the table name specified in the YOUR_TABLE_NAME variable, and then Pinecone stores the task results along with the task name and any other metadata in the index.
2. How to Use BabyAGI
Step 1 Clone the Repository
git clone https://github.com/yoheinakajima/babyagi.git
cd babyagi
Step 2 Install Required Libraries
pip install -r requirements.txt
cp .env.example .env
Step 3 Set Up OpenAI Key
Set the parameters OPENAI_API_KEY, OPENAI_API_MODEL, and PINECONE_API_KEY in the .env file, and set the Pinecone environment in the PINECONE_ENVIRONMENT variable. If you want to use weaviate, please refer to https://babyagi.org/docs/weaviate.html
Step 4 Set the Table Name for Storing Results
Specify the value of the variable TABLE_NAME for storing results
Step 5 Configure Other Variables (Optional)
Specify the BabyAGI instance name by setting the BABY_NAME variable, set the goal of the task management system by setting the OBJECTIVE variable, and set the name of the first task by setting the INITIAL_TASK variable.
Step 6 Run BabyAGI
python babyagi.py
PS: The above steps can also be deployed in Docker. First, install Docker and Docker Compose, and then execute the following code:
docker-compose up
3. Models Supported by BabyAGI
BabyAGI supports all models from OpenAI, as well as the LLaMA model and its extended models (via Llama.cpp). The default model is gpt-3.5-turbo; to use a different model, please specify it via OPENAI_API_MODEL or use the command line.
LLaMA
Download the latest version of Llama.cpp and compile it according to the instructions. You will also need the weights for the Llama model, then link llama/main to llama.cpp/main, link models to the folder where the Llama model weights are stored, and pass the parameters OPENAI_API_MODEL=llama or -l to run the script.
PS: Under no circumstances should you share IPFS, magnet links, or any other model download links anywhere in this repo (including issues, discussions, or pull requests). They will be deleted immediately.
Warning for Continuous Running of BabyAGI
BabyAGI is designed to run continuously as part of a task management system. Continuously running this script may result in excessively high API usage fees, so please use it with caution and at your own risk. Additionally, the script requires proper setup of OpenAI and Pinecone API, so ensure that you have set up the API before running the script.
References:
[1] https://github.com/yoheinakajima/babyagi
[2] http://babyagi.org/