A simple AI agent to explore how this stuff works.
Uses Google's Gemini API through the google-genai package`.
This is a guided project part of Boot.dev's curriculum.
Code committed after this tag is my own personal additions beyond the scope of Boot.dev's curriculum.
- Create a virtual environment and install dependencies
uv venv
source .venv/bin/activate
uv sync- Create a
.envfile in the main directory (alongside.gitignore) and insert your Gemini API key like this:
GEMINI_API_KEY=my_api_key_123456789Other setup option are available in config.py.
uv run main.py <prompt> [--verbose]Try with these prompts:
- "show me what's in the root directory"
- "how does the calculator render results to the console?"
- "please fix the bug in the calculator" (after creating a simple bug like changing operator precedence)
Print API usage stats. Configured by default for Gemini API free plan for the 2.0 Flash model.
uv run main.py statsSample output
Usage stats:
Tokens 24h: 5.2% 10345 / 200000
Requests 24h: 5.5% 11 / 200
Requests 60s: 0.0% 0 / 15
pytestThe agent needs some project to work on, so Boot.dev provides a "calculator" package.
uv run calculator/tests.py
# Ran 9 tests in 0.001s
$ uv run calculator/main.py "3 + 5 * 2"
# 3 + 5 * 2 = 13Some ideas for some features outside the scope of the guided project that I'd like to add:
- Use logging instead of printing
- Use
pytest, plain assertions are more readable thanunittestmethods - API usage DB so you can easily see know many token/request you used (and can still use within free plan limits)
-
statssubcommand - Test
- Conversation ID
- Save request prompt/result
-
-
argparsefor argument parsing - Simplify calling main (
uv run main "prompt"is too many words, maybe withpyproject.tomlthere's a way to install a shell script) - Move code inside an
srcdirectory - Fix or remove all TODOs
- Ability to install this library in any Python project I make so I can use the agent on any codebase