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.2.tar.gz (1.4 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.2-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: doc_intelligence-0.1.2.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","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.2.tar.gz
Algorithm Hash digest
SHA256 cde7996a9ed61b6dd1d8aab56f755aa122964ba797e603c2bbb23f4a198a82b5
MD5 5da2c07eff8b4840e571d6c3e1df744e
BLAKE2b-256 6bdbd8c5ace7d06ec8eff85243965e728960cba8c4600673a7b30f486ec0399b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: doc_intelligence-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 91de177ed5776a711360b73f80427a4d642220e2a1ded5b731fe3c8cabbb946e
MD5 f34be6cfb9442d3165700a3b03f47555
BLAKE2b-256 88038111e9ad731a2eca283b2f8340969fb8bada9a7a41e4f2843b1b72e550f9

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