llama-cloud 0.1.35__py3-none-any.whl → 0.1.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.

Potentially problematic release.


This version of llama-cloud might be problematic. Click here for more details.

Files changed (38) hide show
  1. llama_cloud/__init__.py +32 -4
  2. llama_cloud/resources/__init__.py +1 -3
  3. llama_cloud/resources/admin/client.py +108 -0
  4. llama_cloud/resources/beta/client.py +460 -0
  5. llama_cloud/resources/classifier/client.py +231 -181
  6. llama_cloud/resources/data_sinks/types/data_sink_update_component.py +2 -0
  7. llama_cloud/resources/files/__init__.py +2 -2
  8. llama_cloud/resources/files/client.py +15 -73
  9. llama_cloud/resources/files/types/__init__.py +1 -3
  10. llama_cloud/resources/llama_extract/client.py +96 -4
  11. llama_cloud/types/__init__.py +34 -2
  12. llama_cloud/types/classification_result.py +4 -5
  13. llama_cloud/types/classifier_rule.py +43 -0
  14. llama_cloud/types/classify_job.py +45 -0
  15. llama_cloud/types/{classify_response.py → classify_job_results.py} +3 -6
  16. llama_cloud/types/classify_job_with_status.py +47 -0
  17. llama_cloud/types/classify_parsing_configuration.py +38 -0
  18. llama_cloud/types/cloud_astra_db_vector_store.py +51 -0
  19. llama_cloud/types/cloud_confluence_data_source.py +15 -0
  20. llama_cloud/types/configurable_data_sink_names.py +4 -0
  21. llama_cloud/types/data_sink_component.py +2 -0
  22. llama_cloud/types/data_sink_create_component.py +2 -0
  23. llama_cloud/types/failure_handling_config.py +37 -0
  24. llama_cloud/types/file_classification.py +41 -0
  25. llama_cloud/types/file_create.py +41 -0
  26. llama_cloud/types/file_filter.py +40 -0
  27. llama_cloud/types/file_query_response.py +38 -0
  28. llama_cloud/types/file_store_info_response.py +34 -0
  29. llama_cloud/types/file_store_info_response_status.py +25 -0
  30. llama_cloud/types/llama_extract_mode_availability.py +37 -0
  31. llama_cloud/types/llama_extract_mode_availability_status.py +17 -0
  32. llama_cloud/types/supported_llm_model_names.py +12 -0
  33. {llama_cloud-0.1.35.dist-info → llama_cloud-0.1.37.dist-info}/METADATA +1 -1
  34. {llama_cloud-0.1.35.dist-info → llama_cloud-0.1.37.dist-info}/RECORD +38 -24
  35. /llama_cloud/{resources/files/types → types}/file_create_permission_info_value.py +0 -0
  36. /llama_cloud/{resources/files/types → types}/file_create_resource_info_value.py +0 -0
  37. {llama_cloud-0.1.35.dist-info → llama_cloud-0.1.37.dist-info}/LICENSE +0 -0
  38. {llama_cloud-0.1.35.dist-info → llama_cloud-0.1.37.dist-info}/WHEEL +0 -0
@@ -1,6 +1,5 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- import datetime as dt
4
3
  import typing
5
4
  import urllib.parse
6
5
  from json.decoder import JSONDecodeError
@@ -11,14 +10,13 @@ from ...core.jsonable_encoder import jsonable_encoder
11
10
  from ...core.remove_none_from_dict import remove_none_from_dict
12
11
  from ...errors.unprocessable_entity_error import UnprocessableEntityError
13
12
  from ...types.file import File
13
+ from ...types.file_create import FileCreate
14
14
  from ...types.file_id_presigned_url import FileIdPresignedUrl
15
15
  from ...types.http_validation_error import HttpValidationError
16
16
  from ...types.page_figure_metadata import PageFigureMetadata
17
17
  from ...types.page_screenshot_metadata import PageScreenshotMetadata
18
18
  from ...types.presigned_url import PresignedUrl
19
19
  from .types.file_create_from_url_resource_info_value import FileCreateFromUrlResourceInfoValue
20
- from .types.file_create_permission_info_value import FileCreatePermissionInfoValue
21
- from .types.file_create_resource_info_value import FileCreateResourceInfoValue
22
20
 
23
21
  try:
24
22
  import pydantic
@@ -196,13 +194,7 @@ class FilesClient:
196
194
  expires_at_seconds: typing.Optional[int] = None,
197
195
  project_id: typing.Optional[str] = None,
198
196
  organization_id: typing.Optional[str] = None,
199
- name: str,
200
- external_file_id: typing.Optional[str] = OMIT,
201
- file_size: typing.Optional[int] = OMIT,
202
- last_modified_at: typing.Optional[dt.datetime] = OMIT,
203
- resource_info: typing.Optional[typing.Dict[str, typing.Optional[FileCreateResourceInfoValue]]] = OMIT,
204
- permission_info: typing.Optional[typing.Dict[str, typing.Optional[FileCreatePermissionInfoValue]]] = OMIT,
205
- data_source_id: typing.Optional[str] = OMIT,
197
+ request: FileCreate,
206
198
  ) -> FileIdPresignedUrl:
207
199
  """
208
200
  Create a presigned url for uploading a file.
@@ -217,49 +209,27 @@ class FilesClient:
217
209
 
218
210
  - organization_id: typing.Optional[str].
219
211
 
220
- - name: str. Name that will be used for created file. If possible, always include the file extension in the name.
221
-
222
- - external_file_id: typing.Optional[str].
223
-
224
- - file_size: typing.Optional[int].
225
-
226
- - last_modified_at: typing.Optional[dt.datetime].
227
-
228
- - resource_info: typing.Optional[typing.Dict[str, typing.Optional[FileCreateResourceInfoValue]]].
229
-
230
- - permission_info: typing.Optional[typing.Dict[str, typing.Optional[FileCreatePermissionInfoValue]]].
231
-
232
- - data_source_id: typing.Optional[str].
212
+ - request: FileCreate.
233
213
  ---
214
+ from llama_cloud import FileCreate
234
215
  from llama_cloud.client import LlamaCloud
235
216
 
236
217
  client = LlamaCloud(
237
218
  token="YOUR_TOKEN",
238
219
  )
239
220
  client.files.generate_presigned_url(
240
- name="string",
221
+ request=FileCreate(
222
+ name="string",
223
+ ),
241
224
  )
242
225
  """
243
- _request: typing.Dict[str, typing.Any] = {"name": name}
244
- if external_file_id is not OMIT:
245
- _request["external_file_id"] = external_file_id
246
- if file_size is not OMIT:
247
- _request["file_size"] = file_size
248
- if last_modified_at is not OMIT:
249
- _request["last_modified_at"] = last_modified_at
250
- if resource_info is not OMIT:
251
- _request["resource_info"] = resource_info
252
- if permission_info is not OMIT:
253
- _request["permission_info"] = permission_info
254
- if data_source_id is not OMIT:
255
- _request["data_source_id"] = data_source_id
256
226
  _response = self._client_wrapper.httpx_client.request(
257
227
  "PUT",
258
228
  urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/files"),
259
229
  params=remove_none_from_dict(
260
230
  {"expires_at_seconds": expires_at_seconds, "project_id": project_id, "organization_id": organization_id}
261
231
  ),
262
- json=jsonable_encoder(_request),
232
+ json=jsonable_encoder(request),
263
233
  headers=self._client_wrapper.get_headers(),
264
234
  timeout=60,
265
235
  )
@@ -936,13 +906,7 @@ class AsyncFilesClient:
936
906
  expires_at_seconds: typing.Optional[int] = None,
937
907
  project_id: typing.Optional[str] = None,
938
908
  organization_id: typing.Optional[str] = None,
939
- name: str,
940
- external_file_id: typing.Optional[str] = OMIT,
941
- file_size: typing.Optional[int] = OMIT,
942
- last_modified_at: typing.Optional[dt.datetime] = OMIT,
943
- resource_info: typing.Optional[typing.Dict[str, typing.Optional[FileCreateResourceInfoValue]]] = OMIT,
944
- permission_info: typing.Optional[typing.Dict[str, typing.Optional[FileCreatePermissionInfoValue]]] = OMIT,
945
- data_source_id: typing.Optional[str] = OMIT,
909
+ request: FileCreate,
946
910
  ) -> FileIdPresignedUrl:
947
911
  """
948
912
  Create a presigned url for uploading a file.
@@ -957,49 +921,27 @@ class AsyncFilesClient:
957
921
 
958
922
  - organization_id: typing.Optional[str].
959
923
 
960
- - name: str. Name that will be used for created file. If possible, always include the file extension in the name.
961
-
962
- - external_file_id: typing.Optional[str].
963
-
964
- - file_size: typing.Optional[int].
965
-
966
- - last_modified_at: typing.Optional[dt.datetime].
967
-
968
- - resource_info: typing.Optional[typing.Dict[str, typing.Optional[FileCreateResourceInfoValue]]].
969
-
970
- - permission_info: typing.Optional[typing.Dict[str, typing.Optional[FileCreatePermissionInfoValue]]].
971
-
972
- - data_source_id: typing.Optional[str].
924
+ - request: FileCreate.
973
925
  ---
926
+ from llama_cloud import FileCreate
974
927
  from llama_cloud.client import AsyncLlamaCloud
975
928
 
976
929
  client = AsyncLlamaCloud(
977
930
  token="YOUR_TOKEN",
978
931
  )
979
932
  await client.files.generate_presigned_url(
980
- name="string",
933
+ request=FileCreate(
934
+ name="string",
935
+ ),
981
936
  )
982
937
  """
983
- _request: typing.Dict[str, typing.Any] = {"name": name}
984
- if external_file_id is not OMIT:
985
- _request["external_file_id"] = external_file_id
986
- if file_size is not OMIT:
987
- _request["file_size"] = file_size
988
- if last_modified_at is not OMIT:
989
- _request["last_modified_at"] = last_modified_at
990
- if resource_info is not OMIT:
991
- _request["resource_info"] = resource_info
992
- if permission_info is not OMIT:
993
- _request["permission_info"] = permission_info
994
- if data_source_id is not OMIT:
995
- _request["data_source_id"] = data_source_id
996
938
  _response = await self._client_wrapper.httpx_client.request(
997
939
  "PUT",
998
940
  urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/files"),
999
941
  params=remove_none_from_dict(
1000
942
  {"expires_at_seconds": expires_at_seconds, "project_id": project_id, "organization_id": organization_id}
1001
943
  ),
1002
- json=jsonable_encoder(_request),
944
+ json=jsonable_encoder(request),
1003
945
  headers=self._client_wrapper.get_headers(),
1004
946
  timeout=60,
1005
947
  )
@@ -1,7 +1,5 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
3
  from .file_create_from_url_resource_info_value import FileCreateFromUrlResourceInfoValue
4
- from .file_create_permission_info_value import FileCreatePermissionInfoValue
5
- from .file_create_resource_info_value import FileCreateResourceInfoValue
6
4
 
7
- __all__ = ["FileCreateFromUrlResourceInfoValue", "FileCreatePermissionInfoValue", "FileCreateResourceInfoValue"]
5
+ __all__ = ["FileCreateFromUrlResourceInfoValue"]
@@ -45,10 +45,16 @@ class LlamaExtractClient:
45
45
  self._client_wrapper = client_wrapper
46
46
 
47
47
  def list_extraction_agents(
48
- self, *, project_id: typing.Optional[str] = None, organization_id: typing.Optional[str] = None
48
+ self,
49
+ *,
50
+ include_default: typing.Optional[bool] = None,
51
+ project_id: typing.Optional[str] = None,
52
+ organization_id: typing.Optional[str] = None,
49
53
  ) -> typing.List[ExtractAgent]:
50
54
  """
51
55
  Parameters:
56
+ - include_default: typing.Optional[bool]. Whether to include default agents in the results
57
+
52
58
  - project_id: typing.Optional[str].
53
59
 
54
60
  - organization_id: typing.Optional[str].
@@ -63,7 +69,9 @@ class LlamaExtractClient:
63
69
  _response = self._client_wrapper.httpx_client.request(
64
70
  "GET",
65
71
  urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/extraction-agents"),
66
- params=remove_none_from_dict({"project_id": project_id, "organization_id": organization_id}),
72
+ params=remove_none_from_dict(
73
+ {"include_default": include_default, "project_id": project_id, "organization_id": organization_id}
74
+ ),
67
75
  headers=self._client_wrapper.get_headers(),
68
76
  timeout=60,
69
77
  )
@@ -265,6 +273,44 @@ class LlamaExtractClient:
265
273
  raise ApiError(status_code=_response.status_code, body=_response.text)
266
274
  raise ApiError(status_code=_response.status_code, body=_response_json)
267
275
 
276
+ def get_or_create_default_extraction_agent(
277
+ self, *, project_id: typing.Optional[str] = None, organization_id: typing.Optional[str] = None
278
+ ) -> ExtractAgent:
279
+ """
280
+ Get or create a default extraction agent for the current project.
281
+ The default agent has an empty schema and default configuration.
282
+
283
+ Parameters:
284
+ - project_id: typing.Optional[str].
285
+
286
+ - organization_id: typing.Optional[str].
287
+ ---
288
+ from llama_cloud.client import LlamaCloud
289
+
290
+ client = LlamaCloud(
291
+ token="YOUR_TOKEN",
292
+ )
293
+ client.llama_extract.get_or_create_default_extraction_agent()
294
+ """
295
+ _response = self._client_wrapper.httpx_client.request(
296
+ "GET",
297
+ urllib.parse.urljoin(
298
+ f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/extraction-agents/default"
299
+ ),
300
+ params=remove_none_from_dict({"project_id": project_id, "organization_id": organization_id}),
301
+ headers=self._client_wrapper.get_headers(),
302
+ timeout=60,
303
+ )
304
+ if 200 <= _response.status_code < 300:
305
+ return pydantic.parse_obj_as(ExtractAgent, _response.json()) # type: ignore
306
+ if _response.status_code == 422:
307
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
308
+ try:
309
+ _response_json = _response.json()
310
+ except JSONDecodeError:
311
+ raise ApiError(status_code=_response.status_code, body=_response.text)
312
+ raise ApiError(status_code=_response.status_code, body=_response_json)
313
+
268
314
  def get_extraction_agent(self, extraction_agent_id: str) -> ExtractAgent:
269
315
  """
270
316
  Parameters:
@@ -992,10 +1038,16 @@ class AsyncLlamaExtractClient:
992
1038
  self._client_wrapper = client_wrapper
993
1039
 
994
1040
  async def list_extraction_agents(
995
- self, *, project_id: typing.Optional[str] = None, organization_id: typing.Optional[str] = None
1041
+ self,
1042
+ *,
1043
+ include_default: typing.Optional[bool] = None,
1044
+ project_id: typing.Optional[str] = None,
1045
+ organization_id: typing.Optional[str] = None,
996
1046
  ) -> typing.List[ExtractAgent]:
997
1047
  """
998
1048
  Parameters:
1049
+ - include_default: typing.Optional[bool]. Whether to include default agents in the results
1050
+
999
1051
  - project_id: typing.Optional[str].
1000
1052
 
1001
1053
  - organization_id: typing.Optional[str].
@@ -1010,7 +1062,9 @@ class AsyncLlamaExtractClient:
1010
1062
  _response = await self._client_wrapper.httpx_client.request(
1011
1063
  "GET",
1012
1064
  urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/extraction-agents"),
1013
- params=remove_none_from_dict({"project_id": project_id, "organization_id": organization_id}),
1065
+ params=remove_none_from_dict(
1066
+ {"include_default": include_default, "project_id": project_id, "organization_id": organization_id}
1067
+ ),
1014
1068
  headers=self._client_wrapper.get_headers(),
1015
1069
  timeout=60,
1016
1070
  )
@@ -1212,6 +1266,44 @@ class AsyncLlamaExtractClient:
1212
1266
  raise ApiError(status_code=_response.status_code, body=_response.text)
1213
1267
  raise ApiError(status_code=_response.status_code, body=_response_json)
1214
1268
 
1269
+ async def get_or_create_default_extraction_agent(
1270
+ self, *, project_id: typing.Optional[str] = None, organization_id: typing.Optional[str] = None
1271
+ ) -> ExtractAgent:
1272
+ """
1273
+ Get or create a default extraction agent for the current project.
1274
+ The default agent has an empty schema and default configuration.
1275
+
1276
+ Parameters:
1277
+ - project_id: typing.Optional[str].
1278
+
1279
+ - organization_id: typing.Optional[str].
1280
+ ---
1281
+ from llama_cloud.client import AsyncLlamaCloud
1282
+
1283
+ client = AsyncLlamaCloud(
1284
+ token="YOUR_TOKEN",
1285
+ )
1286
+ await client.llama_extract.get_or_create_default_extraction_agent()
1287
+ """
1288
+ _response = await self._client_wrapper.httpx_client.request(
1289
+ "GET",
1290
+ urllib.parse.urljoin(
1291
+ f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/extraction-agents/default"
1292
+ ),
1293
+ params=remove_none_from_dict({"project_id": project_id, "organization_id": organization_id}),
1294
+ headers=self._client_wrapper.get_headers(),
1295
+ timeout=60,
1296
+ )
1297
+ if 200 <= _response.status_code < 300:
1298
+ return pydantic.parse_obj_as(ExtractAgent, _response.json()) # type: ignore
1299
+ if _response.status_code == 422:
1300
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
1301
+ try:
1302
+ _response_json = _response.json()
1303
+ except JSONDecodeError:
1304
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1305
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1306
+
1215
1307
  async def get_extraction_agent(self, extraction_agent_id: str) -> ExtractAgent:
1216
1308
  """
1217
1309
  Parameters:
@@ -41,7 +41,12 @@ from .chat_app_response import ChatAppResponse
41
41
  from .chat_data import ChatData
42
42
  from .chunk_mode import ChunkMode
43
43
  from .classification_result import ClassificationResult
44
- from .classify_response import ClassifyResponse
44
+ from .classifier_rule import ClassifierRule
45
+ from .classify_job import ClassifyJob
46
+ from .classify_job_results import ClassifyJobResults
47
+ from .classify_job_with_status import ClassifyJobWithStatus
48
+ from .classify_parsing_configuration import ClassifyParsingConfiguration
49
+ from .cloud_astra_db_vector_store import CloudAstraDbVectorStore
45
50
  from .cloud_az_storage_blob_data_source import CloudAzStorageBlobDataSource
46
51
  from .cloud_azure_ai_search_vector_store import CloudAzureAiSearchVectorStore
47
52
  from .cloud_box_data_source import CloudBoxDataSource
@@ -139,13 +144,22 @@ from .extract_schema_validate_response_data_schema_value import ExtractSchemaVal
139
144
  from .extract_state import ExtractState
140
145
  from .extract_target import ExtractTarget
141
146
  from .fail_page_mode import FailPageMode
147
+ from .failure_handling_config import FailureHandlingConfig
142
148
  from .file import File
149
+ from .file_classification import FileClassification
143
150
  from .file_count_by_status_response import FileCountByStatusResponse
151
+ from .file_create import FileCreate
152
+ from .file_create_permission_info_value import FileCreatePermissionInfoValue
153
+ from .file_create_resource_info_value import FileCreateResourceInfoValue
144
154
  from .file_data import FileData
155
+ from .file_filter import FileFilter
145
156
  from .file_id_presigned_url import FileIdPresignedUrl
146
157
  from .file_parse_public import FileParsePublic
147
158
  from .file_permission_info_value import FilePermissionInfoValue
159
+ from .file_query_response import FileQueryResponse
148
160
  from .file_resource_info_value import FileResourceInfoValue
161
+ from .file_store_info_response import FileStoreInfoResponse
162
+ from .file_store_info_response_status import FileStoreInfoResponseStatus
149
163
  from .filter_condition import FilterCondition
150
164
  from .filter_operation import FilterOperation
151
165
  from .filter_operation_eq import FilterOperationEq
@@ -184,6 +198,8 @@ from .job_record_with_usage_metrics import JobRecordWithUsageMetrics
184
198
  from .l_lama_parse_transform_config import LLamaParseTransformConfig
185
199
  from .legacy_parse_job_config import LegacyParseJobConfig
186
200
  from .license_info_response import LicenseInfoResponse
201
+ from .llama_extract_mode_availability import LlamaExtractModeAvailability
202
+ from .llama_extract_mode_availability_status import LlamaExtractModeAvailabilityStatus
187
203
  from .llama_extract_settings import LlamaExtractSettings
188
204
  from .llama_index_core_base_llms_types_chat_message import LlamaIndexCoreBaseLlmsTypesChatMessage
189
205
  from .llama_index_core_base_llms_types_chat_message_blocks_item import (
@@ -418,7 +434,12 @@ __all__ = [
418
434
  "ChatData",
419
435
  "ChunkMode",
420
436
  "ClassificationResult",
421
- "ClassifyResponse",
437
+ "ClassifierRule",
438
+ "ClassifyJob",
439
+ "ClassifyJobResults",
440
+ "ClassifyJobWithStatus",
441
+ "ClassifyParsingConfiguration",
442
+ "CloudAstraDbVectorStore",
422
443
  "CloudAzStorageBlobDataSource",
423
444
  "CloudAzureAiSearchVectorStore",
424
445
  "CloudBoxDataSource",
@@ -512,13 +533,22 @@ __all__ = [
512
533
  "ExtractState",
513
534
  "ExtractTarget",
514
535
  "FailPageMode",
536
+ "FailureHandlingConfig",
515
537
  "File",
538
+ "FileClassification",
516
539
  "FileCountByStatusResponse",
540
+ "FileCreate",
541
+ "FileCreatePermissionInfoValue",
542
+ "FileCreateResourceInfoValue",
517
543
  "FileData",
544
+ "FileFilter",
518
545
  "FileIdPresignedUrl",
519
546
  "FileParsePublic",
520
547
  "FilePermissionInfoValue",
548
+ "FileQueryResponse",
521
549
  "FileResourceInfoValue",
550
+ "FileStoreInfoResponse",
551
+ "FileStoreInfoResponseStatus",
522
552
  "FilterCondition",
523
553
  "FilterOperation",
524
554
  "FilterOperationEq",
@@ -555,6 +585,8 @@ __all__ = [
555
585
  "LLamaParseTransformConfig",
556
586
  "LegacyParseJobConfig",
557
587
  "LicenseInfoResponse",
588
+ "LlamaExtractModeAvailability",
589
+ "LlamaExtractModeAvailabilityStatus",
558
590
  "LlamaExtractSettings",
559
591
  "LlamaIndexCoreBaseLlmsTypesChatMessage",
560
592
  "LlamaIndexCoreBaseLlmsTypesChatMessageBlocksItem",
@@ -17,14 +17,13 @@ except ImportError:
17
17
  class ClassificationResult(pydantic.BaseModel):
18
18
  """
19
19
  Result of classifying a single file.
20
-
21
- Contains the classification outcome with confidence score and matched rule info.
22
20
  """
23
21
 
24
- file_id: str = pydantic.Field(description="The ID of the classified file")
25
- type: str = pydantic.Field(description="The assigned document type ('unknown' if no rules matched)")
22
+ reasoning: str = pydantic.Field(
23
+ description="Step-by-step explanation of why this classification was chosen and the confidence score assigned"
24
+ )
26
25
  confidence: float = pydantic.Field(description="Confidence score of the classification (0.0-1.0)")
27
- matched_rule: typing.Optional[str]
26
+ type: typing.Optional[str]
28
27
 
29
28
  def json(self, **kwargs: typing.Any) -> str:
30
29
  kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
@@ -0,0 +1,43 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ import typing
5
+
6
+ from ..core.datetime_utils import serialize_datetime
7
+
8
+ try:
9
+ import pydantic
10
+ if pydantic.__version__.startswith("1."):
11
+ raise ImportError
12
+ import pydantic.v1 as pydantic # type: ignore
13
+ except ImportError:
14
+ import pydantic # type: ignore
15
+
16
+
17
+ class ClassifierRule(pydantic.BaseModel):
18
+ """
19
+ A rule for classifying documents - v0 simplified version.
20
+
21
+ This represents a single classification rule that will be applied to documents.
22
+ All rules are content-based and use natural language descriptions.
23
+ """
24
+
25
+ type: str = pydantic.Field(
26
+ description="The document type to assign when this rule matches (e.g., 'invoice', 'receipt', 'contract')"
27
+ )
28
+ description: str = pydantic.Field(
29
+ description="Natural language description of what to classify. Be specific about the content characteristics that identify this document type."
30
+ )
31
+
32
+ def json(self, **kwargs: typing.Any) -> str:
33
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
34
+ return super().json(**kwargs_with_defaults)
35
+
36
+ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
37
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
38
+ return super().dict(**kwargs_with_defaults)
39
+
40
+ class Config:
41
+ frozen = True
42
+ smart_union = True
43
+ json_encoders = {dt.datetime: serialize_datetime}
@@ -0,0 +1,45 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ import typing
5
+
6
+ from ..core.datetime_utils import serialize_datetime
7
+ from .classifier_rule import ClassifierRule
8
+ from .classify_parsing_configuration import ClassifyParsingConfiguration
9
+
10
+ try:
11
+ import pydantic
12
+ if pydantic.__version__.startswith("1."):
13
+ raise ImportError
14
+ import pydantic.v1 as pydantic # type: ignore
15
+ except ImportError:
16
+ import pydantic # type: ignore
17
+
18
+
19
+ class ClassifyJob(pydantic.BaseModel):
20
+ """
21
+ A classify job.
22
+ """
23
+
24
+ id: str = pydantic.Field(description="Unique identifier")
25
+ created_at: typing.Optional[dt.datetime]
26
+ updated_at: typing.Optional[dt.datetime]
27
+ rules: typing.List[ClassifierRule] = pydantic.Field(description="The rules to classify the files")
28
+ user_id: str = pydantic.Field(description="The ID of the user")
29
+ project_id: str = pydantic.Field(description="The ID of the project")
30
+ parsing_configuration: typing.Optional[ClassifyParsingConfiguration] = pydantic.Field(
31
+ description="The configuration for the parsing job"
32
+ )
33
+
34
+ def json(self, **kwargs: typing.Any) -> str:
35
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
36
+ return super().json(**kwargs_with_defaults)
37
+
38
+ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
39
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
40
+ return super().dict(**kwargs_with_defaults)
41
+
42
+ class Config:
43
+ frozen = True
44
+ smart_union = True
45
+ json_encoders = {dt.datetime: serialize_datetime}
@@ -4,7 +4,7 @@ import datetime as dt
4
4
  import typing
5
5
 
6
6
  from ..core.datetime_utils import serialize_datetime
7
- from .classification_result import ClassificationResult
7
+ from .file_classification import FileClassification
8
8
 
9
9
  try:
10
10
  import pydantic
@@ -15,17 +15,14 @@ except ImportError:
15
15
  import pydantic # type: ignore
16
16
 
17
17
 
18
- class ClassifyResponse(pydantic.BaseModel):
18
+ class ClassifyJobResults(pydantic.BaseModel):
19
19
  """
20
20
  Response model for the classify endpoint following AIP-132 pagination standard.
21
-
22
- Contains classification results with pagination support and summary statistics.
23
21
  """
24
22
 
25
- items: typing.List[ClassificationResult] = pydantic.Field(description="The list of items.")
23
+ items: typing.List[FileClassification] = pydantic.Field(description="The list of items.")
26
24
  next_page_token: typing.Optional[str]
27
25
  total_size: typing.Optional[int]
28
- unknown_count: int = pydantic.Field(description="Number of files that couldn't be classified")
29
26
 
30
27
  def json(self, **kwargs: typing.Any) -> str:
31
28
  kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
@@ -0,0 +1,47 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ import typing
5
+
6
+ from ..core.datetime_utils import serialize_datetime
7
+ from .classifier_rule import ClassifierRule
8
+ from .classify_parsing_configuration import ClassifyParsingConfiguration
9
+ from .status_enum import StatusEnum
10
+
11
+ try:
12
+ import pydantic
13
+ if pydantic.__version__.startswith("1."):
14
+ raise ImportError
15
+ import pydantic.v1 as pydantic # type: ignore
16
+ except ImportError:
17
+ import pydantic # type: ignore
18
+
19
+
20
+ class ClassifyJobWithStatus(pydantic.BaseModel):
21
+ """
22
+ A classify job with status.
23
+ """
24
+
25
+ id: str = pydantic.Field(description="Unique identifier")
26
+ created_at: typing.Optional[dt.datetime]
27
+ updated_at: typing.Optional[dt.datetime]
28
+ rules: typing.List[ClassifierRule] = pydantic.Field(description="The rules to classify the files")
29
+ user_id: str = pydantic.Field(description="The ID of the user")
30
+ project_id: str = pydantic.Field(description="The ID of the project")
31
+ parsing_configuration: typing.Optional[ClassifyParsingConfiguration] = pydantic.Field(
32
+ description="The configuration for the parsing job"
33
+ )
34
+ status: StatusEnum = pydantic.Field(description="The status of the classify job")
35
+
36
+ def json(self, **kwargs: typing.Any) -> str:
37
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
38
+ return super().json(**kwargs_with_defaults)
39
+
40
+ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
41
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
42
+ return super().dict(**kwargs_with_defaults)
43
+
44
+ class Config:
45
+ frozen = True
46
+ smart_union = True
47
+ json_encoders = {dt.datetime: serialize_datetime}
@@ -0,0 +1,38 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ import typing
5
+
6
+ from ..core.datetime_utils import serialize_datetime
7
+ from .parser_languages import ParserLanguages
8
+
9
+ try:
10
+ import pydantic
11
+ if pydantic.__version__.startswith("1."):
12
+ raise ImportError
13
+ import pydantic.v1 as pydantic # type: ignore
14
+ except ImportError:
15
+ import pydantic # type: ignore
16
+
17
+
18
+ class ClassifyParsingConfiguration(pydantic.BaseModel):
19
+ """
20
+ Parsing configuration for a classify job.
21
+ """
22
+
23
+ lang: typing.Optional[ParserLanguages] = pydantic.Field(description="The language to parse the files in")
24
+ max_pages: typing.Optional[int]
25
+ target_pages: typing.Optional[typing.List[int]]
26
+
27
+ def json(self, **kwargs: typing.Any) -> str:
28
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
29
+ return super().json(**kwargs_with_defaults)
30
+
31
+ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
32
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
33
+ return super().dict(**kwargs_with_defaults)
34
+
35
+ class Config:
36
+ frozen = True
37
+ smart_union = True
38
+ json_encoders = {dt.datetime: serialize_datetime}