chunkr-ai 0.0.14__py3-none-any.whl → 0.0.16__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/__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 +41 -14
- chunkr_ai/api/misc.py +52 -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 +4 -1
- chunkr_ai/models.py +23 -22
- {chunkr_ai-0.0.14.dist-info → chunkr_ai-0.0.16.dist-info}/METADATA +1 -1
- chunkr_ai-0.0.16.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.16.dist-info}/LICENSE +0 -0
- {chunkr_ai-0.0.14.dist-info → chunkr_ai-0.0.16.dist-info}/WHEEL +0 -0
- {chunkr_ai-0.0.14.dist-info → chunkr_ai-0.0.16.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,7 @@ 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
|
class TaskBase(BaseModel, ABC, Generic[T]):
|
11
11
|
configuration: Configuration
|
@@ -62,12 +62,15 @@ class TaskBase(BaseModel, ABC, Generic[T]):
|
|
62
62
|
return None
|
63
63
|
|
64
64
|
def html(self) -> str:
|
65
|
+
"""Get the full HTML of the task"""
|
65
66
|
return self._get_content("html")
|
66
67
|
|
67
68
|
def markdown(self) -> str:
|
69
|
+
"""Get the full markdown of the task"""
|
68
70
|
return self._get_content("markdown")
|
69
71
|
|
70
72
|
def content(self) -> str:
|
73
|
+
"""Get the full content of the task"""
|
71
74
|
return self._get_content("content")
|
72
75
|
|
73
76
|
def _get_content(self, t: str) -> str:
|
chunkr_ai/models.py
CHANGED
@@ -18,32 +18,33 @@ from .api.config import (
|
|
18
18
|
SegmentType,
|
19
19
|
SegmentationStrategy,
|
20
20
|
Status,
|
21
|
+
PipelineType,
|
21
22
|
)
|
22
23
|
|
23
24
|
from .api.task import TaskResponse
|
24
25
|
from .api.task_async import TaskResponseAsync
|
25
26
|
|
26
27
|
__all__ = [
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
28
|
+
"BoundingBox",
|
29
|
+
"Chunk",
|
30
|
+
"ChunkProcessing",
|
31
|
+
"Configuration",
|
32
|
+
"CroppingStrategy",
|
33
|
+
"ExtractedJson",
|
34
|
+
"GenerationConfig",
|
35
|
+
"GenerationStrategy",
|
36
|
+
"JsonSchema",
|
37
|
+
"Model",
|
38
|
+
"OCRResult",
|
39
|
+
"OcrStrategy",
|
40
|
+
"OutputResponse",
|
41
|
+
"Property",
|
42
|
+
"Segment",
|
43
|
+
"SegmentProcessing",
|
44
|
+
"SegmentType",
|
45
|
+
"SegmentationStrategy",
|
46
|
+
"Status",
|
47
|
+
"TaskResponse",
|
48
|
+
"TaskResponseAsync",
|
49
|
+
"PipelineType",
|
49
50
|
]
|
@@ -0,0 +1,21 @@
|
|
1
|
+
chunkr_ai/__init__.py,sha256=q5YosvCNXPNGjV10pZY1gcvdosqUh38nVQTQA9g8EuM,110
|
2
|
+
chunkr_ai/models.py,sha256=iy8bqswbiNf-rCwmDnAF2jkZT7apOpxIxUMX3fWiE7k,924
|
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=TWl0Az6acKQCS1LIpKD4qr_lQ_63wqQ5M6calpLOlDM,5040
|
11
|
+
chunkr_ai/api/misc.py,sha256=bQpURc7soT5GL2ZpY7EiYyvPYWEzDM9qaX-UHa-oFeI,4909
|
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=KLiMhvvbCgcilguQKrtEPMlNs8oaatfQUtn8pYt9t6g,2467
|
17
|
+
chunkr_ai-0.0.16.dist-info/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
18
|
+
chunkr_ai-0.0.16.dist-info/METADATA,sha256=ZZnNe88CL56fIw5-3UouYX0I10N9D7NXGzoBQmtd-oE,4839
|
19
|
+
chunkr_ai-0.0.16.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
20
|
+
chunkr_ai-0.0.16.dist-info/top_level.txt,sha256=0IZY7PZIiS8bw5r4NUQRUQ-ATi-L_3vLQVq3ZLouOW8,10
|
21
|
+
chunkr_ai-0.0.16.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
|