chunkr-ai 0.1.0a1__py3-none-any.whl → 0.1.0a2__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.
- chunkr_ai/_client.py +2 -1
- chunkr_ai/_version.py +1 -1
- chunkr_ai/resources/task/__init__.py +33 -0
- chunkr_ai/resources/{task.py → task/parse.py} +146 -696
- chunkr_ai/resources/task/task.py +664 -0
- chunkr_ai/types/__init__.py +0 -19
- chunkr_ai/types/task/__init__.py +7 -0
- chunkr_ai/types/task/parse_create_params.py +806 -0
- chunkr_ai/types/task/parse_update_params.py +806 -0
- chunkr_ai/types/task/task.py +1186 -0
- {chunkr_ai-0.1.0a1.dist-info → chunkr_ai-0.1.0a2.dist-info}/METADATA +12 -12
- {chunkr_ai-0.1.0a1.dist-info → chunkr_ai-0.1.0a2.dist-info}/RECORD +14 -28
- chunkr_ai/types/auto_generation_config.py +0 -39
- chunkr_ai/types/auto_generation_config_param.py +0 -39
- chunkr_ai/types/bounding_box.py +0 -19
- chunkr_ai/types/chunk_processing.py +0 -40
- chunkr_ai/types/chunk_processing_param.py +0 -42
- chunkr_ai/types/ignore_generation_config.py +0 -39
- chunkr_ai/types/ignore_generation_config_param.py +0 -39
- chunkr_ai/types/llm_generation_config.py +0 -39
- chunkr_ai/types/llm_generation_config_param.py +0 -39
- chunkr_ai/types/llm_processing.py +0 -36
- chunkr_ai/types/llm_processing_param.py +0 -36
- chunkr_ai/types/picture_generation_config.py +0 -39
- chunkr_ai/types/picture_generation_config_param.py +0 -39
- chunkr_ai/types/segment_processing.py +0 -280
- chunkr_ai/types/segment_processing_param.py +0 -281
- chunkr_ai/types/table_generation_config.py +0 -39
- chunkr_ai/types/table_generation_config_param.py +0 -39
- chunkr_ai/types/task.py +0 -379
- chunkr_ai/types/task_parse_params.py +0 -90
- chunkr_ai/types/task_update_params.py +0 -90
- {chunkr_ai-0.1.0a1.dist-info → chunkr_ai-0.1.0a2.dist-info}/WHEEL +0 -0
- {chunkr_ai-0.1.0a1.dist-info → chunkr_ai-0.1.0a2.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,664 @@
|
|
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 Union, Optional
|
6
|
+
from datetime import datetime
|
7
|
+
from typing_extensions import Literal
|
8
|
+
|
9
|
+
import httpx
|
10
|
+
|
11
|
+
from .parse import (
|
12
|
+
ParseResource,
|
13
|
+
AsyncParseResource,
|
14
|
+
ParseResourceWithRawResponse,
|
15
|
+
AsyncParseResourceWithRawResponse,
|
16
|
+
ParseResourceWithStreamingResponse,
|
17
|
+
AsyncParseResourceWithStreamingResponse,
|
18
|
+
)
|
19
|
+
from ...types import task_get_params, task_list_params
|
20
|
+
from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven
|
21
|
+
from ..._utils import maybe_transform, async_maybe_transform
|
22
|
+
from ..._compat import cached_property
|
23
|
+
from ..._resource import SyncAPIResource, AsyncAPIResource
|
24
|
+
from ..._response import (
|
25
|
+
to_raw_response_wrapper,
|
26
|
+
to_streamed_response_wrapper,
|
27
|
+
async_to_raw_response_wrapper,
|
28
|
+
async_to_streamed_response_wrapper,
|
29
|
+
)
|
30
|
+
from ...pagination import SyncTasksPage, AsyncTasksPage
|
31
|
+
from ..._base_client import AsyncPaginator, make_request_options
|
32
|
+
from ...types.task.task import Task
|
33
|
+
|
34
|
+
__all__ = ["TaskResource", "AsyncTaskResource"]
|
35
|
+
|
36
|
+
|
37
|
+
class TaskResource(SyncAPIResource):
|
38
|
+
@cached_property
|
39
|
+
def parse(self) -> ParseResource:
|
40
|
+
return ParseResource(self._client)
|
41
|
+
|
42
|
+
@cached_property
|
43
|
+
def with_raw_response(self) -> TaskResourceWithRawResponse:
|
44
|
+
"""
|
45
|
+
This property can be used as a prefix for any HTTP method call to return
|
46
|
+
the raw response object instead of the parsed content.
|
47
|
+
|
48
|
+
For more information, see https://www.github.com/lumina-ai-inc/chunkr-python#accessing-raw-response-data-eg-headers
|
49
|
+
"""
|
50
|
+
return TaskResourceWithRawResponse(self)
|
51
|
+
|
52
|
+
@cached_property
|
53
|
+
def with_streaming_response(self) -> TaskResourceWithStreamingResponse:
|
54
|
+
"""
|
55
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
56
|
+
|
57
|
+
For more information, see https://www.github.com/lumina-ai-inc/chunkr-python#with_streaming_response
|
58
|
+
"""
|
59
|
+
return TaskResourceWithStreamingResponse(self)
|
60
|
+
|
61
|
+
def list(
|
62
|
+
self,
|
63
|
+
*,
|
64
|
+
base64_urls: bool | NotGiven = NOT_GIVEN,
|
65
|
+
cursor: Union[str, datetime] | NotGiven = NOT_GIVEN,
|
66
|
+
end: Union[str, datetime] | NotGiven = NOT_GIVEN,
|
67
|
+
include_chunks: bool | NotGiven = NOT_GIVEN,
|
68
|
+
limit: int | NotGiven = NOT_GIVEN,
|
69
|
+
sort: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
|
70
|
+
start: Union[str, datetime] | NotGiven = NOT_GIVEN,
|
71
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
72
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
73
|
+
extra_headers: Headers | None = None,
|
74
|
+
extra_query: Query | None = None,
|
75
|
+
extra_body: Body | None = None,
|
76
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
77
|
+
) -> SyncTasksPage[Task]:
|
78
|
+
"""Retrieves a list of tasks with cursor-based pagination.
|
79
|
+
|
80
|
+
By default, tasks are
|
81
|
+
returned in descending order (newest first).
|
82
|
+
|
83
|
+
## Default Behaviors:
|
84
|
+
|
85
|
+
- **limit**: Returns all tasks if not specified
|
86
|
+
- **start**: No start date filter (returns from beginning of time)
|
87
|
+
- **end**: No end date filter (returns up to current time)
|
88
|
+
- **cursor**: Starts from most recent tasks (no pagination offset)
|
89
|
+
- **sort**: 'desc' (descending order, newest first)
|
90
|
+
- **include_chunks**: false (excludes chunks for better performance)
|
91
|
+
- **base64_urls**: false (returns presigned URLs instead of base64)
|
92
|
+
|
93
|
+
## Common Usage Patterns:
|
94
|
+
|
95
|
+
**Basic usage (get all tasks):** `GET /api/v1/tasks`
|
96
|
+
|
97
|
+
**Get first 10 tasks:** `GET /api/v1/tasks?limit=10`
|
98
|
+
|
99
|
+
**Paginate through results:**
|
100
|
+
|
101
|
+
1. First request: `GET /api/v1/tasks?limit=10`
|
102
|
+
2. Use next_cursor from response for subsequent pages:
|
103
|
+
`GET /api/v1/tasks?limit=10&cursor=<timestamp>`
|
104
|
+
|
105
|
+
**Filter by date range:**
|
106
|
+
`GET /api/v1/tasks?start=2025-01-01T00:00:00Z&end=2025-12-31T23:59:59Z`
|
107
|
+
|
108
|
+
**Get detailed results with chunks:** `GET /api/v1/tasks?include_chunks=true`
|
109
|
+
|
110
|
+
**Get base64 encoded content:** `GET /api/v1/tasks?base64_urls=true`
|
111
|
+
|
112
|
+
**Get tasks in ascending order (oldest first):** `GET /api/v1/tasks?sort=asc`
|
113
|
+
|
114
|
+
**Get tasks in descending order (newest first, default):**
|
115
|
+
`GET /api/v1/tasks?sort=desc`
|
116
|
+
|
117
|
+
Args:
|
118
|
+
base64_urls: Whether to return base64 encoded URLs. If false, the URLs will be returned as
|
119
|
+
presigned URLs.
|
120
|
+
|
121
|
+
cursor: Cursor for pagination (timestamp)
|
122
|
+
|
123
|
+
end: End date
|
124
|
+
|
125
|
+
include_chunks: Whether to include chunks in the output response
|
126
|
+
|
127
|
+
limit: Number of tasks per page
|
128
|
+
|
129
|
+
sort: Sort order: 'asc' for ascending, 'desc' for descending (default)
|
130
|
+
|
131
|
+
start: Start date
|
132
|
+
|
133
|
+
extra_headers: Send extra headers
|
134
|
+
|
135
|
+
extra_query: Add additional query parameters to the request
|
136
|
+
|
137
|
+
extra_body: Add additional JSON properties to the request
|
138
|
+
|
139
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
140
|
+
"""
|
141
|
+
return self._get_api_list(
|
142
|
+
"/tasks",
|
143
|
+
page=SyncTasksPage[Task],
|
144
|
+
options=make_request_options(
|
145
|
+
extra_headers=extra_headers,
|
146
|
+
extra_query=extra_query,
|
147
|
+
extra_body=extra_body,
|
148
|
+
timeout=timeout,
|
149
|
+
query=maybe_transform(
|
150
|
+
{
|
151
|
+
"base64_urls": base64_urls,
|
152
|
+
"cursor": cursor,
|
153
|
+
"end": end,
|
154
|
+
"include_chunks": include_chunks,
|
155
|
+
"limit": limit,
|
156
|
+
"sort": sort,
|
157
|
+
"start": start,
|
158
|
+
},
|
159
|
+
task_list_params.TaskListParams,
|
160
|
+
),
|
161
|
+
),
|
162
|
+
model=Task,
|
163
|
+
)
|
164
|
+
|
165
|
+
def delete(
|
166
|
+
self,
|
167
|
+
task_id: Optional[str],
|
168
|
+
*,
|
169
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
170
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
171
|
+
extra_headers: Headers | None = None,
|
172
|
+
extra_query: Query | None = None,
|
173
|
+
extra_body: Body | None = None,
|
174
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
175
|
+
) -> None:
|
176
|
+
"""
|
177
|
+
Delete a task by its ID.
|
178
|
+
|
179
|
+
Requirements:
|
180
|
+
|
181
|
+
- Task must have status `Succeeded` or `Failed`
|
182
|
+
|
183
|
+
Args:
|
184
|
+
extra_headers: Send extra headers
|
185
|
+
|
186
|
+
extra_query: Add additional query parameters to the request
|
187
|
+
|
188
|
+
extra_body: Add additional JSON properties to the request
|
189
|
+
|
190
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
191
|
+
"""
|
192
|
+
if not task_id:
|
193
|
+
raise ValueError(f"Expected a non-empty value for `task_id` but received {task_id!r}")
|
194
|
+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
195
|
+
return self._delete(
|
196
|
+
f"/task/{task_id}",
|
197
|
+
options=make_request_options(
|
198
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
199
|
+
),
|
200
|
+
cast_to=NoneType,
|
201
|
+
)
|
202
|
+
|
203
|
+
def cancel(
|
204
|
+
self,
|
205
|
+
task_id: Optional[str],
|
206
|
+
*,
|
207
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
208
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
209
|
+
extra_headers: Headers | None = None,
|
210
|
+
extra_query: Query | None = None,
|
211
|
+
extra_body: Body | None = None,
|
212
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
213
|
+
) -> None:
|
214
|
+
"""
|
215
|
+
Cancel a task that hasn't started processing yet:
|
216
|
+
|
217
|
+
- For new tasks: Status will be updated to `Cancelled`
|
218
|
+
- For updating tasks: Task will revert to the previous state
|
219
|
+
|
220
|
+
Requirements:
|
221
|
+
|
222
|
+
- Task must have status `Starting`
|
223
|
+
|
224
|
+
Args:
|
225
|
+
extra_headers: Send extra headers
|
226
|
+
|
227
|
+
extra_query: Add additional query parameters to the request
|
228
|
+
|
229
|
+
extra_body: Add additional JSON properties to the request
|
230
|
+
|
231
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
232
|
+
"""
|
233
|
+
if not task_id:
|
234
|
+
raise ValueError(f"Expected a non-empty value for `task_id` but received {task_id!r}")
|
235
|
+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
236
|
+
return self._get(
|
237
|
+
f"/task/{task_id}/cancel",
|
238
|
+
options=make_request_options(
|
239
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
240
|
+
),
|
241
|
+
cast_to=NoneType,
|
242
|
+
)
|
243
|
+
|
244
|
+
def get(
|
245
|
+
self,
|
246
|
+
task_id: Optional[str],
|
247
|
+
*,
|
248
|
+
base64_urls: bool | NotGiven = NOT_GIVEN,
|
249
|
+
include_chunks: bool | NotGiven = NOT_GIVEN,
|
250
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
251
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
252
|
+
extra_headers: Headers | None = None,
|
253
|
+
extra_query: Query | None = None,
|
254
|
+
extra_body: Body | None = None,
|
255
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
256
|
+
) -> Task:
|
257
|
+
"""
|
258
|
+
Retrieves detailed information about a task by its ID, including:
|
259
|
+
|
260
|
+
- Processing status
|
261
|
+
- Task configuration
|
262
|
+
- Output data (if processing is complete)
|
263
|
+
- File metadata (name, page count)
|
264
|
+
- Timestamps (created, started, finished)
|
265
|
+
- Presigned URLs for accessing files
|
266
|
+
|
267
|
+
This endpoint can be used to:
|
268
|
+
|
269
|
+
1. Poll the task status during processing
|
270
|
+
2. Retrieve the final output once processing is complete
|
271
|
+
3. Access task metadata and configuration
|
272
|
+
|
273
|
+
Args:
|
274
|
+
base64_urls: Whether to return base64 encoded URLs. If false, the URLs will be returned as
|
275
|
+
presigned URLs.
|
276
|
+
|
277
|
+
include_chunks: Whether to include chunks in the output response
|
278
|
+
|
279
|
+
extra_headers: Send extra headers
|
280
|
+
|
281
|
+
extra_query: Add additional query parameters to the request
|
282
|
+
|
283
|
+
extra_body: Add additional JSON properties to the request
|
284
|
+
|
285
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
286
|
+
"""
|
287
|
+
if not task_id:
|
288
|
+
raise ValueError(f"Expected a non-empty value for `task_id` but received {task_id!r}")
|
289
|
+
return self._get(
|
290
|
+
f"/task/{task_id}",
|
291
|
+
options=make_request_options(
|
292
|
+
extra_headers=extra_headers,
|
293
|
+
extra_query=extra_query,
|
294
|
+
extra_body=extra_body,
|
295
|
+
timeout=timeout,
|
296
|
+
query=maybe_transform(
|
297
|
+
{
|
298
|
+
"base64_urls": base64_urls,
|
299
|
+
"include_chunks": include_chunks,
|
300
|
+
},
|
301
|
+
task_get_params.TaskGetParams,
|
302
|
+
),
|
303
|
+
),
|
304
|
+
cast_to=Task,
|
305
|
+
)
|
306
|
+
|
307
|
+
|
308
|
+
class AsyncTaskResource(AsyncAPIResource):
|
309
|
+
@cached_property
|
310
|
+
def parse(self) -> AsyncParseResource:
|
311
|
+
return AsyncParseResource(self._client)
|
312
|
+
|
313
|
+
@cached_property
|
314
|
+
def with_raw_response(self) -> AsyncTaskResourceWithRawResponse:
|
315
|
+
"""
|
316
|
+
This property can be used as a prefix for any HTTP method call to return
|
317
|
+
the raw response object instead of the parsed content.
|
318
|
+
|
319
|
+
For more information, see https://www.github.com/lumina-ai-inc/chunkr-python#accessing-raw-response-data-eg-headers
|
320
|
+
"""
|
321
|
+
return AsyncTaskResourceWithRawResponse(self)
|
322
|
+
|
323
|
+
@cached_property
|
324
|
+
def with_streaming_response(self) -> AsyncTaskResourceWithStreamingResponse:
|
325
|
+
"""
|
326
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
327
|
+
|
328
|
+
For more information, see https://www.github.com/lumina-ai-inc/chunkr-python#with_streaming_response
|
329
|
+
"""
|
330
|
+
return AsyncTaskResourceWithStreamingResponse(self)
|
331
|
+
|
332
|
+
def list(
|
333
|
+
self,
|
334
|
+
*,
|
335
|
+
base64_urls: bool | NotGiven = NOT_GIVEN,
|
336
|
+
cursor: Union[str, datetime] | NotGiven = NOT_GIVEN,
|
337
|
+
end: Union[str, datetime] | NotGiven = NOT_GIVEN,
|
338
|
+
include_chunks: bool | NotGiven = NOT_GIVEN,
|
339
|
+
limit: int | NotGiven = NOT_GIVEN,
|
340
|
+
sort: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
|
341
|
+
start: Union[str, datetime] | NotGiven = NOT_GIVEN,
|
342
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
343
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
344
|
+
extra_headers: Headers | None = None,
|
345
|
+
extra_query: Query | None = None,
|
346
|
+
extra_body: Body | None = None,
|
347
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
348
|
+
) -> AsyncPaginator[Task, AsyncTasksPage[Task]]:
|
349
|
+
"""Retrieves a list of tasks with cursor-based pagination.
|
350
|
+
|
351
|
+
By default, tasks are
|
352
|
+
returned in descending order (newest first).
|
353
|
+
|
354
|
+
## Default Behaviors:
|
355
|
+
|
356
|
+
- **limit**: Returns all tasks if not specified
|
357
|
+
- **start**: No start date filter (returns from beginning of time)
|
358
|
+
- **end**: No end date filter (returns up to current time)
|
359
|
+
- **cursor**: Starts from most recent tasks (no pagination offset)
|
360
|
+
- **sort**: 'desc' (descending order, newest first)
|
361
|
+
- **include_chunks**: false (excludes chunks for better performance)
|
362
|
+
- **base64_urls**: false (returns presigned URLs instead of base64)
|
363
|
+
|
364
|
+
## Common Usage Patterns:
|
365
|
+
|
366
|
+
**Basic usage (get all tasks):** `GET /api/v1/tasks`
|
367
|
+
|
368
|
+
**Get first 10 tasks:** `GET /api/v1/tasks?limit=10`
|
369
|
+
|
370
|
+
**Paginate through results:**
|
371
|
+
|
372
|
+
1. First request: `GET /api/v1/tasks?limit=10`
|
373
|
+
2. Use next_cursor from response for subsequent pages:
|
374
|
+
`GET /api/v1/tasks?limit=10&cursor=<timestamp>`
|
375
|
+
|
376
|
+
**Filter by date range:**
|
377
|
+
`GET /api/v1/tasks?start=2025-01-01T00:00:00Z&end=2025-12-31T23:59:59Z`
|
378
|
+
|
379
|
+
**Get detailed results with chunks:** `GET /api/v1/tasks?include_chunks=true`
|
380
|
+
|
381
|
+
**Get base64 encoded content:** `GET /api/v1/tasks?base64_urls=true`
|
382
|
+
|
383
|
+
**Get tasks in ascending order (oldest first):** `GET /api/v1/tasks?sort=asc`
|
384
|
+
|
385
|
+
**Get tasks in descending order (newest first, default):**
|
386
|
+
`GET /api/v1/tasks?sort=desc`
|
387
|
+
|
388
|
+
Args:
|
389
|
+
base64_urls: Whether to return base64 encoded URLs. If false, the URLs will be returned as
|
390
|
+
presigned URLs.
|
391
|
+
|
392
|
+
cursor: Cursor for pagination (timestamp)
|
393
|
+
|
394
|
+
end: End date
|
395
|
+
|
396
|
+
include_chunks: Whether to include chunks in the output response
|
397
|
+
|
398
|
+
limit: Number of tasks per page
|
399
|
+
|
400
|
+
sort: Sort order: 'asc' for ascending, 'desc' for descending (default)
|
401
|
+
|
402
|
+
start: Start date
|
403
|
+
|
404
|
+
extra_headers: Send extra headers
|
405
|
+
|
406
|
+
extra_query: Add additional query parameters to the request
|
407
|
+
|
408
|
+
extra_body: Add additional JSON properties to the request
|
409
|
+
|
410
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
411
|
+
"""
|
412
|
+
return self._get_api_list(
|
413
|
+
"/tasks",
|
414
|
+
page=AsyncTasksPage[Task],
|
415
|
+
options=make_request_options(
|
416
|
+
extra_headers=extra_headers,
|
417
|
+
extra_query=extra_query,
|
418
|
+
extra_body=extra_body,
|
419
|
+
timeout=timeout,
|
420
|
+
query=maybe_transform(
|
421
|
+
{
|
422
|
+
"base64_urls": base64_urls,
|
423
|
+
"cursor": cursor,
|
424
|
+
"end": end,
|
425
|
+
"include_chunks": include_chunks,
|
426
|
+
"limit": limit,
|
427
|
+
"sort": sort,
|
428
|
+
"start": start,
|
429
|
+
},
|
430
|
+
task_list_params.TaskListParams,
|
431
|
+
),
|
432
|
+
),
|
433
|
+
model=Task,
|
434
|
+
)
|
435
|
+
|
436
|
+
async def delete(
|
437
|
+
self,
|
438
|
+
task_id: Optional[str],
|
439
|
+
*,
|
440
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
441
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
442
|
+
extra_headers: Headers | None = None,
|
443
|
+
extra_query: Query | None = None,
|
444
|
+
extra_body: Body | None = None,
|
445
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
446
|
+
) -> None:
|
447
|
+
"""
|
448
|
+
Delete a task by its ID.
|
449
|
+
|
450
|
+
Requirements:
|
451
|
+
|
452
|
+
- Task must have status `Succeeded` or `Failed`
|
453
|
+
|
454
|
+
Args:
|
455
|
+
extra_headers: Send extra headers
|
456
|
+
|
457
|
+
extra_query: Add additional query parameters to the request
|
458
|
+
|
459
|
+
extra_body: Add additional JSON properties to the request
|
460
|
+
|
461
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
462
|
+
"""
|
463
|
+
if not task_id:
|
464
|
+
raise ValueError(f"Expected a non-empty value for `task_id` but received {task_id!r}")
|
465
|
+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
466
|
+
return await self._delete(
|
467
|
+
f"/task/{task_id}",
|
468
|
+
options=make_request_options(
|
469
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
470
|
+
),
|
471
|
+
cast_to=NoneType,
|
472
|
+
)
|
473
|
+
|
474
|
+
async def cancel(
|
475
|
+
self,
|
476
|
+
task_id: Optional[str],
|
477
|
+
*,
|
478
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
479
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
480
|
+
extra_headers: Headers | None = None,
|
481
|
+
extra_query: Query | None = None,
|
482
|
+
extra_body: Body | None = None,
|
483
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
484
|
+
) -> None:
|
485
|
+
"""
|
486
|
+
Cancel a task that hasn't started processing yet:
|
487
|
+
|
488
|
+
- For new tasks: Status will be updated to `Cancelled`
|
489
|
+
- For updating tasks: Task will revert to the previous state
|
490
|
+
|
491
|
+
Requirements:
|
492
|
+
|
493
|
+
- Task must have status `Starting`
|
494
|
+
|
495
|
+
Args:
|
496
|
+
extra_headers: Send extra headers
|
497
|
+
|
498
|
+
extra_query: Add additional query parameters to the request
|
499
|
+
|
500
|
+
extra_body: Add additional JSON properties to the request
|
501
|
+
|
502
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
503
|
+
"""
|
504
|
+
if not task_id:
|
505
|
+
raise ValueError(f"Expected a non-empty value for `task_id` but received {task_id!r}")
|
506
|
+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
507
|
+
return await self._get(
|
508
|
+
f"/task/{task_id}/cancel",
|
509
|
+
options=make_request_options(
|
510
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
511
|
+
),
|
512
|
+
cast_to=NoneType,
|
513
|
+
)
|
514
|
+
|
515
|
+
async def get(
|
516
|
+
self,
|
517
|
+
task_id: Optional[str],
|
518
|
+
*,
|
519
|
+
base64_urls: bool | NotGiven = NOT_GIVEN,
|
520
|
+
include_chunks: bool | NotGiven = NOT_GIVEN,
|
521
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
522
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
523
|
+
extra_headers: Headers | None = None,
|
524
|
+
extra_query: Query | None = None,
|
525
|
+
extra_body: Body | None = None,
|
526
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
527
|
+
) -> Task:
|
528
|
+
"""
|
529
|
+
Retrieves detailed information about a task by its ID, including:
|
530
|
+
|
531
|
+
- Processing status
|
532
|
+
- Task configuration
|
533
|
+
- Output data (if processing is complete)
|
534
|
+
- File metadata (name, page count)
|
535
|
+
- Timestamps (created, started, finished)
|
536
|
+
- Presigned URLs for accessing files
|
537
|
+
|
538
|
+
This endpoint can be used to:
|
539
|
+
|
540
|
+
1. Poll the task status during processing
|
541
|
+
2. Retrieve the final output once processing is complete
|
542
|
+
3. Access task metadata and configuration
|
543
|
+
|
544
|
+
Args:
|
545
|
+
base64_urls: Whether to return base64 encoded URLs. If false, the URLs will be returned as
|
546
|
+
presigned URLs.
|
547
|
+
|
548
|
+
include_chunks: Whether to include chunks in the output response
|
549
|
+
|
550
|
+
extra_headers: Send extra headers
|
551
|
+
|
552
|
+
extra_query: Add additional query parameters to the request
|
553
|
+
|
554
|
+
extra_body: Add additional JSON properties to the request
|
555
|
+
|
556
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
557
|
+
"""
|
558
|
+
if not task_id:
|
559
|
+
raise ValueError(f"Expected a non-empty value for `task_id` but received {task_id!r}")
|
560
|
+
return await self._get(
|
561
|
+
f"/task/{task_id}",
|
562
|
+
options=make_request_options(
|
563
|
+
extra_headers=extra_headers,
|
564
|
+
extra_query=extra_query,
|
565
|
+
extra_body=extra_body,
|
566
|
+
timeout=timeout,
|
567
|
+
query=await async_maybe_transform(
|
568
|
+
{
|
569
|
+
"base64_urls": base64_urls,
|
570
|
+
"include_chunks": include_chunks,
|
571
|
+
},
|
572
|
+
task_get_params.TaskGetParams,
|
573
|
+
),
|
574
|
+
),
|
575
|
+
cast_to=Task,
|
576
|
+
)
|
577
|
+
|
578
|
+
|
579
|
+
class TaskResourceWithRawResponse:
|
580
|
+
def __init__(self, task: TaskResource) -> None:
|
581
|
+
self._task = task
|
582
|
+
|
583
|
+
self.list = to_raw_response_wrapper(
|
584
|
+
task.list,
|
585
|
+
)
|
586
|
+
self.delete = to_raw_response_wrapper(
|
587
|
+
task.delete,
|
588
|
+
)
|
589
|
+
self.cancel = to_raw_response_wrapper(
|
590
|
+
task.cancel,
|
591
|
+
)
|
592
|
+
self.get = to_raw_response_wrapper(
|
593
|
+
task.get,
|
594
|
+
)
|
595
|
+
|
596
|
+
@cached_property
|
597
|
+
def parse(self) -> ParseResourceWithRawResponse:
|
598
|
+
return ParseResourceWithRawResponse(self._task.parse)
|
599
|
+
|
600
|
+
|
601
|
+
class AsyncTaskResourceWithRawResponse:
|
602
|
+
def __init__(self, task: AsyncTaskResource) -> None:
|
603
|
+
self._task = task
|
604
|
+
|
605
|
+
self.list = async_to_raw_response_wrapper(
|
606
|
+
task.list,
|
607
|
+
)
|
608
|
+
self.delete = async_to_raw_response_wrapper(
|
609
|
+
task.delete,
|
610
|
+
)
|
611
|
+
self.cancel = async_to_raw_response_wrapper(
|
612
|
+
task.cancel,
|
613
|
+
)
|
614
|
+
self.get = async_to_raw_response_wrapper(
|
615
|
+
task.get,
|
616
|
+
)
|
617
|
+
|
618
|
+
@cached_property
|
619
|
+
def parse(self) -> AsyncParseResourceWithRawResponse:
|
620
|
+
return AsyncParseResourceWithRawResponse(self._task.parse)
|
621
|
+
|
622
|
+
|
623
|
+
class TaskResourceWithStreamingResponse:
|
624
|
+
def __init__(self, task: TaskResource) -> None:
|
625
|
+
self._task = task
|
626
|
+
|
627
|
+
self.list = to_streamed_response_wrapper(
|
628
|
+
task.list,
|
629
|
+
)
|
630
|
+
self.delete = to_streamed_response_wrapper(
|
631
|
+
task.delete,
|
632
|
+
)
|
633
|
+
self.cancel = to_streamed_response_wrapper(
|
634
|
+
task.cancel,
|
635
|
+
)
|
636
|
+
self.get = to_streamed_response_wrapper(
|
637
|
+
task.get,
|
638
|
+
)
|
639
|
+
|
640
|
+
@cached_property
|
641
|
+
def parse(self) -> ParseResourceWithStreamingResponse:
|
642
|
+
return ParseResourceWithStreamingResponse(self._task.parse)
|
643
|
+
|
644
|
+
|
645
|
+
class AsyncTaskResourceWithStreamingResponse:
|
646
|
+
def __init__(self, task: AsyncTaskResource) -> None:
|
647
|
+
self._task = task
|
648
|
+
|
649
|
+
self.list = async_to_streamed_response_wrapper(
|
650
|
+
task.list,
|
651
|
+
)
|
652
|
+
self.delete = async_to_streamed_response_wrapper(
|
653
|
+
task.delete,
|
654
|
+
)
|
655
|
+
self.cancel = async_to_streamed_response_wrapper(
|
656
|
+
task.cancel,
|
657
|
+
)
|
658
|
+
self.get = async_to_streamed_response_wrapper(
|
659
|
+
task.get,
|
660
|
+
)
|
661
|
+
|
662
|
+
@cached_property
|
663
|
+
def parse(self) -> AsyncParseResourceWithStreamingResponse:
|
664
|
+
return AsyncParseResourceWithStreamingResponse(self._task.parse)
|
chunkr_ai/types/__init__.py
CHANGED
@@ -3,25 +3,6 @@
|
|
3
3
|
from __future__ import annotations
|
4
4
|
|
5
5
|
from .task import Task as Task
|
6
|
-
from .bounding_box import BoundingBox as BoundingBox
|
7
|
-
from .llm_processing import LlmProcessing as LlmProcessing
|
8
6
|
from .task_get_params import TaskGetParams as TaskGetParams
|
9
|
-
from .chunk_processing import ChunkProcessing as ChunkProcessing
|
10
7
|
from .task_list_params import TaskListParams as TaskListParams
|
11
|
-
from .task_parse_params import TaskParseParams as TaskParseParams
|
12
|
-
from .segment_processing import SegmentProcessing as SegmentProcessing
|
13
|
-
from .task_update_params import TaskUpdateParams as TaskUpdateParams
|
14
|
-
from .llm_processing_param import LlmProcessingParam as LlmProcessingParam
|
15
8
|
from .health_check_response import HealthCheckResponse as HealthCheckResponse
|
16
|
-
from .llm_generation_config import LlmGenerationConfig as LlmGenerationConfig
|
17
|
-
from .auto_generation_config import AutoGenerationConfig as AutoGenerationConfig
|
18
|
-
from .chunk_processing_param import ChunkProcessingParam as ChunkProcessingParam
|
19
|
-
from .table_generation_config import TableGenerationConfig as TableGenerationConfig
|
20
|
-
from .ignore_generation_config import IgnoreGenerationConfig as IgnoreGenerationConfig
|
21
|
-
from .segment_processing_param import SegmentProcessingParam as SegmentProcessingParam
|
22
|
-
from .picture_generation_config import PictureGenerationConfig as PictureGenerationConfig
|
23
|
-
from .llm_generation_config_param import LlmGenerationConfigParam as LlmGenerationConfigParam
|
24
|
-
from .auto_generation_config_param import AutoGenerationConfigParam as AutoGenerationConfigParam
|
25
|
-
from .table_generation_config_param import TableGenerationConfigParam as TableGenerationConfigParam
|
26
|
-
from .ignore_generation_config_param import IgnoreGenerationConfigParam as IgnoreGenerationConfigParam
|
27
|
-
from .picture_generation_config_param import PictureGenerationConfigParam as PictureGenerationConfigParam
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
2
|
+
|
3
|
+
from __future__ import annotations
|
4
|
+
|
5
|
+
from .task import Task as Task
|
6
|
+
from .parse_create_params import ParseCreateParams as ParseCreateParams
|
7
|
+
from .parse_update_params import ParseUpdateParams as ParseUpdateParams
|