chunkr-ai 0.1.0a2__tar.gz → 0.1.0a3__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.
- chunkr_ai-0.1.0a3/.release-please-manifest.json +3 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/CHANGELOG.md +24 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/PKG-INFO +38 -20
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/README.md +37 -19
- chunkr_ai-0.1.0a3/api.md +50 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/pyproject.toml +1 -1
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_client.py +18 -10
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_files.py +1 -1
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_version.py +1 -1
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/pagination.py +61 -1
- chunkr_ai-0.1.0a3/src/chunkr_ai/resources/__init__.py +47 -0
- chunkr_ai-0.1.0a3/src/chunkr_ai/resources/files.py +712 -0
- {chunkr_ai-0.1.0a2/src/chunkr_ai/resources/task → chunkr_ai-0.1.0a3/src/chunkr_ai/resources/tasks}/__init__.py +14 -14
- {chunkr_ai-0.1.0a2/src/chunkr_ai/resources/task → chunkr_ai-0.1.0a3/src/chunkr_ai/resources/tasks}/parse.py +48 -52
- chunkr_ai-0.1.0a2/src/chunkr_ai/resources/task/task.py → chunkr_ai-0.1.0a3/src/chunkr_ai/resources/tasks/tasks.py +58 -126
- chunkr_ai-0.1.0a3/src/chunkr_ai/types/__init__.py +15 -0
- chunkr_ai-0.1.0a3/src/chunkr_ai/types/delete.py +10 -0
- chunkr_ai-0.1.0a3/src/chunkr_ai/types/file.py +30 -0
- chunkr_ai-0.1.0a3/src/chunkr_ai/types/file_create_params.py +17 -0
- chunkr_ai-0.1.0a3/src/chunkr_ai/types/file_list_params.py +28 -0
- chunkr_ai-0.1.0a3/src/chunkr_ai/types/file_url.py +15 -0
- chunkr_ai-0.1.0a3/src/chunkr_ai/types/file_url_params.py +15 -0
- chunkr_ai-0.1.0a3/src/chunkr_ai/types/files_page_response.py +20 -0
- {chunkr_ai-0.1.0a2/src/chunkr_ai/types/task → chunkr_ai-0.1.0a3/src/chunkr_ai/types}/task.py +55 -23
- {chunkr_ai-0.1.0a2/src/chunkr_ai/types/task → chunkr_ai-0.1.0a3/src/chunkr_ai/types/tasks}/__init__.py +0 -1
- {chunkr_ai-0.1.0a2/src/chunkr_ai/types/task → chunkr_ai-0.1.0a3/src/chunkr_ai/types/tasks}/parse_create_params.py +61 -23
- {chunkr_ai-0.1.0a2/src/chunkr_ai/types/task → chunkr_ai-0.1.0a3/src/chunkr_ai/types/tasks}/parse_update_params.py +54 -22
- {chunkr_ai-0.1.0a2/tests/api_resources/task → chunkr_ai-0.1.0a3/tests/api_resources/tasks}/test_parse.py +19 -37
- chunkr_ai-0.1.0a3/tests/api_resources/test_files.py +488 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/tests/api_resources/test_health.py +0 -6
- chunkr_ai-0.1.0a2/tests/api_resources/test_task.py → chunkr_ai-0.1.0a3/tests/api_resources/test_tasks.py +37 -71
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/tests/test_client.py +20 -20
- chunkr_ai-0.1.0a2/.release-please-manifest.json +0 -3
- chunkr_ai-0.1.0a2/api.md +0 -33
- chunkr_ai-0.1.0a2/src/chunkr_ai/resources/__init__.py +0 -33
- chunkr_ai-0.1.0a2/src/chunkr_ai/types/__init__.py +0 -8
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/.gitignore +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/CONTRIBUTING.md +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/LICENSE +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/SECURITY.md +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/bin/check-release-environment +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/bin/publish-pypi +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/examples/.keep +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/mypy.ini +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/noxfile.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/release-please-config.json +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/requirements-dev.lock +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/requirements.lock +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr/lib/.keep +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/__init__.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_base_client.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_compat.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_constants.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_exceptions.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_models.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_qs.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_resource.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_response.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_streaming.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_types.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_utils/__init__.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_utils/_logs.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_utils/_proxy.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_utils/_reflection.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_utils/_resources_proxy.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_utils/_streams.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_utils/_sync.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_utils/_transform.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_utils/_typing.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/_utils/_utils.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/lib/.keep +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/py.typed +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/resources/health.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/types/health_check_response.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/types/task_get_params.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/src/chunkr_ai/types/task_list_params.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/tests/__init__.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/tests/api_resources/__init__.py +0 -0
- {chunkr_ai-0.1.0a2/tests/api_resources/task → chunkr_ai-0.1.0a3/tests/api_resources/tasks}/__init__.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/tests/conftest.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/tests/sample_file.txt +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/tests/test_deepcopy.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/tests/test_extract_files.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/tests/test_files.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/tests/test_models.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/tests/test_qs.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/tests/test_required_args.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/tests/test_response.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/tests/test_streaming.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/tests/test_transform.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/tests/test_utils/test_proxy.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/tests/test_utils/test_typing.py +0 -0
- {chunkr_ai-0.1.0a2 → chunkr_ai-0.1.0a3}/tests/utils.py +0 -0
@@ -1,5 +1,29 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.1.0-alpha.3 (2025-08-09)
|
4
|
+
|
5
|
+
Full Changelog: [v0.1.0-alpha.2...v0.1.0-alpha.3](https://github.com/lumina-ai-inc/chunkr-python/compare/v0.1.0-alpha.2...v0.1.0-alpha.3)
|
6
|
+
|
7
|
+
### Features
|
8
|
+
|
9
|
+
* **api:** api update ([a00a95e](https://github.com/lumina-ai-inc/chunkr-python/commit/a00a95ec22d7141e9139dcdeac65f882e9be0d39))
|
10
|
+
* **api:** api update ([145a438](https://github.com/lumina-ai-inc/chunkr-python/commit/145a43891e138f9b986815b105ce65ea2ebaaf17))
|
11
|
+
* **api:** api update ([79170d4](https://github.com/lumina-ai-inc/chunkr-python/commit/79170d4b086300e3beb6cb536c574ba889164ee2))
|
12
|
+
* **api:** api update ([29fe5ea](https://github.com/lumina-ai-inc/chunkr-python/commit/29fe5ea3cc4de3c097ea446927bc499848cd5a2d))
|
13
|
+
* **api:** manual updates ([171e2f9](https://github.com/lumina-ai-inc/chunkr-python/commit/171e2f9046863086957002cb2eb77e726b2cac6e))
|
14
|
+
* **api:** manual updates ([62d6d6e](https://github.com/lumina-ai-inc/chunkr-python/commit/62d6d6e39eb6b5a5dde6c2e2e9f5caa4a01c2828))
|
15
|
+
* **api:** manual updates ([16190d7](https://github.com/lumina-ai-inc/chunkr-python/commit/16190d7c726aad97a749e3c606fa412f4f5fd191))
|
16
|
+
* **api:** manual updates ([5d73fd1](https://github.com/lumina-ai-inc/chunkr-python/commit/5d73fd1fd0368c56777a69992c302d5ee088a8f1))
|
17
|
+
* **api:** manual updates ([9269fd1](https://github.com/lumina-ai-inc/chunkr-python/commit/9269fd1f81567aa69a17a4d4b01adad8d2866e3b))
|
18
|
+
* **api:** manual updates ([ac4cd88](https://github.com/lumina-ai-inc/chunkr-python/commit/ac4cd883378d3f4fb89df50fc4eac8d94655648d))
|
19
|
+
* **api:** manual updates ([f29e11a](https://github.com/lumina-ai-inc/chunkr-python/commit/f29e11ad5014311faba9162e70a6aae40003c994))
|
20
|
+
|
21
|
+
|
22
|
+
### Chores
|
23
|
+
|
24
|
+
* **internal:** update comment in script ([f44c608](https://github.com/lumina-ai-inc/chunkr-python/commit/f44c60889e1b26b85c142aa318a6f7801ae87241))
|
25
|
+
* update @stainless-api/prism-cli to v5.15.0 ([c0aab83](https://github.com/lumina-ai-inc/chunkr-python/commit/c0aab83a4ea61ea57f0424b05f19bbf46efb6ca0))
|
26
|
+
|
3
27
|
## 0.1.0-alpha.2 (2025-08-06)
|
4
28
|
|
5
29
|
Full Changelog: [v0.1.0-alpha.1...v0.1.0-alpha.2](https://github.com/lumina-ai-inc/chunkr-python/compare/v0.1.0-alpha.1...v0.1.0-alpha.2)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: chunkr-ai
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.0a3
|
4
4
|
Summary: The official Python library for the chunkr API
|
5
5
|
Project-URL: Homepage, https://github.com/lumina-ai-inc/chunkr-python
|
6
6
|
Project-URL: Repository, https://github.com/lumina-ai-inc/chunkr-python
|
@@ -70,7 +70,7 @@ client = Chunkr(
|
|
70
70
|
api_key=os.environ.get("CHUNKR_API_KEY"), # This is the default and can be omitted
|
71
71
|
)
|
72
72
|
|
73
|
-
task = client.
|
73
|
+
task = client.tasks.parse.create(
|
74
74
|
file="string",
|
75
75
|
)
|
76
76
|
print(task.task_id)
|
@@ -96,7 +96,7 @@ client = AsyncChunkr(
|
|
96
96
|
|
97
97
|
|
98
98
|
async def main() -> None:
|
99
|
-
task = await client.
|
99
|
+
task = await client.tasks.parse.create(
|
100
100
|
file="string",
|
101
101
|
)
|
102
102
|
print(task.task_id)
|
@@ -131,7 +131,7 @@ async def main() -> None:
|
|
131
131
|
api_key="My API Key",
|
132
132
|
http_client=DefaultAioHttpClient(),
|
133
133
|
) as client:
|
134
|
-
task = await client.
|
134
|
+
task = await client.tasks.parse.create(
|
135
135
|
file="string",
|
136
136
|
)
|
137
137
|
print(task.task_id)
|
@@ -162,7 +162,7 @@ client = Chunkr()
|
|
162
162
|
|
163
163
|
all_tasks = []
|
164
164
|
# Automatically fetches more pages as needed.
|
165
|
-
for task in client.
|
165
|
+
for task in client.tasks.list(
|
166
166
|
limit=100,
|
167
167
|
):
|
168
168
|
# Do something with task here
|
@@ -182,7 +182,7 @@ client = AsyncChunkr()
|
|
182
182
|
async def main() -> None:
|
183
183
|
all_tasks = []
|
184
184
|
# Iterate through items across all pages, issuing requests as needed.
|
185
|
-
async for task in client.
|
185
|
+
async for task in client.tasks.list(
|
186
186
|
limit=100,
|
187
187
|
):
|
188
188
|
all_tasks.append(task)
|
@@ -195,7 +195,7 @@ asyncio.run(main())
|
|
195
195
|
Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:
|
196
196
|
|
197
197
|
```python
|
198
|
-
first_page = await client.
|
198
|
+
first_page = await client.tasks.list(
|
199
199
|
limit=100,
|
200
200
|
)
|
201
201
|
if first_page.has_next_page():
|
@@ -209,7 +209,7 @@ if first_page.has_next_page():
|
|
209
209
|
Or just work directly with the returned data:
|
210
210
|
|
211
211
|
```python
|
212
|
-
first_page = await client.
|
212
|
+
first_page = await client.tasks.list(
|
213
213
|
limit=100,
|
214
214
|
)
|
215
215
|
|
@@ -229,13 +229,31 @@ from chunkr_ai import Chunkr
|
|
229
229
|
|
230
230
|
client = Chunkr()
|
231
231
|
|
232
|
-
task = client.
|
232
|
+
task = client.tasks.parse.create(
|
233
233
|
file="file",
|
234
234
|
chunk_processing={},
|
235
235
|
)
|
236
236
|
print(task.chunk_processing)
|
237
237
|
```
|
238
238
|
|
239
|
+
## File uploads
|
240
|
+
|
241
|
+
Request parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.
|
242
|
+
|
243
|
+
```python
|
244
|
+
from pathlib import Path
|
245
|
+
from chunkr_ai import Chunkr
|
246
|
+
|
247
|
+
client = Chunkr()
|
248
|
+
|
249
|
+
client.files.create(
|
250
|
+
file=Path("/path/to/file"),
|
251
|
+
file_metadata="file_metadata",
|
252
|
+
)
|
253
|
+
```
|
254
|
+
|
255
|
+
The async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.
|
256
|
+
|
239
257
|
## Handling errors
|
240
258
|
|
241
259
|
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `chunkr_ai.APIConnectionError` is raised.
|
@@ -252,8 +270,8 @@ from chunkr_ai import Chunkr
|
|
252
270
|
client = Chunkr()
|
253
271
|
|
254
272
|
try:
|
255
|
-
client.
|
256
|
-
file="
|
273
|
+
client.tasks.parse.create(
|
274
|
+
file="string",
|
257
275
|
)
|
258
276
|
except chunkr_ai.APIConnectionError as e:
|
259
277
|
print("The server could not be reached")
|
@@ -297,8 +315,8 @@ client = Chunkr(
|
|
297
315
|
)
|
298
316
|
|
299
317
|
# Or, configure per-request:
|
300
|
-
client.with_options(max_retries=5).
|
301
|
-
file="
|
318
|
+
client.with_options(max_retries=5).tasks.parse.create(
|
319
|
+
file="string",
|
302
320
|
)
|
303
321
|
```
|
304
322
|
|
@@ -322,8 +340,8 @@ client = Chunkr(
|
|
322
340
|
)
|
323
341
|
|
324
342
|
# Override per-request:
|
325
|
-
client.with_options(timeout=5.0).
|
326
|
-
file="
|
343
|
+
client.with_options(timeout=5.0).tasks.parse.create(
|
344
|
+
file="string",
|
327
345
|
)
|
328
346
|
```
|
329
347
|
|
@@ -365,12 +383,12 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
|
|
365
383
|
from chunkr_ai import Chunkr
|
366
384
|
|
367
385
|
client = Chunkr()
|
368
|
-
response = client.
|
369
|
-
file="
|
386
|
+
response = client.tasks.parse.with_raw_response.create(
|
387
|
+
file="string",
|
370
388
|
)
|
371
389
|
print(response.headers.get('X-My-Header'))
|
372
390
|
|
373
|
-
parse = response.parse() # get the object that `
|
391
|
+
parse = response.parse() # get the object that `tasks.parse.create()` would have returned
|
374
392
|
print(parse.task_id)
|
375
393
|
```
|
376
394
|
|
@@ -385,8 +403,8 @@ The above interface eagerly reads the full response body when you make the reque
|
|
385
403
|
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
|
386
404
|
|
387
405
|
```python
|
388
|
-
with client.
|
389
|
-
file="
|
406
|
+
with client.tasks.parse.with_streaming_response.create(
|
407
|
+
file="string",
|
390
408
|
) as response:
|
391
409
|
print(response.headers.get("X-My-Header"))
|
392
410
|
|
@@ -35,7 +35,7 @@ client = Chunkr(
|
|
35
35
|
api_key=os.environ.get("CHUNKR_API_KEY"), # This is the default and can be omitted
|
36
36
|
)
|
37
37
|
|
38
|
-
task = client.
|
38
|
+
task = client.tasks.parse.create(
|
39
39
|
file="string",
|
40
40
|
)
|
41
41
|
print(task.task_id)
|
@@ -61,7 +61,7 @@ client = AsyncChunkr(
|
|
61
61
|
|
62
62
|
|
63
63
|
async def main() -> None:
|
64
|
-
task = await client.
|
64
|
+
task = await client.tasks.parse.create(
|
65
65
|
file="string",
|
66
66
|
)
|
67
67
|
print(task.task_id)
|
@@ -96,7 +96,7 @@ async def main() -> None:
|
|
96
96
|
api_key="My API Key",
|
97
97
|
http_client=DefaultAioHttpClient(),
|
98
98
|
) as client:
|
99
|
-
task = await client.
|
99
|
+
task = await client.tasks.parse.create(
|
100
100
|
file="string",
|
101
101
|
)
|
102
102
|
print(task.task_id)
|
@@ -127,7 +127,7 @@ client = Chunkr()
|
|
127
127
|
|
128
128
|
all_tasks = []
|
129
129
|
# Automatically fetches more pages as needed.
|
130
|
-
for task in client.
|
130
|
+
for task in client.tasks.list(
|
131
131
|
limit=100,
|
132
132
|
):
|
133
133
|
# Do something with task here
|
@@ -147,7 +147,7 @@ client = AsyncChunkr()
|
|
147
147
|
async def main() -> None:
|
148
148
|
all_tasks = []
|
149
149
|
# Iterate through items across all pages, issuing requests as needed.
|
150
|
-
async for task in client.
|
150
|
+
async for task in client.tasks.list(
|
151
151
|
limit=100,
|
152
152
|
):
|
153
153
|
all_tasks.append(task)
|
@@ -160,7 +160,7 @@ asyncio.run(main())
|
|
160
160
|
Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:
|
161
161
|
|
162
162
|
```python
|
163
|
-
first_page = await client.
|
163
|
+
first_page = await client.tasks.list(
|
164
164
|
limit=100,
|
165
165
|
)
|
166
166
|
if first_page.has_next_page():
|
@@ -174,7 +174,7 @@ if first_page.has_next_page():
|
|
174
174
|
Or just work directly with the returned data:
|
175
175
|
|
176
176
|
```python
|
177
|
-
first_page = await client.
|
177
|
+
first_page = await client.tasks.list(
|
178
178
|
limit=100,
|
179
179
|
)
|
180
180
|
|
@@ -194,13 +194,31 @@ from chunkr_ai import Chunkr
|
|
194
194
|
|
195
195
|
client = Chunkr()
|
196
196
|
|
197
|
-
task = client.
|
197
|
+
task = client.tasks.parse.create(
|
198
198
|
file="file",
|
199
199
|
chunk_processing={},
|
200
200
|
)
|
201
201
|
print(task.chunk_processing)
|
202
202
|
```
|
203
203
|
|
204
|
+
## File uploads
|
205
|
+
|
206
|
+
Request parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.
|
207
|
+
|
208
|
+
```python
|
209
|
+
from pathlib import Path
|
210
|
+
from chunkr_ai import Chunkr
|
211
|
+
|
212
|
+
client = Chunkr()
|
213
|
+
|
214
|
+
client.files.create(
|
215
|
+
file=Path("/path/to/file"),
|
216
|
+
file_metadata="file_metadata",
|
217
|
+
)
|
218
|
+
```
|
219
|
+
|
220
|
+
The async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.
|
221
|
+
|
204
222
|
## Handling errors
|
205
223
|
|
206
224
|
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `chunkr_ai.APIConnectionError` is raised.
|
@@ -217,8 +235,8 @@ from chunkr_ai import Chunkr
|
|
217
235
|
client = Chunkr()
|
218
236
|
|
219
237
|
try:
|
220
|
-
client.
|
221
|
-
file="
|
238
|
+
client.tasks.parse.create(
|
239
|
+
file="string",
|
222
240
|
)
|
223
241
|
except chunkr_ai.APIConnectionError as e:
|
224
242
|
print("The server could not be reached")
|
@@ -262,8 +280,8 @@ client = Chunkr(
|
|
262
280
|
)
|
263
281
|
|
264
282
|
# Or, configure per-request:
|
265
|
-
client.with_options(max_retries=5).
|
266
|
-
file="
|
283
|
+
client.with_options(max_retries=5).tasks.parse.create(
|
284
|
+
file="string",
|
267
285
|
)
|
268
286
|
```
|
269
287
|
|
@@ -287,8 +305,8 @@ client = Chunkr(
|
|
287
305
|
)
|
288
306
|
|
289
307
|
# Override per-request:
|
290
|
-
client.with_options(timeout=5.0).
|
291
|
-
file="
|
308
|
+
client.with_options(timeout=5.0).tasks.parse.create(
|
309
|
+
file="string",
|
292
310
|
)
|
293
311
|
```
|
294
312
|
|
@@ -330,12 +348,12 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
|
|
330
348
|
from chunkr_ai import Chunkr
|
331
349
|
|
332
350
|
client = Chunkr()
|
333
|
-
response = client.
|
334
|
-
file="
|
351
|
+
response = client.tasks.parse.with_raw_response.create(
|
352
|
+
file="string",
|
335
353
|
)
|
336
354
|
print(response.headers.get('X-My-Header'))
|
337
355
|
|
338
|
-
parse = response.parse() # get the object that `
|
356
|
+
parse = response.parse() # get the object that `tasks.parse.create()` would have returned
|
339
357
|
print(parse.task_id)
|
340
358
|
```
|
341
359
|
|
@@ -350,8 +368,8 @@ The above interface eagerly reads the full response body when you make the reque
|
|
350
368
|
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
|
351
369
|
|
352
370
|
```python
|
353
|
-
with client.
|
354
|
-
file="
|
371
|
+
with client.tasks.parse.with_streaming_response.create(
|
372
|
+
file="string",
|
355
373
|
) as response:
|
356
374
|
print(response.headers.get("X-My-Header"))
|
357
375
|
|
chunkr_ai-0.1.0a3/api.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Tasks
|
2
|
+
|
3
|
+
Types:
|
4
|
+
|
5
|
+
```python
|
6
|
+
from chunkr_ai.types import Task
|
7
|
+
```
|
8
|
+
|
9
|
+
Methods:
|
10
|
+
|
11
|
+
- <code title="get /tasks">client.tasks.<a href="./src/chunkr_ai/resources/tasks/tasks.py">list</a>(\*\*<a href="src/chunkr_ai/types/task_list_params.py">params</a>) -> <a href="./src/chunkr_ai/types/task.py">SyncTasksPage[Task]</a></code>
|
12
|
+
- <code title="delete /tasks/{task_id}">client.tasks.<a href="./src/chunkr_ai/resources/tasks/tasks.py">delete</a>(task_id) -> None</code>
|
13
|
+
- <code title="get /tasks/{task_id}/cancel">client.tasks.<a href="./src/chunkr_ai/resources/tasks/tasks.py">cancel</a>(task_id) -> None</code>
|
14
|
+
- <code title="get /tasks/{task_id}">client.tasks.<a href="./src/chunkr_ai/resources/tasks/tasks.py">get</a>(task_id, \*\*<a href="src/chunkr_ai/types/task_get_params.py">params</a>) -> <a href="./src/chunkr_ai/types/task.py">Task</a></code>
|
15
|
+
|
16
|
+
## Parse
|
17
|
+
|
18
|
+
Methods:
|
19
|
+
|
20
|
+
- <code title="post /tasks/parse">client.tasks.parse.<a href="./src/chunkr_ai/resources/tasks/parse.py">create</a>(\*\*<a href="src/chunkr_ai/types/tasks/parse_create_params.py">params</a>) -> <a href="./src/chunkr_ai/types/task.py">Task</a></code>
|
21
|
+
- <code title="patch /tasks/parse/{task_id}">client.tasks.parse.<a href="./src/chunkr_ai/resources/tasks/parse.py">update</a>(task_id, \*\*<a href="src/chunkr_ai/types/tasks/parse_update_params.py">params</a>) -> <a href="./src/chunkr_ai/types/task.py">Task</a></code>
|
22
|
+
|
23
|
+
# Files
|
24
|
+
|
25
|
+
Types:
|
26
|
+
|
27
|
+
```python
|
28
|
+
from chunkr_ai.types import Delete, File, FilesPageResponse, FileURL
|
29
|
+
```
|
30
|
+
|
31
|
+
Methods:
|
32
|
+
|
33
|
+
- <code title="post /files">client.files.<a href="./src/chunkr_ai/resources/files.py">create</a>(\*\*<a href="src/chunkr_ai/types/file_create_params.py">params</a>) -> <a href="./src/chunkr_ai/types/file.py">File</a></code>
|
34
|
+
- <code title="get /files">client.files.<a href="./src/chunkr_ai/resources/files.py">list</a>(\*\*<a href="src/chunkr_ai/types/file_list_params.py">params</a>) -> <a href="./src/chunkr_ai/types/file.py">SyncFilesPage[File]</a></code>
|
35
|
+
- <code title="delete /files/{file_id}">client.files.<a href="./src/chunkr_ai/resources/files.py">delete</a>(file_id) -> <a href="./src/chunkr_ai/types/delete.py">Delete</a></code>
|
36
|
+
- <code title="get /files/{file_id}/content">client.files.<a href="./src/chunkr_ai/resources/files.py">content</a>(file_id) -> None</code>
|
37
|
+
- <code title="get /files/{file_id}">client.files.<a href="./src/chunkr_ai/resources/files.py">get</a>(file_id) -> <a href="./src/chunkr_ai/types/file.py">File</a></code>
|
38
|
+
- <code title="get /files/{file_id}/url">client.files.<a href="./src/chunkr_ai/resources/files.py">url</a>(file_id, \*\*<a href="src/chunkr_ai/types/file_url_params.py">params</a>) -> <a href="./src/chunkr_ai/types/file_url.py">FileURL</a></code>
|
39
|
+
|
40
|
+
# Health
|
41
|
+
|
42
|
+
Types:
|
43
|
+
|
44
|
+
```python
|
45
|
+
from chunkr_ai.types import HealthCheckResponse
|
46
|
+
```
|
47
|
+
|
48
|
+
Methods:
|
49
|
+
|
50
|
+
- <code title="get /health">client.health.<a href="./src/chunkr_ai/resources/health.py">check</a>() -> str</code>
|
@@ -21,7 +21,7 @@ from ._types import (
|
|
21
21
|
)
|
22
22
|
from ._utils import is_given, get_async_library
|
23
23
|
from ._version import __version__
|
24
|
-
from .resources import health
|
24
|
+
from .resources import files, health
|
25
25
|
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
|
26
26
|
from ._exceptions import ChunkrError, APIStatusError
|
27
27
|
from ._base_client import (
|
@@ -29,13 +29,14 @@ from ._base_client import (
|
|
29
29
|
SyncAPIClient,
|
30
30
|
AsyncAPIClient,
|
31
31
|
)
|
32
|
-
from .resources.
|
32
|
+
from .resources.tasks import tasks
|
33
33
|
|
34
34
|
__all__ = ["Timeout", "Transport", "ProxiesTypes", "RequestOptions", "Chunkr", "AsyncChunkr", "Client", "AsyncClient"]
|
35
35
|
|
36
36
|
|
37
37
|
class Chunkr(SyncAPIClient):
|
38
|
-
|
38
|
+
tasks: tasks.TasksResource
|
39
|
+
files: files.FilesResource
|
39
40
|
health: health.HealthResource
|
40
41
|
with_raw_response: ChunkrWithRawResponse
|
41
42
|
with_streaming_response: ChunkrWithStreamedResponse
|
@@ -94,7 +95,8 @@ class Chunkr(SyncAPIClient):
|
|
94
95
|
_strict_response_validation=_strict_response_validation,
|
95
96
|
)
|
96
97
|
|
97
|
-
self.
|
98
|
+
self.tasks = tasks.TasksResource(self)
|
99
|
+
self.files = files.FilesResource(self)
|
98
100
|
self.health = health.HealthResource(self)
|
99
101
|
self.with_raw_response = ChunkrWithRawResponse(self)
|
100
102
|
self.with_streaming_response = ChunkrWithStreamedResponse(self)
|
@@ -205,7 +207,8 @@ class Chunkr(SyncAPIClient):
|
|
205
207
|
|
206
208
|
|
207
209
|
class AsyncChunkr(AsyncAPIClient):
|
208
|
-
|
210
|
+
tasks: tasks.AsyncTasksResource
|
211
|
+
files: files.AsyncFilesResource
|
209
212
|
health: health.AsyncHealthResource
|
210
213
|
with_raw_response: AsyncChunkrWithRawResponse
|
211
214
|
with_streaming_response: AsyncChunkrWithStreamedResponse
|
@@ -264,7 +267,8 @@ class AsyncChunkr(AsyncAPIClient):
|
|
264
267
|
_strict_response_validation=_strict_response_validation,
|
265
268
|
)
|
266
269
|
|
267
|
-
self.
|
270
|
+
self.tasks = tasks.AsyncTasksResource(self)
|
271
|
+
self.files = files.AsyncFilesResource(self)
|
268
272
|
self.health = health.AsyncHealthResource(self)
|
269
273
|
self.with_raw_response = AsyncChunkrWithRawResponse(self)
|
270
274
|
self.with_streaming_response = AsyncChunkrWithStreamedResponse(self)
|
@@ -376,25 +380,29 @@ class AsyncChunkr(AsyncAPIClient):
|
|
376
380
|
|
377
381
|
class ChunkrWithRawResponse:
|
378
382
|
def __init__(self, client: Chunkr) -> None:
|
379
|
-
self.
|
383
|
+
self.tasks = tasks.TasksResourceWithRawResponse(client.tasks)
|
384
|
+
self.files = files.FilesResourceWithRawResponse(client.files)
|
380
385
|
self.health = health.HealthResourceWithRawResponse(client.health)
|
381
386
|
|
382
387
|
|
383
388
|
class AsyncChunkrWithRawResponse:
|
384
389
|
def __init__(self, client: AsyncChunkr) -> None:
|
385
|
-
self.
|
390
|
+
self.tasks = tasks.AsyncTasksResourceWithRawResponse(client.tasks)
|
391
|
+
self.files = files.AsyncFilesResourceWithRawResponse(client.files)
|
386
392
|
self.health = health.AsyncHealthResourceWithRawResponse(client.health)
|
387
393
|
|
388
394
|
|
389
395
|
class ChunkrWithStreamedResponse:
|
390
396
|
def __init__(self, client: Chunkr) -> None:
|
391
|
-
self.
|
397
|
+
self.tasks = tasks.TasksResourceWithStreamingResponse(client.tasks)
|
398
|
+
self.files = files.FilesResourceWithStreamingResponse(client.files)
|
392
399
|
self.health = health.HealthResourceWithStreamingResponse(client.health)
|
393
400
|
|
394
401
|
|
395
402
|
class AsyncChunkrWithStreamedResponse:
|
396
403
|
def __init__(self, client: AsyncChunkr) -> None:
|
397
|
-
self.
|
404
|
+
self.tasks = tasks.AsyncTasksResourceWithStreamingResponse(client.tasks)
|
405
|
+
self.files = files.AsyncFilesResourceWithStreamingResponse(client.files)
|
398
406
|
self.health = health.AsyncHealthResourceWithStreamingResponse(client.health)
|
399
407
|
|
400
408
|
|
@@ -34,7 +34,7 @@ def assert_is_file_content(obj: object, *, key: str | None = None) -> None:
|
|
34
34
|
if not is_file_content(obj):
|
35
35
|
prefix = f"Expected entry at `{key}`" if key is not None else f"Expected file input `{obj!r}`"
|
36
36
|
raise RuntimeError(
|
37
|
-
f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead."
|
37
|
+
f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead. See https://github.com/lumina-ai-inc/chunkr-python/tree/main#file-uploads"
|
38
38
|
) from None
|
39
39
|
|
40
40
|
|
@@ -6,7 +6,7 @@ from typing_extensions import override
|
|
6
6
|
|
7
7
|
from ._base_client import BasePage, PageInfo, BaseSyncPage, BaseAsyncPage
|
8
8
|
|
9
|
-
__all__ = ["SyncTasksPage", "AsyncTasksPage"]
|
9
|
+
__all__ = ["SyncTasksPage", "AsyncTasksPage", "SyncFilesPage", "AsyncFilesPage"]
|
10
10
|
|
11
11
|
_T = TypeVar("_T")
|
12
12
|
|
@@ -69,3 +69,63 @@ class AsyncTasksPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
|
|
69
69
|
return None
|
70
70
|
|
71
71
|
return PageInfo(params={"cursor": next_cursor})
|
72
|
+
|
73
|
+
|
74
|
+
class SyncFilesPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
|
75
|
+
files: List[_T]
|
76
|
+
next_cursor: Optional[datetime] = None
|
77
|
+
has_more: Optional[bool] = None
|
78
|
+
"""Whether there are more pages available"""
|
79
|
+
|
80
|
+
@override
|
81
|
+
def _get_page_items(self) -> List[_T]:
|
82
|
+
files = self.files
|
83
|
+
if not files:
|
84
|
+
return []
|
85
|
+
return files
|
86
|
+
|
87
|
+
@override
|
88
|
+
def has_next_page(self) -> bool:
|
89
|
+
has_more = self.has_more
|
90
|
+
if has_more is not None and has_more is False:
|
91
|
+
return False
|
92
|
+
|
93
|
+
return super().has_next_page()
|
94
|
+
|
95
|
+
@override
|
96
|
+
def next_page_info(self) -> Optional[PageInfo]:
|
97
|
+
next_cursor = self.next_cursor
|
98
|
+
if not next_cursor:
|
99
|
+
return None
|
100
|
+
|
101
|
+
return PageInfo(params={"cursor": next_cursor})
|
102
|
+
|
103
|
+
|
104
|
+
class AsyncFilesPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
|
105
|
+
files: List[_T]
|
106
|
+
next_cursor: Optional[datetime] = None
|
107
|
+
has_more: Optional[bool] = None
|
108
|
+
"""Whether there are more pages available"""
|
109
|
+
|
110
|
+
@override
|
111
|
+
def _get_page_items(self) -> List[_T]:
|
112
|
+
files = self.files
|
113
|
+
if not files:
|
114
|
+
return []
|
115
|
+
return files
|
116
|
+
|
117
|
+
@override
|
118
|
+
def has_next_page(self) -> bool:
|
119
|
+
has_more = self.has_more
|
120
|
+
if has_more is not None and has_more is False:
|
121
|
+
return False
|
122
|
+
|
123
|
+
return super().has_next_page()
|
124
|
+
|
125
|
+
@override
|
126
|
+
def next_page_info(self) -> Optional[PageInfo]:
|
127
|
+
next_cursor = self.next_cursor
|
128
|
+
if not next_cursor:
|
129
|
+
return None
|
130
|
+
|
131
|
+
return PageInfo(params={"cursor": next_cursor})
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
2
|
+
|
3
|
+
from .files import (
|
4
|
+
FilesResource,
|
5
|
+
AsyncFilesResource,
|
6
|
+
FilesResourceWithRawResponse,
|
7
|
+
AsyncFilesResourceWithRawResponse,
|
8
|
+
FilesResourceWithStreamingResponse,
|
9
|
+
AsyncFilesResourceWithStreamingResponse,
|
10
|
+
)
|
11
|
+
from .tasks import (
|
12
|
+
TasksResource,
|
13
|
+
AsyncTasksResource,
|
14
|
+
TasksResourceWithRawResponse,
|
15
|
+
AsyncTasksResourceWithRawResponse,
|
16
|
+
TasksResourceWithStreamingResponse,
|
17
|
+
AsyncTasksResourceWithStreamingResponse,
|
18
|
+
)
|
19
|
+
from .health import (
|
20
|
+
HealthResource,
|
21
|
+
AsyncHealthResource,
|
22
|
+
HealthResourceWithRawResponse,
|
23
|
+
AsyncHealthResourceWithRawResponse,
|
24
|
+
HealthResourceWithStreamingResponse,
|
25
|
+
AsyncHealthResourceWithStreamingResponse,
|
26
|
+
)
|
27
|
+
|
28
|
+
__all__ = [
|
29
|
+
"TasksResource",
|
30
|
+
"AsyncTasksResource",
|
31
|
+
"TasksResourceWithRawResponse",
|
32
|
+
"AsyncTasksResourceWithRawResponse",
|
33
|
+
"TasksResourceWithStreamingResponse",
|
34
|
+
"AsyncTasksResourceWithStreamingResponse",
|
35
|
+
"FilesResource",
|
36
|
+
"AsyncFilesResource",
|
37
|
+
"FilesResourceWithRawResponse",
|
38
|
+
"AsyncFilesResourceWithRawResponse",
|
39
|
+
"FilesResourceWithStreamingResponse",
|
40
|
+
"AsyncFilesResourceWithStreamingResponse",
|
41
|
+
"HealthResource",
|
42
|
+
"AsyncHealthResource",
|
43
|
+
"HealthResourceWithRawResponse",
|
44
|
+
"AsyncHealthResourceWithRawResponse",
|
45
|
+
"HealthResourceWithStreamingResponse",
|
46
|
+
"AsyncHealthResourceWithStreamingResponse",
|
47
|
+
]
|