This repository demonstrates the Spring AI Evaluator Optimizer Workflow Pattern, a powerful self-improving AI system that creates high-quality output through iterative refinement. The pattern uses two specialized LLM roles - a "Generator" (Writer) to create initial content and an "Evaluator" (Editor) to critique and guide improvements until the output meets predefined quality standards.
π Dive Deeper: For a complete walkthrough, detailed explanations of the Evaluator Optimizer Workflow pattern, and step-by-step instructions for building the example application, read our comprehensive blog post.
π Spring AI Evaluator Optimizer Pattern: Building Smarter AI That Gets Better With Each Try
π₯ Visual Learning: Prefer video tutorials? Watch our step-by-step implementation guide on YouTube.
π Spring AI Evaluator Optimizer Pattern: Building Smarter AI That Gets Better With Each Try
Make sure to provide these Java environment variables when running the application:
GEMINI_API_KEY
: Your Google Gemini API key.
This project implements a Smart Email Generator as a real-world example of the Spring AI Evaluator Optimizer Workflow. It showcases how to:
- Set up a Spring Boot application with Spring AI and Google Gemini integration.
- Implement the
EmailEvaluatorOptimizer
workflow with recursive improvement loops. - Create specialized AI personas through carefully crafted system prompts for Writer and Editor roles.
- Build a complete REST API for professional email generation with quality assurance.
- Handle iterative refinement with safety limits and comprehensive error handling.
The application generates professional emails (job follow-ups, raise requests, etc.) that are automatically refined through multiple rounds of AI-powered editing until they meet strict quality criteria, including a 80-word limit for conciseness.
Learn More: This is part of our Spring AI Agentic Workflow series. Check out our other workflow patterns: