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
  • 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 (local or URL)
processor = DocumentProcessor.from_digital_pdf(
    uri="https://example-files.online-convert.com/document/pdf/example.pdf",  # Can also be a local path
    llm=llm,
)

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

# Configure extraction with citations
config = {
    "response_format": License,
    "llm_config": {
        "model": "gpt-5-mini",
        "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)

# Access the extracted data and citations
extracted_data = response["extracted_data"]
metadata = response["metadata"]
print(f"Extracted data: {extracted_data}")
print(f"Metadata: {metadata}")

Sample Output

The extract method returns a dictionary containing the extracted data and metadata with citation information:

{
    'extracted_data': License(license_name='Attribution-ShareAlike 3.0 Unported'),
    'metadata': {
        'license_name': {
            'value': 'Attribution-ShareAlike 3.0 Unported',
            'citations': [{
                'page': 0,
                'bboxes': [{
                    'x0': 0.20106913928643427,
                    'top': 0.8587326111744586,
                    'x1': 0.5648947389639185,
                    'bottom': 0.8718454960091222
                }]
            }]
        }
    }
}

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.3.tar.gz (1.5 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.3-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: doc_intelligence-0.1.3.tar.gz
  • Upload date:
  • Size: 1.5 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.3.tar.gz
Algorithm Hash digest
SHA256 5a5fbe5b3d8638a1b5316fb6dc2dcca697cf8bc00e538e15330fdd084afa0ae9
MD5 32d5b37012293d17a50001fc4761fcef
BLAKE2b-256 896a20361487517972f065a94f879437903c6570dc590cd629f96e17ad0df5e2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: doc_intelligence-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 16.7 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d872ebd19466188fabec9df830d94f11e79c3dc04714270e4e3bbdff65d71b40
MD5 b9e634c37a8e4397447aa84d3cf25517
BLAKE2b-256 14fff151124edaffd78fb2b5554bdbcc2b277103b890e29d8f509ab6fa799960

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