Skip to content

Alberto-Codes/gepa-adk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

208 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

CI Coverage PyPI Python License Ruff docs vetted

gepa-adk

Evolutionary optimization for Google ADK agents.

What is this?

gepa-adk evolves AI agent instructions automatically. Give it an agent and training examples, and it finds better prompts through iterative improvement using genetic algorithms and Pareto frontier selection.

Supports single-agent evolution, multi-agent co-evolution, workflow optimization (Sequential, Loop, Parallel agents), output schema evolution, generation config tuning, and multimodal inputs including video.

Requirements

  • Python 3.12+
  • Ollama with a local model (recommended for development), or any model supported by LiteLLM

Installation

pip install gepa-adk
# For local models (recommended)
export OLLAMA_API_BASE=http://localhost:11434

Quick Start

Evolve a greeting agent to produce formal, Dickens-style greetings:

from google.adk.agents import LlmAgent
from google.adk.models.lite_llm import LiteLlm
from gepa_adk import evolve, run_sync, EvolutionConfig, SimpleCriticOutput

model = LiteLlm(model="ollama_chat/llama3.2:latest")

agent = LlmAgent(
    name="greeter",
    model=model,
    instruction="Greet the user appropriately.",
)

critic = LlmAgent(
    name="critic",
    model=model,
    instruction="Score for formal, Dickens-style greetings. 0.0-1.0.",
    output_schema=SimpleCriticOutput,
)

trainset = [
    {"input": "I am His Majesty, the King."},
    {"input": "I am your mother."},
    {"input": "I am a close friend."},
]

config = EvolutionConfig(
    max_iterations=5,
    patience=1,
    reflection_model="ollama_chat/llama3.2:latest",
)
result = run_sync(evolve(agent, trainset, critic=critic, config=config))
print(f"Score: {result.original_score:.2f} -> {result.final_score:.2f}")
print(result.evolved_components["instruction"])

Examples

Getting started:

Multi-agent & workflows:

Advanced:

Documentation

Getting Started · Guides · API Reference

Credits

Based on GEPA (source). Built on Google ADK (source).

License

Apache 2.0

About

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors