Skip to content

Rather1337/FormGuide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FormGuide

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.

Features

  • 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

Requirements

  • 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:27b available
  • Ports: Flask defaults to http://127.0.0.1:5000; Ollama defaults to http://127.0.0.1:11434

Quickstart

# 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.

How it works

  1. DocumentProcessor (formguide/doc_process.py) converts the uploaded PDF to text using Docling with GPU acceleration.
  2. 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.
  3. run_analysis (formguide/processor.py) orchestrates conversion + agent calls and returns (success: bool, message: str).
  4. app.py exposes /upload (multipart form field file) and renders the simple HTML interface at /. Uploaded files are saved under uploads/.

API response

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).

Repository layout

  • formguide/app.py – Flask entrypoint and routes
  • formguide/processor.py – pipeline wiring document conversion and agent logic
  • formguide/doc_process.py – Docling PDF-to-text helper
  • formguide/agent.py – LangChain + Ollama agent and prompts
  • formguide/templates/index.html – minimal upload UI
  • formguide/static/ – styling assets
  • documents/ – example PDFs and extracted text for manual testing

Development tips

  • Uploads are stored in uploads/; delete contents if you need a clean run.
  • To exercise the pipeline without the UI, run python -m formguide.processor after placing a test file in uploads/ and adjusting the path in __main__.
  • Ruff configuration is present in pyproject.toml; install and run it if you add linting to the workflow.***

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •