retab 0.0.42__py3-none-any.whl → 0.0.44__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 (76) hide show
  1. retab/__init__.py +2 -1
  2. retab/client.py +26 -51
  3. retab/generate_types.py +180 -0
  4. retab/resources/consensus/client.py +1 -1
  5. retab/resources/consensus/responses.py +1 -1
  6. retab/resources/deployments/__init__.py +3 -0
  7. retab/resources/deployments/automations/__init__.py +9 -0
  8. retab/resources/deployments/automations/client.py +244 -0
  9. retab/resources/deployments/automations/endpoints.py +290 -0
  10. retab/resources/deployments/automations/links.py +303 -0
  11. retab/resources/deployments/automations/logs.py +222 -0
  12. retab/resources/deployments/automations/mailboxes.py +423 -0
  13. retab/resources/deployments/automations/outlook.py +377 -0
  14. retab/resources/deployments/automations/tests.py +161 -0
  15. retab/resources/deployments/client.py +148 -0
  16. retab/resources/documents/client.py +94 -68
  17. retab/resources/documents/extractions.py +55 -46
  18. retab/resources/evaluations/__init__.py +2 -2
  19. retab/resources/evaluations/client.py +61 -77
  20. retab/resources/evaluations/documents.py +48 -37
  21. retab/resources/evaluations/iterations.py +58 -40
  22. retab/resources/jsonlUtils.py +3 -4
  23. retab/resources/processors/automations/endpoints.py +49 -39
  24. retab/resources/processors/automations/links.py +52 -43
  25. retab/resources/processors/automations/mailboxes.py +74 -59
  26. retab/resources/processors/automations/outlook.py +104 -82
  27. retab/resources/processors/client.py +35 -30
  28. retab/resources/projects/__init__.py +3 -0
  29. retab/resources/projects/client.py +285 -0
  30. retab/resources/projects/documents.py +244 -0
  31. retab/resources/projects/iterations.py +470 -0
  32. retab/resources/usage.py +2 -0
  33. retab/types/ai_models.py +2 -1
  34. retab/types/deprecated_evals.py +195 -0
  35. retab/types/evaluations/__init__.py +5 -2
  36. retab/types/evaluations/iterations.py +9 -43
  37. retab/types/evaluations/model.py +19 -24
  38. retab/types/extractions.py +1 -0
  39. retab/types/jobs/base.py +1 -1
  40. retab/types/jobs/evaluation.py +1 -1
  41. retab/types/logs.py +5 -6
  42. retab/types/mime.py +1 -10
  43. retab/types/projects/__init__.py +34 -0
  44. retab/types/projects/documents.py +30 -0
  45. retab/types/projects/iterations.py +78 -0
  46. retab/types/projects/model.py +68 -0
  47. retab/types/schemas/enhance.py +22 -5
  48. retab/types/schemas/evaluate.py +2 -2
  49. retab/types/schemas/object.py +27 -25
  50. retab/types/standards.py +2 -2
  51. retab/utils/__init__.py +3 -0
  52. retab/utils/ai_models.py +127 -12
  53. retab/utils/hashing.py +24 -0
  54. retab/utils/json_schema.py +1 -26
  55. retab/utils/mime.py +0 -17
  56. retab/utils/usage/usage.py +0 -1
  57. {retab-0.0.42.dist-info → retab-0.0.44.dist-info}/METADATA +4 -6
  58. {retab-0.0.42.dist-info → retab-0.0.44.dist-info}/RECORD +60 -55
  59. retab/_utils/__init__.py +0 -0
  60. retab/_utils/_model_cards/anthropic.yaml +0 -59
  61. retab/_utils/_model_cards/auto.yaml +0 -43
  62. retab/_utils/_model_cards/gemini.yaml +0 -117
  63. retab/_utils/_model_cards/openai.yaml +0 -301
  64. retab/_utils/_model_cards/xai.yaml +0 -28
  65. retab/_utils/ai_models.py +0 -138
  66. retab/_utils/benchmarking.py +0 -484
  67. retab/_utils/chat.py +0 -327
  68. retab/_utils/display.py +0 -440
  69. retab/_utils/json_schema.py +0 -2156
  70. retab/_utils/mime.py +0 -165
  71. retab/_utils/responses.py +0 -169
  72. retab/_utils/stream_context_managers.py +0 -52
  73. retab/_utils/usage/__init__.py +0 -0
  74. retab/_utils/usage/usage.py +0 -301
  75. {retab-0.0.42.dist-info → retab-0.0.44.dist-info}/WHEEL +0 -0
  76. {retab-0.0.42.dist-info → retab-0.0.44.dist-info}/top_level.txt +0 -0
@@ -1,38 +1,38 @@
1
1
  from typing import Any, Dict, List
2
2
 
3
3
  from ..._resource import AsyncAPIResource, SyncAPIResource
4
- from ...types.evaluations import Evaluation, PatchEvaluationRequest, ListEvaluationParams, CreateEvaluation
4
+ from ...types.projects import Project, PatchProjectRequest, ListProjectParams, BaseProject
5
5
  from ...types.inference_settings import InferenceSettings
6
6
  from ...types.standards import PreparedRequest, DeleteResponse, FieldUnset
7
7
  from .documents import Documents, AsyncDocuments
8
8
  from .iterations import Iterations, AsyncIterations
9
9
 
10
10
 
11
- class EvaluationsMixin:
11
+ class ProjectsMixin:
12
12
  def prepare_create(
13
13
  self,
14
14
  name: str,
15
15
  json_schema: dict[str, Any],
16
- project_id: str = FieldUnset,
17
16
  default_inference_settings: InferenceSettings = FieldUnset,
18
17
  ) -> PreparedRequest:
19
- # Use CreateEvaluation model
20
- eval_data = CreateEvaluation(
21
- name=name,
22
- json_schema=json_schema,
23
- project_id=project_id,
24
- default_inference_settings=default_inference_settings,
25
- )
26
- return PreparedRequest(method="POST", url="/v1/evaluations", data=eval_data.model_dump(exclude_none=True, mode="json"))
18
+ # Use BaseProject model
19
+ eval_dict = {
20
+ "name": name,
21
+ "json_schema": json_schema,
22
+ }
23
+ if default_inference_settings is not FieldUnset:
24
+ eval_dict["default_inference_settings"] = default_inference_settings
25
+
26
+ eval_data = BaseProject(**eval_dict)
27
+ return PreparedRequest(method="POST", url="/v1/evaluations", data=eval_data.model_dump(exclude_unset=True, mode="json"))
27
28
 
28
29
  def prepare_get(self, evaluation_id: str) -> PreparedRequest:
29
- return PreparedRequest(method="GET", url=f"/v1/evaluations/{evaluation_id}")
30
+ return PreparedRequest(method="GET", url=f"/v1/projects/{evaluation_id}")
30
31
 
31
32
  def prepare_update(
32
33
  self,
33
34
  evaluation_id: str,
34
35
  name: str = FieldUnset,
35
- project_id: str = FieldUnset,
36
36
  json_schema: dict[str, Any] = FieldUnset,
37
37
  default_inference_settings: InferenceSettings = FieldUnset,
38
38
  ) -> PreparedRequest:
@@ -42,41 +42,39 @@ class EvaluationsMixin:
42
42
  Only the provided fields will be updated. Fields set to None will be excluded from the update.
43
43
  """
44
44
  # Build a dictionary with only the provided fields
45
- data = PatchEvaluationRequest(
46
- name=name,
47
- project_id=project_id,
48
- json_schema=json_schema,
49
- default_inference_settings=default_inference_settings,
50
- ).model_dump(exclude_unset=True, mode="json")
45
+ update_dict = {}
46
+ if name is not FieldUnset:
47
+ update_dict["name"] = name
48
+ if json_schema is not FieldUnset:
49
+ update_dict["json_schema"] = json_schema
50
+ if default_inference_settings is not FieldUnset:
51
+ update_dict["default_inference_settings"] = default_inference_settings
51
52
 
52
- return PreparedRequest(method="PATCH", url=f"/v1/evaluations/{evaluation_id}", data=data)
53
+ data = PatchProjectRequest(**update_dict).model_dump(exclude_unset=True, mode="json")
53
54
 
54
- def prepare_list(self, project_id: str = FieldUnset) -> PreparedRequest:
55
+ return PreparedRequest(method="PATCH", url=f"/v1/projects/{evaluation_id}", data=data)
56
+
57
+ def prepare_list(self) -> PreparedRequest:
55
58
  """
56
59
  Prepare a request to list evaluations.
57
60
 
58
61
  Usage:
59
- >>> client.evals.list(project_id="project_id") # List all evaluations for a project
60
- >>> client.evals.list() # List all evaluations (no project_id)
61
-
62
- This does not work:
63
- >>> client.evals.list(project_id=None)
64
-
65
- Args:
66
- project_id: The project ID to list evaluations for
62
+ >>> client.evaluations.list() # List all evaluations
67
63
 
68
64
  Returns:
69
65
  PreparedRequest: The prepared request
70
66
  """
71
- params = ListEvaluationParams(project_id=project_id).model_dump(exclude_unset=True, exclude_defaults=True, mode="json")
67
+ params_dict = {}
68
+
69
+ params = ListProjectParams(**params_dict).model_dump(exclude_unset=True, exclude_defaults=True, mode="json")
72
70
  return PreparedRequest(method="GET", url="/v1/evaluations", params=params)
73
71
 
74
72
  def prepare_delete(self, id: str) -> PreparedRequest:
75
- return PreparedRequest(method="DELETE", url=f"/v1/evaluations/{id}")
73
+ return PreparedRequest(method="DELETE", url=f"/v1/projects/{id}")
76
74
 
77
75
 
78
- class Evaluations(SyncAPIResource, EvaluationsMixin):
79
- """Evaluations API wrapper"""
76
+ class Projects(SyncAPIResource, ProjectsMixin):
77
+ """Projects API wrapper"""
80
78
 
81
79
  def __init__(self, *args, **kwargs):
82
80
  super().__init__(*args, **kwargs)
@@ -87,29 +85,27 @@ class Evaluations(SyncAPIResource, EvaluationsMixin):
87
85
  self,
88
86
  name: str,
89
87
  json_schema: dict[str, Any],
90
- project_id: str = FieldUnset,
91
88
  default_inference_settings: InferenceSettings = FieldUnset,
92
- ) -> Evaluation:
89
+ ) -> Project:
93
90
  """
94
91
  Create a new evaluation.
95
92
 
96
93
  Args:
97
94
  name: The name of the evaluation
98
95
  json_schema: The JSON schema for the evaluation
99
- project_id: The project ID to associate with the evaluation
100
96
  documents: The documents to associate with the evaluation
101
97
  default_inference_settings: The default inference settings to associate with the evaluation
102
98
 
103
99
  Returns:
104
- Evaluation: The created evaluation
100
+ Project: The created evaluation
105
101
  Raises:
106
102
  HTTPException if the request fails
107
103
  """
108
- request = self.prepare_create(name, json_schema, project_id, default_inference_settings=default_inference_settings)
104
+ request = self.prepare_create(name, json_schema, default_inference_settings=default_inference_settings)
109
105
  response = self._client._prepared_request(request)
110
- return Evaluation(**response)
106
+ return Project(**response)
111
107
 
112
- def get(self, evaluation_id: str) -> Evaluation:
108
+ def get(self, evaluation_id: str) -> Project:
113
109
  """
114
110
  Get an evaluation by ID.
115
111
 
@@ -117,64 +113,59 @@ class Evaluations(SyncAPIResource, EvaluationsMixin):
117
113
  evaluation_id: The ID of the evaluation to retrieve
118
114
 
119
115
  Returns:
120
- Evaluation: The evaluation
116
+ Project: The evaluation
121
117
  Raises:
122
118
  HTTPException if the request fails
123
119
  """
124
120
  request = self.prepare_get(evaluation_id)
125
121
  response = self._client._prepared_request(request)
126
- return Evaluation(**response)
122
+ return Project(**response)
127
123
 
128
124
  def update(
129
125
  self,
130
126
  evaluation_id: str,
131
127
  name: str = FieldUnset,
132
- project_id: str = FieldUnset,
133
128
  json_schema: dict[str, Any] = FieldUnset,
134
129
  default_inference_settings: InferenceSettings = FieldUnset,
135
- ) -> Evaluation:
130
+ ) -> Project:
136
131
  """
137
132
  Update an evaluation with partial updates.
138
133
 
139
134
  Args:
140
135
  evaluation_id: The ID of the evaluation to update
141
136
  name: Optional new name for the evaluation
142
- project_id: Optional new project ID
143
137
  json_schema: Optional new JSON schema
144
138
  documents: Optional list of documents to update
145
139
  iterations: Optional list of iterations to update
146
140
  default_inference_settings: Optional annotation properties
147
141
 
148
142
  Returns:
149
- Evaluation: The updated evaluation
143
+ Project: The updated evaluation
150
144
  Raises:
151
145
  HTTPException if the request fails
152
146
  """
153
147
  request = self.prepare_update(
154
148
  evaluation_id=evaluation_id,
155
149
  name=name,
156
- project_id=project_id,
157
150
  json_schema=json_schema,
158
151
  default_inference_settings=default_inference_settings,
159
152
  )
160
153
  response = self._client._prepared_request(request)
161
- return Evaluation(**response)
154
+ return Project(**response)
162
155
 
163
- def list(self, project_id: str = FieldUnset) -> List[Evaluation]:
156
+ def list(self) -> List[Project]:
164
157
  """
165
158
  List evaluations for a project.
166
159
 
167
160
  Args:
168
- project_id: The project ID to list evaluations for
169
-
170
161
  Returns:
171
- List[Evaluation]: List of evaluations
162
+ List[Project]: List of evaluations
172
163
  Raises:
173
164
  HTTPException if the request fails
174
165
  """
175
- request = self.prepare_list(project_id)
166
+ request = self.prepare_list()
176
167
  response = self._client._prepared_request(request)
177
- return [Evaluation(**item) for item in response.get("data", [])]
168
+ return [Project(**item) for item in response.get("data", [])]
178
169
 
179
170
  def delete(self, evaluation_id: str) -> DeleteResponse:
180
171
  """
@@ -192,33 +183,32 @@ class Evaluations(SyncAPIResource, EvaluationsMixin):
192
183
  return self._client._prepared_request(request)
193
184
 
194
185
 
195
- class AsyncEvaluations(AsyncAPIResource, EvaluationsMixin):
196
- """Async Evaluations API wrapper"""
186
+ class AsyncProjects(AsyncAPIResource, ProjectsMixin):
187
+ """Async Projects API wrapper"""
197
188
 
198
189
  def __init__(self, *args, **kwargs):
199
190
  super().__init__(*args, **kwargs)
200
191
  self.documents = AsyncDocuments(self._client)
201
192
  self.iterations = AsyncIterations(self._client)
202
193
 
203
- async def create(self, name: str, json_schema: Dict[str, Any], project_id: str = FieldUnset) -> Evaluation:
194
+ async def create(self, name: str, json_schema: Dict[str, Any]) -> Project:
204
195
  """
205
196
  Create a new evaluation.
206
197
 
207
198
  Args:
208
199
  name: The name of the evaluation
209
200
  json_schema: The JSON schema for the evaluation
210
- project_id: The project ID to associate with the evaluation
211
201
 
212
202
  Returns:
213
- Evaluation: The created evaluation
203
+ Project: The created evaluation
214
204
  Raises:
215
205
  HTTPException if the request fails
216
206
  """
217
- request = self.prepare_create(name, json_schema, project_id=project_id)
207
+ request = self.prepare_create(name, json_schema)
218
208
  response = await self._client._prepared_request(request)
219
- return Evaluation(**response)
209
+ return Project(**response)
220
210
 
221
- async def get(self, evaluation_id: str) -> Evaluation:
211
+ async def get(self, evaluation_id: str) -> Project:
222
212
  """
223
213
  Get an evaluation by ID.
224
214
 
@@ -226,64 +216,58 @@ class AsyncEvaluations(AsyncAPIResource, EvaluationsMixin):
226
216
  evaluation_id: The ID of the evaluation to retrieve
227
217
 
228
218
  Returns:
229
- Evaluation: The evaluation
219
+ Project: The evaluation
230
220
  Raises:
231
221
  HTTPException if the request fails
232
222
  """
233
223
  request = self.prepare_get(evaluation_id)
234
224
  response = await self._client._prepared_request(request)
235
- return Evaluation(**response)
225
+ return Project(**response)
236
226
 
237
227
  async def update(
238
228
  self,
239
229
  evaluation_id: str,
240
230
  name: str = FieldUnset,
241
- project_id: str = FieldUnset,
242
231
  json_schema: dict[str, Any] = FieldUnset,
243
232
  default_inference_settings: InferenceSettings = FieldUnset,
244
- ) -> Evaluation:
233
+ ) -> Project:
245
234
  """
246
235
  Update an evaluation with partial updates.
247
236
 
248
237
  Args:
249
238
  id: The ID of the evaluation to update
250
239
  name: Optional new name for the evaluation
251
- project_id: Optional new project ID
252
240
  json_schema: Optional new JSON schema
253
241
  documents: Optional list of documents to update
254
242
  iterations: Optional list of iterations to update
255
243
  default_inference_settings: Optional annotation properties
256
244
 
257
245
  Returns:
258
- Evaluation: The updated evaluation
246
+ Project: The updated evaluation
259
247
  Raises:
260
248
  HTTPException if the request fails
261
249
  """
262
250
  request = self.prepare_update(
263
251
  evaluation_id=evaluation_id,
264
252
  name=name,
265
- project_id=project_id,
266
253
  json_schema=json_schema,
267
254
  default_inference_settings=default_inference_settings,
268
255
  )
269
256
  response = await self._client._prepared_request(request)
270
- return Evaluation(**response)
257
+ return Project(**response)
271
258
 
272
- async def list(self, project_id: str = FieldUnset) -> List[Evaluation]:
259
+ async def list(self) -> List[Project]:
273
260
  """
274
261
  List evaluations for a project.
275
262
 
276
- Args:
277
- project_id: The project ID to list evaluations for
278
-
279
263
  Returns:
280
- List[Evaluation]: List of evaluations
264
+ List[Project]: List of evaluations
281
265
  Raises:
282
266
  HTTPException if the request fails
283
267
  """
284
- request = self.prepare_list(project_id)
268
+ request = self.prepare_list()
285
269
  response = await self._client._prepared_request(request)
286
- return [Evaluation(**item) for item in response.get("data", [])]
270
+ return [Project(**item) for item in response.get("data", [])]
287
271
 
288
272
  async def delete(self, evaluation_id: str) -> DeleteResponse:
289
273
  """
@@ -7,7 +7,8 @@ from pydantic import HttpUrl
7
7
 
8
8
  from ..._resource import AsyncAPIResource, SyncAPIResource
9
9
  from ...utils.mime import prepare_mime_document
10
- from ...types.evaluations import DocumentItem, EvaluationDocument, PatchEvaluationDocumentRequest
10
+ from ...types.projects import DocumentItem, ProjectDocument, PatchProjectDocumentRequest
11
+ from ...types.predictions import PredictionMetadata
11
12
  from ...types.mime import MIMEData
12
13
  from ...types.standards import PreparedRequest, DeleteResponse, FieldUnset
13
14
  from ...types.documents.extractions import RetabParsedChatCompletion
@@ -15,33 +16,37 @@ from ...types.documents.extractions import RetabParsedChatCompletion
15
16
 
16
17
  class DocumentsMixin:
17
18
  def prepare_get(self, evaluation_id: str, document_id: str) -> PreparedRequest:
18
- return PreparedRequest(method="GET", url=f"/v1/evaluations/{evaluation_id}/documents/{document_id}")
19
+ return PreparedRequest(method="GET", url=f"/v1/projects/{evaluation_id}/documents/{document_id}")
19
20
 
20
- def prepare_create(self, evaluation_id: str, document: MIMEData, annotation: dict[str, Any]) -> PreparedRequest:
21
+ def prepare_create(self, evaluation_id: str, document: MIMEData, annotation: dict[str, Any], annotation_metadata: dict[str, Any] | None = None) -> PreparedRequest:
21
22
  # Serialize the MIMEData
22
- document_item = DocumentItem(mime_data=document, annotation=annotation, annotation_metadata=None)
23
- return PreparedRequest(method="POST", url=f"/v1/evaluations/{evaluation_id}/documents", data=document_item.model_dump(mode="json"))
23
+ document_item = DocumentItem(mime_data=document, annotation=annotation, annotation_metadata=PredictionMetadata(**annotation_metadata) if annotation_metadata else None)
24
+ return PreparedRequest(method="POST", url=f"/v1/projects/{evaluation_id}/documents", data=document_item.model_dump(mode="json"))
24
25
 
25
26
  def prepare_list(self, evaluation_id: str) -> PreparedRequest:
26
- return PreparedRequest(method="GET", url=f"/v1/evaluations/{evaluation_id}/documents")
27
+ return PreparedRequest(method="GET", url=f"/v1/projects/{evaluation_id}/documents")
27
28
 
28
- def prepare_update(self, evaluation_id: str, document_id: str, annotation: dict[str, Any] = FieldUnset) -> PreparedRequest:
29
- update_request = PatchEvaluationDocumentRequest(annotation=annotation)
30
- return PreparedRequest(
31
- method="PATCH", url=f"/v1/evaluations/{evaluation_id}/documents/{document_id}", data=update_request.model_dump(mode="json", exclude_unset=True, exclude_defaults=True)
32
- )
29
+ def prepare_update(self, evaluation_id: str, document_id: str, annotation: dict[str, Any]) -> PreparedRequest:
30
+ update_request = PatchProjectDocumentRequest(annotation=annotation)
31
+ return PreparedRequest(method="PATCH", url=f"/v1/projects/{evaluation_id}/documents/{document_id}", data=update_request.model_dump(mode="json", exclude_unset=True))
33
32
 
34
33
  def prepare_delete(self, evaluation_id: str, document_id: str) -> PreparedRequest:
35
- return PreparedRequest(method="DELETE", url=f"/v1/evaluations/{evaluation_id}/documents/{document_id}")
34
+ return PreparedRequest(method="DELETE", url=f"/v1/projects/{evaluation_id}/documents/{document_id}")
36
35
 
37
36
  def prepare_llm_annotate(self, evaluation_id: str, document_id: str) -> PreparedRequest:
38
- return PreparedRequest(method="POST", url=f"/v1/evaluations/{evaluation_id}/documents/{document_id}/llm-annotate", data={"stream": False})
37
+ return PreparedRequest(method="POST", url=f"/v1/projects/{evaluation_id}/documents/{document_id}/llm-annotate", data={"stream": False})
39
38
 
40
39
 
41
40
  class Documents(SyncAPIResource, DocumentsMixin):
42
41
  """Documents API wrapper for evaluations"""
43
42
 
44
- def create(self, evaluation_id: str, document: Union[Path, str, IOBase, MIMEData, PIL.Image.Image, HttpUrl], annotation: Dict[str, Any]) -> EvaluationDocument:
43
+ def create(
44
+ self,
45
+ evaluation_id: str,
46
+ document: Union[Path, str, IOBase, MIMEData, PIL.Image.Image, HttpUrl],
47
+ annotation: Dict[str, Any],
48
+ annotation_metadata: Dict[str, Any] | None = None,
49
+ ) -> ProjectDocument:
45
50
  """
46
51
  Create a document for an evaluation.
47
52
 
@@ -56,7 +61,7 @@ class Documents(SyncAPIResource, DocumentsMixin):
56
61
  annotation: The ground truth for the document
57
62
 
58
63
  Returns:
59
- EvaluationDocument: The created document
64
+ ProjectDocument: The created document
60
65
  Raises:
61
66
  HTTPException if the request fails
62
67
  """
@@ -64,11 +69,11 @@ class Documents(SyncAPIResource, DocumentsMixin):
64
69
  mime_document: MIMEData = prepare_mime_document(document)
65
70
 
66
71
  # Let prepare_create handle the serialization
67
- request = self.prepare_create(evaluation_id, mime_document, annotation)
72
+ request = self.prepare_create(evaluation_id, mime_document, annotation, annotation_metadata)
68
73
  response = self._client._prepared_request(request)
69
- return EvaluationDocument(**response)
74
+ return ProjectDocument(**response)
70
75
 
71
- def list(self, evaluation_id: str) -> List[EvaluationDocument]:
76
+ def list(self, evaluation_id: str) -> List[ProjectDocument]:
72
77
  """
73
78
  List documents for an evaluation.
74
79
 
@@ -76,15 +81,15 @@ class Documents(SyncAPIResource, DocumentsMixin):
76
81
  evaluation_id: The ID of the evaluation
77
82
 
78
83
  Returns:
79
- List[EvaluationDocument]: List of documents
84
+ List[ProjectDocument]: List of documents
80
85
  Raises:
81
86
  HTTPException if the request fails
82
87
  """
83
88
  request = self.prepare_list(evaluation_id)
84
89
  response = self._client._prepared_request(request)
85
- return [EvaluationDocument(**item) for item in response.get("data", [])]
90
+ return [ProjectDocument(**item) for item in response.get("data", [])]
86
91
 
87
- def get(self, evaluation_id: str, document_id: str) -> EvaluationDocument:
92
+ def get(self, evaluation_id: str, document_id: str) -> ProjectDocument:
88
93
  """
89
94
  Get a document by ID.
90
95
 
@@ -93,15 +98,15 @@ class Documents(SyncAPIResource, DocumentsMixin):
93
98
  document_id: The ID of the document
94
99
 
95
100
  Returns:
96
- EvaluationDocument: The document
101
+ ProjectDocument: The document
97
102
  Raises:
98
103
  HTTPException if the request fails
99
104
  """
100
105
  request = self.prepare_get(evaluation_id, document_id)
101
106
  response = self._client._prepared_request(request)
102
- return EvaluationDocument(**response)
107
+ return ProjectDocument(**response)
103
108
 
104
- def update(self, evaluation_id: str, document_id: str, annotation: dict[str, Any] = FieldUnset) -> EvaluationDocument:
109
+ def update(self, evaluation_id: str, document_id: str, annotation: dict[str, Any]) -> ProjectDocument:
105
110
  """
106
111
  Update a document.
107
112
 
@@ -110,13 +115,13 @@ class Documents(SyncAPIResource, DocumentsMixin):
110
115
  document_id: The ID of the document
111
116
  annotation: The ground truth for the document
112
117
  Returns:
113
- EvaluationDocument: The updated document
118
+ ProjectDocument: The updated document
114
119
  Raises:
115
120
  HTTPException if the request fails
116
121
  """
117
122
  request = self.prepare_update(evaluation_id, document_id, annotation=annotation)
118
123
  response = self._client._prepared_request(request)
119
- return EvaluationDocument(**response)
124
+ return ProjectDocument(**response)
120
125
 
121
126
  def delete(self, evaluation_id: str, document_id: str) -> DeleteResponse:
122
127
  """
@@ -146,7 +151,13 @@ class Documents(SyncAPIResource, DocumentsMixin):
146
151
  class AsyncDocuments(AsyncAPIResource, DocumentsMixin):
147
152
  """Async Documents API wrapper for evaluations"""
148
153
 
149
- async def create(self, evaluation_id: str, document: Union[Path, str, IOBase, MIMEData, PIL.Image.Image, HttpUrl], annotation: Dict[str, Any]) -> EvaluationDocument:
154
+ async def create(
155
+ self,
156
+ evaluation_id: str,
157
+ document: Union[Path, str, IOBase, MIMEData, PIL.Image.Image, HttpUrl],
158
+ annotation: Dict[str, Any],
159
+ annotation_metadata: Dict[str, Any] | None = None,
160
+ ) -> ProjectDocument:
150
161
  """
151
162
  Create a document for an evaluation.
152
163
 
@@ -159,9 +170,9 @@ class AsyncDocuments(AsyncAPIResource, DocumentsMixin):
159
170
  - A PIL Image object
160
171
  - A URL (HttpUrl)
161
172
  annotation: The ground truth for the document
162
-
173
+ annotation_metadata: The metadata of the annotation
163
174
  Returns:
164
- EvaluationDocument: The created document
175
+ ProjectDocument: The created document
165
176
  Raises:
166
177
  HTTPException if the request fails
167
178
  """
@@ -169,11 +180,11 @@ class AsyncDocuments(AsyncAPIResource, DocumentsMixin):
169
180
  mime_document: MIMEData = prepare_mime_document(document)
170
181
 
171
182
  # Let prepare_create handle the serialization
172
- request = self.prepare_create(evaluation_id, mime_document, annotation)
183
+ request = self.prepare_create(evaluation_id, mime_document, annotation, annotation_metadata)
173
184
  response = await self._client._prepared_request(request)
174
- return EvaluationDocument(**response)
185
+ return ProjectDocument(**response)
175
186
 
176
- async def list(self, evaluation_id: str) -> List[EvaluationDocument]:
187
+ async def list(self, evaluation_id: str) -> List[ProjectDocument]:
177
188
  """
178
189
  List documents for an evaluation.
179
190
 
@@ -181,15 +192,15 @@ class AsyncDocuments(AsyncAPIResource, DocumentsMixin):
181
192
  evaluation_id: The ID of the evaluation
182
193
 
183
194
  Returns:
184
- List[EvaluationDocument]: List of documents
195
+ List[ProjectDocument]: List of documents
185
196
  Raises:
186
197
  HTTPException if the request fails
187
198
  """
188
199
  request = self.prepare_list(evaluation_id)
189
200
  response = await self._client._prepared_request(request)
190
- return [EvaluationDocument(**item) for item in response.get("data", [])]
201
+ return [ProjectDocument(**item) for item in response.get("data", [])]
191
202
 
192
- async def update(self, evaluation_id: str, document_id: str, annotation: dict[str, Any] = FieldUnset) -> EvaluationDocument:
203
+ async def update(self, evaluation_id: str, document_id: str, annotation: dict[str, Any]) -> ProjectDocument:
193
204
  """
194
205
  Update a document.
195
206
 
@@ -199,13 +210,13 @@ class AsyncDocuments(AsyncAPIResource, DocumentsMixin):
199
210
  annotation: The ground truth for the document
200
211
 
201
212
  Returns:
202
- EvaluationDocument: The updated document
213
+ ProjectDocument: The updated document
203
214
  Raises:
204
215
  HTTPException if the request fails
205
216
  """
206
217
  request = self.prepare_update(evaluation_id, document_id, annotation)
207
218
  response = await self._client._prepared_request(request)
208
- return EvaluationDocument(**response)
219
+ return ProjectDocument(**response)
209
220
 
210
221
  async def delete(self, evaluation_id: str, document_id: str) -> DeleteResponse:
211
222
  """