llama-cloud 0.1.34__py3-none-any.whl → 0.1.36__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 (60) hide show
  1. llama_cloud/__init__.py +54 -2
  2. llama_cloud/client.py +3 -0
  3. llama_cloud/resources/__init__.py +6 -0
  4. llama_cloud/resources/admin/client.py +51 -0
  5. llama_cloud/resources/beta/client.py +211 -8
  6. llama_cloud/resources/classifier/client.py +231 -181
  7. llama_cloud/resources/data_sinks/types/data_sink_update_component.py +2 -0
  8. llama_cloud/resources/files/client.py +226 -0
  9. llama_cloud/resources/llama_extract/__init__.py +4 -0
  10. llama_cloud/resources/llama_extract/client.py +275 -4
  11. llama_cloud/resources/llama_extract/types/__init__.py +4 -0
  12. llama_cloud/resources/llama_extract/types/extract_stateless_request_data_schema.py +9 -0
  13. llama_cloud/resources/llama_extract/types/extract_stateless_request_data_schema_zero_value.py +7 -0
  14. llama_cloud/resources/parsing/client.py +24 -0
  15. llama_cloud/resources/users/__init__.py +2 -0
  16. llama_cloud/resources/users/client.py +155 -0
  17. llama_cloud/types/__init__.py +48 -2
  18. llama_cloud/types/classification_result.py +4 -5
  19. llama_cloud/types/classifier_rule.py +43 -0
  20. llama_cloud/types/classify_job.py +45 -0
  21. llama_cloud/types/{classify_response.py → classify_job_results.py} +3 -6
  22. llama_cloud/types/classify_job_with_status.py +47 -0
  23. llama_cloud/types/classify_parsing_configuration.py +38 -0
  24. llama_cloud/types/cloud_astra_db_vector_store.py +51 -0
  25. llama_cloud/types/cloud_confluence_data_source.py +15 -0
  26. llama_cloud/types/configurable_data_sink_names.py +4 -0
  27. llama_cloud/types/data_sink_component.py +2 -0
  28. llama_cloud/types/data_sink_create_component.py +2 -0
  29. llama_cloud/types/data_source_reader_version_metadata.py +2 -1
  30. llama_cloud/types/data_source_reader_version_metadata_reader_version.py +17 -0
  31. llama_cloud/types/extract_agent.py +3 -0
  32. llama_cloud/types/extract_config.py +4 -0
  33. llama_cloud/types/failure_handling_config.py +37 -0
  34. llama_cloud/types/file_classification.py +41 -0
  35. llama_cloud/types/file_data.py +36 -0
  36. llama_cloud/types/file_store_info_response.py +34 -0
  37. llama_cloud/types/file_store_info_response_status.py +25 -0
  38. llama_cloud/types/legacy_parse_job_config.py +3 -0
  39. llama_cloud/types/llama_extract_settings.py +4 -0
  40. llama_cloud/types/llama_parse_parameters.py +3 -0
  41. llama_cloud/types/managed_open_ai_embedding.py +36 -0
  42. llama_cloud/types/managed_open_ai_embedding_config.py +34 -0
  43. llama_cloud/types/multimodal_parse_resolution.py +17 -0
  44. llama_cloud/types/paginated_response_quota_configuration.py +36 -0
  45. llama_cloud/types/parse_job_config.py +3 -0
  46. llama_cloud/types/pipeline_embedding_config.py +11 -0
  47. llama_cloud/types/quota_configuration.py +53 -0
  48. llama_cloud/types/quota_configuration_configuration_type.py +33 -0
  49. llama_cloud/types/quota_configuration_status.py +21 -0
  50. llama_cloud/types/quota_rate_limit_configuration_value.py +38 -0
  51. llama_cloud/types/quota_rate_limit_configuration_value_denominator_units.py +29 -0
  52. llama_cloud/types/supported_llm_model_names.py +12 -0
  53. llama_cloud/types/update_user_response.py +33 -0
  54. llama_cloud/types/usage_response_active_alerts_item.py +4 -0
  55. llama_cloud/types/user_summary.py +38 -0
  56. llama_cloud/types/webhook_configuration_webhook_events_item.py +20 -0
  57. {llama_cloud-0.1.34.dist-info → llama_cloud-0.1.36.dist-info}/METADATA +2 -4
  58. {llama_cloud-0.1.34.dist-info → llama_cloud-0.1.36.dist-info}/RECORD +60 -34
  59. {llama_cloud-0.1.34.dist-info → llama_cloud-0.1.36.dist-info}/WHEEL +1 -1
  60. {llama_cloud-0.1.34.dist-info → llama_cloud-0.1.36.dist-info}/LICENSE +0 -0
@@ -207,6 +207,9 @@ class FilesClient:
207
207
  """
208
208
  Create a presigned url for uploading a file.
209
209
 
210
+ The presigned url is valid for a limited time period, after which it will expire.
211
+ Be careful on accidental exposure of the presigned url, as it may allow unauthorized access to the file before the expiration.
212
+
210
213
  Parameters:
211
214
  - expires_at_seconds: typing.Optional[int].
212
215
 
@@ -658,6 +661,116 @@ class FilesClient:
658
661
  raise ApiError(status_code=_response.status_code, body=_response.text)
659
662
  raise ApiError(status_code=_response.status_code, body=_response_json)
660
663
 
664
+ def generate_file_page_screenshot_presigned_url(
665
+ self,
666
+ id: str,
667
+ page_index: int,
668
+ *,
669
+ project_id: typing.Optional[str] = None,
670
+ organization_id: typing.Optional[str] = None,
671
+ ) -> PresignedUrl:
672
+ """
673
+ Returns a presigned url to read a page screenshot.
674
+
675
+ The presigned url is valid for a limited time period, after which it will expire.
676
+ Be careful on accidental exposure of the presigned url, as it may allow unauthorized access to the file before the expiration.
677
+
678
+ Parameters:
679
+ - id: str.
680
+
681
+ - page_index: int.
682
+
683
+ - project_id: typing.Optional[str].
684
+
685
+ - organization_id: typing.Optional[str].
686
+ ---
687
+ from llama_cloud.client import LlamaCloud
688
+
689
+ client = LlamaCloud(
690
+ token="YOUR_TOKEN",
691
+ )
692
+ client.files.generate_file_page_screenshot_presigned_url(
693
+ id="string",
694
+ page_index=1,
695
+ )
696
+ """
697
+ _response = self._client_wrapper.httpx_client.request(
698
+ "POST",
699
+ urllib.parse.urljoin(
700
+ f"{self._client_wrapper.get_base_url()}/",
701
+ f"api/v1/files/{id}/page_screenshots/{page_index}/presigned_url",
702
+ ),
703
+ params=remove_none_from_dict({"project_id": project_id, "organization_id": organization_id}),
704
+ headers=self._client_wrapper.get_headers(),
705
+ timeout=60,
706
+ )
707
+ if 200 <= _response.status_code < 300:
708
+ return pydantic.parse_obj_as(PresignedUrl, _response.json()) # type: ignore
709
+ if _response.status_code == 422:
710
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
711
+ try:
712
+ _response_json = _response.json()
713
+ except JSONDecodeError:
714
+ raise ApiError(status_code=_response.status_code, body=_response.text)
715
+ raise ApiError(status_code=_response.status_code, body=_response_json)
716
+
717
+ def generate_file_page_figure_presigned_url(
718
+ self,
719
+ id: str,
720
+ page_index: int,
721
+ figure_name: str,
722
+ *,
723
+ project_id: typing.Optional[str] = None,
724
+ organization_id: typing.Optional[str] = None,
725
+ ) -> PresignedUrl:
726
+ """
727
+ Returns a presigned url to read a page figure.
728
+
729
+ The presigned url is valid for a limited time period, after which it will expire.
730
+ Be careful on accidental exposure of the presigned url, as it may allow unauthorized access to the file before the expiration.
731
+
732
+ Parameters:
733
+ - id: str.
734
+
735
+ - page_index: int.
736
+
737
+ - figure_name: str.
738
+
739
+ - project_id: typing.Optional[str].
740
+
741
+ - organization_id: typing.Optional[str].
742
+ ---
743
+ from llama_cloud.client import LlamaCloud
744
+
745
+ client = LlamaCloud(
746
+ token="YOUR_TOKEN",
747
+ )
748
+ client.files.generate_file_page_figure_presigned_url(
749
+ id="string",
750
+ page_index=1,
751
+ figure_name="string",
752
+ )
753
+ """
754
+ _response = self._client_wrapper.httpx_client.request(
755
+ "POST",
756
+ urllib.parse.urljoin(
757
+ f"{self._client_wrapper.get_base_url()}/",
758
+ f"api/v1/files/{id}/page-figures/{page_index}/{figure_name}/presigned_url",
759
+ ),
760
+ params=remove_none_from_dict({"project_id": project_id, "organization_id": organization_id}),
761
+ headers=self._client_wrapper.get_headers(),
762
+ timeout=60,
763
+ )
764
+ if 200 <= _response.status_code < 300:
765
+ return pydantic.parse_obj_as(PresignedUrl, _response.json()) # type: ignore
766
+ if _response.status_code == 422:
767
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
768
+ try:
769
+ _response_json = _response.json()
770
+ except JSONDecodeError:
771
+ raise ApiError(status_code=_response.status_code, body=_response.text)
772
+ raise ApiError(status_code=_response.status_code, body=_response_json)
773
+
661
774
 
662
775
  class AsyncFilesClient:
663
776
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
@@ -834,6 +947,9 @@ class AsyncFilesClient:
834
947
  """
835
948
  Create a presigned url for uploading a file.
836
949
 
950
+ The presigned url is valid for a limited time period, after which it will expire.
951
+ Be careful on accidental exposure of the presigned url, as it may allow unauthorized access to the file before the expiration.
952
+
837
953
  Parameters:
838
954
  - expires_at_seconds: typing.Optional[int].
839
955
 
@@ -1284,3 +1400,113 @@ class AsyncFilesClient:
1284
1400
  except JSONDecodeError:
1285
1401
  raise ApiError(status_code=_response.status_code, body=_response.text)
1286
1402
  raise ApiError(status_code=_response.status_code, body=_response_json)
1403
+
1404
+ async def generate_file_page_screenshot_presigned_url(
1405
+ self,
1406
+ id: str,
1407
+ page_index: int,
1408
+ *,
1409
+ project_id: typing.Optional[str] = None,
1410
+ organization_id: typing.Optional[str] = None,
1411
+ ) -> PresignedUrl:
1412
+ """
1413
+ Returns a presigned url to read a page screenshot.
1414
+
1415
+ The presigned url is valid for a limited time period, after which it will expire.
1416
+ Be careful on accidental exposure of the presigned url, as it may allow unauthorized access to the file before the expiration.
1417
+
1418
+ Parameters:
1419
+ - id: str.
1420
+
1421
+ - page_index: int.
1422
+
1423
+ - project_id: typing.Optional[str].
1424
+
1425
+ - organization_id: typing.Optional[str].
1426
+ ---
1427
+ from llama_cloud.client import AsyncLlamaCloud
1428
+
1429
+ client = AsyncLlamaCloud(
1430
+ token="YOUR_TOKEN",
1431
+ )
1432
+ await client.files.generate_file_page_screenshot_presigned_url(
1433
+ id="string",
1434
+ page_index=1,
1435
+ )
1436
+ """
1437
+ _response = await self._client_wrapper.httpx_client.request(
1438
+ "POST",
1439
+ urllib.parse.urljoin(
1440
+ f"{self._client_wrapper.get_base_url()}/",
1441
+ f"api/v1/files/{id}/page_screenshots/{page_index}/presigned_url",
1442
+ ),
1443
+ params=remove_none_from_dict({"project_id": project_id, "organization_id": organization_id}),
1444
+ headers=self._client_wrapper.get_headers(),
1445
+ timeout=60,
1446
+ )
1447
+ if 200 <= _response.status_code < 300:
1448
+ return pydantic.parse_obj_as(PresignedUrl, _response.json()) # type: ignore
1449
+ if _response.status_code == 422:
1450
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
1451
+ try:
1452
+ _response_json = _response.json()
1453
+ except JSONDecodeError:
1454
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1455
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1456
+
1457
+ async def generate_file_page_figure_presigned_url(
1458
+ self,
1459
+ id: str,
1460
+ page_index: int,
1461
+ figure_name: str,
1462
+ *,
1463
+ project_id: typing.Optional[str] = None,
1464
+ organization_id: typing.Optional[str] = None,
1465
+ ) -> PresignedUrl:
1466
+ """
1467
+ Returns a presigned url to read a page figure.
1468
+
1469
+ The presigned url is valid for a limited time period, after which it will expire.
1470
+ Be careful on accidental exposure of the presigned url, as it may allow unauthorized access to the file before the expiration.
1471
+
1472
+ Parameters:
1473
+ - id: str.
1474
+
1475
+ - page_index: int.
1476
+
1477
+ - figure_name: str.
1478
+
1479
+ - project_id: typing.Optional[str].
1480
+
1481
+ - organization_id: typing.Optional[str].
1482
+ ---
1483
+ from llama_cloud.client import AsyncLlamaCloud
1484
+
1485
+ client = AsyncLlamaCloud(
1486
+ token="YOUR_TOKEN",
1487
+ )
1488
+ await client.files.generate_file_page_figure_presigned_url(
1489
+ id="string",
1490
+ page_index=1,
1491
+ figure_name="string",
1492
+ )
1493
+ """
1494
+ _response = await self._client_wrapper.httpx_client.request(
1495
+ "POST",
1496
+ urllib.parse.urljoin(
1497
+ f"{self._client_wrapper.get_base_url()}/",
1498
+ f"api/v1/files/{id}/page-figures/{page_index}/{figure_name}/presigned_url",
1499
+ ),
1500
+ params=remove_none_from_dict({"project_id": project_id, "organization_id": organization_id}),
1501
+ headers=self._client_wrapper.get_headers(),
1502
+ timeout=60,
1503
+ )
1504
+ if 200 <= _response.status_code < 300:
1505
+ return pydantic.parse_obj_as(PresignedUrl, _response.json()) # type: ignore
1506
+ if _response.status_code == 422:
1507
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
1508
+ try:
1509
+ _response_json = _response.json()
1510
+ except JSONDecodeError:
1511
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1512
+ raise ApiError(status_code=_response.status_code, body=_response_json)
@@ -9,6 +9,8 @@ from .types import (
9
9
  ExtractJobCreateBatchDataSchemaOverrideZeroValue,
10
10
  ExtractSchemaValidateRequestDataSchema,
11
11
  ExtractSchemaValidateRequestDataSchemaZeroValue,
12
+ ExtractStatelessRequestDataSchema,
13
+ ExtractStatelessRequestDataSchemaZeroValue,
12
14
  )
13
15
 
14
16
  __all__ = [
@@ -20,4 +22,6 @@ __all__ = [
20
22
  "ExtractJobCreateBatchDataSchemaOverrideZeroValue",
21
23
  "ExtractSchemaValidateRequestDataSchema",
22
24
  "ExtractSchemaValidateRequestDataSchemaZeroValue",
25
+ "ExtractStatelessRequestDataSchema",
26
+ "ExtractStatelessRequestDataSchemaZeroValue",
23
27
  ]
@@ -17,13 +17,16 @@ from ...types.extract_resultset import ExtractResultset
17
17
  from ...types.extract_run import ExtractRun
18
18
  from ...types.extract_schema_generate_response import ExtractSchemaGenerateResponse
19
19
  from ...types.extract_schema_validate_response import ExtractSchemaValidateResponse
20
+ from ...types.file_data import FileData
20
21
  from ...types.http_validation_error import HttpValidationError
21
22
  from ...types.llama_extract_settings import LlamaExtractSettings
22
23
  from ...types.paginated_extract_runs_response import PaginatedExtractRunsResponse
24
+ from ...types.webhook_configuration import WebhookConfiguration
23
25
  from .types.extract_agent_create_data_schema import ExtractAgentCreateDataSchema
24
26
  from .types.extract_agent_update_data_schema import ExtractAgentUpdateDataSchema
25
27
  from .types.extract_job_create_batch_data_schema_override import ExtractJobCreateBatchDataSchemaOverride
26
28
  from .types.extract_schema_validate_request_data_schema import ExtractSchemaValidateRequestDataSchema
29
+ from .types.extract_stateless_request_data_schema import ExtractStatelessRequestDataSchema
27
30
 
28
31
  try:
29
32
  import pydantic
@@ -42,10 +45,16 @@ class LlamaExtractClient:
42
45
  self._client_wrapper = client_wrapper
43
46
 
44
47
  def list_extraction_agents(
45
- 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,
46
53
  ) -> typing.List[ExtractAgent]:
47
54
  """
48
55
  Parameters:
56
+ - include_default: typing.Optional[bool]. Whether to include default agents in the results
57
+
49
58
  - project_id: typing.Optional[str].
50
59
 
51
60
  - organization_id: typing.Optional[str].
@@ -60,7 +69,9 @@ class LlamaExtractClient:
60
69
  _response = self._client_wrapper.httpx_client.request(
61
70
  "GET",
62
71
  urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/extraction-agents"),
63
- 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
+ ),
64
75
  headers=self._client_wrapper.get_headers(),
65
76
  timeout=60,
66
77
  )
@@ -262,6 +273,44 @@ class LlamaExtractClient:
262
273
  raise ApiError(status_code=_response.status_code, body=_response.text)
263
274
  raise ApiError(status_code=_response.status_code, body=_response_json)
264
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
+
265
314
  def get_extraction_agent(self, extraction_agent_id: str) -> ExtractAgent:
266
315
  """
267
316
  Parameters:
@@ -517,6 +566,7 @@ class LlamaExtractClient:
517
566
  LlamaExtractSettings,
518
567
  LlamaParseParameters,
519
568
  LlamaParseParametersPriority,
569
+ MultimodalParseResolution,
520
570
  ParsingMode,
521
571
  )
522
572
  from llama_cloud.client import LlamaCloud
@@ -542,6 +592,7 @@ class LlamaExtractClient:
542
592
  parse_mode=ParsingMode.PARSE_PAGE_WITHOUT_LLM,
543
593
  replace_failed_page_mode=FailPageMode.RAW_TEXT,
544
594
  ),
595
+ multimodal_parse_resolution=MultimodalParseResolution.MEDIUM,
545
596
  ),
546
597
  )
547
598
  """
@@ -895,16 +946,108 @@ class LlamaExtractClient:
895
946
  raise ApiError(status_code=_response.status_code, body=_response.text)
896
947
  raise ApiError(status_code=_response.status_code, body=_response_json)
897
948
 
949
+ def extract_stateless(
950
+ self,
951
+ *,
952
+ project_id: typing.Optional[str] = None,
953
+ organization_id: typing.Optional[str] = None,
954
+ webhook_configurations: typing.Optional[typing.List[WebhookConfiguration]] = OMIT,
955
+ data_schema: ExtractStatelessRequestDataSchema,
956
+ config: ExtractConfig,
957
+ file_id: typing.Optional[str] = OMIT,
958
+ text: typing.Optional[str] = OMIT,
959
+ file: typing.Optional[FileData] = OMIT,
960
+ ) -> ExtractJob:
961
+ """
962
+ Stateless extraction endpoint that uses a default extraction agent in the user's default project.
963
+ Requires data_schema, config, and either file_id, text, or base64 encoded file data.
964
+
965
+ Parameters:
966
+ - project_id: typing.Optional[str].
967
+
968
+ - organization_id: typing.Optional[str].
969
+
970
+ - webhook_configurations: typing.Optional[typing.List[WebhookConfiguration]].
971
+
972
+ - data_schema: ExtractStatelessRequestDataSchema. The schema of the data to extract
973
+
974
+ - config: ExtractConfig. The configuration parameters for the extraction
975
+
976
+ - file_id: typing.Optional[str].
977
+
978
+ - text: typing.Optional[str].
979
+
980
+ - file: typing.Optional[FileData].
981
+ ---
982
+ from llama_cloud import (
983
+ DocumentChunkMode,
984
+ ExtractConfig,
985
+ ExtractConfigPriority,
986
+ ExtractMode,
987
+ ExtractTarget,
988
+ FileData,
989
+ )
990
+ from llama_cloud.client import LlamaCloud
991
+
992
+ client = LlamaCloud(
993
+ token="YOUR_TOKEN",
994
+ )
995
+ client.llama_extract.extract_stateless(
996
+ config=ExtractConfig(
997
+ priority=ExtractConfigPriority.LOW,
998
+ extraction_target=ExtractTarget.PER_DOC,
999
+ extraction_mode=ExtractMode.FAST,
1000
+ chunk_mode=DocumentChunkMode.PAGE,
1001
+ ),
1002
+ file=FileData(
1003
+ data="string",
1004
+ mime_type="string",
1005
+ ),
1006
+ )
1007
+ """
1008
+ _request: typing.Dict[str, typing.Any] = {"data_schema": data_schema, "config": config}
1009
+ if webhook_configurations is not OMIT:
1010
+ _request["webhook_configurations"] = webhook_configurations
1011
+ if file_id is not OMIT:
1012
+ _request["file_id"] = file_id
1013
+ if text is not OMIT:
1014
+ _request["text"] = text
1015
+ if file is not OMIT:
1016
+ _request["file"] = file
1017
+ _response = self._client_wrapper.httpx_client.request(
1018
+ "POST",
1019
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/run"),
1020
+ params=remove_none_from_dict({"project_id": project_id, "organization_id": organization_id}),
1021
+ json=jsonable_encoder(_request),
1022
+ headers=self._client_wrapper.get_headers(),
1023
+ timeout=60,
1024
+ )
1025
+ if 200 <= _response.status_code < 300:
1026
+ return pydantic.parse_obj_as(ExtractJob, _response.json()) # type: ignore
1027
+ if _response.status_code == 422:
1028
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
1029
+ try:
1030
+ _response_json = _response.json()
1031
+ except JSONDecodeError:
1032
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1033
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1034
+
898
1035
 
899
1036
  class AsyncLlamaExtractClient:
900
1037
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
901
1038
  self._client_wrapper = client_wrapper
902
1039
 
903
1040
  async def list_extraction_agents(
904
- 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,
905
1046
  ) -> typing.List[ExtractAgent]:
906
1047
  """
907
1048
  Parameters:
1049
+ - include_default: typing.Optional[bool]. Whether to include default agents in the results
1050
+
908
1051
  - project_id: typing.Optional[str].
909
1052
 
910
1053
  - organization_id: typing.Optional[str].
@@ -919,7 +1062,9 @@ class AsyncLlamaExtractClient:
919
1062
  _response = await self._client_wrapper.httpx_client.request(
920
1063
  "GET",
921
1064
  urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/extraction-agents"),
922
- 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
+ ),
923
1068
  headers=self._client_wrapper.get_headers(),
924
1069
  timeout=60,
925
1070
  )
@@ -1121,6 +1266,44 @@ class AsyncLlamaExtractClient:
1121
1266
  raise ApiError(status_code=_response.status_code, body=_response.text)
1122
1267
  raise ApiError(status_code=_response.status_code, body=_response_json)
1123
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
+
1124
1307
  async def get_extraction_agent(self, extraction_agent_id: str) -> ExtractAgent:
1125
1308
  """
1126
1309
  Parameters:
@@ -1376,6 +1559,7 @@ class AsyncLlamaExtractClient:
1376
1559
  LlamaExtractSettings,
1377
1560
  LlamaParseParameters,
1378
1561
  LlamaParseParametersPriority,
1562
+ MultimodalParseResolution,
1379
1563
  ParsingMode,
1380
1564
  )
1381
1565
  from llama_cloud.client import AsyncLlamaCloud
@@ -1401,6 +1585,7 @@ class AsyncLlamaExtractClient:
1401
1585
  parse_mode=ParsingMode.PARSE_PAGE_WITHOUT_LLM,
1402
1586
  replace_failed_page_mode=FailPageMode.RAW_TEXT,
1403
1587
  ),
1588
+ multimodal_parse_resolution=MultimodalParseResolution.MEDIUM,
1404
1589
  ),
1405
1590
  )
1406
1591
  """
@@ -1753,3 +1938,89 @@ class AsyncLlamaExtractClient:
1753
1938
  except JSONDecodeError:
1754
1939
  raise ApiError(status_code=_response.status_code, body=_response.text)
1755
1940
  raise ApiError(status_code=_response.status_code, body=_response_json)
1941
+
1942
+ async def extract_stateless(
1943
+ self,
1944
+ *,
1945
+ project_id: typing.Optional[str] = None,
1946
+ organization_id: typing.Optional[str] = None,
1947
+ webhook_configurations: typing.Optional[typing.List[WebhookConfiguration]] = OMIT,
1948
+ data_schema: ExtractStatelessRequestDataSchema,
1949
+ config: ExtractConfig,
1950
+ file_id: typing.Optional[str] = OMIT,
1951
+ text: typing.Optional[str] = OMIT,
1952
+ file: typing.Optional[FileData] = OMIT,
1953
+ ) -> ExtractJob:
1954
+ """
1955
+ Stateless extraction endpoint that uses a default extraction agent in the user's default project.
1956
+ Requires data_schema, config, and either file_id, text, or base64 encoded file data.
1957
+
1958
+ Parameters:
1959
+ - project_id: typing.Optional[str].
1960
+
1961
+ - organization_id: typing.Optional[str].
1962
+
1963
+ - webhook_configurations: typing.Optional[typing.List[WebhookConfiguration]].
1964
+
1965
+ - data_schema: ExtractStatelessRequestDataSchema. The schema of the data to extract
1966
+
1967
+ - config: ExtractConfig. The configuration parameters for the extraction
1968
+
1969
+ - file_id: typing.Optional[str].
1970
+
1971
+ - text: typing.Optional[str].
1972
+
1973
+ - file: typing.Optional[FileData].
1974
+ ---
1975
+ from llama_cloud import (
1976
+ DocumentChunkMode,
1977
+ ExtractConfig,
1978
+ ExtractConfigPriority,
1979
+ ExtractMode,
1980
+ ExtractTarget,
1981
+ FileData,
1982
+ )
1983
+ from llama_cloud.client import AsyncLlamaCloud
1984
+
1985
+ client = AsyncLlamaCloud(
1986
+ token="YOUR_TOKEN",
1987
+ )
1988
+ await client.llama_extract.extract_stateless(
1989
+ config=ExtractConfig(
1990
+ priority=ExtractConfigPriority.LOW,
1991
+ extraction_target=ExtractTarget.PER_DOC,
1992
+ extraction_mode=ExtractMode.FAST,
1993
+ chunk_mode=DocumentChunkMode.PAGE,
1994
+ ),
1995
+ file=FileData(
1996
+ data="string",
1997
+ mime_type="string",
1998
+ ),
1999
+ )
2000
+ """
2001
+ _request: typing.Dict[str, typing.Any] = {"data_schema": data_schema, "config": config}
2002
+ if webhook_configurations is not OMIT:
2003
+ _request["webhook_configurations"] = webhook_configurations
2004
+ if file_id is not OMIT:
2005
+ _request["file_id"] = file_id
2006
+ if text is not OMIT:
2007
+ _request["text"] = text
2008
+ if file is not OMIT:
2009
+ _request["file"] = file
2010
+ _response = await self._client_wrapper.httpx_client.request(
2011
+ "POST",
2012
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/run"),
2013
+ params=remove_none_from_dict({"project_id": project_id, "organization_id": organization_id}),
2014
+ json=jsonable_encoder(_request),
2015
+ headers=self._client_wrapper.get_headers(),
2016
+ timeout=60,
2017
+ )
2018
+ if 200 <= _response.status_code < 300:
2019
+ return pydantic.parse_obj_as(ExtractJob, _response.json()) # type: ignore
2020
+ if _response.status_code == 422:
2021
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
2022
+ try:
2023
+ _response_json = _response.json()
2024
+ except JSONDecodeError:
2025
+ raise ApiError(status_code=_response.status_code, body=_response.text)
2026
+ raise ApiError(status_code=_response.status_code, body=_response_json)
@@ -8,6 +8,8 @@ from .extract_job_create_batch_data_schema_override import ExtractJobCreateBatch
8
8
  from .extract_job_create_batch_data_schema_override_zero_value import ExtractJobCreateBatchDataSchemaOverrideZeroValue
9
9
  from .extract_schema_validate_request_data_schema import ExtractSchemaValidateRequestDataSchema
10
10
  from .extract_schema_validate_request_data_schema_zero_value import ExtractSchemaValidateRequestDataSchemaZeroValue
11
+ from .extract_stateless_request_data_schema import ExtractStatelessRequestDataSchema
12
+ from .extract_stateless_request_data_schema_zero_value import ExtractStatelessRequestDataSchemaZeroValue
11
13
 
12
14
  __all__ = [
13
15
  "ExtractAgentCreateDataSchema",
@@ -18,4 +20,6 @@ __all__ = [
18
20
  "ExtractJobCreateBatchDataSchemaOverrideZeroValue",
19
21
  "ExtractSchemaValidateRequestDataSchema",
20
22
  "ExtractSchemaValidateRequestDataSchemaZeroValue",
23
+ "ExtractStatelessRequestDataSchema",
24
+ "ExtractStatelessRequestDataSchemaZeroValue",
21
25
  ]
@@ -0,0 +1,9 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ from .extract_stateless_request_data_schema_zero_value import ExtractStatelessRequestDataSchemaZeroValue
6
+
7
+ ExtractStatelessRequestDataSchema = typing.Union[
8
+ typing.Dict[str, typing.Optional[ExtractStatelessRequestDataSchemaZeroValue]], str
9
+ ]
@@ -0,0 +1,7 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ ExtractStatelessRequestDataSchemaZeroValue = typing.Union[
6
+ typing.Dict[str, typing.Any], typing.List[typing.Any], str, int, float, bool
7
+ ]