chunkr-ai 0.0.25__py3-none-any.whl → 0.0.26__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.
@@ -2,6 +2,7 @@ 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
5
6
 
6
7
  from .configuration import Configuration, OutputConfiguration, OutputResponse, Status
7
8
  from .protocol import ChunkrClientProtocol
@@ -101,17 +102,59 @@ class TaskResponse(BaseModel, Generic[T]):
101
102
  r.raise_for_status()
102
103
  return await self.poll()
103
104
 
104
- def html(self) -> str:
105
- """Get the full HTML of the task"""
106
- return self._get_content("html")
105
+ def html(self, output_file: str = None) -> str:
106
+ """Get the full HTML of the task
107
+
108
+ Args:
109
+ output_file (str, optional): Path to save the HTML content. Defaults to None.
110
+ """
111
+ content = self._get_content("html")
112
+ if output_file:
113
+ with open(output_file, "w", encoding="utf-8") as f:
114
+ f.write(content)
115
+ return content
107
116
 
108
- def markdown(self) -> str:
109
- """Get the full markdown of the task"""
110
- return self._get_content("markdown")
117
+ def markdown(self, output_file: str = None) -> str:
118
+ """Get the full markdown of the task
119
+
120
+ Args:
121
+ output_file (str, optional): Path to save the markdown content. Defaults to None.
122
+ """
123
+ content = self._get_content("markdown")
124
+ if output_file:
125
+ with open(output_file, "w", encoding="utf-8") as f:
126
+ f.write(content)
127
+ return content
111
128
 
112
- def content(self) -> str:
113
- """Get the full content of the task"""
114
- return self._get_content("content")
129
+ def content(self, output_file: str = None) -> str:
130
+ """Get the full content of the task
131
+
132
+ Args:
133
+ output_file (str, optional): Path to save the content. Defaults to None.
134
+ """
135
+ content = self._get_content("content")
136
+ if output_file:
137
+ with open(output_file, "w", encoding="utf-8") as f:
138
+ f.write(content)
139
+ return content
140
+
141
+ def json(self, output_file: str = None) -> dict:
142
+ """Get the full task data as JSON
143
+
144
+ Args:
145
+ output_file (str, optional): Path to save the task data as JSON. Defaults to None.
146
+ """
147
+ class DateTimeEncoder(json.JSONEncoder):
148
+ def default(self, obj):
149
+ if isinstance(obj, datetime):
150
+ return obj.isoformat()
151
+ return super().default(obj)
152
+
153
+ data = self.model_dump()
154
+ if output_file:
155
+ with open(output_file, "w", encoding="utf-8") as f:
156
+ json.dump(data, f, cls=DateTimeEncoder, indent=2)
157
+ return data
115
158
 
116
159
  def _get_content(self, t: str) -> str:
117
160
  if not self.output:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: chunkr-ai
3
- Version: 0.0.25
3
+ Version: 0.0.26
4
4
  Summary: Python client for Chunkr: open source document intelligence
5
5
  Author-email: Ishaan Kapoor <ishaan@lumina.sh>
6
6
  License: MIT License
@@ -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=CZIa3w5qPvSZDbDJ-LAtg7OOY91LsruemaXNyO2PymI,4256
12
- chunkr_ai-0.0.25.dist-info/LICENSE,sha256=w3R12yNDyZpMiy2lxy_hvNbsldC75ww79sF0u11rkho,1069
13
- chunkr_ai-0.0.25.dist-info/METADATA,sha256=CG1cO9YX7TpAHwBXgqLDgF9nwmVv30WLsWzfULx06W4,6996
14
- chunkr_ai-0.0.25.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
15
- chunkr_ai-0.0.25.dist-info/top_level.txt,sha256=0IZY7PZIiS8bw5r4NUQRUQ-ATi-L_3vLQVq3ZLouOW8,10
16
- chunkr_ai-0.0.25.dist-info/RECORD,,
11
+ chunkr_ai/api/task_response.py,sha256=lYzR3Oa6HwLmW5Plo5AF4Ky3UMXHU9zcUMRYOHb7Gwg,5805
12
+ chunkr_ai-0.0.26.dist-info/LICENSE,sha256=w3R12yNDyZpMiy2lxy_hvNbsldC75ww79sF0u11rkho,1069
13
+ chunkr_ai-0.0.26.dist-info/METADATA,sha256=LcIn-LIE_RsPawnkh26NyU2EGicKOQ1Qf1KsAu0dPuw,6996
14
+ chunkr_ai-0.0.26.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
15
+ chunkr_ai-0.0.26.dist-info/top_level.txt,sha256=0IZY7PZIiS8bw5r4NUQRUQ-ATi-L_3vLQVq3ZLouOW8,10
16
+ chunkr_ai-0.0.26.dist-info/RECORD,,