chunkr-ai 0.1.0a6__py3-none-any.whl → 0.1.0a8__py3-none-any.whl

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.
Files changed (69) hide show
  1. chunkr_ai/__init__.py +2 -0
  2. chunkr_ai/_base_client.py +3 -3
  3. chunkr_ai/_client.py +31 -3
  4. chunkr_ai/_compat.py +48 -48
  5. chunkr_ai/_constants.py +5 -5
  6. chunkr_ai/_exceptions.py +4 -0
  7. chunkr_ai/_models.py +41 -41
  8. chunkr_ai/_types.py +35 -1
  9. chunkr_ai/_utils/__init__.py +9 -2
  10. chunkr_ai/_utils/_compat.py +45 -0
  11. chunkr_ai/_utils/_datetime_parse.py +136 -0
  12. chunkr_ai/_utils/_transform.py +11 -1
  13. chunkr_ai/_utils/_typing.py +6 -1
  14. chunkr_ai/_utils/_utils.py +0 -1
  15. chunkr_ai/_version.py +1 -1
  16. chunkr_ai/resources/__init__.py +14 -0
  17. chunkr_ai/resources/files.py +3 -3
  18. chunkr_ai/resources/tasks/__init__.py +14 -0
  19. chunkr_ai/resources/tasks/extract.py +393 -0
  20. chunkr_ai/resources/tasks/parse.py +110 -286
  21. chunkr_ai/resources/tasks/tasks.py +64 -32
  22. chunkr_ai/resources/webhooks.py +193 -0
  23. chunkr_ai/types/__init__.py +27 -1
  24. chunkr_ai/types/bounding_box.py +19 -0
  25. chunkr_ai/types/cell.py +39 -0
  26. chunkr_ai/types/cell_style.py +28 -0
  27. chunkr_ai/types/chunk.py +40 -0
  28. chunkr_ai/types/chunk_processing.py +40 -0
  29. chunkr_ai/types/chunk_processing_param.py +42 -0
  30. chunkr_ai/types/extract_configuration.py +24 -0
  31. chunkr_ai/types/extract_output_response.py +62 -0
  32. chunkr_ai/types/file_create_params.py +2 -1
  33. chunkr_ai/types/file_info.py +21 -0
  34. chunkr_ai/types/generation_config.py +29 -0
  35. chunkr_ai/types/generation_config_param.py +29 -0
  36. chunkr_ai/types/llm_processing.py +36 -0
  37. chunkr_ai/types/llm_processing_param.py +36 -0
  38. chunkr_ai/types/ocr_result.py +28 -0
  39. chunkr_ai/types/page.py +27 -0
  40. chunkr_ai/types/parse_configuration.py +64 -0
  41. chunkr_ai/types/parse_configuration_param.py +65 -0
  42. chunkr_ai/types/parse_output_response.py +29 -0
  43. chunkr_ai/types/segment.py +109 -0
  44. chunkr_ai/types/segment_processing.py +228 -0
  45. chunkr_ai/types/segment_processing_param.py +229 -0
  46. chunkr_ai/types/task_extract_updated_webhook_event.py +22 -0
  47. chunkr_ai/types/task_get_params.py +0 -3
  48. chunkr_ai/types/task_list_params.py +7 -1
  49. chunkr_ai/types/task_parse_updated_webhook_event.py +22 -0
  50. chunkr_ai/types/task_response.py +68 -0
  51. chunkr_ai/types/tasks/__init__.py +7 -1
  52. chunkr_ai/types/tasks/extract_create_params.py +47 -0
  53. chunkr_ai/types/tasks/extract_create_response.py +67 -0
  54. chunkr_ai/types/tasks/extract_get_params.py +18 -0
  55. chunkr_ai/types/tasks/extract_get_response.py +67 -0
  56. chunkr_ai/types/tasks/parse_create_params.py +25 -793
  57. chunkr_ai/types/tasks/parse_create_response.py +55 -0
  58. chunkr_ai/types/tasks/parse_get_params.py +18 -0
  59. chunkr_ai/types/tasks/parse_get_response.py +55 -0
  60. chunkr_ai/types/unwrap_webhook_event.py +11 -0
  61. chunkr_ai/types/version_info.py +31 -0
  62. chunkr_ai/types/webhook_url_response.py +9 -0
  63. {chunkr_ai-0.1.0a6.dist-info → chunkr_ai-0.1.0a8.dist-info}/METADATA +14 -13
  64. chunkr_ai-0.1.0a8.dist-info/RECORD +88 -0
  65. chunkr_ai/types/task.py +0 -1225
  66. chunkr_ai/types/tasks/parse_update_params.py +0 -845
  67. chunkr_ai-0.1.0a6.dist-info/RECORD +0 -52
  68. {chunkr_ai-0.1.0a6.dist-info → chunkr_ai-0.1.0a8.dist-info}/WHEEL +0 -0
  69. {chunkr_ai-0.1.0a6.dist-info → chunkr_ai-0.1.0a8.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,393 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Optional
6
+
7
+ import httpx
8
+
9
+ from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
10
+ from ..._utils import maybe_transform, async_maybe_transform
11
+ from ..._compat import cached_property
12
+ from ..._resource import SyncAPIResource, AsyncAPIResource
13
+ from ..._response import (
14
+ to_raw_response_wrapper,
15
+ to_streamed_response_wrapper,
16
+ async_to_raw_response_wrapper,
17
+ async_to_streamed_response_wrapper,
18
+ )
19
+ from ...types.tasks import extract_get_params, extract_create_params
20
+ from ..._base_client import make_request_options
21
+ from ...types.parse_configuration_param import ParseConfigurationParam
22
+ from ...types.tasks.extract_get_response import ExtractGetResponse
23
+ from ...types.tasks.extract_create_response import ExtractCreateResponse
24
+
25
+ __all__ = ["ExtractResource", "AsyncExtractResource"]
26
+
27
+
28
+ class ExtractResource(SyncAPIResource):
29
+ @cached_property
30
+ def with_raw_response(self) -> ExtractResourceWithRawResponse:
31
+ """
32
+ This property can be used as a prefix for any HTTP method call to return
33
+ the raw response object instead of the parsed content.
34
+
35
+ For more information, see https://www.github.com/lumina-ai-inc/chunkr-python#accessing-raw-response-data-eg-headers
36
+ """
37
+ return ExtractResourceWithRawResponse(self)
38
+
39
+ @cached_property
40
+ def with_streaming_response(self) -> ExtractResourceWithStreamingResponse:
41
+ """
42
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
43
+
44
+ For more information, see https://www.github.com/lumina-ai-inc/chunkr-python#with_streaming_response
45
+ """
46
+ return ExtractResourceWithStreamingResponse(self)
47
+
48
+ def create(
49
+ self,
50
+ *,
51
+ file: str,
52
+ schema: object,
53
+ expires_in: Optional[int] | NotGiven = NOT_GIVEN,
54
+ file_name: Optional[str] | NotGiven = NOT_GIVEN,
55
+ parse_configuration: Optional[ParseConfigurationParam] | NotGiven = NOT_GIVEN,
56
+ system_prompt: Optional[str] | NotGiven = NOT_GIVEN,
57
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
58
+ # The extra values given here take precedence over values defined on the client or passed to this method.
59
+ extra_headers: Headers | None = None,
60
+ extra_query: Query | None = None,
61
+ extra_body: Body | None = None,
62
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
63
+ idempotency_key: str | None = None,
64
+ ) -> ExtractCreateResponse:
65
+ """
66
+ Queues a document/parsed task for extraction and returns a `TaskResponse` with
67
+ the assigned `task_id`, initial configuration, file metadata, and timestamps.
68
+ The initial status is `Starting`.
69
+
70
+ Creates an extract task and returns its metadata immediately.
71
+
72
+ Args:
73
+ file:
74
+ The file to be extracted. Supported inputs:
75
+
76
+ - `ch://files/{file_id}`: Reference to an existing file. Upload via the Files
77
+ API
78
+ - `http(s)://...`: Remote URL to fetch
79
+ - `data:*;base64,...` or raw base64 string
80
+ - `task_id`: Reference to an existing `parse`task.
81
+
82
+ schema: The schema to be used for the extraction.
83
+
84
+ expires_in: The number of seconds until task is deleted. Expired tasks can **not** be
85
+ updated, polled or accessed via web interface.
86
+
87
+ file_name: The name of the file to be extracted. If not set a name will be generated. Can
88
+ not be provided if the `file` is a `task_id`.
89
+
90
+ parse_configuration: Optional configuration for the `parse` task. Can not be used if `file` is a
91
+ `task_id`.
92
+
93
+ system_prompt: The system prompt to be used for the extraction.
94
+
95
+ extra_headers: Send extra headers
96
+
97
+ extra_query: Add additional query parameters to the request
98
+
99
+ extra_body: Add additional JSON properties to the request
100
+
101
+ timeout: Override the client-level default timeout for this request, in seconds
102
+
103
+ idempotency_key: Specify a custom idempotency key for this request
104
+ """
105
+ return self._post(
106
+ "/tasks/extract",
107
+ body=maybe_transform(
108
+ {
109
+ "file": file,
110
+ "schema": schema,
111
+ "expires_in": expires_in,
112
+ "file_name": file_name,
113
+ "parse_configuration": parse_configuration,
114
+ "system_prompt": system_prompt,
115
+ },
116
+ extract_create_params.ExtractCreateParams,
117
+ ),
118
+ options=make_request_options(
119
+ extra_headers=extra_headers,
120
+ extra_query=extra_query,
121
+ extra_body=extra_body,
122
+ timeout=timeout,
123
+ idempotency_key=idempotency_key,
124
+ ),
125
+ cast_to=ExtractCreateResponse,
126
+ )
127
+
128
+ def get(
129
+ self,
130
+ task_id: Optional[str],
131
+ *,
132
+ base64_urls: bool | NotGiven = NOT_GIVEN,
133
+ include_chunks: bool | NotGiven = NOT_GIVEN,
134
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
135
+ # The extra values given here take precedence over values defined on the client or passed to this method.
136
+ extra_headers: Headers | None = None,
137
+ extra_query: Query | None = None,
138
+ extra_body: Body | None = None,
139
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
140
+ ) -> ExtractGetResponse:
141
+ """
142
+ Retrieves the current state of an extract task.
143
+
144
+ Returns task details such as processing status, configuration, output (when
145
+ available), file metadata, and timestamps.
146
+
147
+ Typical uses:
148
+
149
+ - Poll a task during processing
150
+ - Retrieve the final output once processing is complete
151
+ - Access task metadata and configuration
152
+
153
+ Args:
154
+ base64_urls: Whether to return base64 encoded URLs. If false, the URLs will be returned as
155
+ presigned URLs.
156
+
157
+ include_chunks: Whether to include chunks in the output response
158
+
159
+ extra_headers: Send extra headers
160
+
161
+ extra_query: Add additional query parameters to the request
162
+
163
+ extra_body: Add additional JSON properties to the request
164
+
165
+ timeout: Override the client-level default timeout for this request, in seconds
166
+ """
167
+ if not task_id:
168
+ raise ValueError(f"Expected a non-empty value for `task_id` but received {task_id!r}")
169
+ return self._get(
170
+ f"/tasks/{task_id}/extract",
171
+ options=make_request_options(
172
+ extra_headers=extra_headers,
173
+ extra_query=extra_query,
174
+ extra_body=extra_body,
175
+ timeout=timeout,
176
+ query=maybe_transform(
177
+ {
178
+ "base64_urls": base64_urls,
179
+ "include_chunks": include_chunks,
180
+ },
181
+ extract_get_params.ExtractGetParams,
182
+ ),
183
+ ),
184
+ cast_to=ExtractGetResponse,
185
+ )
186
+
187
+
188
+ class AsyncExtractResource(AsyncAPIResource):
189
+ @cached_property
190
+ def with_raw_response(self) -> AsyncExtractResourceWithRawResponse:
191
+ """
192
+ This property can be used as a prefix for any HTTP method call to return
193
+ the raw response object instead of the parsed content.
194
+
195
+ For more information, see https://www.github.com/lumina-ai-inc/chunkr-python#accessing-raw-response-data-eg-headers
196
+ """
197
+ return AsyncExtractResourceWithRawResponse(self)
198
+
199
+ @cached_property
200
+ def with_streaming_response(self) -> AsyncExtractResourceWithStreamingResponse:
201
+ """
202
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
203
+
204
+ For more information, see https://www.github.com/lumina-ai-inc/chunkr-python#with_streaming_response
205
+ """
206
+ return AsyncExtractResourceWithStreamingResponse(self)
207
+
208
+ async def create(
209
+ self,
210
+ *,
211
+ file: str,
212
+ schema: object,
213
+ expires_in: Optional[int] | NotGiven = NOT_GIVEN,
214
+ file_name: Optional[str] | NotGiven = NOT_GIVEN,
215
+ parse_configuration: Optional[ParseConfigurationParam] | NotGiven = NOT_GIVEN,
216
+ system_prompt: Optional[str] | NotGiven = NOT_GIVEN,
217
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
218
+ # The extra values given here take precedence over values defined on the client or passed to this method.
219
+ extra_headers: Headers | None = None,
220
+ extra_query: Query | None = None,
221
+ extra_body: Body | None = None,
222
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
223
+ idempotency_key: str | None = None,
224
+ ) -> ExtractCreateResponse:
225
+ """
226
+ Queues a document/parsed task for extraction and returns a `TaskResponse` with
227
+ the assigned `task_id`, initial configuration, file metadata, and timestamps.
228
+ The initial status is `Starting`.
229
+
230
+ Creates an extract task and returns its metadata immediately.
231
+
232
+ Args:
233
+ file:
234
+ The file to be extracted. Supported inputs:
235
+
236
+ - `ch://files/{file_id}`: Reference to an existing file. Upload via the Files
237
+ API
238
+ - `http(s)://...`: Remote URL to fetch
239
+ - `data:*;base64,...` or raw base64 string
240
+ - `task_id`: Reference to an existing `parse`task.
241
+
242
+ schema: The schema to be used for the extraction.
243
+
244
+ expires_in: The number of seconds until task is deleted. Expired tasks can **not** be
245
+ updated, polled or accessed via web interface.
246
+
247
+ file_name: The name of the file to be extracted. If not set a name will be generated. Can
248
+ not be provided if the `file` is a `task_id`.
249
+
250
+ parse_configuration: Optional configuration for the `parse` task. Can not be used if `file` is a
251
+ `task_id`.
252
+
253
+ system_prompt: The system prompt to be used for the extraction.
254
+
255
+ extra_headers: Send extra headers
256
+
257
+ extra_query: Add additional query parameters to the request
258
+
259
+ extra_body: Add additional JSON properties to the request
260
+
261
+ timeout: Override the client-level default timeout for this request, in seconds
262
+
263
+ idempotency_key: Specify a custom idempotency key for this request
264
+ """
265
+ return await self._post(
266
+ "/tasks/extract",
267
+ body=await async_maybe_transform(
268
+ {
269
+ "file": file,
270
+ "schema": schema,
271
+ "expires_in": expires_in,
272
+ "file_name": file_name,
273
+ "parse_configuration": parse_configuration,
274
+ "system_prompt": system_prompt,
275
+ },
276
+ extract_create_params.ExtractCreateParams,
277
+ ),
278
+ options=make_request_options(
279
+ extra_headers=extra_headers,
280
+ extra_query=extra_query,
281
+ extra_body=extra_body,
282
+ timeout=timeout,
283
+ idempotency_key=idempotency_key,
284
+ ),
285
+ cast_to=ExtractCreateResponse,
286
+ )
287
+
288
+ async def get(
289
+ self,
290
+ task_id: Optional[str],
291
+ *,
292
+ base64_urls: bool | NotGiven = NOT_GIVEN,
293
+ include_chunks: bool | NotGiven = NOT_GIVEN,
294
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
295
+ # The extra values given here take precedence over values defined on the client or passed to this method.
296
+ extra_headers: Headers | None = None,
297
+ extra_query: Query | None = None,
298
+ extra_body: Body | None = None,
299
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
300
+ ) -> ExtractGetResponse:
301
+ """
302
+ Retrieves the current state of an extract task.
303
+
304
+ Returns task details such as processing status, configuration, output (when
305
+ available), file metadata, and timestamps.
306
+
307
+ Typical uses:
308
+
309
+ - Poll a task during processing
310
+ - Retrieve the final output once processing is complete
311
+ - Access task metadata and configuration
312
+
313
+ Args:
314
+ base64_urls: Whether to return base64 encoded URLs. If false, the URLs will be returned as
315
+ presigned URLs.
316
+
317
+ include_chunks: Whether to include chunks in the output response
318
+
319
+ extra_headers: Send extra headers
320
+
321
+ extra_query: Add additional query parameters to the request
322
+
323
+ extra_body: Add additional JSON properties to the request
324
+
325
+ timeout: Override the client-level default timeout for this request, in seconds
326
+ """
327
+ if not task_id:
328
+ raise ValueError(f"Expected a non-empty value for `task_id` but received {task_id!r}")
329
+ return await self._get(
330
+ f"/tasks/{task_id}/extract",
331
+ options=make_request_options(
332
+ extra_headers=extra_headers,
333
+ extra_query=extra_query,
334
+ extra_body=extra_body,
335
+ timeout=timeout,
336
+ query=await async_maybe_transform(
337
+ {
338
+ "base64_urls": base64_urls,
339
+ "include_chunks": include_chunks,
340
+ },
341
+ extract_get_params.ExtractGetParams,
342
+ ),
343
+ ),
344
+ cast_to=ExtractGetResponse,
345
+ )
346
+
347
+
348
+ class ExtractResourceWithRawResponse:
349
+ def __init__(self, extract: ExtractResource) -> None:
350
+ self._extract = extract
351
+
352
+ self.create = to_raw_response_wrapper(
353
+ extract.create,
354
+ )
355
+ self.get = to_raw_response_wrapper(
356
+ extract.get,
357
+ )
358
+
359
+
360
+ class AsyncExtractResourceWithRawResponse:
361
+ def __init__(self, extract: AsyncExtractResource) -> None:
362
+ self._extract = extract
363
+
364
+ self.create = async_to_raw_response_wrapper(
365
+ extract.create,
366
+ )
367
+ self.get = async_to_raw_response_wrapper(
368
+ extract.get,
369
+ )
370
+
371
+
372
+ class ExtractResourceWithStreamingResponse:
373
+ def __init__(self, extract: ExtractResource) -> None:
374
+ self._extract = extract
375
+
376
+ self.create = to_streamed_response_wrapper(
377
+ extract.create,
378
+ )
379
+ self.get = to_streamed_response_wrapper(
380
+ extract.get,
381
+ )
382
+
383
+
384
+ class AsyncExtractResourceWithStreamingResponse:
385
+ def __init__(self, extract: AsyncExtractResource) -> None:
386
+ self._extract = extract
387
+
388
+ self.create = async_to_streamed_response_wrapper(
389
+ extract.create,
390
+ )
391
+ self.get = async_to_streamed_response_wrapper(
392
+ extract.get,
393
+ )