Vanguardia EPIS is designed to operate even when there is no active internet connection or when the Gemini API quota has been exhausted. The mechanism that makes this possible is a local JSON cache of pre-generated AI responses — one entry per student. TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Pierrot-01/Hackathon_epis_2026/llms.txt
Use this file to discover all available pages before exploring further.
generar_cache.py script populates this cache by calling the Gemini API once per student while you do have connectivity, so the server can serve those responses indefinitely afterward without making any further API calls.
Why Pre-Generate the Cache?
Rate limit protection
Live demos that call the Gemini API in real time risk hitting per-minute or per-day rate limits mid-presentation. Pre-generating eliminates this risk entirely.
Offline operation
Rural school environments frequently lack reliable connectivity. A pre-generated cache guarantees the system works regardless of network availability.
Art. VIII §6.1 compliance
The project constitution mandates a cache-based resilience mechanism as a non-negotiable architectural requirement. Running this script fulfils that obligation.
Genuine AI responses
All cached entries are generated by the live Gemini model — never written by hand — fulfilling Art. VIII §8.1.1 and §8.1.2 of the specification.
How the Script Works
generar_cache.py is run from the project root and follows this sequence for every student record in the dataset:
Verify GEMINI_API_KEY
The script reads
GEMINI_API_KEY from the environment. If the variable is not set, it prints an error and exits immediately:Classify each student with the rule engine
For every student record,
clasificar_estudiante() is called to determine their risk level using the deterministic rule engine. This step does not call any external API — it is purely local logic.Risk levels produced by the classifier:| Symbol | Level | Meaning |
|---|---|---|
| 🔴 | Alto | High dropout risk |
| 🟡 | Medio | Moderate risk |
| 🟢 | Bajo | Low risk |
| ⚪ | Dato insuficiente | Insufficient data to classify |
Skip ⚪ students
Students classified as ⚪ (insufficient data) do not receive an AI-generated explanation — there is not enough information to make a meaningful analysis. These students are skipped silently with a log entry:
Call Gemini live for each remaining student
For every student with a 🔴, 🟡, or 🟢 classification, If a call fails (e.g., network error or quota exceeded), the entry is marked with ❌ and the script continues to the next student:
generar_explicacion() is called with the student’s ID, name, grade, risk level, risk trigger reasons, and any missing variables. The script logs progress inline:Running the Script
Make sure your API key is exported, then run from the project root:Cache File Structure
The output is saved atcache/respuestas_ia.json. Each key is a student ID, and each value contains the AI-generated explanation, teaching recommendation, and a generation timestamp:
Cache entries are never written by hand — they are always produced by calling the live Gemini model. This guarantees authenticity of all AI-generated content, as required by Art. VIII §8.1.1 and §8.1.2 of the project specification.
How the Cache Is Consumed
The server modulefallback.py reads cache/respuestas_ia.json at startup using lazy loading. When the generar_explicacion() function is called for a student:
- It first checks whether
GEMINI_API_KEYis available and attempts a live API call. - If the live call fails (no key, quota exceeded, or network error), it looks up the student ID in the loaded cache.
- If a cache entry is found, it is returned with
origen_ia: "fallback". - If neither a live response nor a cache entry is available, the response is returned with
origen_ia: "error_sin_cache".