Python service for generating and maintaining purely functional DEAP evolutionary algorithm code in currently rigid 12-cell Jupyter notebook format.
TODO integrate with VolPE system
EVOC DEAP Agent is an intelligent service that creates, modifies, and fixes DEAP code following a strict functional programming style with exactly 12 cells, perfect for Jupyter notebooks.
- Flexible Input: Accepts any JSON structure - extra fields automatically sent to LLM as "other_specifications"
- Generate: Create complete DEAP notebooks from structured JSON specifications
- Modify: Update existing notebooks via natural language instructions
- Fix: Automatically repair broken code using error tracebacks
- Smart Dependencies: Hybrid static + LLM-based dependency detection
- Structured Output: 100% JSON via Instructor + Pydantic (no markdown)
- Memory Layer: Mem0 integration for session history and preferences
- LangGraph Workflow: State management with validation loops
- FastAPI: For REST API
- LangGraph: Workflow orchestration with state management
- Instructor + Pydantic: Guaranteed structured LLM outputs
- Mem0: Session memory and preference tracking
- Groq: Fast LLM inference (compatible with ChatGroq)
- Python 3.11+
Every generated notebook follows this exact structure:
- Cell 0: Imports (DEAP, NumPy, Matplotlib, etc.)
- Cell 1: Problem configuration (dimensions, bounds)
- Cell 2: Creator setup (
creator.createfor Fitness and Individual) - Cell 3: Evaluate function (
def evaluate) - Cell 4: Mate/crossover function (
def mate) - Cell 5: Mutation function (
def mutate) - Cell 6: Selection function (
def select) - Cell 7: Additional operators (optional)
- Cell 8: Initialization functions (
def create_individual) - Cell 9: Toolbox registration (
toolbox.register()calls) - Cell 10: Main evolution loop (eaSimple, eaMuPlusLambda, or custom)
- Cell 11: Results, plotting, statistics
- Docker and Docker Compose
- Groq API key (get one at groq.com)
-
Clone and navigate to the project:
cd evoc-deap-agent -
Set up environment variables:
cp .env.example .env # Edit .env and add your GROQ_API_KEY -
Build the Docker image:
docker build -t evoc-deap-agent . -
Run the container:
docker run -p 8000:8000 --env-file .env evoc-deap-agent
Or use Docker Compose:
docker-compose up
-
Verify it's running:
curl http://localhost:8000/health
-
Install Python 3.11+ (if not already installed)
python --version # Should be 3.11 or higher -
Create virtual environment (recommended):
python -m venv venv # On Windows: venv\Scripts\activate # On macOS/Linux: source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
Create a
.envfile in the project root:cp .env.example .env
Then edit
.envand add your API keys: -
Run the service:
python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
Or directly:
python -m app.main
-
Access the API:
- API Root: http://localhost:8000
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- Health Check: http://localhost:8000/health
-
Test the API:
curl http://localhost:8000/health
Expected response:
{"status": "healthy", "version": "2.0.0"}