Hey folks! I've seen a few questions floating around about getting BabyAGI running locally for tinkering. It's actually a lot simpler than it looks if you're comfortable with Python and Docker. I just went through the setup again yesterday to double-check the steps, and you can have the core system up and querying in about 15 minutes. Let's get you started.
First, you'll want to clone the repo and get your dependencies in place. I prefer using a virtual environment every single time—it keeps things clean.
```bash
git clone https://github.com/yoheinakajima/babyagi.git
cd babyagi
python -m venv venv
source venv/bin/activate # On Windows: venvScriptsactivate
pip install -r requirements.txt
```
Next, the crucial bit: the environment variables. You'll need an OpenAI API key. I keep mine in a `.env` file so it's not accidentally committed. BabyAGI uses this for its LLM calls.
```bash
cp .env.example .env
# Now edit .env and set your OPENAI_API_KEY, and optionally change OPENAI_API_MODEL
```
Finally, you can run the classic BabyAGI script. This is the one that creates and executes tasks autonomously.
```bash
python babyagi.py
```
But here's my pro-tip from testing this a few times: before you run the main agent, test your connection and model with a simple script. I made a quick `test_setup.py` to verify everything's talking correctly.
```python
import openai
import os
from dotenv import load_dotenv
load_dotenv()
client = openai.OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
try:
response = client.chat.completions.create(
model=os.getenv("OPENAI_API_MODEL", "gpt-4"),
messages=[{"role": "user", "content": "Say 'Hello from BabyAGI local setup!'"}],
max_tokens=10
)
print("✅ Setup is good! Response:", response.choices[0].message.content)
except Exception as e:
print("❌ Something's off:", e)
```
Run that with `python test_setup.py`. If you get a green check, you're golden! 🎉
The default `babyagi.py` will start creating tasks, which can get expensive quickly. I always recommend setting a clear objective in the script and maybe adding a task limit for your first run. Just open `babyagi.py` and look for the `OBJECTIVE` variable near the top.
That's it! You should now have a working local instance. This is perfect for understanding the core loop before you dive into modifying agents or trying the more advanced flavors like BabyBeeAGI.
Happy to help troubleshoot if anyone hits a snag—just drop your error in a reply.
~d