openextract 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openextract-0.3.0/.github/CODEOWNERS +1 -0
- openextract-0.3.0/.github/ISSUE_TEMPLATE/bug_report.yml +68 -0
- openextract-0.3.0/.github/ISSUE_TEMPLATE/config.yml +5 -0
- openextract-0.3.0/.github/ISSUE_TEMPLATE/feature_request.yml +37 -0
- openextract-0.3.0/.github/PULL_REQUEST_TEMPLATE.md +21 -0
- openextract-0.3.0/.github/workflows/ci.yml +25 -0
- openextract-0.3.0/.github/workflows/deploy-docs.yml +42 -0
- openextract-0.3.0/.github/workflows/release.yml +59 -0
- openextract-0.3.0/.gitignore +14 -0
- openextract-0.3.0/.python-version +1 -0
- openextract-0.3.0/CHANGELOG.md +26 -0
- openextract-0.3.0/CONTRIBUTING.md +54 -0
- openextract-0.3.0/LICENSE +21 -0
- openextract-0.3.0/PKG-INFO +113 -0
- openextract-0.3.0/README.md +87 -0
- openextract-0.3.0/SECURITY.md +20 -0
- openextract-0.3.0/docs/.nojekyll +0 -0
- openextract-0.3.0/docs/_config.yml +18 -0
- openextract-0.3.0/docs/index.html +375 -0
- openextract-0.3.0/pyproject.toml +57 -0
- openextract-0.3.0/src/openextract/__init__.py +28 -0
- openextract-0.3.0/src/openextract/_extract.py +75 -0
- openextract-0.3.0/src/openextract/exceptions.py +25 -0
- openextract-0.3.0/tests/__init__.py +0 -0
- openextract-0.3.0/tests/test.pdf +0 -0
- openextract-0.3.0/tests/test_extract.py +220 -0
- openextract-0.3.0/uv.lock +1030 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* @colesmcintosh
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
name: Bug Report
|
|
2
|
+
description: Report a bug or unexpected behavior
|
|
3
|
+
labels: ["bug"]
|
|
4
|
+
body:
|
|
5
|
+
- type: markdown
|
|
6
|
+
attributes:
|
|
7
|
+
value: |
|
|
8
|
+
Thanks for taking the time to report a bug. Please fill out the information below.
|
|
9
|
+
|
|
10
|
+
- type: textarea
|
|
11
|
+
id: description
|
|
12
|
+
attributes:
|
|
13
|
+
label: Description
|
|
14
|
+
description: A clear description of the bug
|
|
15
|
+
placeholder: What happened?
|
|
16
|
+
validations:
|
|
17
|
+
required: true
|
|
18
|
+
|
|
19
|
+
- type: textarea
|
|
20
|
+
id: reproduction
|
|
21
|
+
attributes:
|
|
22
|
+
label: Steps to Reproduce
|
|
23
|
+
description: Minimal code example or steps to reproduce the issue
|
|
24
|
+
placeholder: |
|
|
25
|
+
```python
|
|
26
|
+
from openextract import extract
|
|
27
|
+
# your code here
|
|
28
|
+
```
|
|
29
|
+
validations:
|
|
30
|
+
required: true
|
|
31
|
+
|
|
32
|
+
- type: textarea
|
|
33
|
+
id: expected
|
|
34
|
+
attributes:
|
|
35
|
+
label: Expected Behavior
|
|
36
|
+
description: What did you expect to happen?
|
|
37
|
+
validations:
|
|
38
|
+
required: true
|
|
39
|
+
|
|
40
|
+
- type: textarea
|
|
41
|
+
id: actual
|
|
42
|
+
attributes:
|
|
43
|
+
label: Actual Behavior
|
|
44
|
+
description: What actually happened?
|
|
45
|
+
validations:
|
|
46
|
+
required: true
|
|
47
|
+
|
|
48
|
+
- type: input
|
|
49
|
+
id: version
|
|
50
|
+
attributes:
|
|
51
|
+
label: openextract Version
|
|
52
|
+
placeholder: "0.1.4"
|
|
53
|
+
validations:
|
|
54
|
+
required: true
|
|
55
|
+
|
|
56
|
+
- type: input
|
|
57
|
+
id: python-version
|
|
58
|
+
attributes:
|
|
59
|
+
label: Python Version
|
|
60
|
+
placeholder: "3.12"
|
|
61
|
+
validations:
|
|
62
|
+
required: true
|
|
63
|
+
|
|
64
|
+
- type: textarea
|
|
65
|
+
id: additional
|
|
66
|
+
attributes:
|
|
67
|
+
label: Additional Context
|
|
68
|
+
description: Any other relevant information (OS, LLM provider, error messages, etc.)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: Feature Request
|
|
2
|
+
description: Suggest a new feature or enhancement
|
|
3
|
+
labels: ["enhancement"]
|
|
4
|
+
body:
|
|
5
|
+
- type: markdown
|
|
6
|
+
attributes:
|
|
7
|
+
value: |
|
|
8
|
+
Thanks for suggesting a feature. Please describe your idea below.
|
|
9
|
+
|
|
10
|
+
- type: textarea
|
|
11
|
+
id: problem
|
|
12
|
+
attributes:
|
|
13
|
+
label: Problem Statement
|
|
14
|
+
description: What problem does this feature solve?
|
|
15
|
+
placeholder: I'm trying to... but currently...
|
|
16
|
+
validations:
|
|
17
|
+
required: true
|
|
18
|
+
|
|
19
|
+
- type: textarea
|
|
20
|
+
id: solution
|
|
21
|
+
attributes:
|
|
22
|
+
label: Proposed Solution
|
|
23
|
+
description: How would you like this to work?
|
|
24
|
+
validations:
|
|
25
|
+
required: true
|
|
26
|
+
|
|
27
|
+
- type: textarea
|
|
28
|
+
id: alternatives
|
|
29
|
+
attributes:
|
|
30
|
+
label: Alternatives Considered
|
|
31
|
+
description: Any alternative solutions or workarounds you've considered?
|
|
32
|
+
|
|
33
|
+
- type: textarea
|
|
34
|
+
id: additional
|
|
35
|
+
attributes:
|
|
36
|
+
label: Additional Context
|
|
37
|
+
description: Any other context, examples, or references
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
## Summary
|
|
2
|
+
|
|
3
|
+
<!-- Brief description of the changes -->
|
|
4
|
+
|
|
5
|
+
## Changes
|
|
6
|
+
|
|
7
|
+
<!-- List of specific changes made -->
|
|
8
|
+
|
|
9
|
+
-
|
|
10
|
+
|
|
11
|
+
## Testing
|
|
12
|
+
|
|
13
|
+
<!-- How were these changes tested? -->
|
|
14
|
+
|
|
15
|
+
-
|
|
16
|
+
|
|
17
|
+
## Checklist
|
|
18
|
+
|
|
19
|
+
- [ ] Tests pass locally (`uv run pytest`)
|
|
20
|
+
- [ ] Linting passes (`uv run ruff check .`)
|
|
21
|
+
- [ ] Documentation updated (if applicable)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
lint:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- uses: astral-sh/setup-uv@v4
|
|
15
|
+
- run: uv sync --dev
|
|
16
|
+
- run: uv run ruff check .
|
|
17
|
+
- run: uv run ruff format --check .
|
|
18
|
+
|
|
19
|
+
test:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v4
|
|
23
|
+
- uses: astral-sh/setup-uv@v4
|
|
24
|
+
- run: uv sync --dev
|
|
25
|
+
- run: uv run pytest -v
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
name: Deploy static content to Pages
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
# Runs on pushes targeting the default branch
|
|
5
|
+
push:
|
|
6
|
+
branches: ["main"]
|
|
7
|
+
|
|
8
|
+
# Allows you to run this workflow manually from the Actions tab
|
|
9
|
+
workflow_dispatch:
|
|
10
|
+
|
|
11
|
+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
pages: write
|
|
15
|
+
id-token: write
|
|
16
|
+
|
|
17
|
+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
|
18
|
+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
|
19
|
+
concurrency:
|
|
20
|
+
group: "pages"
|
|
21
|
+
cancel-in-progress: false
|
|
22
|
+
|
|
23
|
+
jobs:
|
|
24
|
+
# Single deploy job since we're just deploying
|
|
25
|
+
deploy:
|
|
26
|
+
environment:
|
|
27
|
+
name: github-pages
|
|
28
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
steps:
|
|
31
|
+
- name: Checkout
|
|
32
|
+
uses: actions/checkout@v4
|
|
33
|
+
- name: Setup Pages
|
|
34
|
+
uses: actions/configure-pages@v5
|
|
35
|
+
- name: Upload artifact
|
|
36
|
+
uses: actions/upload-pages-artifact@v3
|
|
37
|
+
with:
|
|
38
|
+
# Upload docs directory
|
|
39
|
+
path: './docs'
|
|
40
|
+
- name: Deploy to GitHub Pages
|
|
41
|
+
id: deployment
|
|
42
|
+
uses: actions/deploy-pages@v4
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
release:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
permissions:
|
|
11
|
+
contents: write
|
|
12
|
+
id-token: write
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
with:
|
|
16
|
+
fetch-depth: 0
|
|
17
|
+
|
|
18
|
+
- uses: astral-sh/setup-uv@v4
|
|
19
|
+
|
|
20
|
+
- name: Get version from pyproject.toml
|
|
21
|
+
id: version
|
|
22
|
+
run: |
|
|
23
|
+
VERSION=$(grep -Po '(?<=^version = ")[^"]*' pyproject.toml)
|
|
24
|
+
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
25
|
+
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
|
|
26
|
+
|
|
27
|
+
- name: Check if release exists
|
|
28
|
+
id: check_release
|
|
29
|
+
run: |
|
|
30
|
+
VERSION=${{ steps.version.outputs.version }}
|
|
31
|
+
# Check git tag
|
|
32
|
+
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
|
|
33
|
+
echo "exists=true" >> $GITHUB_OUTPUT
|
|
34
|
+
echo "Tag v$VERSION already exists"
|
|
35
|
+
exit 0
|
|
36
|
+
fi
|
|
37
|
+
# Check PyPI
|
|
38
|
+
if curl -s "https://pypi.org/pypi/openextract/$VERSION/json" | grep -q '"version"'; then
|
|
39
|
+
echo "exists=true" >> $GITHUB_OUTPUT
|
|
40
|
+
echo "Version $VERSION already exists on PyPI"
|
|
41
|
+
else
|
|
42
|
+
echo "exists=false" >> $GITHUB_OUTPUT
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
- name: Build package
|
|
46
|
+
if: steps.check_release.outputs.exists == 'false'
|
|
47
|
+
run: uv build
|
|
48
|
+
|
|
49
|
+
- name: Publish to PyPI
|
|
50
|
+
if: steps.check_release.outputs.exists == 'false'
|
|
51
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
52
|
+
|
|
53
|
+
- name: Create GitHub Release
|
|
54
|
+
if: steps.check_release.outputs.exists == 'false'
|
|
55
|
+
uses: softprops/action-gh-release@v2
|
|
56
|
+
with:
|
|
57
|
+
tag_name: ${{ steps.version.outputs.tag }}
|
|
58
|
+
name: ${{ steps.version.outputs.tag }}
|
|
59
|
+
generate_release_notes: true
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
|
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
5
|
+
|
|
6
|
+
## [0.2.0] - 2026-01-11
|
|
7
|
+
- Landing page redesign and security updates.
|
|
8
|
+
|
|
9
|
+
## [0.1.4] - 2025-12-21
|
|
10
|
+
- Restructure project as installable Python package.
|
|
11
|
+
- Add tests and error handling.
|
|
12
|
+
- Initial commit: media extraction utility with pydantic-ai.
|
|
13
|
+
|
|
14
|
+
## [0.1.2] - 2025-09-13
|
|
15
|
+
- Add bytes-only vision API.
|
|
16
|
+
- Render PDFs to images.
|
|
17
|
+
- Support multimodal messaging.
|
|
18
|
+
|
|
19
|
+
## [0.1.1] - 2025-09-10
|
|
20
|
+
- Merge pull request #12 from Mellow-Artificial-Intelligence/new-release.
|
|
21
|
+
|
|
22
|
+
[Unreleased]: https://github.com/Mellow-Artificial-Intelligence/openextract/compare/v0.2.0...HEAD
|
|
23
|
+
[0.2.0]: https://github.com/Mellow-Artificial-Intelligence/openextract/compare/v0.1.4...v0.2.0
|
|
24
|
+
[0.1.4]: https://github.com/Mellow-Artificial-Intelligence/openextract/compare/v0.1.2...v0.1.4
|
|
25
|
+
[0.1.2]: https://github.com/Mellow-Artificial-Intelligence/openextract/compare/v0.1.1...v0.1.2
|
|
26
|
+
[0.1.1]: https://github.com/Mellow-Artificial-Intelligence/openextract/releases/tag/v0.1.1
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Contributing to openextract
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in contributing to openextract!
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
1. Clone the repository:
|
|
8
|
+
```bash
|
|
9
|
+
git clone https://github.com/Mellow-Artificial-Intelligence/openextract.git
|
|
10
|
+
cd openextract
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
2. Install dependencies with uv:
|
|
14
|
+
```bash
|
|
15
|
+
uv sync --dev
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
3. Run tests:
|
|
19
|
+
```bash
|
|
20
|
+
uv run pytest
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
4. Run linting:
|
|
24
|
+
```bash
|
|
25
|
+
uv run ruff check .
|
|
26
|
+
uv run ruff format --check .
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Making Changes
|
|
30
|
+
|
|
31
|
+
1. Create a new branch from `main`
|
|
32
|
+
2. Make your changes
|
|
33
|
+
3. Ensure tests pass and code is formatted
|
|
34
|
+
4. Submit a pull request
|
|
35
|
+
|
|
36
|
+
## Pull Request Guidelines
|
|
37
|
+
|
|
38
|
+
- PRs require approval from a code owner before merging
|
|
39
|
+
- Keep changes focused and atomic
|
|
40
|
+
- Update tests for new functionality
|
|
41
|
+
- Follow existing code style (enforced by ruff)
|
|
42
|
+
|
|
43
|
+
## Code Style
|
|
44
|
+
|
|
45
|
+
This project uses [ruff](https://docs.astral.sh/ruff/) for linting and formatting. Run before submitting:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
uv run ruff check . --fix
|
|
49
|
+
uv run ruff format .
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Questions?
|
|
53
|
+
|
|
54
|
+
Open an issue on GitHub.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Cole McIntosh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: openextract
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Extract structured data from documents, images, audio, and video using LLMs
|
|
5
|
+
Project-URL: Homepage, https://github.com/Mellow-Artificial-Intelligence/openextract
|
|
6
|
+
Project-URL: Documentation, https://mellow-artificial-intelligence.github.io/openextract/
|
|
7
|
+
Project-URL: Repository, https://github.com/Mellow-Artificial-Intelligence/openextract
|
|
8
|
+
Project-URL: Issues, https://github.com/Mellow-Artificial-Intelligence/openextract/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/Mellow-Artificial-Intelligence/openextract/blob/main/CHANGELOG.md
|
|
10
|
+
Author: Cole McIntosh
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: ai,document,extraction,llm,pydantic,structured-data
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Requires-Python: >=3.12
|
|
22
|
+
Requires-Dist: pydantic-ai-slim[google,logfire]>=1.37.0
|
|
23
|
+
Requires-Dist: pydantic>=2.12.5
|
|
24
|
+
Requires-Dist: python-dotenv>=1.2.2
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# openextract
|
|
28
|
+
|
|
29
|
+
[](https://pypi.org/project/openextract/)
|
|
30
|
+
[](https://pypi.org/project/openextract/)
|
|
31
|
+
[](https://www.python.org/downloads/)
|
|
32
|
+
[](https://github.com/Mellow-Artificial-Intelligence/openextract/actions/workflows/ci.yml)
|
|
33
|
+
[](https://opensource.org/licenses/MIT)
|
|
34
|
+
[](https://github.com/Mellow-Artificial-Intelligence/openextract)
|
|
35
|
+
[](https://docs.pydantic.dev/)
|
|
36
|
+
[](https://ai.pydantic.dev/)
|
|
37
|
+
|
|
38
|
+
Extract structured data from documents, images, audio, and video using LLMs.
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
uv add openextract
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from pydantic import BaseModel
|
|
50
|
+
from openextract import extract
|
|
51
|
+
|
|
52
|
+
class PdfInfo(BaseModel):
|
|
53
|
+
summary: str
|
|
54
|
+
language: str
|
|
55
|
+
|
|
56
|
+
result = extract(
|
|
57
|
+
schema=PdfInfo,
|
|
58
|
+
model="openai-responses:gpt-5.2",
|
|
59
|
+
url="https://example.com/document.pdf",
|
|
60
|
+
instructions="return a 2 sentence summary and the primary language of the document",
|
|
61
|
+
)
|
|
62
|
+
print(result)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Logging
|
|
66
|
+
|
|
67
|
+
To enable logfire instrumentation for tracing:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from openextract import configure_logging
|
|
71
|
+
|
|
72
|
+
configure_logging()
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Error Handling
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from openextract import (
|
|
79
|
+
extract,
|
|
80
|
+
ExtractionError,
|
|
81
|
+
ModelError,
|
|
82
|
+
SchemaValidationError,
|
|
83
|
+
UrlFetchError,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
try:
|
|
87
|
+
result = extract(...)
|
|
88
|
+
except UrlFetchError as e:
|
|
89
|
+
print(f"Failed to fetch URL: {e}")
|
|
90
|
+
except SchemaValidationError as e:
|
|
91
|
+
print(f"Output didn't match schema: {e}")
|
|
92
|
+
except ModelError as e:
|
|
93
|
+
print(f"Model API error: {e}")
|
|
94
|
+
except ExtractionError as e:
|
|
95
|
+
print(f"Extraction failed: {e}")
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Supported Media Types
|
|
99
|
+
|
|
100
|
+
| Type | Extensions |
|
|
101
|
+
|------|------------|
|
|
102
|
+
| Documents | `.pdf`, `.doc`, `.docx`, `.txt`, `.html`, `.csv`, `.xls`, `.xlsx` |
|
|
103
|
+
| Images | `.jpg`, `.jpeg`, `.png`, `.gif`, `.webp`, `.bmp`, `.svg` |
|
|
104
|
+
| Audio | `.mp3`, `.wav`, `.ogg`, `.flac`, `.aac`, `.m4a` |
|
|
105
|
+
| Video | `.mp4`, `.mov`, `.avi`, `.mkv`, `.webm`, `.wmv` |
|
|
106
|
+
|
|
107
|
+
## Changelog
|
|
108
|
+
|
|
109
|
+
See [CHANGELOG.md](CHANGELOG.md) for release history.
|
|
110
|
+
|
|
111
|
+
## Contributing
|
|
112
|
+
|
|
113
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# openextract
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/openextract/)
|
|
4
|
+
[](https://pypi.org/project/openextract/)
|
|
5
|
+
[](https://www.python.org/downloads/)
|
|
6
|
+
[](https://github.com/Mellow-Artificial-Intelligence/openextract/actions/workflows/ci.yml)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
[](https://github.com/Mellow-Artificial-Intelligence/openextract)
|
|
9
|
+
[](https://docs.pydantic.dev/)
|
|
10
|
+
[](https://ai.pydantic.dev/)
|
|
11
|
+
|
|
12
|
+
Extract structured data from documents, images, audio, and video using LLMs.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
uv add openextract
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from pydantic import BaseModel
|
|
24
|
+
from openextract import extract
|
|
25
|
+
|
|
26
|
+
class PdfInfo(BaseModel):
|
|
27
|
+
summary: str
|
|
28
|
+
language: str
|
|
29
|
+
|
|
30
|
+
result = extract(
|
|
31
|
+
schema=PdfInfo,
|
|
32
|
+
model="openai-responses:gpt-5.2",
|
|
33
|
+
url="https://example.com/document.pdf",
|
|
34
|
+
instructions="return a 2 sentence summary and the primary language of the document",
|
|
35
|
+
)
|
|
36
|
+
print(result)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Logging
|
|
40
|
+
|
|
41
|
+
To enable logfire instrumentation for tracing:
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from openextract import configure_logging
|
|
45
|
+
|
|
46
|
+
configure_logging()
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Error Handling
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from openextract import (
|
|
53
|
+
extract,
|
|
54
|
+
ExtractionError,
|
|
55
|
+
ModelError,
|
|
56
|
+
SchemaValidationError,
|
|
57
|
+
UrlFetchError,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
try:
|
|
61
|
+
result = extract(...)
|
|
62
|
+
except UrlFetchError as e:
|
|
63
|
+
print(f"Failed to fetch URL: {e}")
|
|
64
|
+
except SchemaValidationError as e:
|
|
65
|
+
print(f"Output didn't match schema: {e}")
|
|
66
|
+
except ModelError as e:
|
|
67
|
+
print(f"Model API error: {e}")
|
|
68
|
+
except ExtractionError as e:
|
|
69
|
+
print(f"Extraction failed: {e}")
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Supported Media Types
|
|
73
|
+
|
|
74
|
+
| Type | Extensions |
|
|
75
|
+
|------|------------|
|
|
76
|
+
| Documents | `.pdf`, `.doc`, `.docx`, `.txt`, `.html`, `.csv`, `.xls`, `.xlsx` |
|
|
77
|
+
| Images | `.jpg`, `.jpeg`, `.png`, `.gif`, `.webp`, `.bmp`, `.svg` |
|
|
78
|
+
| Audio | `.mp3`, `.wav`, `.ogg`, `.flac`, `.aac`, `.m4a` |
|
|
79
|
+
| Video | `.mp4`, `.mov`, `.avi`, `.mkv`, `.webm`, `.wmv` |
|
|
80
|
+
|
|
81
|
+
## Changelog
|
|
82
|
+
|
|
83
|
+
See [CHANGELOG.md](CHANGELOG.md) for release history.
|
|
84
|
+
|
|
85
|
+
## Contributing
|
|
86
|
+
|
|
87
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
| Version | Supported |
|
|
6
|
+
| ------- | ------------------ |
|
|
7
|
+
| 0.2.x | :white_check_mark: |
|
|
8
|
+
| 0.1.x | :x: |
|
|
9
|
+
|
|
10
|
+
## Reporting a Vulnerability
|
|
11
|
+
|
|
12
|
+
If you discover a security vulnerability, please report it by emailing the maintainers directly rather than opening a public issue.
|
|
13
|
+
|
|
14
|
+
**Please include:**
|
|
15
|
+
- Description of the vulnerability
|
|
16
|
+
- Steps to reproduce
|
|
17
|
+
- Potential impact
|
|
18
|
+
- Any suggested fixes (optional)
|
|
19
|
+
|
|
20
|
+
We will acknowledge receipt within 48 hours and aim to provide a fix within 7 days for critical issues.
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
title: openextract Documentation
|
|
2
|
+
description: Open-source framework that extracts structured data from PDFs
|
|
3
|
+
baseurl: "/openextract"
|
|
4
|
+
url: "https://mellow-artificial-intelligence.github.io"
|
|
5
|
+
|
|
6
|
+
markdown: kramdown
|
|
7
|
+
highlighter: rouge
|
|
8
|
+
theme: minima
|
|
9
|
+
|
|
10
|
+
plugins:
|
|
11
|
+
- jekyll-feed
|
|
12
|
+
- jekyll-sitemap
|
|
13
|
+
|
|
14
|
+
exclude:
|
|
15
|
+
- Gemfile
|
|
16
|
+
- Gemfile.lock
|
|
17
|
+
- node_modules
|
|
18
|
+
- vendor
|