This repository contains Python code demonstrating various agentic workflow patterns using the Gemini 2.0 API and the Google Gen AI SDK. These examples are inspired by the Building effective agents article from Anthropic, adapted for the Google Gemini platform.
This project explores the implementation of agentic systems with Gemini, focusing on the building blocks and workflow patterns described in the Anthropic article. The key idea is to build effective applications by starting with simple prompts and gradually adding complexity, using agentic workflows when simpler solutions aren't sufficient.
The following patterns are implemented:
- Prompt Chaining: Decomposing a task into a sequence of steps, where each LLM call uses the output of the previous one.
- Routing: Classifying an input and directing it to a specialized task or LLM call.
- Parallelization: Running multiple LLM calls simultaneously:
- Sectioning: Breaking a task into independent subtasks for concurrent execution.
- Voting: Running the same task multiple times to get diverse outputs and improve the final result.
- Orchestrator-Workers: A central LLM dynamically breaks down tasks, delegates them to worker LLMs, and synthesizes results.
- Evaluator-Optimizer: One LLM generates a response while another provides evaluation and feedback in a loop.
- Simple Agents: LLMs using tools based on environmental feedback in a loop for autonomous tasks.
- Python 3.8 or higher
- A Google AI Gemini API key (get one from Google AI Studio)
-
Clone this repository:
git clone https://github.com/arham-kk/gemini-agent-cookbook.git cd gemini-agent-cookbook
-
Install the required Python packages:
pip install -r requirements.txt
-
Set up your API key:
-
Add your Gemini API key to the
.env
file in the following format:GEMINI_API_KEY=your_api_key_here
-
This project is licensed under the MIT License
Contributions are welcome! Please feel free to submit issues or pull requests.