proofpudding 0.1.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.
@@ -0,0 +1,140 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ *.manifest
31
+ *.spec
32
+
33
+ # Installer logs
34
+ pip-log.txt
35
+ pip-delete-this-directory.txt
36
+
37
+ # Unit test / coverage reports
38
+ htmlcov/
39
+ .tox/
40
+ .nox/
41
+ .coverage
42
+ .coverage.*
43
+ .cache
44
+ nosetests.xml
45
+ coverage.xml
46
+ *.cover
47
+ *.py,cover
48
+ .hypothesis/
49
+ .pytest_cache/
50
+
51
+ # Translations
52
+ *.mo
53
+ *.pot
54
+
55
+ # Django stuff:
56
+ *.log
57
+ local_settings.py
58
+ db.sqlite3
59
+ db.sqlite3-journal
60
+
61
+ # Flask stuff:
62
+ instance/
63
+ .webassets-cache
64
+
65
+ # Scrapy stuff:
66
+ .scrapy
67
+
68
+ # Sphinx documentation
69
+ docs/_build/
70
+
71
+ # PyBuilder
72
+ .pybuilder/
73
+ target/
74
+
75
+ # Jupyter Notebook
76
+ .ipynb_checkpoints
77
+
78
+ # IPython
79
+ profile_default/
80
+ ipython_config.py
81
+
82
+ # pyenv
83
+ .python-version
84
+
85
+ # pipenv
86
+ Pipfile.lock
87
+
88
+ # PEP 582
89
+ __pypackages__/
90
+
91
+ # Celery stuff
92
+ celerybeat-schedule
93
+ celerybeat.pid
94
+
95
+ # SageMath parsed files
96
+ *.sage.py
97
+
98
+ # Environments
99
+ .env
100
+ .venv
101
+ env/
102
+ venv/
103
+ ENV/
104
+ env.bak/
105
+ venv.bak/
106
+
107
+ # Spyder project settings
108
+ .spyderproject
109
+ .spyproject
110
+
111
+ # Rope project settings
112
+ .ropeproject
113
+
114
+ # mkdocs documentation
115
+ /site
116
+
117
+ # mypy
118
+ .mypy_cache/
119
+ .dmypy.json
120
+ dmypy.json
121
+
122
+ # Pyre type checker
123
+ .pyre/
124
+
125
+ # pytype static type analyzer
126
+ .pytype/
127
+
128
+ # Cython debug symbols
129
+ cython_debug/
130
+
131
+ # IDE
132
+ .idea/
133
+ .vscode/
134
+ *.swp
135
+ *.swo
136
+ *~
137
+
138
+ # OS
139
+ .DS_Store
140
+ Thumbs.db
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Pudding AI
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,290 @@
1
+ Metadata-Version: 2.4
2
+ Name: proofpudding
3
+ Version: 0.1.0
4
+ Summary: Python SDK for the Pudding API - Document processing and Q&A
5
+ Project-URL: Homepage, https://github.com/pudding-ai/pudding-sdk
6
+ Project-URL: Documentation, https://github.com/pudding-ai/pudding-sdk#readme
7
+ Project-URL: Repository, https://github.com/pudding-ai/pudding-sdk
8
+ Project-URL: Issues, https://github.com/pudding-ai/pudding-sdk/issues
9
+ Author-email: Pudding Team <support@pudding.dev>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: api,document-processing,pdf,pudding,question-answering,sdk
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: httpx>=0.25.0
25
+ Requires-Dist: pydantic>=2.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: mypy>=1.0; extra == 'dev'
28
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
29
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
30
+ Requires-Dist: pytest>=7.0; extra == 'dev'
31
+ Requires-Dist: respx>=0.20.0; extra == 'dev'
32
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
33
+ Description-Content-Type: text/markdown
34
+
35
+ # Pudding SDK
36
+
37
+ A Python SDK for the Pudding API - Document processing and question answering.
38
+
39
+ [![PyPI version](https://badge.fury.io/py/pudding-sdk.svg)](https://badge.fury.io/py/pudding-sdk)
40
+ [![Python Versions](https://img.shields.io/pypi/pyversions/pudding-sdk.svg)](https://pypi.org/project/pudding-sdk/)
41
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ pip install pudding-sdk
47
+ ```
48
+
49
+ ## Requirements
50
+
51
+ - Python 3.10+
52
+ - httpx
53
+ - pydantic >= 2.0
54
+
55
+ ## Quick Start
56
+
57
+ ```python
58
+ from pudding import PuddingClient
59
+ from pudding.exceptions import NotFoundError, ValidationError
60
+
61
+ # Initialize client
62
+ client = PuddingClient(access_token="pk_your_api_key")
63
+
64
+ # Check API health
65
+ health = client.health.check()
66
+ print(f"API Status: {health.status}")
67
+
68
+ # Upload a document
69
+ doc = client.documents.upload(file_path="./contract.pdf")
70
+ print(f"Uploaded: {doc.id}")
71
+
72
+ # Ask a question about the document
73
+ job = client.jobs.create(
74
+ document_id=doc.id,
75
+ question="What is the effective date of this contract?"
76
+ )
77
+
78
+ if job.success:
79
+ print(f"Answer: {job.result.answer}")
80
+ print(f"Confidence: {job.result.confidence}")
81
+ for citation in job.result.citations:
82
+ print(f" - Page {citation.page}: {citation.quote}")
83
+ else:
84
+ print(f"Failed: {job.error}")
85
+
86
+ # List all documents with pagination
87
+ docs = client.documents.list(skip=0, limit=10)
88
+ print(f"Total documents: {docs.total}")
89
+ for doc in docs.items:
90
+ print(f" - {doc.filename} ({doc.size_bytes} bytes)")
91
+
92
+ # List jobs for a specific document
93
+ jobs = client.jobs.list(document_id=doc.id)
94
+
95
+ # Delete a document (also deletes associated jobs)
96
+ try:
97
+ deleted = client.documents.delete(document_id=doc.id)
98
+ print(f"Deleted: {deleted.filename}")
99
+ except NotFoundError:
100
+ print("Document not found")
101
+ ```
102
+
103
+ ## Async Support
104
+
105
+ The SDK provides both synchronous and asynchronous clients:
106
+
107
+ ```python
108
+ from pudding import PuddingClient, AsyncPuddingClient
109
+
110
+ # Synchronous client
111
+ client = PuddingClient(access_token="pk_your_api_key")
112
+ docs = client.documents.list()
113
+
114
+ # Asynchronous client
115
+ async_client = AsyncPuddingClient(access_token="pk_your_api_key")
116
+ docs = await async_client.documents.list()
117
+ ```
118
+
119
+ ## Context Manager Support
120
+
121
+ Both clients support context managers for proper resource cleanup:
122
+
123
+ ```python
124
+ # Synchronous
125
+ with PuddingClient(access_token="pk_your_api_key") as client:
126
+ docs = client.documents.list()
127
+
128
+ # Asynchronous
129
+ async with AsyncPuddingClient(access_token="pk_your_api_key") as client:
130
+ docs = await client.documents.list()
131
+ ```
132
+
133
+ ## Configuration
134
+
135
+ ### Initialization Options
136
+
137
+ ```python
138
+ client = PuddingClient(
139
+ access_token="pk_your_api_key", # Required: Your API key
140
+ timeout=60.0, # Optional: Request timeout in seconds (default: 1800 for jobs)
141
+ max_retries=3, # Optional: Max retries for transient errors (default: 3)
142
+ )
143
+ ```
144
+
145
+ ### Custom Timeout for Jobs
146
+
147
+ Job creation is a blocking operation that waits for document processing. The default timeout is 1800 seconds (30 minutes):
148
+
149
+ ```python
150
+ # Use a custom timeout for the entire client
151
+ client = PuddingClient(access_token="...", timeout=3600.0) # 1 hour
152
+ ```
153
+
154
+ ## API Reference
155
+
156
+ ### Health Checks
157
+
158
+ ```python
159
+ # Check API health
160
+ health = client.health.check()
161
+ print(health.status) # "healthy"
162
+ print(health.version) # API version
163
+ print(health.environment) # Environment name
164
+
165
+ # Check readiness (includes database status)
166
+ ready = client.health.ready()
167
+ print(ready.status) # "ready" or "not_ready"
168
+ print(ready.database) # "connected" or error message
169
+ ```
170
+
171
+ ### Documents
172
+
173
+ ```python
174
+ # Upload a document from file path
175
+ doc = client.documents.upload(file_path="/path/to/document.pdf")
176
+
177
+ # Upload a document from bytes
178
+ with open("document.pdf", "rb") as f:
179
+ doc = client.documents.upload(file=f.read(), filename="document.pdf")
180
+
181
+ # List documents with pagination
182
+ doc_list = client.documents.list(skip=0, limit=20)
183
+ print(f"Total: {doc_list.total}")
184
+ for doc in doc_list.items:
185
+ print(f"{doc.id}: {doc.filename}")
186
+
187
+ # Delete a document
188
+ deleted_doc = client.documents.delete(document_id="uuid-string")
189
+ ```
190
+
191
+ ### Jobs
192
+
193
+ ```python
194
+ # Create a job (process document with a question)
195
+ job = client.jobs.create(
196
+ document_id="uuid-string",
197
+ question="What is the total revenue mentioned in this document?"
198
+ )
199
+
200
+ # Access job results
201
+ if job.success:
202
+ print(job.result.answer)
203
+ print(job.result.confidence) # "high", "medium", "low", or "not_found"
204
+ for citation in job.result.citations:
205
+ print(f"Page {citation.page}: {citation.quote}")
206
+
207
+ # List all jobs
208
+ job_list = client.jobs.list(skip=0, limit=20)
209
+
210
+ # List jobs for a specific document
211
+ job_list = client.jobs.list(document_id="uuid-string")
212
+ ```
213
+
214
+ ## Exception Handling
215
+
216
+ The SDK provides a comprehensive exception hierarchy:
217
+
218
+ ```python
219
+ from pudding.exceptions import (
220
+ PuddingError, # Base exception for all SDK errors
221
+ AuthenticationError, # 401: Invalid or missing API key
222
+ NotFoundError, # 404: Resource not found
223
+ ValidationError, # 400: Invalid request
224
+ RateLimitError, # 429: Too many requests
225
+ ServerError, # 500: Internal server error
226
+ GatewayError, # 502: Upstream service error
227
+ TimeoutError, # 504: Request timed out
228
+ )
229
+
230
+ try:
231
+ doc = client.documents.upload(file_path="./document.txt")
232
+ except ValidationError as e:
233
+ print(f"Validation failed: {e.message}") # "Only PDF files are allowed"
234
+ except AuthenticationError as e:
235
+ print(f"Auth failed: {e.message}")
236
+ except PuddingError as e:
237
+ print(f"API error ({e.status_code}): {e.message}")
238
+ ```
239
+
240
+ ## Logging
241
+
242
+ The SDK uses Python's standard logging module. Configure logging level as needed:
243
+
244
+ ```python
245
+ import logging
246
+
247
+ # Enable debug logging for the SDK
248
+ logging.getLogger("pudding").setLevel(logging.DEBUG)
249
+ ```
250
+
251
+ ## Development
252
+
253
+ ### Setup
254
+
255
+ ```bash
256
+ # Clone the repository
257
+ git clone https://github.com/pudding-ai/pudding-sdk.git
258
+ cd pudding-sdk
259
+
260
+ # Install with development dependencies
261
+ pip install -e ".[dev]"
262
+ ```
263
+
264
+ ### Running Tests
265
+
266
+ ```bash
267
+ pytest
268
+ ```
269
+
270
+ ### Running Tests with Coverage
271
+
272
+ ```bash
273
+ pytest --cov=pudding --cov-report=html
274
+ ```
275
+
276
+ ### Type Checking
277
+
278
+ ```bash
279
+ mypy src/pudding
280
+ ```
281
+
282
+ ### Linting
283
+
284
+ ```bash
285
+ ruff check src/pudding tests
286
+ ```
287
+
288
+ ## License
289
+
290
+ MIT License - see [LICENSE](LICENSE) for details.
@@ -0,0 +1,256 @@
1
+ # Pudding SDK
2
+
3
+ A Python SDK for the Pudding API - Document processing and question answering.
4
+
5
+ [![PyPI version](https://badge.fury.io/py/pudding-sdk.svg)](https://badge.fury.io/py/pudding-sdk)
6
+ [![Python Versions](https://img.shields.io/pypi/pyversions/pudding-sdk.svg)](https://pypi.org/project/pudding-sdk/)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ pip install pudding-sdk
13
+ ```
14
+
15
+ ## Requirements
16
+
17
+ - Python 3.10+
18
+ - httpx
19
+ - pydantic >= 2.0
20
+
21
+ ## Quick Start
22
+
23
+ ```python
24
+ from pudding import PuddingClient
25
+ from pudding.exceptions import NotFoundError, ValidationError
26
+
27
+ # Initialize client
28
+ client = PuddingClient(access_token="pk_your_api_key")
29
+
30
+ # Check API health
31
+ health = client.health.check()
32
+ print(f"API Status: {health.status}")
33
+
34
+ # Upload a document
35
+ doc = client.documents.upload(file_path="./contract.pdf")
36
+ print(f"Uploaded: {doc.id}")
37
+
38
+ # Ask a question about the document
39
+ job = client.jobs.create(
40
+ document_id=doc.id,
41
+ question="What is the effective date of this contract?"
42
+ )
43
+
44
+ if job.success:
45
+ print(f"Answer: {job.result.answer}")
46
+ print(f"Confidence: {job.result.confidence}")
47
+ for citation in job.result.citations:
48
+ print(f" - Page {citation.page}: {citation.quote}")
49
+ else:
50
+ print(f"Failed: {job.error}")
51
+
52
+ # List all documents with pagination
53
+ docs = client.documents.list(skip=0, limit=10)
54
+ print(f"Total documents: {docs.total}")
55
+ for doc in docs.items:
56
+ print(f" - {doc.filename} ({doc.size_bytes} bytes)")
57
+
58
+ # List jobs for a specific document
59
+ jobs = client.jobs.list(document_id=doc.id)
60
+
61
+ # Delete a document (also deletes associated jobs)
62
+ try:
63
+ deleted = client.documents.delete(document_id=doc.id)
64
+ print(f"Deleted: {deleted.filename}")
65
+ except NotFoundError:
66
+ print("Document not found")
67
+ ```
68
+
69
+ ## Async Support
70
+
71
+ The SDK provides both synchronous and asynchronous clients:
72
+
73
+ ```python
74
+ from pudding import PuddingClient, AsyncPuddingClient
75
+
76
+ # Synchronous client
77
+ client = PuddingClient(access_token="pk_your_api_key")
78
+ docs = client.documents.list()
79
+
80
+ # Asynchronous client
81
+ async_client = AsyncPuddingClient(access_token="pk_your_api_key")
82
+ docs = await async_client.documents.list()
83
+ ```
84
+
85
+ ## Context Manager Support
86
+
87
+ Both clients support context managers for proper resource cleanup:
88
+
89
+ ```python
90
+ # Synchronous
91
+ with PuddingClient(access_token="pk_your_api_key") as client:
92
+ docs = client.documents.list()
93
+
94
+ # Asynchronous
95
+ async with AsyncPuddingClient(access_token="pk_your_api_key") as client:
96
+ docs = await client.documents.list()
97
+ ```
98
+
99
+ ## Configuration
100
+
101
+ ### Initialization Options
102
+
103
+ ```python
104
+ client = PuddingClient(
105
+ access_token="pk_your_api_key", # Required: Your API key
106
+ timeout=60.0, # Optional: Request timeout in seconds (default: 1800 for jobs)
107
+ max_retries=3, # Optional: Max retries for transient errors (default: 3)
108
+ )
109
+ ```
110
+
111
+ ### Custom Timeout for Jobs
112
+
113
+ Job creation is a blocking operation that waits for document processing. The default timeout is 1800 seconds (30 minutes):
114
+
115
+ ```python
116
+ # Use a custom timeout for the entire client
117
+ client = PuddingClient(access_token="...", timeout=3600.0) # 1 hour
118
+ ```
119
+
120
+ ## API Reference
121
+
122
+ ### Health Checks
123
+
124
+ ```python
125
+ # Check API health
126
+ health = client.health.check()
127
+ print(health.status) # "healthy"
128
+ print(health.version) # API version
129
+ print(health.environment) # Environment name
130
+
131
+ # Check readiness (includes database status)
132
+ ready = client.health.ready()
133
+ print(ready.status) # "ready" or "not_ready"
134
+ print(ready.database) # "connected" or error message
135
+ ```
136
+
137
+ ### Documents
138
+
139
+ ```python
140
+ # Upload a document from file path
141
+ doc = client.documents.upload(file_path="/path/to/document.pdf")
142
+
143
+ # Upload a document from bytes
144
+ with open("document.pdf", "rb") as f:
145
+ doc = client.documents.upload(file=f.read(), filename="document.pdf")
146
+
147
+ # List documents with pagination
148
+ doc_list = client.documents.list(skip=0, limit=20)
149
+ print(f"Total: {doc_list.total}")
150
+ for doc in doc_list.items:
151
+ print(f"{doc.id}: {doc.filename}")
152
+
153
+ # Delete a document
154
+ deleted_doc = client.documents.delete(document_id="uuid-string")
155
+ ```
156
+
157
+ ### Jobs
158
+
159
+ ```python
160
+ # Create a job (process document with a question)
161
+ job = client.jobs.create(
162
+ document_id="uuid-string",
163
+ question="What is the total revenue mentioned in this document?"
164
+ )
165
+
166
+ # Access job results
167
+ if job.success:
168
+ print(job.result.answer)
169
+ print(job.result.confidence) # "high", "medium", "low", or "not_found"
170
+ for citation in job.result.citations:
171
+ print(f"Page {citation.page}: {citation.quote}")
172
+
173
+ # List all jobs
174
+ job_list = client.jobs.list(skip=0, limit=20)
175
+
176
+ # List jobs for a specific document
177
+ job_list = client.jobs.list(document_id="uuid-string")
178
+ ```
179
+
180
+ ## Exception Handling
181
+
182
+ The SDK provides a comprehensive exception hierarchy:
183
+
184
+ ```python
185
+ from pudding.exceptions import (
186
+ PuddingError, # Base exception for all SDK errors
187
+ AuthenticationError, # 401: Invalid or missing API key
188
+ NotFoundError, # 404: Resource not found
189
+ ValidationError, # 400: Invalid request
190
+ RateLimitError, # 429: Too many requests
191
+ ServerError, # 500: Internal server error
192
+ GatewayError, # 502: Upstream service error
193
+ TimeoutError, # 504: Request timed out
194
+ )
195
+
196
+ try:
197
+ doc = client.documents.upload(file_path="./document.txt")
198
+ except ValidationError as e:
199
+ print(f"Validation failed: {e.message}") # "Only PDF files are allowed"
200
+ except AuthenticationError as e:
201
+ print(f"Auth failed: {e.message}")
202
+ except PuddingError as e:
203
+ print(f"API error ({e.status_code}): {e.message}")
204
+ ```
205
+
206
+ ## Logging
207
+
208
+ The SDK uses Python's standard logging module. Configure logging level as needed:
209
+
210
+ ```python
211
+ import logging
212
+
213
+ # Enable debug logging for the SDK
214
+ logging.getLogger("pudding").setLevel(logging.DEBUG)
215
+ ```
216
+
217
+ ## Development
218
+
219
+ ### Setup
220
+
221
+ ```bash
222
+ # Clone the repository
223
+ git clone https://github.com/pudding-ai/pudding-sdk.git
224
+ cd pudding-sdk
225
+
226
+ # Install with development dependencies
227
+ pip install -e ".[dev]"
228
+ ```
229
+
230
+ ### Running Tests
231
+
232
+ ```bash
233
+ pytest
234
+ ```
235
+
236
+ ### Running Tests with Coverage
237
+
238
+ ```bash
239
+ pytest --cov=pudding --cov-report=html
240
+ ```
241
+
242
+ ### Type Checking
243
+
244
+ ```bash
245
+ mypy src/pudding
246
+ ```
247
+
248
+ ### Linting
249
+
250
+ ```bash
251
+ ruff check src/pudding tests
252
+ ```
253
+
254
+ ## License
255
+
256
+ MIT License - see [LICENSE](LICENSE) for details.