This document describes the AI-powered synthesis system that generates weekly summaries of citizen contributions for the Audierne2026 participatory campaign.
The system uses Claude API (Anthropic) to intelligently analyze and summarize contributions, producing a one-page French report organized by program category.
GitHub Issues (Contributions)
↓
GitHub API
↓
ai_synthesis.py
↓
Claude API
↓
One-page French Summary
↓
GitHub Issue (Report)
scripts/ai_synthesis.py)The script:
conforme charte (validated contributions)Claude receives:
Claude produces:
The workflow:
sk-ant-api03-...)Go to your repository settings:
Settings → Secrets and variables → Actions → New repository secret
Add the following secret:
| Name | Value |
|---|---|
ANTHROPIC_API_KEY |
Your Claude API key |
Note: GITHUB_TOKEN is automatically provided by GitHub Actions.
The workflow file is located at:
.github/workflows/synthese_ia.yml
Push changes to your repository:
git add scripts/ai_synthesis.py .github/workflows/synthese_ia.yml
git commit -m "Add AI synthesis workflow"
git push
To enable weekly automatic runs, uncomment these lines in the workflow:
schedule:
- cron: '0 8 * * 1' # Every Monday at 8am UTC
For local testing:
.env file:
ANTHROPIC_API_KEY=sk-ant-api03-your-key
GITHUB_TOKEN=ghp_your-github-token
GITHUB_REPO=audierne2026/participons
pip install requests python-dotenv
python scripts/ai_synthesis.py --days 7 --output synthese.md
# Synthèse des contributions citoyennes
**Période :** 7 derniers jours
## Logement & Urbanisme
**3 contributions**
Les citoyens soulèvent principalement la question de l'ancienne
école maritime (#38) avec une proposition de réhabilitation en
lieu culturel. Cette idée rejoint les objectifs du programme sur
la préservation du patrimoine.
**Points clés :**
- Réhabilitation du bâtiment abandonné rue Amiral Guepratte
- Création d'un espace polyvalent (culturel/apprentissage)
- Besoin d'étude de faisabilité
## Environnement
**2 contributions**
Préoccupation sur les dunes de Trez Goarem (#15, #14) : conflit
entre promenades canines et protection des oiseaux nicheurs.
**Proposition :** Identifier un terrain alternatif moins sensible.
## Pistes d'action
1. Prioriser l'étude de faisabilité pour l'école maritime
2. Organiser une concertation sur Trez Goarem avec associations
3. Enrichir la section Environnement du programme
| Argument | Default | Description |
|---|---|---|
--days, -d |
7 | Time window in days |
--output, -o |
synthese_ia.md |
Output file path |
--no-ai |
False | Disable AI, use basic extraction |
| Input | Default | Description |
|---|---|---|
days |
7 | Period to analyze |
create_issue |
true | Create GitHub issue with report |
The prompt instructs Claude to:
Tu es un assistant pour la campagne municipale Audierne2026.
Tu dois générer une synthèse en français des contributions
citoyennes reçues ces {days} derniers jours.
[Contribution data in JSON format]
Génère une synthèse d'UNE PAGE MAXIMUM en français avec :
1. Un titre "Synthèse des contributions citoyennes"
2. La période couverte
3. Pour CHAQUE catégorie : nombre, points clés, enrichissement programme
4. Une section "Pistes d'action" avec 3 recommandations
IMPORTANT : Reste factuel, cite les numéros d'issues, sois concis.
Using Claude Sonnet model:
| Metric | Cost |
|---|---|
| Input tokens | ~$3 / 1M tokens |
| Output tokens | ~$15 / 1M tokens |
| Per synthesis | ~$0.01-0.05 |
| Monthly (4 runs) | ~$0.04-0.20 |
Very affordable for regular use.
If ANTHROPIC_API_KEY is not set, the script automatically falls back to basic extraction mode:
This ensures the workflow doesn’t fail if the API key is missing.
This synthesis fits into the broader contribution process:
1. Anonymous submission (Framaforms)
↓
2. Daily aggregation (poll_email.py)
↓
3. Compliance review (Team)
↓
4. Contextualization (GitHub Issues)
↓
5. AI Synthesis (ai_synthesis.py) ← THIS TOOL
↓
6. Discussion migration
↓
7. Program integration (February 2026)
The AI synthesis helps the team:
Cause: Rate limiting (no token) or insufficient permissions.
Solution:
GITHUB_TOKEN is setissues: readCause: Invalid or expired API key.
Solution:
ANTHROPIC_API_KEY in secretsCause: No contributions matching criteria in the time window.
Solution:
--days parameterconforme charte labelCause: Many contributions in the period.
Solution:
Planned improvements:
| Date | Version | Changes |
|---|---|---|
| 2026-01-07 | 1.0 | Initial implementation |
For issues with the AI synthesis:
aideThis tool is part of the Audierne2026 open participatory campaign. Repository: https://github.com/audierne2026/participons