GWÖ-Antragsprüfer: Automatische Gemeinwohl-Bilanzierung von Parlamentsanträgen nach der GWÖ-Matrix 2.0
Vier Sub-Issues unter Umbrella #50 — opt-in via 'pytest -m integration', Default-Suite (77 Unit-Tests) bleibt unberührt. - Sub-Issue A (#51): test_adapters_live.py — pro aktivem BL Reachability, Drucksache-ID-Format, Type-Filter, Datum-/Fraktion-Plausibilität, PDF-Link-HEAD-Probe (slow). NI als xfail (Login-Wall). - Sub-Issue B (#52): test_frontend_xref.py + ground_truth.py — pro BL ein manuell kuratiertes Frontend-Sample (Drucksache + Title-Substring + Fraktionen + Datum + PDF-URL), gegen das adapter.get_document() gespiegelt wird. Fängt Bug-Klasse 14 (Cross-Bundesland-Match). - Sub-Issue C (#53): test_wahlprogramme_indexed.py — Indexing-Status pro aktivem BL aus embeddings.db, PDF-Inhalts-Plausibilität (14 Marker + Wahlperioden-Horizont), expliziter Anti-Marker für Bug-Klasse 8 (CDU-BE 2021 vs 2026 PDF-Tausch durch abgeordnetenwatch). - Sub-Issue D (#54): test_citations_substring.py — Property-Verification: jedes vom LLM zitierte Snippet muss als (whitespace-normalisierter) Substring auf der angegebenen PDF-Seite vorhanden sein. Strict-Match mit Truncation-Marker-Toleranz, kein Fuzzy. Liest reale Assessments aus gwoe-antraege.db. Fängt Bug-Klassen 7/10/17 (Halluzination). Architektur: separates tests/integration/ Verzeichnis mit eigenem conftest.py, das die Stubs der Unit-Suite (fitz/bs4/openai/pydantic_settings) gezielt entfernt und auf echte Module umstellt — mit Fallback-Skip via pytest.require_module wenn lokale Dev-Maschine die Prod-Deps nicht hat. 206 neue Integration-Tests, 13 Helper-Unit-Tests. 77 Unit-Tests bleiben grün. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| app | ||
| tests | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| .tarignore | ||
| docker-compose.yml | ||
| Dockerfile | ||
| LICENSE | ||
| pytest.ini | ||
| README.md | ||
| requirements-dev.txt | ||
| requirements.txt | ||
GWÖ-Antragsprüfer
Automatische Gemeinwohl-Bilanzierung von Parlamentsanträgen nach der GWÖ-Matrix 2.0 für Gemeinden
🎯 Was ist das?
Der GWÖ-Antragsprüfer analysiert Anträge aus Landesparlamenten (aktuell NRW) und bewertet sie nach den Kriterien der Gemeinwohl-Ökonomie (GWÖ):
- GWÖ-Score (0-10): Wie gut entspricht der Antrag den GWÖ-Werten?
- Matrix-Zuordnung: Welche Felder der GWÖ-Matrix werden adressiert?
- Programmtreue: Passt der Antrag zu Wahl- und Parteiprogrammen?
- Verbesserungsvorschläge: Konkrete Textänderungen mit GWÖ-Begründung
✨ Features
- 🔍 Landtag-Suche: Direkte Anbindung an OPAL (NRW Parlamentsdokumentation)
- 📊 GWÖ-Matrix-Visualisierung: 5×5-Tabelle mit Bewertungssymbolen
- 🏷️ Tag-Wolke: Filter nach Themen mit Multi-Select
- 🎯 Partei-Filter: Durchschnittswerte pro Fraktion
- 📄 PDF-Export: Professionelle Berichte im GWÖ-Design
- 🔒 Security: CSP, CORS, Rate Limiting
🚀 Schnellstart
Voraussetzungen
- Python 3.12+
- Docker & Docker Compose
- DashScope API-Key (Qwen LLM)
Installation
# Repository klonen
git clone https://github.com/tobiasroedel/gwoe-antragspruefer.git
cd gwoe-antragspruefer
# Environment-Variablen
cp .env.example .env
# DASHSCOPE_API_KEY eintragen
# Mit Docker starten
docker compose up -d
# Oder lokal entwickeln
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload
Die App läuft auf http://localhost:8000
📁 Projektstruktur
webapp/
├── app/
│ ├── main.py # FastAPI-Endpoints
│ ├── analyzer.py # LLM-Analyse-Logik
│ ├── database.py # SQLite-Persistenz
│ ├── models.py # Pydantic-Modelle
│ ├── parlamente.py # Landtag-Adapter (OPAL)
│ ├── report.py # PDF-Generierung
│ ├── config.py # Settings
│ ├── kontext/ # GWÖ-Matrix, Wahlprogramme
│ ├── templates/ # Jinja2-HTML
│ └── static/ # CSS, JS, Assets
├── data/ # SQLite-DBs (Volume)
├── reports/ # Generierte PDFs (Volume)
├── docker-compose.yml
├── Dockerfile
└── requirements.txt
🔧 Konfiguration
Environment-Variablen
| Variable | Beschreibung | Default |
|---|---|---|
DASHSCOPE_API_KEY |
Alibaba DashScope API-Key | (required) |
LLM_MODEL_DEFAULT |
Standard-Modell | qwen-plus-latest |
LLM_MODEL_PREMIUM |
Premium-Modell | qwen-max |
Unterstützte Bundesländer
| Code | Name | Status |
|---|---|---|
| NRW | Nordrhein-Westfalen | ✅ Aktiv |
| BY | Bayern | 🔜 Geplant |
| BW | Baden-Württemberg | 🔜 Geplant |
📊 API-Endpoints
| Methode | Pfad | Beschreibung |
|---|---|---|
| GET | / |
Web-UI |
| GET | /api/assessments |
Alle Bewertungen |
| GET | /api/assessment?drucksache=18/12345 |
Einzelne Bewertung |
| POST | /api/analyze-drucksache |
Neue Analyse starten |
| GET | /api/search?q=Klima |
Interne Suche |
| GET | /api/search-landtag?q=Klima |
Landtag-Suche |
| GET | /api/assessment/pdf?drucksache=18/12345 |
PDF-Download |
🧠 GWÖ-Prompt (v5)
Der Analyse-Prompt basiert auf:
- GWÖ-Matrix 2.0 für Gemeinden (Arbeitsbuch)
- ECOnGOOD Corporate Design Manual 2024
- Wahlprogramme der NRW-Landtagsparteien 2022
Ausgabe-Format:
- GWÖ-Score mit Matrix-Feldern und Symbolen (++/+/○/−/−−)
- Wahlprogramm- und Parteiprogrammtreue
- Verbesserungsvorschläge im Redline-Format (Original → Vorschlag → Begründung)
- Themen-Tags für Kategorisierung
🛠️ Entwicklung
# Tests ausführen
pytest
# Linting
ruff check app/
# Type-Checking
mypy app/
📝 Lizenz
MIT License - siehe LICENSE
🙏 Credits
- Gemeinwohl-Ökonomie - Matrix und Arbeitsbücher
- Alibaba DashScope - Qwen LLM API
- Landtag NRW - OPAL-Dokumentation
Entwickelt von Tobias Rödel · tobiasroedel.de