retab 0.0.35__py3-none-any.whl → 0.0.37__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.
Files changed (134) hide show
  1. {uiform → retab}/_utils/ai_models.py +2 -2
  2. {uiform → retab}/_utils/benchmarking.py +15 -16
  3. {uiform → retab}/_utils/chat.py +9 -14
  4. {uiform → retab}/_utils/display.py +0 -3
  5. {uiform → retab}/_utils/json_schema.py +9 -14
  6. {uiform → retab}/_utils/mime.py +11 -14
  7. {uiform → retab}/_utils/responses.py +9 -3
  8. {uiform → retab}/_utils/stream_context_managers.py +1 -1
  9. {uiform → retab}/_utils/usage/usage.py +28 -28
  10. {uiform → retab}/client.py +32 -31
  11. {uiform → retab}/resources/consensus/client.py +17 -36
  12. {uiform → retab}/resources/consensus/completions.py +24 -47
  13. {uiform → retab}/resources/consensus/completions_stream.py +26 -38
  14. {uiform → retab}/resources/consensus/responses.py +31 -80
  15. {uiform → retab}/resources/consensus/responses_stream.py +31 -79
  16. {uiform → retab}/resources/documents/client.py +59 -45
  17. {uiform → retab}/resources/documents/extractions.py +181 -90
  18. {uiform → retab}/resources/evals.py +56 -43
  19. retab/resources/evaluations/__init__.py +3 -0
  20. retab/resources/evaluations/client.py +301 -0
  21. retab/resources/evaluations/documents.py +233 -0
  22. retab/resources/evaluations/iterations.py +452 -0
  23. {uiform → retab}/resources/files.py +2 -2
  24. {uiform → retab}/resources/jsonlUtils.py +220 -216
  25. retab/resources/models.py +73 -0
  26. retab/resources/processors/automations/client.py +244 -0
  27. {uiform → retab}/resources/processors/automations/endpoints.py +77 -118
  28. retab/resources/processors/automations/links.py +294 -0
  29. {uiform → retab}/resources/processors/automations/logs.py +30 -19
  30. {uiform → retab}/resources/processors/automations/mailboxes.py +136 -174
  31. retab/resources/processors/automations/outlook.py +337 -0
  32. {uiform → retab}/resources/processors/automations/tests.py +22 -25
  33. {uiform → retab}/resources/processors/client.py +179 -164
  34. {uiform → retab}/resources/schemas.py +78 -66
  35. {uiform → retab}/resources/secrets/external_api_keys.py +1 -5
  36. retab/resources/secrets/webhook.py +64 -0
  37. {uiform → retab}/resources/usage.py +39 -2
  38. {uiform → retab}/types/ai_models.py +13 -13
  39. {uiform → retab}/types/automations/cron.py +19 -12
  40. {uiform → retab}/types/automations/endpoints.py +7 -4
  41. {uiform → retab}/types/automations/links.py +7 -3
  42. {uiform → retab}/types/automations/mailboxes.py +9 -9
  43. {uiform → retab}/types/automations/outlook.py +15 -11
  44. retab/types/browser_canvas.py +3 -0
  45. {uiform → retab}/types/chat.py +2 -2
  46. {uiform → retab}/types/completions.py +9 -12
  47. retab/types/consensus.py +19 -0
  48. {uiform → retab}/types/db/annotations.py +3 -3
  49. {uiform → retab}/types/db/files.py +8 -6
  50. {uiform → retab}/types/documents/create_messages.py +18 -20
  51. {uiform → retab}/types/documents/extractions.py +69 -24
  52. {uiform → retab}/types/evals.py +5 -5
  53. retab/types/evaluations/__init__.py +31 -0
  54. retab/types/evaluations/documents.py +30 -0
  55. retab/types/evaluations/iterations.py +112 -0
  56. retab/types/evaluations/model.py +73 -0
  57. retab/types/events.py +79 -0
  58. {uiform → retab}/types/extractions.py +33 -10
  59. retab/types/inference_settings.py +15 -0
  60. retab/types/jobs/base.py +54 -0
  61. retab/types/jobs/batch_annotation.py +12 -0
  62. {uiform → retab}/types/jobs/evaluation.py +1 -2
  63. {uiform → retab}/types/logs.py +37 -34
  64. retab/types/metrics.py +32 -0
  65. {uiform → retab}/types/mime.py +22 -20
  66. {uiform → retab}/types/modalities.py +10 -10
  67. retab/types/predictions.py +19 -0
  68. {uiform → retab}/types/schemas/enhance.py +4 -2
  69. {uiform → retab}/types/schemas/evaluate.py +7 -4
  70. {uiform → retab}/types/schemas/generate.py +6 -3
  71. {uiform → retab}/types/schemas/layout.py +1 -1
  72. {uiform → retab}/types/schemas/object.py +13 -14
  73. {uiform → retab}/types/schemas/templates.py +1 -3
  74. {uiform → retab}/types/secrets/external_api_keys.py +0 -1
  75. {uiform → retab}/types/standards.py +18 -1
  76. {retab-0.0.35.dist-info → retab-0.0.37.dist-info}/METADATA +7 -6
  77. retab-0.0.37.dist-info/RECORD +107 -0
  78. retab-0.0.37.dist-info/top_level.txt +1 -0
  79. retab-0.0.35.dist-info/RECORD +0 -111
  80. retab-0.0.35.dist-info/top_level.txt +0 -1
  81. uiform/_utils/benchmarking copy.py +0 -588
  82. uiform/resources/deployments/__init__.py +0 -9
  83. uiform/resources/deployments/client.py +0 -78
  84. uiform/resources/deployments/endpoints.py +0 -322
  85. uiform/resources/deployments/links.py +0 -452
  86. uiform/resources/deployments/logs.py +0 -211
  87. uiform/resources/deployments/mailboxes.py +0 -496
  88. uiform/resources/deployments/outlook.py +0 -531
  89. uiform/resources/deployments/tests.py +0 -158
  90. uiform/resources/models.py +0 -45
  91. uiform/resources/processors/automations/client.py +0 -78
  92. uiform/resources/processors/automations/links.py +0 -356
  93. uiform/resources/processors/automations/outlook.py +0 -444
  94. uiform/resources/secrets/webhook.py +0 -62
  95. uiform/types/consensus.py +0 -10
  96. uiform/types/deployments/cron.py +0 -59
  97. uiform/types/deployments/endpoints.py +0 -28
  98. uiform/types/deployments/links.py +0 -36
  99. uiform/types/deployments/mailboxes.py +0 -67
  100. uiform/types/deployments/outlook.py +0 -76
  101. uiform/types/deployments/webhooks.py +0 -21
  102. uiform/types/events.py +0 -76
  103. uiform/types/jobs/base.py +0 -150
  104. uiform/types/jobs/batch_annotation.py +0 -22
  105. uiform/types/secrets/__init__.py +0 -0
  106. {uiform → retab}/__init__.py +0 -0
  107. {uiform → retab}/_resource.py +0 -0
  108. {uiform → retab}/_utils/__init__.py +0 -0
  109. {uiform → retab}/_utils/usage/__init__.py +0 -0
  110. {uiform → retab}/py.typed +0 -0
  111. {uiform → retab}/resources/__init__.py +0 -0
  112. {uiform → retab}/resources/consensus/__init__.py +0 -0
  113. {uiform → retab}/resources/documents/__init__.py +0 -0
  114. {uiform → retab}/resources/finetuning.py +0 -0
  115. {uiform → retab}/resources/openai_example.py +0 -0
  116. {uiform → retab}/resources/processors/__init__.py +0 -0
  117. {uiform → retab}/resources/processors/automations/__init__.py +0 -0
  118. {uiform → retab}/resources/prompt_optimization.py +0 -0
  119. {uiform → retab}/resources/secrets/__init__.py +0 -0
  120. {uiform → retab}/resources/secrets/client.py +0 -0
  121. {uiform → retab}/types/__init__.py +0 -0
  122. {uiform → retab}/types/automations/__init__.py +0 -0
  123. {uiform → retab}/types/automations/webhooks.py +0 -0
  124. {uiform → retab}/types/db/__init__.py +0 -0
  125. {uiform/types/deployments → retab/types/documents}/__init__.py +0 -0
  126. {uiform → retab}/types/documents/correct_orientation.py +0 -0
  127. {uiform/types/documents → retab/types/jobs}/__init__.py +0 -0
  128. {uiform → retab}/types/jobs/finetune.py +0 -0
  129. {uiform → retab}/types/jobs/prompt_optimization.py +0 -0
  130. {uiform → retab}/types/jobs/webcrawl.py +0 -0
  131. {uiform → retab}/types/pagination.py +0 -0
  132. {uiform/types/jobs → retab/types/schemas}/__init__.py +0 -0
  133. {uiform/types/schemas → retab/types/secrets}/__init__.py +0 -0
  134. {retab-0.0.35.dist-info → retab-0.0.37.dist-info}/WHEEL +0 -0
@@ -0,0 +1,452 @@
1
+ from typing import Any, Dict, List, Optional
2
+
3
+ from openai.types.chat.chat_completion_reasoning_effort import ChatCompletionReasoningEffort
4
+
5
+ from ..._resource import AsyncAPIResource, SyncAPIResource
6
+ from ...types.browser_canvas import BrowserCanvas
7
+ from ...types.evaluations import CreateIterationRequest, Iteration, ProcessIterationRequest, IterationDocumentStatusResponse, PatchIterationRequest
8
+ from ...types.inference_settings import InferenceSettings
9
+ from ...types.metrics import DistancesResult
10
+ from ...types.modalities import Modality
11
+ from ...types.standards import DeleteResponse, PreparedRequest, FieldUnset
12
+ from ...types.documents.extractions import UiParsedChatCompletion
13
+
14
+
15
+ class IterationsMixin:
16
+ def prepare_get(self, evaluation_id: str, iteration_id: str) -> PreparedRequest:
17
+ return PreparedRequest(method="GET", url=f"/v1/evaluations/{evaluation_id}/iterations/{iteration_id}")
18
+
19
+ def prepare_list(self, evaluation_id: str, model: Optional[str] = None) -> PreparedRequest:
20
+ params = {}
21
+ if model:
22
+ params["model"] = model
23
+ return PreparedRequest(method="GET", url=f"/v1/evaluations/{evaluation_id}/iterations", params=params)
24
+
25
+ def prepare_create(
26
+ self,
27
+ evaluation_id: str,
28
+ model: str = FieldUnset,
29
+ json_schema: Optional[Dict[str, Any]] = None,
30
+ temperature: float = FieldUnset,
31
+ modality: Modality = FieldUnset,
32
+ reasoning_effort: ChatCompletionReasoningEffort = FieldUnset,
33
+ image_resolution_dpi: int = FieldUnset,
34
+ browser_canvas: BrowserCanvas = FieldUnset,
35
+ n_consensus: int = FieldUnset,
36
+ ) -> PreparedRequest:
37
+ inference_settings = InferenceSettings(
38
+ model=model,
39
+ temperature=temperature,
40
+ modality=modality,
41
+ reasoning_effort=reasoning_effort,
42
+ image_resolution_dpi=image_resolution_dpi,
43
+ browser_canvas=browser_canvas,
44
+ n_consensus=n_consensus,
45
+ )
46
+
47
+ request = CreateIterationRequest(inference_settings=inference_settings, json_schema=json_schema)
48
+
49
+ return PreparedRequest(method="POST", url=f"/v1/evaluations/{evaluation_id}/iterations", data=request.model_dump(exclude_unset=True, exclude_defaults=True, mode="json"))
50
+
51
+ def prepare_update(
52
+ self,
53
+ evaluation_id: str,
54
+ iteration_id: str,
55
+ json_schema: Dict[str, Any] = FieldUnset,
56
+ model: str = FieldUnset,
57
+ temperature: float = FieldUnset,
58
+ modality: Modality = FieldUnset,
59
+ reasoning_effort: ChatCompletionReasoningEffort = FieldUnset,
60
+ image_resolution_dpi: int = FieldUnset,
61
+ browser_canvas: BrowserCanvas = FieldUnset,
62
+ n_consensus: int = FieldUnset,
63
+ ) -> PreparedRequest:
64
+ inference_settings = InferenceSettings(
65
+ model=model,
66
+ temperature=temperature,
67
+ modality=modality,
68
+ reasoning_effort=reasoning_effort,
69
+ image_resolution_dpi=image_resolution_dpi,
70
+ browser_canvas=browser_canvas,
71
+ n_consensus=n_consensus,
72
+ )
73
+ if not inference_settings.model_dump(exclude_unset=True, mode="json"):
74
+ inference_settings = FieldUnset
75
+
76
+ iteration_data = PatchIterationRequest(json_schema=json_schema, inference_settings=inference_settings)
77
+
78
+ return PreparedRequest(
79
+ method="PATCH", url=f"/v1/evaluations/{evaluation_id}/iterations/{iteration_id}", data=iteration_data.model_dump(exclude_unset=True, exclude_defaults=True, mode="json")
80
+ )
81
+
82
+ def prepare_delete(self, evaluation_id: str, iteration_id: str) -> PreparedRequest:
83
+ return PreparedRequest(method="DELETE", url=f"/v1/evaluations/{evaluation_id}/iterations/{iteration_id}")
84
+
85
+ def prepare_compute_distances(self, evaluation_id: str, iteration_id: str, document_id: str) -> PreparedRequest:
86
+ return PreparedRequest(method="GET", url=f"/v1/evaluations/{evaluation_id}/iterations/{iteration_id}/documents/{document_id}/distances")
87
+
88
+ def prepare_process(
89
+ self,
90
+ evaluation_id: str,
91
+ iteration_id: str,
92
+ document_ids: Optional[List[str]] = None,
93
+ only_outdated: bool = True,
94
+ ) -> PreparedRequest:
95
+ request = ProcessIterationRequest(
96
+ document_ids=document_ids,
97
+ only_outdated=only_outdated,
98
+ )
99
+ return PreparedRequest(method="POST", url=f"/v1/evaluations/{evaluation_id}/iterations/{iteration_id}/process", data=request.model_dump(exclude_none=True, mode="json"))
100
+
101
+ def prepare_process_document(self, evaluation_id: str, iteration_id: str, document_id: str) -> PreparedRequest:
102
+ return PreparedRequest(method="POST", url=f"/v1/evaluations/{evaluation_id}/iterations/{iteration_id}/documents/{document_id}/process", data={"stream": False})
103
+
104
+ def prepare_status(self, evaluation_id: str, iteration_id: str) -> PreparedRequest:
105
+ return PreparedRequest(method="GET", url=f"/v1/evaluations/{evaluation_id}/iterations/{iteration_id}/status")
106
+
107
+
108
+ class Iterations(SyncAPIResource, IterationsMixin):
109
+ """Iterations API wrapper for evaluations"""
110
+
111
+ def __init__(self, *args, **kwargs):
112
+ super().__init__(*args, **kwargs)
113
+
114
+ def get(self, evaluation_id: str, iteration_id: str) -> Iteration:
115
+ request = self.prepare_get(evaluation_id, iteration_id)
116
+ response = self._client._prepared_request(request)
117
+ return Iteration(**response)
118
+
119
+ def list(self, evaluation_id: str, model: Optional[str] = None) -> List[Iteration]:
120
+ """
121
+ List iterations for an evaluation.
122
+
123
+ Args:
124
+ evaluation_id: The ID of the evaluation
125
+ model: Optional model to filter by
126
+
127
+ Returns:
128
+ List[Iteration]: List of iterations
129
+ Raises:
130
+ HTTPException if the request fails
131
+ """
132
+ request = self.prepare_list(evaluation_id, model)
133
+ response = self._client._prepared_request(request)
134
+ return [Iteration(**item) for item in response.get("data", [])]
135
+
136
+ def create(
137
+ self,
138
+ evaluation_id: str,
139
+ model: str,
140
+ temperature: float = 0.0,
141
+ modality: Modality = "native",
142
+ json_schema: Optional[Dict[str, Any]] = None,
143
+ reasoning_effort: ChatCompletionReasoningEffort = "medium",
144
+ image_resolution_dpi: int = 96,
145
+ browser_canvas: BrowserCanvas = "A4",
146
+ n_consensus: int = 1,
147
+ ) -> Iteration:
148
+ """
149
+ Create a new iteration for an evaluation.
150
+
151
+ Args:
152
+ evaluation_id: The ID of the evaluation
153
+ json_schema: The JSON schema for the iteration (if not set, we use the one of the eval)
154
+ model: The model to use for the iteration
155
+ temperature: The temperature to use for the model
156
+ modality: The modality to use (text, image, etc.)
157
+ reasoning_effort: The reasoning effort setting for the model (auto, low, medium, high)
158
+ image_resolution_dpi: The DPI of the image. Defaults to 96.
159
+ browser_canvas: The canvas size of the browser. Must be one of:
160
+ - "A3" (11.7in x 16.54in)
161
+ - "A4" (8.27in x 11.7in)
162
+ - "A5" (5.83in x 8.27in)
163
+ Defaults to "A4".
164
+ n_consensus: Number of consensus iterations to perform
165
+
166
+ Returns:
167
+ Iteration: The created iteration
168
+ Raises:
169
+ HTTPException if the request fails
170
+ """
171
+ request = self.prepare_create(
172
+ evaluation_id=evaluation_id,
173
+ json_schema=json_schema,
174
+ model=model,
175
+ temperature=temperature,
176
+ modality=modality,
177
+ reasoning_effort=reasoning_effort,
178
+ image_resolution_dpi=image_resolution_dpi,
179
+ browser_canvas=browser_canvas,
180
+ n_consensus=n_consensus,
181
+ )
182
+ response = self._client._prepared_request(request)
183
+ return Iteration(**response)
184
+
185
+ def delete(self, evaluation_id: str, iteration_id: str) -> DeleteResponse:
186
+ """
187
+ Delete an iteration.
188
+
189
+ Args:
190
+ iteration_id: The ID of the iteration
191
+
192
+ Returns:
193
+ DeleteResponse: The response containing success status and ID
194
+ Raises:
195
+ HTTPException if the request fails
196
+ """
197
+ request = self.prepare_delete(evaluation_id, iteration_id)
198
+ return self._client._prepared_request(request)
199
+
200
+ def compute_distances(self, evaluation_id: str, iteration_id: str, document_id: str) -> DistancesResult:
201
+ """
202
+ Get distances for a document in an iteration.
203
+
204
+ Args:
205
+ iteration_id: The ID of the iteration
206
+ document_id: The ID of the document
207
+
208
+ Returns:
209
+ DistancesResult: The distances
210
+ Raises:
211
+ HTTPException if the request fails
212
+ """
213
+ request = self.prepare_compute_distances(evaluation_id, iteration_id, document_id)
214
+ response = self._client._prepared_request(request)
215
+ return DistancesResult(**response)
216
+
217
+ def process(
218
+ self,
219
+ evaluation_id: str,
220
+ iteration_id: str,
221
+ document_ids: Optional[List[str]] = None,
222
+ only_outdated: bool = True,
223
+ ) -> Iteration:
224
+ """
225
+ Process an iteration by running extractions on documents.
226
+
227
+ Args:
228
+ iteration_id: The ID of the iteration
229
+ document_ids: Optional list of specific document IDs to process
230
+ only_outdated: Whether to only process documents that need updates
231
+
232
+ Returns:
233
+ Iteration: The updated iteration
234
+ Raises:
235
+ HTTPException if the request fails
236
+ """
237
+ request = self.prepare_process(evaluation_id, iteration_id, document_ids, only_outdated)
238
+ response = self._client._prepared_request(request)
239
+ return Iteration(**response)
240
+
241
+ def process_document(self, evaluation_id: str, iteration_id: str, document_id: str) -> UiParsedChatCompletion:
242
+ """
243
+ Process a single document within an iteration.
244
+ This method updates the iteration document with the latest extraction.
245
+
246
+ Args:
247
+ iteration_id: The ID of the iteration
248
+ document_id: The ID of the document
249
+
250
+ Returns:
251
+ UiParsedChatCompletion: The parsed chat completion
252
+ Raises:
253
+ HTTPException if the request fails
254
+ """
255
+ request = self.prepare_process_document(evaluation_id, iteration_id, document_id)
256
+ response = self._client._prepared_request(request)
257
+ return UiParsedChatCompletion(**response)
258
+
259
+ def status(self, evaluation_id: str, iteration_id: str) -> IterationDocumentStatusResponse:
260
+ """
261
+ Get the status of documents in an iteration.
262
+
263
+ Args:
264
+ iteration_id: The ID of the iteration
265
+
266
+ Returns:
267
+ IterationDocumentStatusResponse: The status of documents
268
+ Raises:
269
+ HTTPException if the request fails
270
+ """
271
+ request = self.prepare_status(evaluation_id, iteration_id)
272
+ response = self._client._prepared_request(request)
273
+ return IterationDocumentStatusResponse(**response)
274
+
275
+
276
+ class AsyncIterations(AsyncAPIResource, IterationsMixin):
277
+ """Async Iterations API wrapper for evaluations"""
278
+
279
+ def __init__(self, *args, **kwargs):
280
+ super().__init__(*args, **kwargs)
281
+
282
+ async def get(self, evaluation_id: str, iteration_id: str) -> Iteration:
283
+ """
284
+ Get an iteration by ID.
285
+
286
+ Args:
287
+ iteration_id: The ID of the iteration
288
+
289
+ Returns:
290
+ Iteration: The iteration
291
+ Raises:
292
+ HTTPException if the request fails
293
+ """
294
+ request = self.prepare_get(evaluation_id, iteration_id)
295
+ response = await self._client._prepared_request(request)
296
+ return Iteration(**response)
297
+
298
+ async def list(self, evaluation_id: str, model: Optional[str] = None) -> List[Iteration]:
299
+ """
300
+ List iterations for an evaluation.
301
+
302
+ Args:
303
+ evaluation_id: The ID of the evaluation
304
+ model: Optional model to filter by
305
+
306
+ Returns:
307
+ List[Iteration]: List of iterations
308
+ Raises:
309
+ HTTPException if the request fails
310
+ """
311
+ request = self.prepare_list(evaluation_id, model)
312
+ response = await self._client._prepared_request(request)
313
+ return [Iteration(**item) for item in response.get("data", [])]
314
+
315
+ async def create(
316
+ self,
317
+ evaluation_id: str,
318
+ model: str,
319
+ temperature: float = 0.0,
320
+ modality: Modality = "native",
321
+ json_schema: Optional[Dict[str, Any]] = None,
322
+ reasoning_effort: ChatCompletionReasoningEffort = "medium",
323
+ image_resolution_dpi: int = 96,
324
+ browser_canvas: BrowserCanvas = "A4",
325
+ n_consensus: int = 1,
326
+ ) -> Iteration:
327
+ """
328
+ Create a new iteration for an evaluation.
329
+
330
+ Args:
331
+ evaluation_id: The ID of the evaluation
332
+ json_schema: The JSON schema for the iteration
333
+ model: The model to use for the iteration
334
+ temperature: The temperature to use for the model
335
+ modality: The modality to use (text, image, etc.)
336
+ reasoning_effort: The reasoning effort setting for the model (auto, low, medium, high)
337
+ image_resolution_dpi: The DPI of the image. Defaults to 96.
338
+ browser_canvas: The canvas size of the browser. Must be one of:
339
+ - "A3" (11.7in x 16.54in)
340
+ - "A4" (8.27in x 11.7in)
341
+ - "A5" (5.83in x 8.27in)
342
+ Defaults to "A4".
343
+ n_consensus: Number of consensus iterations to perform
344
+
345
+ Returns:
346
+ Iteration: The created iteration
347
+ Raises:
348
+ HTTPException if the request fails
349
+ """
350
+ request = self.prepare_create(
351
+ evaluation_id=evaluation_id,
352
+ json_schema=json_schema,
353
+ model=model,
354
+ temperature=temperature,
355
+ modality=modality,
356
+ reasoning_effort=reasoning_effort,
357
+ image_resolution_dpi=image_resolution_dpi,
358
+ browser_canvas=browser_canvas,
359
+ n_consensus=n_consensus,
360
+ )
361
+ response = await self._client._prepared_request(request)
362
+ return Iteration(**response)
363
+
364
+ async def delete(self, evaluation_id: str, iteration_id: str) -> DeleteResponse:
365
+ """
366
+ Delete an iteration.
367
+
368
+ Args:
369
+ iteration_id: The ID of the iteration
370
+
371
+ Returns:
372
+ DeleteResponse: The response containing success status and ID
373
+ Raises:
374
+ HTTPException if the request fails
375
+ """
376
+ request = self.prepare_delete(evaluation_id, iteration_id)
377
+ return await self._client._prepared_request(request)
378
+
379
+ async def compute_distances(self, evaluation_id: str, iteration_id: str, document_id: str) -> DistancesResult:
380
+ """
381
+ Get distances for a document in an iteration.
382
+
383
+ Args:
384
+ iteration_id: The ID of the iteration
385
+ document_id: The ID of the document
386
+
387
+ Returns:
388
+ DistancesResult: The distances
389
+ Raises:
390
+ HTTPException if the request fails
391
+ """
392
+ request = self.prepare_compute_distances(evaluation_id, iteration_id, document_id)
393
+ response = await self._client._prepared_request(request)
394
+ return DistancesResult(**response)
395
+
396
+ async def process(
397
+ self,
398
+ evaluation_id: str,
399
+ iteration_id: str,
400
+ document_ids: Optional[List[str]] = None,
401
+ only_outdated: bool = True,
402
+ ) -> Iteration:
403
+ """
404
+ Process an iteration by running extractions on documents.
405
+
406
+ Args:
407
+ iteration_id: The ID of the iteration
408
+ document_ids: Optional list of specific document IDs to process
409
+ only_outdated: Whether to only process documents that need updates
410
+
411
+ Returns:
412
+ Iteration: The updated iteration
413
+ Raises:
414
+ HTTPException if the request fails
415
+ """
416
+ request = self.prepare_process(evaluation_id, iteration_id, document_ids, only_outdated)
417
+ response = await self._client._prepared_request(request)
418
+ return Iteration(**response)
419
+
420
+ async def process_document(self, evaluation_id: str, iteration_id: str, document_id: str) -> UiParsedChatCompletion:
421
+ """
422
+ Process a single document within an iteration.
423
+ This method updates the iteration document with the latest extraction.
424
+
425
+ Args:
426
+ iteration_id: The ID of the iteration
427
+ document_id: The ID of the document
428
+
429
+ Returns:
430
+ UiParsedChatCompletion: The parsed chat completion
431
+ Raises:
432
+ HTTPException if the request fails
433
+ """
434
+ request = self.prepare_process_document(evaluation_id, iteration_id, document_id)
435
+ response = await self._client._prepared_request(request)
436
+ return UiParsedChatCompletion(**response)
437
+
438
+ async def status(self, evaluation_id: str, iteration_id: str) -> IterationDocumentStatusResponse:
439
+ """
440
+ Get the status of documents in an iteration.
441
+
442
+ Args:
443
+ iteration_id: The ID of the iteration
444
+
445
+ Returns:
446
+ IterationDocumentStatusResponse: The status of documents
447
+ Raises:
448
+ HTTPException if the request fails
449
+ """
450
+ request = self.prepare_status(evaluation_id, iteration_id)
451
+ response = await self._client._prepared_request(request)
452
+ return IterationDocumentStatusResponse(**response)
@@ -11,7 +11,7 @@ class Files(SyncAPIResource):
11
11
  # Tell Pydantic that _client is not a "field" for serialization/validation,
12
12
  # but rather a private attribute to store arbitrary data.
13
13
 
14
- def create(self, file: Any, purpose: Literal['assistants', 'batch', 'fine-tune', 'vision']) -> Any:
14
+ def create(self, file: Any, purpose: Literal["assistants", "batch", "fine-tune", "vision"]) -> Any:
15
15
  openai_client = OpenAI(api_key=self._client.headers["OpenAI-Api-Key"])
16
16
  return openai_client.files.create(file=file, purpose=purpose)
17
17
 
@@ -19,6 +19,6 @@ class Files(SyncAPIResource):
19
19
  class AsyncFiles(AsyncAPIResource):
20
20
  """Files Asyncronous API wrapper"""
21
21
 
22
- async def create(self, file: Any, purpose: Literal['assistants', 'batch', 'fine-tune', 'vision']) -> Any:
22
+ async def create(self, file: Any, purpose: Literal["assistants", "batch", "fine-tune", "vision"]) -> Any:
23
23
  async with AsyncOpenAI(api_key=self._client.headers["OpenAI-Api-Key"]) as openai_client:
24
24
  return await openai_client.files.create(file=file, purpose=purpose)