Skip to content

Add Docling document model, visual enrichment, and processing trace - #344

Open
farhat-is-coding wants to merge 6 commits into
devfrom
farhat/feat/docling-document-model
Open

Add Docling document model, visual enrichment, and processing trace#344
farhat-is-coding wants to merge 6 commits into
devfrom
farhat/feat/docling-document-model

Conversation

@farhat-is-coding

Copy link
Copy Markdown
Collaborator

What changed

  • Parse supported documents once into a persisted Docling document model with reading order, pages, sections, tables, pictures, captions, bounding boxes, and heading context.
  • Classify document pictures locally and route substantive figures to context-aware Gemini descriptions.
  • Transcribe textless scanned pages through the vision lane while preserving mixed-document text.
  • Rebuild enriched text in original reading order before embedding and indexing.
  • Cache visual enrichment by user, content, context, model, and prompt version.
  • Record provider usage through the existing billing transaction path.
  • Persist a four-stage processing journey: parsing, visual enrichment, embedding generation, and vector indexing.
  • Distinguish visual operations, fresh Gemini requests, cache hits, and failed operations.
  • Expose document structure and processing-journey API responses.
  • Add the required database migrations and environment configuration.

Why

The previous upload path flattened PDFs too early, losing useful document structure and leaving figures unsearchable. Failures were also attributed to the overall upload rather than the exact parsing, enrichment, embedding, or indexing stage.

This change preserves Docling's structural model, adds searchable visual meaning with source context, and makes processing behavior, cost, caching, and failures inspectable.

Impact

Mixed text-and-image PDFs now retain headings, tables, captions, and visual descriptions in retrieval text. Textless pages can recover searchable transcription through Gemini. Existing non-Docling and non-visual documents continue through the normal path.

Internal-reference resolution and the user-approved large scanned-document OCR workflow are intentionally out of scope for follow-up PRs.

Validation

  • Black formatting and isort checks passed.
  • 18 focused document-enrichment and processing-journey tests passed.
  • Migrations applied locally.
  • Verified with real mixed PDFs through Docling, Gemini enrichment, embeddings, and local Weaviate.
  • Confirmed cached reprocessing creates no new provider transactions and now reports cache work separately.

@farhat-is-coding
farhat-is-coding marked this pull request as ready for review August 15, 2026 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant