chunkr-ai 0.0.14__py3-none-any.whl → 0.0.15__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- chunkr_ai/__init__.py +1 -1
- chunkr_ai/api/auth.py +4 -4
- chunkr_ai/api/base.py +58 -48
- chunkr_ai/api/chunkr.py +21 -20
- chunkr_ai/api/chunkr_async.py +26 -20
- chunkr_ai/api/chunkr_base.py +34 -27
- chunkr_ai/api/config.py +38 -14
- chunkr_ai/api/misc.py +51 -44
- chunkr_ai/api/protocol.py +5 -3
- chunkr_ai/api/schema.py +66 -58
- chunkr_ai/api/task.py +13 -16
- chunkr_ai/api/task_async.py +16 -7
- chunkr_ai/api/task_base.py +2 -1
- chunkr_ai/models.py +21 -22
- {chunkr_ai-0.0.14.dist-info → chunkr_ai-0.0.15.dist-info}/METADATA +1 -1
- chunkr_ai-0.0.15.dist-info/RECORD +21 -0
- chunkr_ai-0.0.14.dist-info/RECORD +0 -21
- {chunkr_ai-0.0.14.dist-info → chunkr_ai-0.0.15.dist-info}/LICENSE +0 -0
- {chunkr_ai-0.0.14.dist-info → chunkr_ai-0.0.15.dist-info}/WHEEL +0 -0
- {chunkr_ai-0.0.14.dist-info → chunkr_ai-0.0.15.dist-info}/top_level.txt +0 -0
chunkr_ai/api/task_async.py
CHANGED
@@ -3,21 +3,24 @@ from .misc import prepare_upload_data
|
|
3
3
|
from .task_base import TaskBase
|
4
4
|
import asyncio
|
5
5
|
|
6
|
+
|
6
7
|
class TaskResponseAsync(TaskBase):
|
7
8
|
async def _poll_request(self) -> dict:
|
8
9
|
try:
|
9
10
|
if not self._client._client:
|
10
11
|
raise ValueError("Client not found")
|
11
|
-
r = await self._client._client.get(
|
12
|
+
r = await self._client._client.get(
|
13
|
+
self.task_url, headers=self._client._headers()
|
14
|
+
)
|
12
15
|
r.raise_for_status()
|
13
16
|
return r.json()
|
14
17
|
except (ConnectionError, TimeoutError) as _:
|
15
18
|
print("Connection error while polling the task, retrying...")
|
16
19
|
await asyncio.sleep(0.5)
|
17
|
-
except Exception
|
20
|
+
except Exception:
|
18
21
|
raise
|
19
22
|
|
20
|
-
async def poll(self) ->
|
23
|
+
async def poll(self) -> "TaskResponseAsync":
|
21
24
|
if not self.task_url:
|
22
25
|
raise ValueError("Task URL not found")
|
23
26
|
if not self._client._client:
|
@@ -30,13 +33,15 @@ class TaskResponseAsync(TaskBase):
|
|
30
33
|
return res
|
31
34
|
await asyncio.sleep(0.5)
|
32
35
|
|
33
|
-
async def update(self, config: Configuration) ->
|
36
|
+
async def update(self, config: Configuration) -> "TaskResponseAsync":
|
34
37
|
if not self.task_url:
|
35
38
|
raise ValueError("Task URL not found")
|
36
39
|
if not self._client._client:
|
37
40
|
raise ValueError("Client not found")
|
38
41
|
f = prepare_upload_data(None, config)
|
39
|
-
r = await self._client._client.patch(
|
42
|
+
r = await self._client._client.patch(
|
43
|
+
self.task_url, files=f, headers=self._client._headers()
|
44
|
+
)
|
40
45
|
r.raise_for_status()
|
41
46
|
updated = TaskResponseAsync(**r.json()).with_client(self._client)
|
42
47
|
self.__dict__.update(updated.__dict__)
|
@@ -47,7 +52,9 @@ class TaskResponseAsync(TaskBase):
|
|
47
52
|
raise ValueError("Task URL not found")
|
48
53
|
if not self._client._client:
|
49
54
|
raise ValueError("Client not found")
|
50
|
-
r = await self._client._client.get(
|
55
|
+
r = await self._client._client.get(
|
56
|
+
f"{self.task_url}/cancel", headers=self._client._headers()
|
57
|
+
)
|
51
58
|
r.raise_for_status()
|
52
59
|
return await self.poll()
|
53
60
|
|
@@ -56,5 +63,7 @@ class TaskResponseAsync(TaskBase):
|
|
56
63
|
raise ValueError("Task URL not found")
|
57
64
|
if not self._client._client:
|
58
65
|
raise ValueError("Client not found")
|
59
|
-
r = await self._client._client.delete(
|
66
|
+
r = await self._client._client.delete(
|
67
|
+
self.task_url, headers=self._client._headers()
|
68
|
+
)
|
60
69
|
r.raise_for_status()
|
chunkr_ai/api/task_base.py
CHANGED
@@ -5,7 +5,8 @@ from typing import TypeVar, Optional, Generic
|
|
5
5
|
from pydantic import BaseModel, PrivateAttr
|
6
6
|
from datetime import datetime
|
7
7
|
|
8
|
-
T = TypeVar(
|
8
|
+
T = TypeVar("T", bound="TaskBase")
|
9
|
+
|
9
10
|
|
10
11
|
class TaskBase(BaseModel, ABC, Generic[T]):
|
11
12
|
configuration: Configuration
|
chunkr_ai/models.py
CHANGED
@@ -24,26 +24,25 @@ from .api.task import TaskResponse
|
|
24
24
|
from .api.task_async import TaskResponseAsync
|
25
25
|
|
26
26
|
__all__ = [
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
'TaskResponseAsync',
|
27
|
+
"BoundingBox",
|
28
|
+
"Chunk",
|
29
|
+
"ChunkProcessing",
|
30
|
+
"Configuration",
|
31
|
+
"CroppingStrategy",
|
32
|
+
"ExtractedJson",
|
33
|
+
"GenerationConfig",
|
34
|
+
"GenerationStrategy",
|
35
|
+
"JsonSchema",
|
36
|
+
"Model",
|
37
|
+
"OCRResult",
|
38
|
+
"OcrStrategy",
|
39
|
+
"OutputResponse",
|
40
|
+
"Property",
|
41
|
+
"Segment",
|
42
|
+
"SegmentProcessing",
|
43
|
+
"SegmentType",
|
44
|
+
"SegmentationStrategy",
|
45
|
+
"Status",
|
46
|
+
"TaskResponse",
|
47
|
+
"TaskResponseAsync",
|
49
48
|
]
|
@@ -0,0 +1,21 @@
|
|
1
|
+
chunkr_ai/__init__.py,sha256=q5YosvCNXPNGjV10pZY1gcvdosqUh38nVQTQA9g8EuM,110
|
2
|
+
chunkr_ai/models.py,sha256=KPcZDkRAziyke33ciEZymvCA28_QuSozoR11fXtjats,886
|
3
|
+
chunkr_ai/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
+
chunkr_ai/api/api.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
+
chunkr_ai/api/auth.py,sha256=hlv0GiUmlsbFO1wLL9sslqOnsBSoBqkL_6Mk2SDvxgE,413
|
6
|
+
chunkr_ai/api/base.py,sha256=QvHl8FInKHYKPLWDeEPpCchB1uktzOwTW7iPnyXccUc,6449
|
7
|
+
chunkr_ai/api/chunkr.py,sha256=0extAWVeZtI7B-g14smTfFZD_csdJNCcVNXx2_L69OQ,2617
|
8
|
+
chunkr_ai/api/chunkr_async.py,sha256=aa0s_tnYoujHBsfe8uLiPpVEnb2l9A3CXwPP34w9Mk8,4127
|
9
|
+
chunkr_ai/api/chunkr_base.py,sha256=k34Dyt1f21NBWZvZJ3w6Svvpg4SKnzr2ldGQ4ib96Wc,4951
|
10
|
+
chunkr_ai/api/config.py,sha256=0vbPMAYvs-tb7zIDIoSFQekz8bK0-iw3iz7BqMnHbDI,4930
|
11
|
+
chunkr_ai/api/misc.py,sha256=Dk8lWrgX-pZYcvcP2SzRhCdyBwMSSTrE8y7MzVQnScw,4878
|
12
|
+
chunkr_ai/api/protocol.py,sha256=lxIR_qoCA2a1OXjpq3LrWMdS0jRHct1bEmBlUzV8gvE,526
|
13
|
+
chunkr_ai/api/schema.py,sha256=yYesvueGgtmRa7Fi_Tpdv8A2bzHlx-B-5DxRAPlaDHo,4926
|
14
|
+
chunkr_ai/api/task.py,sha256=28J4dR8BDjvtkh3CQjW_YUEkgPXhCHBGu0wH6AQKKuE,2474
|
15
|
+
chunkr_ai/api/task_async.py,sha256=K5hTEOnmD42snPZg_JtJsVWg6QBUFZ1aBz1Abwv58-A,2529
|
16
|
+
chunkr_ai/api/task_base.py,sha256=esEawvntjzfaPnV78KW2IbIFqI74-eJV_g70BVIubbY,2329
|
17
|
+
chunkr_ai-0.0.15.dist-info/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
18
|
+
chunkr_ai-0.0.15.dist-info/METADATA,sha256=097bhYg2V6cuxLkiVmiSTNuGzlBvGFV1Hw2bFWxBYKc,4839
|
19
|
+
chunkr_ai-0.0.15.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
20
|
+
chunkr_ai-0.0.15.dist-info/top_level.txt,sha256=0IZY7PZIiS8bw5r4NUQRUQ-ATi-L_3vLQVq3ZLouOW8,10
|
21
|
+
chunkr_ai-0.0.15.dist-info/RECORD,,
|
@@ -1,21 +0,0 @@
|
|
1
|
-
chunkr_ai/__init__.py,sha256=eXygrEhGxxIHXNYIlHF2eied8rGsx2RphgR8Wo4lRyo,110
|
2
|
-
chunkr_ai/models.py,sha256=-dbwtTHTcGhH3LXUdVUPkobbPoeFNXRizeAW8BCGSkE,903
|
3
|
-
chunkr_ai/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
-
chunkr_ai/api/api.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
-
chunkr_ai/api/auth.py,sha256=iSd5Jek2BFaHGw9HY-RrqgwP56BHFU0xbSuJS4fU6AA,425
|
6
|
-
chunkr_ai/api/base.py,sha256=WDHx8tU0fl9_-yvYTKL-U0uaxHv-8_bRfiw9Xkl-mWM,6499
|
7
|
-
chunkr_ai/api/chunkr.py,sha256=A1KEjA4zRJkGZhYwhWde4CFncrljEMky4SO4LPzYvws,2652
|
8
|
-
chunkr_ai/api/chunkr_async.py,sha256=OvXd9Ma3rsp6q8nJsWzNgTKAGk-py93DqAENE8fMQfc,4153
|
9
|
-
chunkr_ai/api/chunkr_base.py,sha256=run4UJVKa7Gx8I_ME0Mol-c_b-NIcexNkgxHu_hbX5M,4996
|
10
|
-
chunkr_ai/api/config.py,sha256=joTn7jiOlJXTwwza-jHauLV-39CMzaxZVGB9JBm8Cok,4862
|
11
|
-
chunkr_ai/api/misc.py,sha256=9vnfrbJ7sFlZqwEIQ4NTMb5rhPOmETT7e1jR-b42PXM,4977
|
12
|
-
chunkr_ai/api/protocol.py,sha256=li-zy7Z-ChR9kZqJlixQv1kUYrmesPHxwUtnE5p16tQ,529
|
13
|
-
chunkr_ai/api/schema.py,sha256=OeLOhBRXeRBgEImg0Q6O9Z10ojT6aSEVvwnDR8UeENo,4971
|
14
|
-
chunkr_ai/api/task.py,sha256=j-Odecnbj3NjAGDyUNmZHgqsRDYhHs3xBWgsT2rrHjs,2517
|
15
|
-
chunkr_ai/api/task_async.py,sha256=HpuVW928s-V3jjPa8L5i86lvKcpKbMhkCuV1nKSyXVA,2437
|
16
|
-
chunkr_ai/api/task_base.py,sha256=9S8UCsrEOAH48PmOpLlyAifKDrtaUtrBMUmMZq4Dceg,2328
|
17
|
-
chunkr_ai-0.0.14.dist-info/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
18
|
-
chunkr_ai-0.0.14.dist-info/METADATA,sha256=1reEDprWgXg6bKCGKv6LXJxZZR-dQeJn9DeXGbp4Iwk,4839
|
19
|
-
chunkr_ai-0.0.14.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
20
|
-
chunkr_ai-0.0.14.dist-info/top_level.txt,sha256=0IZY7PZIiS8bw5r4NUQRUQ-ATi-L_3vLQVq3ZLouOW8,10
|
21
|
-
chunkr_ai-0.0.14.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|