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.

Features

  • Extract structured data from PDF documents using LLMs
  • Automatic citation tracking with page numbers, line numbers, and bounding boxes
  • Support for digital PDFs
  • Type-safe data models using Pydantic
  • OpenAI integration with support for reasoning models

Installation

Requirements

  • Python >= 3.10
  • OpenAI API key

Install with uv

uv pip install doc-intelligence

Or with pip:

pip install doc-intelligence

Quick Start

Set up your OpenAI API key:

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 doc_intelligence.processer import DocumentProcessor
from doc_intelligence.llm import OpenAILLM
from pydantic import BaseModel

# Load environment variables
load_dotenv()

# Initialize the LLM
llm = OpenAILLM()

# Create a processor from a PDF file
processor = DocumentProcessor.from_digital_pdf(
    uri="path/to/your/document.pdf",
    llm=llm,
)

# Define your data model
class Balance(BaseModel):
    ending_balance: float

# Configure extraction with citations
config = {
    "response_format": Balance,
    "llm_config": {
        "model": "gpt-5",
        "reasoning": {"effort": "minimal"},
    },
    "extraction_config": {
        "include_citations": True,
        "extraction_mode": "single_pass",
        "page_numbers": [0, 1],  # Optional: specify which pages to process
    }
}

# Extract structured data
response = processor.extract(config)

# Get the extracted data and citations
data, citations = response
print(f"Extracted data: {data}")
print(f"Citations: {citations}")

Sample Output

The extract method returns a tuple containing the extracted data and citation information:

(Balance(ending_balance=111.61),
 {'ending_balance': {'value': 111.61,
   'citations': [{'page': 0,
     'bboxes': [{'x0': 0.058823529411764705,
       'top': 0.6095707475757575,
       'x1': 0.5635455037254902,
       'bottom': 0.6221969596969696}]}]}})

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.1.tar.gz (165.8 kB 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.1-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: doc_intelligence-0.1.1.tar.gz
  • Upload date:
  • Size: 165.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","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.1.tar.gz
Algorithm Hash digest
SHA256 670659a213938fc32b52adfdb87407ab7ab5cd7dab8864bec1171323a7cd72e9
MD5 e8cce58d0195f2ae960242da3b619dda
BLAKE2b-256 e755bdde645e29211d1c624cc65c0e40a3f5cf3e6840d3f05b6d9f02b3b9d2a4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: doc_intelligence-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 434b4ff6639a19f1a855ddaa67d741b1a41e30caaff108e1988f2cadbb6a2b43
MD5 45378e010f605301a7392b5e63831db1
BLAKE2b-256 46e5127f27da21b1b7da1326783a1945e426185e0946ebf86e08aa8fc989a175

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