A lightweight single-agent orchestration framework using Google Gemini API.
- 🤖 Simple Agent Orchestration: Clean single-agent implementation with Gemini
- 💬 Streaming Responses: Real-time streaming chat responses
- 🔧 Built-in Tools: Support for code execution and web search
- 📝 Conversation History: Automatic conversation management
- ⚙️ YAML Configuration: Easy configuration via YAML files
- 🎨 Rich CLI: Beautiful terminal interface with Rich
- Create a virtual environment:
python -m venv gemini-agent- Copy and configure the environment file:
cp .env.example .env
# Edit .env and add your Google API key from: https://aistudio.google.com/apikey- Activate the virtual environment and install dependencies:
. gemini-agent\Scripts\activate.ps1
pip install -r requirements.txtSingle Question Mode:
. gemini-agent\Scripts\activate.ps1
python -m gemini_agent.cli --model gemini-2.5-pro "Your question here"Interactive Mode:
. gemini-agent\Scripts\activate.ps1
python -m gemini_agent.cli --model gemini-2.5-proWith Configuration File:
. gemini-agent\Scripts\activate.ps1
python -m gemini_agent.cli --config config.yaml "Your question here"With Code Execution Enabled:
. gemini-agent\Scripts\activate.ps1
python -m gemini_agent.cli --model gemini-2.5-pro --enable-code-execution "Calculate the first 10 prime numbers"With Web Search Enabled:
. gemini-agent\Scripts\activate.ps1
python -m gemini_agent.cli --model gemini-2.5-pro --enable-web-search "What's the latest news on AI?"- Clone or navigate to this directory:
cd dummy-agent-framework- Install dependencies:
pip install -r requirements.txtOr install in development mode:
pip install -e .- Set up your API key:
cp .env.example .env
# Edit .env and add your Google API keyGet your API key from: https://aistudio.google.com/apikey
Start a conversation with the agent:
python -m gemini_agent.cli --config config.yamlOr if installed:
gemini-agent --config config.yamlAsk a single question:
python -m gemini_agent.cli --config config.yaml "What is the capital of France?"Quick usage without config:
python -m gemini_agent.cli "Explain quantum computing in simple terms"With custom settings:
python -m gemini_agent.cli --model gemini-2.5-pro --enable-web-search "What's the latest news on AI?"The framework uses YAML configuration files. See config.yaml for a basic example.
agent:
id: "gemini-agent"
backend:
type: "gemini"
model: "gemini-2.0-flash-exp"
enable_code_execution: false
enable_web_search: false
temperature: 1.0
system_message: "You are a helpful AI assistant."
ui:
display_type: "rich_terminal"
logging_enabled: trueThe examples/ directory contains several pre-configured setups:
config_code_execution.yaml: Agent with Python code executionconfig_web_search.yaml: Agent with web search capabilityconfig_full_tools.yaml: Agent with all tools enabled
Try them:
python -m gemini_agent.cli --config examples/config_code_execution.yaml "Calculate fibonacci(20)"python -m gemini_agent.cli --config examples/config_code_execution.yamlYou: Calculate the first 10 prime numbers
Agent: [executes code and shows results]
python -m gemini_agent.cli --config examples/config_web_search.yamlYou: What's the current weather in Paris?
Agent: [searches web and provides current information]
python -m gemini_agent.cli --system-message "You are a Python expert" "How do I sort a dictionary by value?"python -m gemini_agent.cli --helpOptions:
--config: Path to YAML configuration file--model: Gemini model to use (default: gemini-2.0-flash-exp)--system-message: Custom system prompt--enable-code-execution: Enable code execution capability--enable-web-search: Enable web search capability--temperature: Sampling temperature (0-2)--verbose: Enable verbose logging
gemini-2.0-flash-exp- Fast, efficient model (default)gemini-2.5-pro- More capable model for complex tasksgemini-1.5-flash- Previous generation flash modelgemini-1.5-pro- Previous generation pro model
dummy-agent-framework/
├── gemini_agent/
│ ├── __init__.py # Package initialization
│ ├── agent.py # Agent class with conversation management
│ ├── backend.py # Gemini API wrapper
│ ├── cli.py # Command-line interface
│ └── config.py # Configuration loader
├── examples/
│ ├── config_code_execution.yaml
│ ├── config_web_search.yaml
│ └── config_full_tools.yaml
├── config.yaml # Default configuration
├── requirements.txt # Python dependencies
├── setup.py # Package setup
├── .env.example # Environment template
└── README.md # This file
The Agent class manages conversation history and provides a simple chat interface:
from gemini_agent import create_agent
agent = create_agent(
model="gemini-2.0-flash-exp",
system_message="You are a helpful assistant",
enable_code_execution=True
)
# Streaming chat
async for chunk in agent.chat("Hello!"):
if chunk.type == "content":
print(chunk.content, end="")
# Simple chat (non-streaming)
response = await agent.chat_simple("What is 2+2?")
print(response)Low-level wrapper around the Google Gemini API:
from gemini_agent.backend import GeminiBackend
backend = GeminiBackend(
model="gemini-2.0-flash-exp",
enable_code_execution=True,
enable_web_search=True
)
async for chunk in backend.chat_stream(messages):
print(chunk)Create a .env file with:
GOOGLE_API_KEY=your_api_key_here
# or
GEMINI_API_KEY=your_api_key_hereWhen in interactive mode:
exit,quit,bye,q- Exit the conversationreset- Clear conversation history
This framework is a simplified single-agent implementation based on other frameowork's architecture:
Other frameworks (Full Framework):
- Multi-agent coordination
- Binary decision voting system
- Advanced memory management
- Multiple LLM backend support
- Complex orchestration
This Framework (Simple Agent):
- Single agent only
- Gemini-specific
- Streamlined conversation management
- Easy to understand and extend
- Perfect for learning and simple use cases
Install in development mode:
pip install -e .Run with verbose logging:
python -m gemini_agent.cli --verbose- Ensure your
GOOGLE_API_KEYorGEMINI_API_KEYis set in.env - Verify the key is valid at https://aistudio.google.com/apikey
- Make sure all dependencies are installed:
pip install -r requirements.txt - If using Python 3.9-3.11, ensure compatibility with google-genai library
- Check available models in Google AI Studio
- Some models may require different access levels
This is a reference implementation. Feel free to:
- Add new features
- Improve error handling
- Add more examples
- Extend with custom tools
MIT License - Feel free to use and modify