Skip to main content

Document AI - Intelligent document processing and extraction

Project description

Document AI

Documentation: https://zeel-04.github.io/document-ai/

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 uv

First, install uv if you haven't already:

curl -LsSf https://astral.sh/uv/install.sh | sh

Install from Source

Clone the repository and install the package:

git clone https://github.com/zeel-04/document-ai.git
cd document-ai
uv sync

Install from Git (Alternative)

You can also install directly from the git repository:

uv pip install git+https://github.com/zeel-04/document-ai.git

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 document_ai.processer import DocumentProcessor
from document_ai.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/document-ai.git
cd document-ai
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.0.7.tar.gz (166.1 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.0.7-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: doc_intelligence-0.0.7.tar.gz
  • Upload date:
  • Size: 166.1 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.0.7.tar.gz
Algorithm Hash digest
SHA256 a817f8f7aba16ea0f49e74b5753cf7bc605ee9add14d92d53f7f09842c6f1fa2
MD5 af6c5615634a2407801f2d8697cda12a
BLAKE2b-256 9e1be63be3d8a46610eb2433f693ce296297221ad2781cf2c067b7a48e4cdcea

See more details on using hashes here.

File details

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

File metadata

  • Download URL: doc_intelligence-0.0.7-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.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a6f27584760d53389ca5749e41dfab73c2a7df3bfad5fdb8fe655779442506df
MD5 65dba5e9b37e3f408121d478c1fd5e8e
BLAKE2b-256 57b45bdb41d2e9ddcf609d5f30374483187bb6aacb8778e37364005462709248

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