chunkr-ai 0.0.25__py3-none-any.whl → 0.0.27__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/api/task_response.py +57 -9
- {chunkr_ai-0.0.25.dist-info → chunkr_ai-0.0.27.dist-info}/METADATA +1 -1
- {chunkr_ai-0.0.25.dist-info → chunkr_ai-0.0.27.dist-info}/RECORD +6 -6
- {chunkr_ai-0.0.25.dist-info → chunkr_ai-0.0.27.dist-info}/LICENSE +0 -0
- {chunkr_ai-0.0.25.dist-info → chunkr_ai-0.0.27.dist-info}/WHEEL +0 -0
- {chunkr_ai-0.0.25.dist-info → chunkr_ai-0.0.27.dist-info}/top_level.txt +0 -0
chunkr_ai/api/task_response.py
CHANGED
@@ -2,6 +2,8 @@ from datetime import datetime
|
|
2
2
|
from typing import TypeVar, Optional, Generic
|
3
3
|
from pydantic import BaseModel, PrivateAttr
|
4
4
|
import asyncio
|
5
|
+
import json
|
6
|
+
import os
|
5
7
|
|
6
8
|
from .configuration import Configuration, OutputConfiguration, OutputResponse, Status
|
7
9
|
from .protocol import ChunkrClientProtocol
|
@@ -101,17 +103,63 @@ class TaskResponse(BaseModel, Generic[T]):
|
|
101
103
|
r.raise_for_status()
|
102
104
|
return await self.poll()
|
103
105
|
|
104
|
-
def html(self) -> str:
|
105
|
-
"""Get the full HTML of the task
|
106
|
-
|
106
|
+
def html(self, output_file: str = None) -> str:
|
107
|
+
"""Get the full HTML of the task
|
108
|
+
|
109
|
+
Args:
|
110
|
+
output_file (str, optional): Path to save the HTML content. Defaults to None.
|
111
|
+
"""
|
112
|
+
content = self._get_content("html")
|
113
|
+
if output_file:
|
114
|
+
os.makedirs(os.path.dirname(output_file), exist_ok=True)
|
115
|
+
with open(output_file, "w", encoding="utf-8") as f:
|
116
|
+
f.write(content)
|
117
|
+
return content
|
107
118
|
|
108
|
-
def markdown(self) -> str:
|
109
|
-
"""Get the full markdown of the task
|
110
|
-
|
119
|
+
def markdown(self, output_file: str = None) -> str:
|
120
|
+
"""Get the full markdown of the task
|
121
|
+
|
122
|
+
Args:
|
123
|
+
output_file (str, optional): Path to save the markdown content. Defaults to None.
|
124
|
+
"""
|
125
|
+
content = self._get_content("markdown")
|
126
|
+
if output_file:
|
127
|
+
os.makedirs(os.path.dirname(output_file), exist_ok=True)
|
128
|
+
with open(output_file, "w", encoding="utf-8") as f:
|
129
|
+
f.write(content)
|
130
|
+
return content
|
111
131
|
|
112
|
-
def content(self) -> str:
|
113
|
-
"""Get the full content of the task
|
114
|
-
|
132
|
+
def content(self, output_file: str = None) -> str:
|
133
|
+
"""Get the full content of the task
|
134
|
+
|
135
|
+
Args:
|
136
|
+
output_file (str, optional): Path to save the content. Defaults to None.
|
137
|
+
"""
|
138
|
+
content = self._get_content("content")
|
139
|
+
if output_file:
|
140
|
+
os.makedirs(os.path.dirname(output_file), exist_ok=True)
|
141
|
+
with open(output_file, "w", encoding="utf-8") as f:
|
142
|
+
f.write(content)
|
143
|
+
return content
|
144
|
+
|
145
|
+
def json(self, output_file: str = None) -> dict:
|
146
|
+
"""Get the full task data as JSON
|
147
|
+
|
148
|
+
Args:
|
149
|
+
output_file (str, optional): Path to save the task data as JSON. Defaults to None.
|
150
|
+
"""
|
151
|
+
class DateTimeEncoder(json.JSONEncoder):
|
152
|
+
def default(self, obj):
|
153
|
+
if isinstance(obj, datetime):
|
154
|
+
return obj.isoformat()
|
155
|
+
return super().default(obj)
|
156
|
+
|
157
|
+
data = self.model_dump()
|
158
|
+
if output_file:
|
159
|
+
os.makedirs(os.path.dirname(output_file), exist_ok=True)
|
160
|
+
with open(output_file, "w", encoding="utf-8") as f:
|
161
|
+
json.dump(data, f, cls=DateTimeEncoder, indent=2)
|
162
|
+
return data
|
115
163
|
|
116
164
|
def _get_content(self, t: str) -> str:
|
117
165
|
if not self.output:
|
@@ -8,9 +8,9 @@ chunkr_ai/api/configuration.py,sha256=0wnrKlUIO7opvV963Gr_S8tlAjpo_IkNmbTi1_FwEu
|
|
8
8
|
chunkr_ai/api/decorators.py,sha256=HSq3vcxOeUJkaWaf7HOvCyg9dWkVo8cG5BrU-jhbhmc,4053
|
9
9
|
chunkr_ai/api/misc.py,sha256=5PBI6pvOXr0x-3WieSKLrC8MA0iGPa-IG-5FEZ3vnr0,5724
|
10
10
|
chunkr_ai/api/protocol.py,sha256=LjPrYSq52m1afIlAo0yVGXlGZxPRh8J6g7S4PAit3Zo,388
|
11
|
-
chunkr_ai/api/task_response.py,sha256=
|
12
|
-
chunkr_ai-0.0.
|
13
|
-
chunkr_ai-0.0.
|
14
|
-
chunkr_ai-0.0.
|
15
|
-
chunkr_ai-0.0.
|
16
|
-
chunkr_ai-0.0.
|
11
|
+
chunkr_ai/api/task_response.py,sha256=uvM5uNIImDnivsgujjOh2kxRYuUoqKDhLE1nOH2dJjo,6091
|
12
|
+
chunkr_ai-0.0.27.dist-info/LICENSE,sha256=w3R12yNDyZpMiy2lxy_hvNbsldC75ww79sF0u11rkho,1069
|
13
|
+
chunkr_ai-0.0.27.dist-info/METADATA,sha256=JveCsruUSPzQmP7EwO6LwcilW8rH9XMR0X1jhszxVsY,6996
|
14
|
+
chunkr_ai-0.0.27.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
15
|
+
chunkr_ai-0.0.27.dist-info/top_level.txt,sha256=0IZY7PZIiS8bw5r4NUQRUQ-ATi-L_3vLQVq3ZLouOW8,10
|
16
|
+
chunkr_ai-0.0.27.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|