This Python script is an example of a LLM-powered autonomous agent. The system uses OpenAI API to create and execute tasks. The core idea of the project is to provide the assistant with the tools it needs to do any task - if it's smart enough. It can arbitrarily execute code and control its own flow and memory, for a sufficiently intelligent agent, either by pre-training, fine-tuning or prompt-optimization, this should be enough (if it is possible at all)
I have tested and am developing with only GPT-3
The script works by running an infinite loop that does the following steps:
1- Write a function to finish the most relevant task (execution_agent); 2- Read the changes and pass them to execution_agent again (change_propagation_agent;
Both agents share the same "personality" and the same chore prompt. Currently, I have removed the use of Pinecone but will be bringing it back into an agent to handle I/O on different babyagi memory types.
execution_agent tools:
- openai_call
- memory_agent (to retrieve and/or save information)
memory_agent tools:
- openai_call
- get_ada_embedding
- append_to_index
- search_in_index
- create_new_index (hardcoded disabled)
Execution_agent and memory_agent perform actions by running arbitrary Python code;
To use the script, you will need to follow these steps:
- Install the required packages:
pip install -r requirements.txt
- Copy the .env.example file to .env:
cp .env.example .env
. This is where you will set the following variables. - Set your OpenAI key and model in the OPENAI_API_KEY, OPENAPI_API_MODEL variables.
- Set the objective of the task management system in the OBJECTIVE variable. Alternatively you can pass it to the script as a quote argument.
./babyagi.py ["<objective>"]
- Set the first task of the system in the FIRST_TASK variable.
- Run the script.
OBJECTIVE=I need to complete the first task
FIRST_TASK=I must rickroll myself
OBJECTIVE=I need to complete the first task
FIRST_TASK=I must analyze my cognitive archictecture during my chain of thoughts and then in my 'answer:' I will write 10 examples of multi_step_objective-first_task pairs to showcase my capabilities, I must append the result in the ./output2.txt file.
OBJECTIVE=Improve my prompts at ./prompts.py file
FIRST_TASK=Plan what to do. I must create a initial end-to-end task list, which the final task will make my objective completed.
This script is designed to run indefinitely until the task list is empty. So it can be in an endless loop, depending on the objective and first task.
I recommend using this script in a virtual machine and always making a backup if changing something. BabyAGI can run commands and python code on your computer. The results are almost always unexpected.
BabyAGI is a pared-down version of the original Task-Driven Autonomous Agent (Mar 28, 2023, by @yoheynakajima)
BASI is a modified version of BabyAGI created to show how LLMs can perform in the real world.
Made with focus by @LatentLich