QM2 Evolution: From Static Engine to AI-Powered Intelligence
Source: Dev.to
Overview
A high‑performance CLI quiz engine built with Python, now evolved into a smart study companion with Gemini AI integration and 84 % test coverage.
New Release: QM2 v1.1.0
The latest version adds a “brain” to the engine by integrating Google Gemini AI. The goal is to generate a 20‑question, high‑quality quiz on any topic in under 10 seconds using the Gemini 1.5 & 2.0 Flash models.
AI‑Powered Features
- Topic‑to‑Quiz – Simply provide a topic (e.g., “Advanced Python Decorators” or “World War II History”) and the tool creates a full quiz instantly.
- Multi‑Type Support – The AI generates all four supported question types:
- Multiple Choice
- True/False
- Fill‑in‑the‑blank
- Matching pairs
- Smart Retries – Exponential backoff and a fallback chain (Gemini 2.0 Flash → 1.5 Flash → 1.5 Pro) keep the experience uninterrupted even when rate limits are hit.
- Advanced JSON Sanitization – A custom module strips any AI “chatter” and extracts a clean, valid quiz schema.
Implementation Details
- Google GenAI SDK – Handles communication with Gemini models.
- Exponential Backoff Logic – Gracefully manages API rate limits.
- Mocked AI Testing –
unittest.mocksimulates Gemini responses, allowing CI/CD to verify JSON parsing and fallback logic without a real API key or token usage.
Installation & Usage
# Upgrade to the latest version
pip install --upgrade qm2# Set your Gemini API key
export GEMINI_API_KEY="your_google_ai_key"
# Run QM2
qm2Enter a topic when prompted, and the CLI will generate the quiz on the fly.
Documentation & Resources
- PyPI:
- GitHub:
- Docs:
Call to Action
If QM2 helps your study sessions, consider starring the GitHub repository. Your feedback is welcome—let’s discuss the future of AI‑generated educational content in the comments!