Skip to main content

FastAPI service for LLM-powered PDF analysis

Project description

PDF Vision Processor

A FastAPI service that converts PDFs into page images, sends them to an OpenAI-compatible Vision LLM, and exposes the parsed layout/markdown through both REST APIs and a built-in UI. The project now ships as an installable package named pdf-vision-processor so it can be deployed with a single CLI command.

Installation (PyPI)

python -m venv venv && source venv/bin/activate
pip install pdf-vision-processor
pdf-vision-processor --host 0.0.0.0 --port 8080

The CLI loads a .env file from your current working directory (if present), applies overrides from environment variables prefixed with PDF_VISION_PROCESSOR_, and falls back to sensible defaults. Static assets and Jinja templates are bundled inside the wheel.

Note: PyMuPDF (fitz) is expected to be available in the runtime environment (e.g., preinstalled in the platform image). The PyPI package does not vendor it; install pymupdf manually if your deployment does not already include it.

Configuration

Setting CLI Flag Environment Variable Default
Host interface --host PDF_VISION_PROCESSOR_HOST 127.0.0.1
Port --port PDF_VISION_PROCESSOR_PORT 8000
Reload --reload/--no-reload PDF_VISION_PROCESSOR_RELOAD False
Log level --log-level PDF_VISION_PROCESSOR_LOG_LEVEL info
Data directory --data-dir PDF_VISION_PROCESSOR_DATA_DIR ~/.pdf-vision-processor/data
Logs directory --logs-dir PDF_VISION_PROCESSOR_LOG_DIR ~/.pdf-vision-processor/logs
Database URL --database-url PDF_VISION_PROCESSOR_DATABASE_URL sqlite:///<home>/db.sqlite3

Additional LLM specific variables (e.g., LLM_API_KEY, LLM_BASE_URL, LLM_MODEL, LLM_MAX_TOKENS) continue to be read from the environment; see docs/env_config.md for the full catalog. When no overrides are provided, uploads, derived images, and logs are stored under ~/.pdf-vision-processor/ so the package works even when installed system-wide.

Optional project-level configuration can also be provided through a config.toml file with sections named [server], [paths], and [database]. The CLI resolves settings in the following order: CLI flags → environment variables → config.toml → defaults.

Running from Source

Developers contributing to the repository can still use run.py, which now delegates directly to the packaged CLI to ensure consistent behavior:

python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
python run.py --host 127.0.0.1 --port 8000 --reload

Ensure your virtual environment already has pymupdf installed (or install it manually) before running the processor locally.

Assets, templates, and compatibility shims remain under the legacy app/ namespace for existing imports, but all active code now lives inside the pdf_vision_processor/ package (matching what ships to PyPI).

Usage

  1. Upload – Visit / and upload a PDF.
  2. Process – Click Process next to the document to kick off background ingestion.
  3. Inspect – Open the document view to see rendered pages, bounding box overlays, and extracted Markdown side-by-side.

API Examples

# Upload a PDF
curl -X POST -F "file=@/path/to/document.pdf" http://localhost:8000/upload

# Start processing (replace {id} with the returned document id)
curl -X POST http://localhost:8000/process/{id}

# Retrieve page analysis
curl http://localhost:8000/pages/{page_id}/analysis

Packaging & Release Workflow

Use the helper script to build and validate distribution artifacts:

python scripts/build_dist.py --bump patch
# optional: publish to TestPyPI / PyPI with twine upload dist/*

The script bumps the version (optional), cleans previous artifacts, runs setup.py sdist bdist_wheel, and executes twine check so we catch metadata issues before publication. See docs/plans/publishing_checklist.md for the full release checklist.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdf_vision_processor-0.1.0.tar.gz (27.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdf_vision_processor-0.1.0-py3-none-any.whl (29.9 kB view details)

Uploaded Python 3

File details

Details for the file pdf_vision_processor-0.1.0.tar.gz.

File metadata

  • Download URL: pdf_vision_processor-0.1.0.tar.gz
  • Upload date:
  • Size: 27.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for pdf_vision_processor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 afe8b6b5785ae1a1b705fc8b378e4978fa3ee132a33594dc86868509f07ef57d
MD5 b4fb2b1a0a4a9392fe387948ce1963f4
BLAKE2b-256 b7e6e0d4992fe4da85ebbd7658f949759824fefaa990f72e985042c4f865de30

See more details on using hashes here.

File details

Details for the file pdf_vision_processor-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pdf_vision_processor-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b4e754884a61ac23e2a987ed818ef46b3bc63c105c324fc2883972c1e6c8e0af
MD5 1a59056f776d86b31bdaf53db63a2c42
BLAKE2b-256 ce157154ba0d53fdd78f0871f193a7bfc3467f0bc0c3e829a0ecf4a337583dde

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page