Skip to content

paatre/ai-agent-gemini

Repository files navigation

AI Agent with Gemini 2.0 Flash

This is a simple AI Agent project that utilizes Google's gemini-2.0-flash-001. The agent is capable of making function calls to interact with the file system and run Python scripts. This allows the model to perform a variety of tasks beyond simple text generation, such as:

  • Listing files and directories
  • Reading file contents
  • Executing Python files with optional arguments
  • Writing or overwriting files

The model has a generous free tier with free-of-charge input and output tokens and a rate limit of 200 requests per day. Read more about the pricing and the rate limits here and here.

The project is built using Python and Google's Gen AI SDK.

Setup

First, clone the repository:

git clone https://github.com/paatre/ai-agent-gemini.git

After that navigate to the project directory and install the dependencies:

cd ai-agent-gemini
uv venv
source .venv/bin/activate # On Windows use `.\venv\Scripts\activate`
uv sync

To use the Gemini client, you need to set up a Google AI Studio account and obtain an API key which the client will use for authentication. You can do that from the Google AI Studio directly: https://aistudio.google.com/apikey. You need to sign in with your Google account. Note that you need a project which the API key will be associated with but the Google AI Studio will do that for you automatically.

After you have your API key, set it to an .env file in the project root:

GEMINI_API_KEY=your_api_key_here

The .env file will be loaded automatically by the python-dotenv package. The .env file is included in .gitignore.

Usage

You can run the agent with:

uv run main.py <content>

Replace <content> with the content you want the agent to process. For example:

uv run main.py "Read the content of prompts.py"

The agent will then respond with an answer to the query.

If you use a --verbose flag, the AI agent outputs your prompt and the result will also contain information about function calls and token usage:

uv run main.py "Read the content of prompts.py" --verbose

The agent isn't interactive, it exits if you don't give content.

About

This is a simple AI agent that utilizes Google's gemini-2.0-flash-001 with a multi-turn conversation capabilities using functions provided to it as tools..

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages