This is a simple yet powerful AI agent powered by Google's Gemini model. It's designed to understand natural language commands, interact with your local file system, and execute code to perform a variety of development tasks.
- Natural Language Understanding: Leverages the Gemini API to interpret complex requests.
- File System Tools: Can list directory contents, read files, and write/overwrite files.
- Code Execution: Capable of running Python scripts to test changes or perform tasks.
- Iterative Problem-Solving: Works in a loop, using tools and refining its approach until the task is complete.
- Simple Command-Line Interface: Easy to run from your terminal.
The agent operates on a simple loop:
- You provide a prompt (a task) to the agent.
- The Gemini model determines which tool to use based on the prompt (e.g.,
read_file,execute_python). - The agent executes the tool and sends the result back to the model.
- The model analyzes the result and decides on the next step.
- This process repeats until the model determines the task is complete, at which point it gives a final answer.
- Python 3.10+
- uv (a fast Python package installer and runner)
-
Clone the repository:
git clone https://github.com/ty-strong/ai-agent.git cd ai-agent -
Set up your environment: Create a file named
.envin the root of the project and add your Gemini API key. You can get a key from Google AI Studio.# .env GEMINI_API_KEY="YOUR_API_KEY_HERE"
To run the agent, use uv run from your terminal. Pass your request as a string argument. uv will automatically create a virtual environment and install the dependencies listed in pyproject.toml.
uv run main.py "Your task for the agent here"For more detailed output on the agent's thought process and tool usage, add the --verbose flag:
uv run main.py "Your task for the agent here" --verboseImagine you have a calculator.py with a bug where it doesn't respect operator precedence (e.g., 3 + 7 * 2 incorrectly returns 20). You can ask the agent to fix it:
uv run main.py "In calculator.py, fix the bug where 3 + 7 * 2 returns 20 instead of 17"