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