How badreddinebensalahengineering/qr-cache-builder works
This local Flask tool helps an operator enrich a bilingual chatbot Q&A cache: enter a question, inspect similar groups, generate and assess French/English reformulations, select variants, provide answers, and save or edit a group. The browser calls Flask endpoints; the server coordinates language detection, paraphrase generation, semantic collision/novelty scoring, translation, and JSON persistence. Groq is used when configured; otherwise generation falls back to local Ollama, with rule-based paraphrasers as another fallback. The excerpts show key calls, but not every route or UI interaction.
Main entry points: app.py Flask workflow · app.js Question editor · llm_paraphraser.py LLM paraphrases · rule_paraphraser.py English rules
Components 12
Operator interface
- Question editor
static/app.js
Application API
- Flask workflow
app.py
Language and generation
- LLM paraphrases
llm_paraphraser.py - English rules
rule_paraphraser.py - French rules
rule_paraphraser_fr.py - Language detection and translation
translator.py
Matching and persistence
- Semantic matching and scoring
app.py - Text deduplication
text_utils.py - Q&A groups
Other components
- Operator
- Groq API
- Ollama service
Connections 13
- Operator → Question editor: enters questions
static/app.js - Question editor → Flask workflow: requests suggestions
static/app.js - Question editor → Flask workflow: saves groups
static/app.js - Question editor → Flask workflow: requests translation
static/app.js - Flask workflow → Q&A groups: reads and writes
app.py - Flask workflow → Language detection and translation: detects and translates
app.py - Flask workflow → LLM paraphrases: generates variants
app.py - Flask workflow → English rules: uses fallback
app.py - Flask workflow → French rules: uses fallback
app.py - Flask workflow → Semantic matching and scoring: scores candidates
app.py - Flask workflow → Text deduplication: deduplicates variants
app.py - LLM paraphrases → Groq API: calls when configured
llm_paraphraser.py - LLM paraphrases → Ollama service: calls otherwise
llm_paraphraser.py