BabyAGI is an experimental project whose name comes from the original version released in March 2023, which first introduced task planning as a method for developing autonomous agents. The original version has been archived and moved to the babyagi_archive repository (September 2024 snapshot). The current version was built by Yohei, who states that he has never held a developer position; the purpose of this repository is to share ideas, spark discussion, and provide experienced developers with something to try, and it explicitly states that it is not suitable for production environments and should be used with caution.
The current BabyAGI is an experimental framework for self-building autonomous agents. The project believes that the best way to build a general autonomous agent is to build the simplest thing that can build itself. At its core is a new function framework called functionz, used to store, manage, and execute functions from a database. The framework provides a graph-based structure to track imports, dependent functions, and authentication keys, and has automatic loading and comprehensive logging capabilities. In addition, it comes with a dashboard for managing functions, running updates, and viewing logs.
Installation and startup method: install via pip install babyagi. Import babyagi in Python code and create an app, for example by calling babyagi.create_app('/dashboard') in main and running it, then access http://localhost:8080/dashboard to open the BabyAGI dashboard.
Function registration and management: Users can register functions via register_function; functions can carry metadata to enhance capabilities and manage relationships. Available metadata fields include: imports (list of external libraries the function depends on), dependencies (list of other functions the function depends on), key_dependencies (list of keys required by the function), metadata["description"] (description of the function's purpose). In addition to register_function, you can also use load_function to load plugins or draft function packages. BabyAGI has built-in function packs, and you can also point to a file path to load custom packages. Function packs are located in the babyagi/functionz/packs directory. By organizing related functions into packs, function construction and management become easier.
Key dependency management: key_dependencies can be stored directly from code, or managed through the dashboard. In the dashboard, you can use the add_key_wrapper feature to securely add keys.
Execution environment and logging: BabyAGI automatically loads the necessary function packs and manages dependencies, ensuring a seamless execution environment. It also logs all activity, including relationships between functions, to comprehensively track function execution and dependencies. The logging system records every function call, including inputs, outputs, execution time, and any errors, making monitoring and debugging easier. Key logging features include: execution tracking (records the start and end times of function execution, function name, arguments, keyword arguments, and execution time), error logging (captures and records errors during execution, providing detailed error information), dependency management (automatically resolves and records dependencies between functions, ensuring all required functions and libraries are loaded before execution), trigger logging (records the execution of triggered functions, detailing which functions were triggered by other functions and their execution results), comprehensive records (maintains a history of all function executions for reviewing past activity, understanding function relationships, and analyzing performance metrics).
Trigger mechanism: Triggers allow certain functions to execute automatically when specific events or operations occur within the system. For example, when a function is added or updated, a trigger can initiate the generation of a description for that function. Triggers enhance BabyAGI's autonomy by implementing automated workflows and reducing manual intervention. However, triggers need to be managed carefully to avoid unexpected recursive execution or conflicts between dependent functions.
Dashboard features: Provides a user-friendly interface to manage functions, monitor execution, and handle configuration. Main featuresinclude: function management (register, unregister, and update functions directly in the dashboard), dependency visualization (view and manage dependencies between functions), key management (securely add and manage keys through the dashboard interface), logging and monitoring (access comprehensive logs of function execution, including inputs, outputs, and execution time), trigger management (set triggers to automatically execute functions based on specific events or conditions). After running the application, visit http://localhost:8080/dashboard You can use it now.
Preloaded function packs: BabyAGI includes two preloaded function packs. The default functions (packs/default_functions.py) provide: function execution (run, add, update, or retrieve functions and versions), secret management (add and retrieve secrets), triggers (add triggers to execute functions based on other functions), and logs (retrieve logs with optional filtering). The AI functions (packs/ai_generator.py) provide: AI descriptions and embeddings (automatically generate descriptions and embeddings for functions), and function selection (find or select similar functions based on a prompt).
Running self-building agents: BabyAGI includes two experimental self-building agents that demonstrate how the framework can help self-building coding agents leverage existing functions to write new functions. First, the process_user_input function in the code_writing_functions package first determines whether to use an existing function or generate a new function. If a new function is needed, it breaks it down into smaller reusable components and combines them into the final function. After running, you will see the function generation process in the shell, and when complete, the new function will appear in the dashboard. Second, the self_build function in the self_build package receives a user description and generates X different tasks that the user might pose to an AI assistant. Each task is handled by process_user_input, and if existing functions are insufficient, new functions are created. For example, it will generate 3 different tasks that a salesperson might pose to an AI assistant, and create functions to handle these tasks. The generated functions are stored in the dashboard, but the generated code is very basic and may need improvement. Warning: These draft features are experimental concepts, may not work as expected, require substantial improvement, and should be used with caution.
Contributions and license: The project welcomes contributions, but the author admits to not doing a good enough job managing PRs. Since he works alone at night and on weekends, progress will be slow, so please be patient. The author may first build a small core team before collaborating with a larger group. BabyAGI is released under the MIT license, see the LICENSE file for details.