67bb0095fa
Implements a two-layer approach to ensure legal texts are accurate and current: Option A — runtime injection (legifrance_client.py): - LegifranceClient: OAuth2 via PISTE (oauth.piste.gouv.fr), fetches consolidated article text via api.piste.gouv.fr/dila/legifrance/lf-engine-app - Redis cache with 24h TTL (in-memory fallback if no Redis) - build_filter_prompt() injects live texts into the prompt with explicit priority over static descriptions — model uses official Légifrance text, not training memory - Graceful fallback to static prompt if API is unavailable — filtering never blocks Option B — weekly sync script (scripts/check_legal_refs.py): - Reads legal_refs.yaml (11 tracked articles, priority critical/high/medium) - Fetches current text from Légifrance, diffs against stored baseline - --init: resolves LEGIARTI IDs on first run - --check: report only; --update: saves new texts to YAML - Exit code 2 when changes detected (CI/n8n-compatible) Supporting changes: - legal_refs.yaml: tracked articles with code LEGITEXT IDs, priorities, rationale - requirements.txt: add pyyaml>=6.0.2 and requests>=2.32.0 - .env.example: document PISTE_CLIENT_ID, PISTE_CLIENT_SECRET, LEGIFRANCE_CACHE_TTL - transparence.tsx: document the Légifrance injection for public transparency - Fixed portal URL: piste.gouv.fr (not piste.api.gouv.fr — verified June 2026) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
68 lines
4.1 KiB
Bash
68 lines
4.1 KiB
Bash
# La Voix du Peuple — Variables d'environnement
|
|
# Copiez ce fichier en .env et remplissez les valeurs.
|
|
# Sécurisez le fichier : chmod 600 .env
|
|
|
|
# ─── Base de données PostgreSQL ──────────────────────────────────────────────
|
|
# Format : postgresql://utilisateur:motdepasse@hote:port/nomdb
|
|
DATABASE_URL=postgresql://voixdupeuple:CHANGEME@localhost:5432/voixdupeuple
|
|
|
|
# ─── IA — Mistral (recommandé — souveraineté européenne) ─────────────────────
|
|
# Obtenez votre clé sur https://console.mistral.ai
|
|
MISTRAL_API_KEY=sk-...
|
|
|
|
# ─── IA — Alternative OpenAI-compatible (si Mistral non disponible) ──────────
|
|
# OPENAI_API_KEY=sk-...
|
|
# OPENAI_BASE_URL=https://votre-proxy.example.com/v1 # Optionnel : proxy/Ollama
|
|
|
|
# ─── Modèles IA (optionnel — valeurs par défaut ci-dessous) ──────────────────
|
|
# FILTER_MODEL=mistral-small-latest # Modèle de filtrage (rapide, économique)
|
|
# SYNTHESIS_MODEL=mistral-large-latest # Modèle de synthèse (haute qualité)
|
|
|
|
# ─── Sécurité Flask ───────────────────────────────────────────────────────────
|
|
# Générez avec : python3 -c "import secrets; print(secrets.token_hex(32))"
|
|
SECRET_KEY=CHANGEZ_CE_SECRET_AVEC_UNE_VALEUR_ALEATOIRE_LONGUE
|
|
|
|
# ─── Panel d'administration ───────────────────────────────────────────────────
|
|
# Mot de passe pour accéder à /admin
|
|
ADMIN_SECRET=CHANGEZ_CE_MOT_DE_PASSE_ADMIN
|
|
|
|
# ─── Flask ────────────────────────────────────────────────────────────────────
|
|
FLASK_ENV=production
|
|
PORT=8080
|
|
|
|
# ─── Anti-abus (optionnel — valeurs par défaut raisonnables) ─────────────────
|
|
# REDIS_URL=redis://localhost:6379/0 # Rate limiting persistant (recommandé en prod)
|
|
# RATE_LIMIT_CONTRIBUTIONS=5 per minute;3 per hour # Limite de soumissions
|
|
# CONTRIBUTION_COOLDOWN_SECONDS=3600 # Délai entre deux soumissions (même session)
|
|
# FLOOD_THRESHOLD=10 # Alerte flood : nb soumissions / 5 min / IP
|
|
|
|
# ─── hCaptcha (optionnel — recommandé en production) ─────────────────────────
|
|
# Créez un compte sur https://www.hcaptcha.com (RGPD-friendly)
|
|
# HCAPTCHA_SECRET_KEY=votre-cle-secrete-hcaptcha
|
|
# VITE_HCAPTCHA_SITE_KEY=votre-cle-de-site-hcaptcha # Nécessite rebuild frontend
|
|
|
|
# ─── API Légifrance — Injection dynamique des textes légaux (optionnel) ───────
|
|
# Permet de récupérer les textes des articles légaux en vigueur depuis Légifrance
|
|
# et de les injecter dans le prompt de filtrage, garantissant que le modèle IA
|
|
# travaille sur les textes officiels consolidés du jour, et non sa mémoire d'entraînement.
|
|
#
|
|
# Inscription gratuite sur https://piste.gouv.fr
|
|
# Créez une application → activez l'API Légifrance → copiez Client ID et Client Secret.
|
|
#
|
|
# PISTE_CLIENT_ID=votre-client-id
|
|
# PISTE_CLIENT_SECRET=votre-client-secret
|
|
#
|
|
# Durée de cache des textes légaux (Redis, défaut 24h) :
|
|
# LEGIFRANCE_CACHE_TTL=86400
|
|
#
|
|
# Initialisation (première fois, pour résoudre les LEGIARTI IDs) :
|
|
# python scripts/check_legal_refs.py --init
|
|
# Vérification hebdomadaire des changements :
|
|
# python scripts/check_legal_refs.py --check
|
|
# Mise à jour du YAML après changement :
|
|
# python scripts/check_legal_refs.py --update
|
|
|
|
# ─── Frontend ─────────────────────────────────────────────────────────────────
|
|
# URL publique du site (utilisée par le QR code et les exports)
|
|
VITE_APP_URL=https://votredomaine.fr
|