GWÖ-Antragsprüfer: Automatische Gemeinwohl-Bilanzierung von Parlamentsanträgen nach der GWÖ-Matrix 2.0
Atomic refactor of the three modules that previously hardcoded NRW
behaviour. After this commit, every analysis path consults the central
BUNDESLAENDER registry for governing fractions, parliament name, and
state metadata.
wahlprogramme.py
- WAHLPROGRAMME is now nested {bundesland: {partei: meta}}; NRW data
hoisted unchanged under the "NRW" key.
- New WAHLPROGRAMM_KONTEXT_FILES dict maps a state to its overview
markdown file (currently only NRW).
- find_relevant_quotes(text, fraktionen, bundesland) — bundesland is
now a required positional. Governing fractions for the requested
state are merged with the submitting fractions before lookup.
- Helpers get_wahlprogramm() and parteien_mit_wahlprogramm() expose
the new shape to other modules.
- ValueError on unknown bundesland (no silent fallback).
embeddings.py
- Schema migration in init_embeddings_db: adds a `bundesland` column
to the chunks table when missing, plus an index, and backfills
existing rows from the PROGRAMME registry. Grundsatzprogramme
(federal level) keep bundesland NULL by design.
- find_relevant_chunks accepts a bundesland filter that matches state
rows OR NULL — so federal Grundsatzprogramme remain visible to every
analysis.
- get_relevant_quotes_for_antrag(text, fraktionen, bundesland, …) —
bundesland required, governing fractions read from BUNDESLAENDER
instead of hardcoded ["CDU","GRÜNE"]. Order-preserving dedup
replaces the previous set-based merge.
- index_programm now writes the bundesland column on insert.
- Dropped the hardcoded "Wahlprogramm NRW 2022" label in
format_quotes_for_prompt — bundesland context is implicit in the
surrounding prompt block.
analyzer.py
- get_bundesland_context reads parlament_name, regierungsfraktionen,
landtagsfraktionen and the optional WAHLPROGRAMM_KONTEXT_FILES entry
from the central registry. Throws ValueError on unknown OR inactive
bundesland — kills the silent NRW fallback that previously masked
configuration gaps.
- The Antragsteller-detection heuristic now iterates
BUNDESLAENDER[bundesland].landtagsfraktionen instead of
WAHLPROGRAMME.keys(), so we recognise parties for which we don't
yet have a Wahlprogramm PDF.
- Both quote lookups (semantic + keyword fallback) now receive the
bundesland.
Resolves issue #5. Foundation for #2 (LSA), #3 (Berlin), #4 (MV).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
||
|---|---|---|
| app | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| .tarignore | ||
| docker-compose.yml | ||
| Dockerfile | ||
| LICENSE | ||
| README.md | ||
| 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