AI-assisted pre-check for Wohngeld applications. FormGuide converts uploaded income-proof PDFs to text with Docling (GPU), asks a local Gemma 3 27B model (via Ollama) whether the document is valid, and extracts applicant name, first name, and monthly income. A minimal Flask UI/API handles uploads and shows the result.
- PDF-to-text conversion with Docling configured for CUDA 12
- LangChain agent using ChatOllama (Gemma 3 27B) for validation and data extraction
- Simple Flask frontend (
/) plus JSON upload endpoint at/upload - Sample documents in
documents/for quick smoke tests
- Python 3.12+ and Pixi (or another env manager)
- NVIDIA GPU with CUDA 12 (Docling is initialized for GPU use)
- Ollama running locally with
gemma3:27bavailable - Ports: Flask defaults to
http://127.0.0.1:5000; Ollama defaults tohttp://127.0.0.1:11434
# 1) Create/enter the env
pixi install
pixi shell
# 2) Start Ollama in another terminal (only once you may need to pull the model)
ollama pull gemma3:27b
ollama serve
# 3) Run the Flask app (inside the Pixi shell)
python formguide/app.py
# 4) Open the UI
# Visit http://127.0.0.1:5000 and upload a PDF from the documents/ folder.DocumentProcessor(formguide/doc_process.py) converts the uploaded PDF to text using Docling with GPU acceleration.FormGuideAgent(formguide/agent.py) is a LangChain agent backed by ChatOllama (Gemma 3 27B). It first checks if the document looks like an income proof (JA/NEIN), then extracts(Nachname, Vorname, Monatseinkommen)when valid.run_analysis(formguide/processor.py) orchestrates conversion + agent calls and returns(success: bool, message: str).app.pyexposes/upload(multipart form fieldfile) and renders the simple HTML interface at/. Uploaded files are saved underuploads/.
POST /upload returns JSON: {"success": true|false, "error": "<text>"}. On success the error field currently carries the extracted income string; on failure it contains the rejection reason (frontend expects this format).
formguide/app.py– Flask entrypoint and routesformguide/processor.py– pipeline wiring document conversion and agent logicformguide/doc_process.py– Docling PDF-to-text helperformguide/agent.py– LangChain + Ollama agent and promptsformguide/templates/index.html– minimal upload UIformguide/static/– styling assetsdocuments/– example PDFs and extracted text for manual testing
- Uploads are stored in
uploads/; delete contents if you need a clean run. - To exercise the pipeline without the UI, run
python -m formguide.processorafter placing a test file inuploads/and adjusting the path in__main__. - Ruff configuration is present in
pyproject.toml; install and run it if you add linting to the workflow.***