Skip to main content

Document AI - Intelligent document processing and extraction

Project description

Document AI

Documentation: https://zeel-04.github.io/doc-intelligence/

A library for parsing, formatting, and processing documents that can be used to build AI-powered document processing pipelines with structured data extraction and citation support.

Document AI

Features

  • Extract structured data from PDF documents using LLMs
  • Automatic citation tracking with page numbers, line numbers, and bounding boxes
  • Support for digital PDFs (local files and URLs)
  • Type-safe data models using Pydantic
  • Multi-provider LLM support: OpenAI, Anthropic, Gemini, Ollama

Installation

Requirements

  • Python >= 3.10
  • An API key for your chosen LLM provider (OpenAI, Anthropic, or Gemini) — or a local Ollama server

Install with uv

uv pip install doc-intelligence

Or with pip:

pip install doc-intelligence

Quick Start

Set up your API key (example with OpenAI):

echo "OPENAI_API_KEY=your-api-key-here" > .env

Here's a simple example to extract structured data from a PDF:

from dotenv import load_dotenv
from pydantic import BaseModel

from doc_intelligence import PDFProcessor

# Load environment variables
load_dotenv()

# Define your data model
class License(BaseModel):
    license_name: str

# Create a processor and extract in two lines
processor = PDFProcessor(provider="openai")
result = processor.extract(
    uri="https://example-files.online-convert.com/document/pdf/example.pdf",
    response_format=License,
    include_citations=True,
    extraction_mode="single_pass",
    model="gpt-4o-mini",
)

# Access the extracted data and citations
print(f"Extracted data: {result.data}")
print(f"Metadata: {result.metadata}")

Sample Output

The extract method returns an ExtractionResult with .data and .metadata attributes:

result.data
# License(license_name='Attribution-ShareAlike 3.0 Unported')

result.metadata
# {
#     'license_name': {
#         'value': 'Attribution-ShareAlike 3.0 Unported',
#         'citations': [{
#             'page': 0,
#             'bboxes': [{
#                 'x0': 0.201,
#                 'top': 0.859,
#                 'x1': 0.565,
#                 'bottom': 0.872
#             }]
#         }]
#     }
# }

Documentation

For more detailed documentation, see the docs directory or visit the documentation site.

Development Setup

Prerequisites:

  • Python 3.10+
  • uv
git clone https://github.com/zeel-04/doc-intelligence.git
cd doc_intelligence
uv venv
uv sync

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

doc_intelligence-0.1.4.tar.gz (3.3 MB view details)

Uploaded Source

Built Distribution

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

doc_intelligence-0.1.4-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file doc_intelligence-0.1.4.tar.gz.

File metadata

  • Download URL: doc_intelligence-0.1.4.tar.gz
  • Upload date:
  • Size: 3.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for doc_intelligence-0.1.4.tar.gz
Algorithm Hash digest
SHA256 0f54b2dd915697fdb1cbe37d96539a2a6e03cc38e795d86727572c4a8a4b6ccd
MD5 39766515f1634c4ae65daf94d497351c
BLAKE2b-256 af269de9624207610a20c0f452a42e9151356adbafe4d25c803deb1e1aea6aab

See more details on using hashes here.

File details

Details for the file doc_intelligence-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: doc_intelligence-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 23.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for doc_intelligence-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b2ca00dfa8ec77b4591e724a46b5f0bdba51adcc2c5936be2dfd2fd31b720ba2
MD5 308965bdb71a18ba6743642adcf137b9
BLAKE2b-256 291f0d87c13dda66cc9fc04ae9dfe1360978a3dbd71a1ece6982986fddbad4cb

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