Metadata-Version: 2.1
Name: gptpdf
Version: 0.0.1
Summary: Using GPT to parse PDF
Home-page: https://github.com/CosmosShadow/gptpdf
License: Apache 2.0
Author: Chen Li
Author-email: lichenarthurdata@gmail.com
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: GeneralAgent (>=0.3.11,<0.4.0)
Requires-Dist: pymupdf (>=1.24.7,<2.0.0)
Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
Requires-Dist: shapely (>=2.0.1,<3.0.0)
Project-URL: Repository, https://github.com/CosmosShadow/gptpdf
Description-Content-Type: text/markdown

# gptpdf
Using GPT to parse PDF

## Introduction

This package uses OpenAI's GPT-4o to parse PDFs to Markdowns.
It perfectly parse text, image, math equations, charts, and tables.
It almost cost $0.013 per page.


## DEMO

See [examples/attention_is_all_you_need/output.md](examples/attention_is_all_you_need/output.md)

## Installation

```bash
pip install gptpdf
```

## Usage

```python
from gptpdf import parse_pdf
pdf_path = '../examples/attention_is_all_you_need.pdf'
output_dir = '../examples/attention_is_all_you_need/'
api_key = os.getenv('OPENAI_API_KEY')
base_url = os.getenv('OPENAI_API_BASE')
# Manually provide OPENAI_API_KEY and OPEN_API_BASE
content, image_paths = parse_pdf(pdf_path, output_dir=output_dir, api_key=api_key, base_url=base_url, model='gpt-4o')
print(content)
print(image_paths)
# also output_dir/output.md is generated
```

```python
from gptpdf import parse_pdf
pdf_path = '../examples/attention_is_all_you_need.pdf'
output_dir = '../examples/attention_is_all_you_need/'
# Use OPENAI_API_KEY and OPENAI_API_BASE from environment variables
content, image_paths = parse_pdf(pdf_path, output_dir=output_dir, model='gpt-4o', verbose=True)
print(content)
print(image_paths)
# also output_dir/output.md is generated
```
