llama-cloud 0.1.13__py3-none-any.whl → 0.1.15__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.
- llama_cloud/__init__.py +44 -10
- llama_cloud/resources/__init__.py +0 -14
- llama_cloud/resources/llama_extract/__init__.py +0 -17
- llama_cloud/resources/llama_extract/client.py +195 -246
- llama_cloud/resources/organizations/client.py +15 -5
- llama_cloud/resources/parsing/client.py +16 -0
- llama_cloud/resources/pipelines/client.py +145 -10
- llama_cloud/resources/projects/client.py +25 -9
- llama_cloud/resources/reports/client.py +16 -6
- llama_cloud/types/__init__.py +50 -4
- llama_cloud/types/{plan.py → base_plan.py} +16 -13
- llama_cloud/types/base_plan_metronome_plan_type.py +17 -0
- llama_cloud/types/base_plan_name.py +45 -0
- llama_cloud/types/base_plan_plan_frequency.py +25 -0
- llama_cloud/types/billing_period.py +32 -0
- llama_cloud/types/chunk_mode.py +4 -0
- llama_cloud/types/credit_type.py +32 -0
- llama_cloud/types/data_source.py +1 -0
- llama_cloud/types/extract_agent_create.py +39 -0
- llama_cloud/types/extract_agent_update.py +38 -0
- llama_cloud/types/extract_job_create_batch.py +42 -0
- llama_cloud/types/extract_job_create_batch_data_schema_override.py +9 -0
- llama_cloud/types/extract_job_create_batch_data_schema_override_zero_value.py +7 -0
- llama_cloud/types/extract_schema_validate_request.py +32 -0
- llama_cloud/types/free_credits_usage.py +34 -0
- llama_cloud/types/llama_parse_parameters.py +2 -0
- llama_cloud/types/paginated_extract_runs_response.py +39 -0
- llama_cloud/types/paginated_list_cloud_documents_response.py +35 -0
- llama_cloud/types/pipeline_data_source.py +1 -0
- llama_cloud/types/pipeline_file.py +1 -0
- llama_cloud/types/plan_limits.py +52 -0
- llama_cloud/types/recurring_credit_grant.py +44 -0
- llama_cloud/types/usage.py +7 -5
- llama_cloud/types/usage_active_alerts_item.py +25 -0
- llama_cloud/types/{interval_usage_and_plan.py → usage_and_plan.py} +4 -6
- {llama_cloud-0.1.13.dist-info → llama_cloud-0.1.15.dist-info}/METADATA +3 -1
- {llama_cloud-0.1.13.dist-info → llama_cloud-0.1.15.dist-info}/RECORD +45 -29
- {llama_cloud-0.1.13.dist-info → llama_cloud-0.1.15.dist-info}/WHEEL +1 -1
- llama_cloud/resources/llama_extract/types/__init__.py +0 -17
- /llama_cloud/{resources/llama_extract/types → types}/extract_agent_create_data_schema.py +0 -0
- /llama_cloud/{resources/llama_extract/types → types}/extract_agent_create_data_schema_zero_value.py +0 -0
- /llama_cloud/{resources/llama_extract/types → types}/extract_agent_update_data_schema.py +0 -0
- /llama_cloud/{resources/llama_extract/types → types}/extract_agent_update_data_schema_zero_value.py +0 -0
- /llama_cloud/{resources/llama_extract/types → types}/extract_schema_validate_request_data_schema.py +0 -0
- /llama_cloud/{resources/llama_extract/types → types}/extract_schema_validate_request_data_schema_zero_value.py +0 -0
- {llama_cloud-0.1.13.dist-info → llama_cloud-0.1.15.dist-info}/LICENSE +0 -0
|
@@ -10,17 +10,18 @@ from ...core.jsonable_encoder import jsonable_encoder
|
|
|
10
10
|
from ...core.remove_none_from_dict import remove_none_from_dict
|
|
11
11
|
from ...errors.unprocessable_entity_error import UnprocessableEntityError
|
|
12
12
|
from ...types.extract_agent import ExtractAgent
|
|
13
|
-
from ...types.
|
|
13
|
+
from ...types.extract_agent_create import ExtractAgentCreate
|
|
14
|
+
from ...types.extract_agent_update import ExtractAgentUpdate
|
|
14
15
|
from ...types.extract_job import ExtractJob
|
|
15
16
|
from ...types.extract_job_create import ExtractJobCreate
|
|
17
|
+
from ...types.extract_job_create_batch import ExtractJobCreateBatch
|
|
16
18
|
from ...types.extract_resultset import ExtractResultset
|
|
17
19
|
from ...types.extract_run import ExtractRun
|
|
20
|
+
from ...types.extract_schema_validate_request import ExtractSchemaValidateRequest
|
|
18
21
|
from ...types.extract_schema_validate_response import ExtractSchemaValidateResponse
|
|
19
22
|
from ...types.http_validation_error import HttpValidationError
|
|
20
23
|
from ...types.llama_extract_settings import LlamaExtractSettings
|
|
21
|
-
from
|
|
22
|
-
from .types.extract_agent_update_data_schema import ExtractAgentUpdateDataSchema
|
|
23
|
-
from .types.extract_schema_validate_request_data_schema import ExtractSchemaValidateRequestDataSchema
|
|
24
|
+
from ...types.paginated_extract_runs_response import PaginatedExtractRunsResponse
|
|
24
25
|
|
|
25
26
|
try:
|
|
26
27
|
import pydantic
|
|
@@ -52,7 +53,7 @@ class LlamaExtractClient:
|
|
|
52
53
|
"""
|
|
53
54
|
_response = self._client_wrapper.httpx_client.request(
|
|
54
55
|
"GET",
|
|
55
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/
|
|
56
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/extraction-agents"),
|
|
56
57
|
params=remove_none_from_dict({"project_id": project_id}),
|
|
57
58
|
headers=self._client_wrapper.get_headers(),
|
|
58
59
|
timeout=60,
|
|
@@ -72,9 +73,7 @@ class LlamaExtractClient:
|
|
|
72
73
|
*,
|
|
73
74
|
project_id: typing.Optional[str] = None,
|
|
74
75
|
organization_id: typing.Optional[str] = None,
|
|
75
|
-
|
|
76
|
-
data_schema: ExtractAgentCreateDataSchema,
|
|
77
|
-
config: ExtractConfig,
|
|
76
|
+
request: ExtractAgentCreate,
|
|
78
77
|
) -> ExtractAgent:
|
|
79
78
|
"""
|
|
80
79
|
Parameters:
|
|
@@ -82,31 +81,34 @@ class LlamaExtractClient:
|
|
|
82
81
|
|
|
83
82
|
- organization_id: typing.Optional[str].
|
|
84
83
|
|
|
85
|
-
-
|
|
86
|
-
|
|
87
|
-
- data_schema: ExtractAgentCreateDataSchema. The schema of the data.
|
|
88
|
-
|
|
89
|
-
- config: ExtractConfig. The configuration parameters for the extraction agent.
|
|
84
|
+
- request: ExtractAgentCreate.
|
|
90
85
|
---
|
|
91
|
-
from llama_cloud import
|
|
86
|
+
from llama_cloud import (
|
|
87
|
+
ExtractAgentCreate,
|
|
88
|
+
ExtractConfig,
|
|
89
|
+
ExtractMode,
|
|
90
|
+
ExtractTarget,
|
|
91
|
+
)
|
|
92
92
|
from llama_cloud.client import LlamaCloud
|
|
93
93
|
|
|
94
94
|
client = LlamaCloud(
|
|
95
95
|
token="YOUR_TOKEN",
|
|
96
96
|
)
|
|
97
97
|
client.llama_extract.create_extraction_agent(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
request=ExtractAgentCreate(
|
|
99
|
+
name="string",
|
|
100
|
+
config=ExtractConfig(
|
|
101
|
+
extraction_target=ExtractTarget.PER_DOC,
|
|
102
|
+
extraction_mode=ExtractMode.FAST,
|
|
103
|
+
),
|
|
102
104
|
),
|
|
103
105
|
)
|
|
104
106
|
"""
|
|
105
107
|
_response = self._client_wrapper.httpx_client.request(
|
|
106
108
|
"POST",
|
|
107
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/
|
|
109
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/extraction-agents"),
|
|
108
110
|
params=remove_none_from_dict({"project_id": project_id, "organization_id": organization_id}),
|
|
109
|
-
json=jsonable_encoder(
|
|
111
|
+
json=jsonable_encoder(request),
|
|
110
112
|
headers=self._client_wrapper.get_headers(),
|
|
111
113
|
timeout=60,
|
|
112
114
|
)
|
|
@@ -120,29 +122,30 @@ class LlamaExtractClient:
|
|
|
120
122
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
121
123
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
122
124
|
|
|
123
|
-
def validate_extraction_schema(
|
|
124
|
-
self, *, data_schema: ExtractSchemaValidateRequestDataSchema
|
|
125
|
-
) -> ExtractSchemaValidateResponse:
|
|
125
|
+
def validate_extraction_schema(self, *, request: ExtractSchemaValidateRequest) -> ExtractSchemaValidateResponse:
|
|
126
126
|
"""
|
|
127
127
|
Validates an extraction agent's schema definition.
|
|
128
128
|
Returns the normalized and validated schema if valid, otherwise raises an HTTP 400.
|
|
129
129
|
|
|
130
130
|
Parameters:
|
|
131
|
-
-
|
|
131
|
+
- request: ExtractSchemaValidateRequest.
|
|
132
132
|
---
|
|
133
|
+
from llama_cloud import ExtractSchemaValidateRequest
|
|
133
134
|
from llama_cloud.client import LlamaCloud
|
|
134
135
|
|
|
135
136
|
client = LlamaCloud(
|
|
136
137
|
token="YOUR_TOKEN",
|
|
137
138
|
)
|
|
138
|
-
client.llama_extract.validate_extraction_schema(
|
|
139
|
+
client.llama_extract.validate_extraction_schema(
|
|
140
|
+
request=ExtractSchemaValidateRequest(),
|
|
141
|
+
)
|
|
139
142
|
"""
|
|
140
143
|
_response = self._client_wrapper.httpx_client.request(
|
|
141
144
|
"POST",
|
|
142
145
|
urllib.parse.urljoin(
|
|
143
|
-
f"{self._client_wrapper.get_base_url()}/", "api/v1/
|
|
146
|
+
f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/extraction-agents/schema/validation"
|
|
144
147
|
),
|
|
145
|
-
json=jsonable_encoder(
|
|
148
|
+
json=jsonable_encoder(request),
|
|
146
149
|
headers=self._client_wrapper.get_headers(),
|
|
147
150
|
timeout=60,
|
|
148
151
|
)
|
|
@@ -175,7 +178,7 @@ class LlamaExtractClient:
|
|
|
175
178
|
_response = self._client_wrapper.httpx_client.request(
|
|
176
179
|
"GET",
|
|
177
180
|
urllib.parse.urljoin(
|
|
178
|
-
f"{self._client_wrapper.get_base_url()}/", f"api/v1/
|
|
181
|
+
f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/extraction-agents/by-name/{name}"
|
|
179
182
|
),
|
|
180
183
|
params=remove_none_from_dict({"project_id": project_id}),
|
|
181
184
|
headers=self._client_wrapper.get_headers(),
|
|
@@ -208,8 +211,7 @@ class LlamaExtractClient:
|
|
|
208
211
|
_response = self._client_wrapper.httpx_client.request(
|
|
209
212
|
"GET",
|
|
210
213
|
urllib.parse.urljoin(
|
|
211
|
-
f"{self._client_wrapper.get_base_url()}/",
|
|
212
|
-
f"api/v1/extractionv2/extraction-agents/{extraction_agent_id}",
|
|
214
|
+
f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/extraction-agents/{extraction_agent_id}"
|
|
213
215
|
),
|
|
214
216
|
headers=self._client_wrapper.get_headers(),
|
|
215
217
|
timeout=60,
|
|
@@ -224,18 +226,19 @@ class LlamaExtractClient:
|
|
|
224
226
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
225
227
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
226
228
|
|
|
227
|
-
def update_extraction_agent(
|
|
228
|
-
self, extraction_agent_id: str, *, data_schema: ExtractAgentUpdateDataSchema, config: ExtractConfig
|
|
229
|
-
) -> ExtractAgent:
|
|
229
|
+
def update_extraction_agent(self, extraction_agent_id: str, *, request: ExtractAgentUpdate) -> ExtractAgent:
|
|
230
230
|
"""
|
|
231
231
|
Parameters:
|
|
232
232
|
- extraction_agent_id: str.
|
|
233
233
|
|
|
234
|
-
-
|
|
235
|
-
|
|
236
|
-
- config: ExtractConfig. The configuration parameters for the extraction agent.
|
|
234
|
+
- request: ExtractAgentUpdate.
|
|
237
235
|
---
|
|
238
|
-
from llama_cloud import
|
|
236
|
+
from llama_cloud import (
|
|
237
|
+
ExtractAgentUpdate,
|
|
238
|
+
ExtractConfig,
|
|
239
|
+
ExtractMode,
|
|
240
|
+
ExtractTarget,
|
|
241
|
+
)
|
|
239
242
|
from llama_cloud.client import LlamaCloud
|
|
240
243
|
|
|
241
244
|
client = LlamaCloud(
|
|
@@ -243,19 +246,20 @@ class LlamaExtractClient:
|
|
|
243
246
|
)
|
|
244
247
|
client.llama_extract.update_extraction_agent(
|
|
245
248
|
extraction_agent_id="string",
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
+
request=ExtractAgentUpdate(
|
|
250
|
+
config=ExtractConfig(
|
|
251
|
+
extraction_target=ExtractTarget.PER_DOC,
|
|
252
|
+
extraction_mode=ExtractMode.FAST,
|
|
253
|
+
),
|
|
249
254
|
),
|
|
250
255
|
)
|
|
251
256
|
"""
|
|
252
257
|
_response = self._client_wrapper.httpx_client.request(
|
|
253
258
|
"PUT",
|
|
254
259
|
urllib.parse.urljoin(
|
|
255
|
-
f"{self._client_wrapper.get_base_url()}/",
|
|
256
|
-
f"api/v1/extractionv2/extraction-agents/{extraction_agent_id}",
|
|
260
|
+
f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/extraction-agents/{extraction_agent_id}"
|
|
257
261
|
),
|
|
258
|
-
json=jsonable_encoder(
|
|
262
|
+
json=jsonable_encoder(request),
|
|
259
263
|
headers=self._client_wrapper.get_headers(),
|
|
260
264
|
timeout=60,
|
|
261
265
|
)
|
|
@@ -286,8 +290,7 @@ class LlamaExtractClient:
|
|
|
286
290
|
_response = self._client_wrapper.httpx_client.request(
|
|
287
291
|
"DELETE",
|
|
288
292
|
urllib.parse.urljoin(
|
|
289
|
-
f"{self._client_wrapper.get_base_url()}/",
|
|
290
|
-
f"api/v1/extractionv2/extraction-agents/{extraction_agent_id}",
|
|
293
|
+
f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/extraction-agents/{extraction_agent_id}"
|
|
291
294
|
),
|
|
292
295
|
headers=self._client_wrapper.get_headers(),
|
|
293
296
|
timeout=60,
|
|
@@ -318,7 +321,7 @@ class LlamaExtractClient:
|
|
|
318
321
|
"""
|
|
319
322
|
_response = self._client_wrapper.httpx_client.request(
|
|
320
323
|
"GET",
|
|
321
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/
|
|
324
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/jobs"),
|
|
322
325
|
params=remove_none_from_dict({"extraction_agent_id": extraction_agent_id}),
|
|
323
326
|
headers=self._client_wrapper.get_headers(),
|
|
324
327
|
timeout=60,
|
|
@@ -362,7 +365,7 @@ class LlamaExtractClient:
|
|
|
362
365
|
"""
|
|
363
366
|
_response = self._client_wrapper.httpx_client.request(
|
|
364
367
|
"POST",
|
|
365
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/
|
|
368
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/jobs"),
|
|
366
369
|
json=jsonable_encoder(request),
|
|
367
370
|
headers=self._client_wrapper.get_headers(),
|
|
368
371
|
timeout=60,
|
|
@@ -393,7 +396,7 @@ class LlamaExtractClient:
|
|
|
393
396
|
"""
|
|
394
397
|
_response = self._client_wrapper.httpx_client.request(
|
|
395
398
|
"GET",
|
|
396
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/
|
|
399
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/jobs/{job_id}"),
|
|
397
400
|
headers=self._client_wrapper.get_headers(),
|
|
398
401
|
timeout=60,
|
|
399
402
|
)
|
|
@@ -407,9 +410,9 @@ class LlamaExtractClient:
|
|
|
407
410
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
408
411
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
409
412
|
|
|
410
|
-
def
|
|
413
|
+
def run_job_test_user(
|
|
411
414
|
self, *, job_create: ExtractJobCreate, extract_settings: typing.Optional[LlamaExtractSettings] = OMIT
|
|
412
|
-
) ->
|
|
415
|
+
) -> ExtractJob:
|
|
413
416
|
"""
|
|
414
417
|
Parameters:
|
|
415
418
|
- job_create: ExtractJobCreate.
|
|
@@ -431,7 +434,7 @@ class LlamaExtractClient:
|
|
|
431
434
|
client = LlamaCloud(
|
|
432
435
|
token="YOUR_TOKEN",
|
|
433
436
|
)
|
|
434
|
-
client.llama_extract.
|
|
437
|
+
client.llama_extract.run_job_test_user(
|
|
435
438
|
job_create=ExtractJobCreate(
|
|
436
439
|
extraction_agent_id="string",
|
|
437
440
|
file_id="string",
|
|
@@ -453,13 +456,13 @@ class LlamaExtractClient:
|
|
|
453
456
|
_request["extract_settings"] = extract_settings
|
|
454
457
|
_response = self._client_wrapper.httpx_client.request(
|
|
455
458
|
"POST",
|
|
456
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/
|
|
459
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/jobs/test"),
|
|
457
460
|
json=jsonable_encoder(_request),
|
|
458
461
|
headers=self._client_wrapper.get_headers(),
|
|
459
462
|
timeout=60,
|
|
460
463
|
)
|
|
461
464
|
if 200 <= _response.status_code < 300:
|
|
462
|
-
return pydantic.parse_obj_as(
|
|
465
|
+
return pydantic.parse_obj_as(ExtractJob, _response.json()) # type: ignore
|
|
463
466
|
if _response.status_code == 422:
|
|
464
467
|
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
465
468
|
try:
|
|
@@ -468,14 +471,14 @@ class LlamaExtractClient:
|
|
|
468
471
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
469
472
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
470
473
|
|
|
471
|
-
def
|
|
474
|
+
def run_batch_jobs(self, *, request: ExtractJobCreateBatch) -> typing.List[ExtractJob]:
|
|
472
475
|
"""
|
|
473
476
|
Parameters:
|
|
474
|
-
- request:
|
|
477
|
+
- request: ExtractJobCreateBatch.
|
|
475
478
|
---
|
|
476
479
|
from llama_cloud import (
|
|
477
480
|
ExtractConfig,
|
|
478
|
-
|
|
481
|
+
ExtractJobCreateBatch,
|
|
479
482
|
ExtractMode,
|
|
480
483
|
ExtractTarget,
|
|
481
484
|
)
|
|
@@ -484,10 +487,10 @@ class LlamaExtractClient:
|
|
|
484
487
|
client = LlamaCloud(
|
|
485
488
|
token="YOUR_TOKEN",
|
|
486
489
|
)
|
|
487
|
-
client.llama_extract.
|
|
488
|
-
request=
|
|
490
|
+
client.llama_extract.run_batch_jobs(
|
|
491
|
+
request=ExtractJobCreateBatch(
|
|
489
492
|
extraction_agent_id="string",
|
|
490
|
-
|
|
493
|
+
file_ids=[],
|
|
491
494
|
config_override=ExtractConfig(
|
|
492
495
|
extraction_target=ExtractTarget.PER_DOC,
|
|
493
496
|
extraction_mode=ExtractMode.FAST,
|
|
@@ -497,13 +500,13 @@ class LlamaExtractClient:
|
|
|
497
500
|
"""
|
|
498
501
|
_response = self._client_wrapper.httpx_client.request(
|
|
499
502
|
"POST",
|
|
500
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/
|
|
503
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/jobs/batch"),
|
|
501
504
|
json=jsonable_encoder(request),
|
|
502
505
|
headers=self._client_wrapper.get_headers(),
|
|
503
506
|
timeout=60,
|
|
504
507
|
)
|
|
505
508
|
if 200 <= _response.status_code < 300:
|
|
506
|
-
return pydantic.parse_obj_as(
|
|
509
|
+
return pydantic.parse_obj_as(typing.List[ExtractJob], _response.json()) # type: ignore
|
|
507
510
|
if _response.status_code == 422:
|
|
508
511
|
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
509
512
|
try:
|
|
@@ -512,59 +515,28 @@ class LlamaExtractClient:
|
|
|
512
515
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
513
516
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
514
517
|
|
|
515
|
-
def
|
|
516
|
-
self, *, job_create: ExtractJobCreate, extract_settings: typing.Optional[LlamaExtractSettings] = OMIT
|
|
517
|
-
) -> ExtractJob:
|
|
518
|
+
def get_job_result(self, job_id: str) -> ExtractResultset:
|
|
518
519
|
"""
|
|
519
520
|
Parameters:
|
|
520
|
-
-
|
|
521
|
-
|
|
522
|
-
- extract_settings: typing.Optional[LlamaExtractSettings].
|
|
521
|
+
- job_id: str.
|
|
523
522
|
---
|
|
524
|
-
from llama_cloud import (
|
|
525
|
-
ChunkMode,
|
|
526
|
-
ExtractConfig,
|
|
527
|
-
ExtractJobCreate,
|
|
528
|
-
ExtractMode,
|
|
529
|
-
ExtractTarget,
|
|
530
|
-
LlamaExtractSettings,
|
|
531
|
-
LlamaParseParameters,
|
|
532
|
-
ParsingMode,
|
|
533
|
-
)
|
|
534
523
|
from llama_cloud.client import LlamaCloud
|
|
535
524
|
|
|
536
525
|
client = LlamaCloud(
|
|
537
526
|
token="YOUR_TOKEN",
|
|
538
527
|
)
|
|
539
|
-
client.llama_extract.
|
|
540
|
-
|
|
541
|
-
extraction_agent_id="string",
|
|
542
|
-
file_id="string",
|
|
543
|
-
config_override=ExtractConfig(
|
|
544
|
-
extraction_target=ExtractTarget.PER_DOC,
|
|
545
|
-
extraction_mode=ExtractMode.FAST,
|
|
546
|
-
),
|
|
547
|
-
),
|
|
548
|
-
extract_settings=LlamaExtractSettings(
|
|
549
|
-
chunk_mode=ChunkMode.PAGE,
|
|
550
|
-
llama_parse_params=LlamaParseParameters(
|
|
551
|
-
parse_mode=ParsingMode.PARSE_PAGE_WITHOUT_LLM,
|
|
552
|
-
),
|
|
553
|
-
),
|
|
528
|
+
client.llama_extract.get_job_result(
|
|
529
|
+
job_id="string",
|
|
554
530
|
)
|
|
555
531
|
"""
|
|
556
|
-
_request: typing.Dict[str, typing.Any] = {"job_create": job_create}
|
|
557
|
-
if extract_settings is not OMIT:
|
|
558
|
-
_request["extract_settings"] = extract_settings
|
|
559
532
|
_response = self._client_wrapper.httpx_client.request(
|
|
560
|
-
"
|
|
561
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/
|
|
562
|
-
json=jsonable_encoder(_request),
|
|
533
|
+
"GET",
|
|
534
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/jobs/{job_id}/result"),
|
|
563
535
|
headers=self._client_wrapper.get_headers(),
|
|
564
536
|
timeout=60,
|
|
565
537
|
)
|
|
566
538
|
if 200 <= _response.status_code < 300:
|
|
567
|
-
return pydantic.parse_obj_as(
|
|
539
|
+
return pydantic.parse_obj_as(ExtractResultset, _response.json()) # type: ignore
|
|
568
540
|
if _response.status_code == 422:
|
|
569
541
|
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
570
542
|
try:
|
|
@@ -573,30 +545,35 @@ class LlamaExtractClient:
|
|
|
573
545
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
574
546
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
575
547
|
|
|
576
|
-
def
|
|
548
|
+
def list_extract_runs(
|
|
549
|
+
self, *, extraction_agent_id: str, skip: typing.Optional[int] = None, limit: typing.Optional[int] = None
|
|
550
|
+
) -> PaginatedExtractRunsResponse:
|
|
577
551
|
"""
|
|
578
552
|
Parameters:
|
|
579
|
-
-
|
|
553
|
+
- extraction_agent_id: str.
|
|
554
|
+
|
|
555
|
+
- skip: typing.Optional[int].
|
|
556
|
+
|
|
557
|
+
- limit: typing.Optional[int].
|
|
580
558
|
---
|
|
581
559
|
from llama_cloud.client import LlamaCloud
|
|
582
560
|
|
|
583
561
|
client = LlamaCloud(
|
|
584
562
|
token="YOUR_TOKEN",
|
|
585
563
|
)
|
|
586
|
-
client.llama_extract.
|
|
587
|
-
|
|
564
|
+
client.llama_extract.list_extract_runs(
|
|
565
|
+
extraction_agent_id="string",
|
|
588
566
|
)
|
|
589
567
|
"""
|
|
590
568
|
_response = self._client_wrapper.httpx_client.request(
|
|
591
569
|
"GET",
|
|
592
|
-
urllib.parse.urljoin(
|
|
593
|
-
|
|
594
|
-
),
|
|
570
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/runs"),
|
|
571
|
+
params=remove_none_from_dict({"extraction_agent_id": extraction_agent_id, "skip": skip, "limit": limit}),
|
|
595
572
|
headers=self._client_wrapper.get_headers(),
|
|
596
573
|
timeout=60,
|
|
597
574
|
)
|
|
598
575
|
if 200 <= _response.status_code < 300:
|
|
599
|
-
return pydantic.parse_obj_as(
|
|
576
|
+
return pydantic.parse_obj_as(PaginatedExtractRunsResponse, _response.json()) # type: ignore
|
|
600
577
|
if _response.status_code == 422:
|
|
601
578
|
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
602
579
|
try:
|
|
@@ -605,29 +582,28 @@ class LlamaExtractClient:
|
|
|
605
582
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
606
583
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
607
584
|
|
|
608
|
-
def
|
|
585
|
+
def get_run_by_job_id(self, job_id: str) -> ExtractRun:
|
|
609
586
|
"""
|
|
610
587
|
Parameters:
|
|
611
|
-
-
|
|
588
|
+
- job_id: str.
|
|
612
589
|
---
|
|
613
590
|
from llama_cloud.client import LlamaCloud
|
|
614
591
|
|
|
615
592
|
client = LlamaCloud(
|
|
616
593
|
token="YOUR_TOKEN",
|
|
617
594
|
)
|
|
618
|
-
client.llama_extract.
|
|
619
|
-
|
|
595
|
+
client.llama_extract.get_run_by_job_id(
|
|
596
|
+
job_id="string",
|
|
620
597
|
)
|
|
621
598
|
"""
|
|
622
599
|
_response = self._client_wrapper.httpx_client.request(
|
|
623
600
|
"GET",
|
|
624
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/
|
|
625
|
-
params=remove_none_from_dict({"extraction_agent_id": extraction_agent_id}),
|
|
601
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/runs/by-job/{job_id}"),
|
|
626
602
|
headers=self._client_wrapper.get_headers(),
|
|
627
603
|
timeout=60,
|
|
628
604
|
)
|
|
629
605
|
if 200 <= _response.status_code < 300:
|
|
630
|
-
return pydantic.parse_obj_as(
|
|
606
|
+
return pydantic.parse_obj_as(ExtractRun, _response.json()) # type: ignore
|
|
631
607
|
if _response.status_code == 422:
|
|
632
608
|
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
633
609
|
try:
|
|
@@ -636,25 +612,23 @@ class LlamaExtractClient:
|
|
|
636
612
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
637
613
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
638
614
|
|
|
639
|
-
def
|
|
615
|
+
def get_run(self, run_id: str) -> ExtractRun:
|
|
640
616
|
"""
|
|
641
617
|
Parameters:
|
|
642
|
-
-
|
|
618
|
+
- run_id: str.
|
|
643
619
|
---
|
|
644
620
|
from llama_cloud.client import LlamaCloud
|
|
645
621
|
|
|
646
622
|
client = LlamaCloud(
|
|
647
623
|
token="YOUR_TOKEN",
|
|
648
624
|
)
|
|
649
|
-
client.llama_extract.
|
|
650
|
-
|
|
625
|
+
client.llama_extract.get_run(
|
|
626
|
+
run_id="string",
|
|
651
627
|
)
|
|
652
628
|
"""
|
|
653
629
|
_response = self._client_wrapper.httpx_client.request(
|
|
654
630
|
"GET",
|
|
655
|
-
urllib.parse.urljoin(
|
|
656
|
-
f"{self._client_wrapper.get_base_url()}/", f"api/v1/extractionv2/runs/by-job/{job_id}"
|
|
657
|
-
),
|
|
631
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/runs/{run_id}"),
|
|
658
632
|
headers=self._client_wrapper.get_headers(),
|
|
659
633
|
timeout=60,
|
|
660
634
|
)
|
|
@@ -668,7 +642,7 @@ class LlamaExtractClient:
|
|
|
668
642
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
669
643
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
670
644
|
|
|
671
|
-
def
|
|
645
|
+
def delete_extraction_run(self, run_id: str) -> typing.Any:
|
|
672
646
|
"""
|
|
673
647
|
Parameters:
|
|
674
648
|
- run_id: str.
|
|
@@ -678,18 +652,18 @@ class LlamaExtractClient:
|
|
|
678
652
|
client = LlamaCloud(
|
|
679
653
|
token="YOUR_TOKEN",
|
|
680
654
|
)
|
|
681
|
-
client.llama_extract.
|
|
655
|
+
client.llama_extract.delete_extraction_run(
|
|
682
656
|
run_id="string",
|
|
683
657
|
)
|
|
684
658
|
"""
|
|
685
659
|
_response = self._client_wrapper.httpx_client.request(
|
|
686
|
-
"
|
|
687
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/
|
|
660
|
+
"DELETE",
|
|
661
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/runs/{run_id}"),
|
|
688
662
|
headers=self._client_wrapper.get_headers(),
|
|
689
663
|
timeout=60,
|
|
690
664
|
)
|
|
691
665
|
if 200 <= _response.status_code < 300:
|
|
692
|
-
return pydantic.parse_obj_as(
|
|
666
|
+
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
|
|
693
667
|
if _response.status_code == 422:
|
|
694
668
|
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
695
669
|
try:
|
|
@@ -717,7 +691,7 @@ class AsyncLlamaExtractClient:
|
|
|
717
691
|
"""
|
|
718
692
|
_response = await self._client_wrapper.httpx_client.request(
|
|
719
693
|
"GET",
|
|
720
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/
|
|
694
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/extraction-agents"),
|
|
721
695
|
params=remove_none_from_dict({"project_id": project_id}),
|
|
722
696
|
headers=self._client_wrapper.get_headers(),
|
|
723
697
|
timeout=60,
|
|
@@ -737,9 +711,7 @@ class AsyncLlamaExtractClient:
|
|
|
737
711
|
*,
|
|
738
712
|
project_id: typing.Optional[str] = None,
|
|
739
713
|
organization_id: typing.Optional[str] = None,
|
|
740
|
-
|
|
741
|
-
data_schema: ExtractAgentCreateDataSchema,
|
|
742
|
-
config: ExtractConfig,
|
|
714
|
+
request: ExtractAgentCreate,
|
|
743
715
|
) -> ExtractAgent:
|
|
744
716
|
"""
|
|
745
717
|
Parameters:
|
|
@@ -747,31 +719,34 @@ class AsyncLlamaExtractClient:
|
|
|
747
719
|
|
|
748
720
|
- organization_id: typing.Optional[str].
|
|
749
721
|
|
|
750
|
-
-
|
|
751
|
-
|
|
752
|
-
- data_schema: ExtractAgentCreateDataSchema. The schema of the data.
|
|
753
|
-
|
|
754
|
-
- config: ExtractConfig. The configuration parameters for the extraction agent.
|
|
722
|
+
- request: ExtractAgentCreate.
|
|
755
723
|
---
|
|
756
|
-
from llama_cloud import
|
|
724
|
+
from llama_cloud import (
|
|
725
|
+
ExtractAgentCreate,
|
|
726
|
+
ExtractConfig,
|
|
727
|
+
ExtractMode,
|
|
728
|
+
ExtractTarget,
|
|
729
|
+
)
|
|
757
730
|
from llama_cloud.client import AsyncLlamaCloud
|
|
758
731
|
|
|
759
732
|
client = AsyncLlamaCloud(
|
|
760
733
|
token="YOUR_TOKEN",
|
|
761
734
|
)
|
|
762
735
|
await client.llama_extract.create_extraction_agent(
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
736
|
+
request=ExtractAgentCreate(
|
|
737
|
+
name="string",
|
|
738
|
+
config=ExtractConfig(
|
|
739
|
+
extraction_target=ExtractTarget.PER_DOC,
|
|
740
|
+
extraction_mode=ExtractMode.FAST,
|
|
741
|
+
),
|
|
767
742
|
),
|
|
768
743
|
)
|
|
769
744
|
"""
|
|
770
745
|
_response = await self._client_wrapper.httpx_client.request(
|
|
771
746
|
"POST",
|
|
772
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/
|
|
747
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/extraction-agents"),
|
|
773
748
|
params=remove_none_from_dict({"project_id": project_id, "organization_id": organization_id}),
|
|
774
|
-
json=jsonable_encoder(
|
|
749
|
+
json=jsonable_encoder(request),
|
|
775
750
|
headers=self._client_wrapper.get_headers(),
|
|
776
751
|
timeout=60,
|
|
777
752
|
)
|
|
@@ -786,28 +761,31 @@ class AsyncLlamaExtractClient:
|
|
|
786
761
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
787
762
|
|
|
788
763
|
async def validate_extraction_schema(
|
|
789
|
-
self, *,
|
|
764
|
+
self, *, request: ExtractSchemaValidateRequest
|
|
790
765
|
) -> ExtractSchemaValidateResponse:
|
|
791
766
|
"""
|
|
792
767
|
Validates an extraction agent's schema definition.
|
|
793
768
|
Returns the normalized and validated schema if valid, otherwise raises an HTTP 400.
|
|
794
769
|
|
|
795
770
|
Parameters:
|
|
796
|
-
-
|
|
771
|
+
- request: ExtractSchemaValidateRequest.
|
|
797
772
|
---
|
|
773
|
+
from llama_cloud import ExtractSchemaValidateRequest
|
|
798
774
|
from llama_cloud.client import AsyncLlamaCloud
|
|
799
775
|
|
|
800
776
|
client = AsyncLlamaCloud(
|
|
801
777
|
token="YOUR_TOKEN",
|
|
802
778
|
)
|
|
803
|
-
await client.llama_extract.validate_extraction_schema(
|
|
779
|
+
await client.llama_extract.validate_extraction_schema(
|
|
780
|
+
request=ExtractSchemaValidateRequest(),
|
|
781
|
+
)
|
|
804
782
|
"""
|
|
805
783
|
_response = await self._client_wrapper.httpx_client.request(
|
|
806
784
|
"POST",
|
|
807
785
|
urllib.parse.urljoin(
|
|
808
|
-
f"{self._client_wrapper.get_base_url()}/", "api/v1/
|
|
786
|
+
f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/extraction-agents/schema/validation"
|
|
809
787
|
),
|
|
810
|
-
json=jsonable_encoder(
|
|
788
|
+
json=jsonable_encoder(request),
|
|
811
789
|
headers=self._client_wrapper.get_headers(),
|
|
812
790
|
timeout=60,
|
|
813
791
|
)
|
|
@@ -840,7 +818,7 @@ class AsyncLlamaExtractClient:
|
|
|
840
818
|
_response = await self._client_wrapper.httpx_client.request(
|
|
841
819
|
"GET",
|
|
842
820
|
urllib.parse.urljoin(
|
|
843
|
-
f"{self._client_wrapper.get_base_url()}/", f"api/v1/
|
|
821
|
+
f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/extraction-agents/by-name/{name}"
|
|
844
822
|
),
|
|
845
823
|
params=remove_none_from_dict({"project_id": project_id}),
|
|
846
824
|
headers=self._client_wrapper.get_headers(),
|
|
@@ -873,8 +851,7 @@ class AsyncLlamaExtractClient:
|
|
|
873
851
|
_response = await self._client_wrapper.httpx_client.request(
|
|
874
852
|
"GET",
|
|
875
853
|
urllib.parse.urljoin(
|
|
876
|
-
f"{self._client_wrapper.get_base_url()}/",
|
|
877
|
-
f"api/v1/extractionv2/extraction-agents/{extraction_agent_id}",
|
|
854
|
+
f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/extraction-agents/{extraction_agent_id}"
|
|
878
855
|
),
|
|
879
856
|
headers=self._client_wrapper.get_headers(),
|
|
880
857
|
timeout=60,
|
|
@@ -889,18 +866,19 @@ class AsyncLlamaExtractClient:
|
|
|
889
866
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
890
867
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
891
868
|
|
|
892
|
-
async def update_extraction_agent(
|
|
893
|
-
self, extraction_agent_id: str, *, data_schema: ExtractAgentUpdateDataSchema, config: ExtractConfig
|
|
894
|
-
) -> ExtractAgent:
|
|
869
|
+
async def update_extraction_agent(self, extraction_agent_id: str, *, request: ExtractAgentUpdate) -> ExtractAgent:
|
|
895
870
|
"""
|
|
896
871
|
Parameters:
|
|
897
872
|
- extraction_agent_id: str.
|
|
898
873
|
|
|
899
|
-
-
|
|
900
|
-
|
|
901
|
-
- config: ExtractConfig. The configuration parameters for the extraction agent.
|
|
874
|
+
- request: ExtractAgentUpdate.
|
|
902
875
|
---
|
|
903
|
-
from llama_cloud import
|
|
876
|
+
from llama_cloud import (
|
|
877
|
+
ExtractAgentUpdate,
|
|
878
|
+
ExtractConfig,
|
|
879
|
+
ExtractMode,
|
|
880
|
+
ExtractTarget,
|
|
881
|
+
)
|
|
904
882
|
from llama_cloud.client import AsyncLlamaCloud
|
|
905
883
|
|
|
906
884
|
client = AsyncLlamaCloud(
|
|
@@ -908,19 +886,20 @@ class AsyncLlamaExtractClient:
|
|
|
908
886
|
)
|
|
909
887
|
await client.llama_extract.update_extraction_agent(
|
|
910
888
|
extraction_agent_id="string",
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
889
|
+
request=ExtractAgentUpdate(
|
|
890
|
+
config=ExtractConfig(
|
|
891
|
+
extraction_target=ExtractTarget.PER_DOC,
|
|
892
|
+
extraction_mode=ExtractMode.FAST,
|
|
893
|
+
),
|
|
914
894
|
),
|
|
915
895
|
)
|
|
916
896
|
"""
|
|
917
897
|
_response = await self._client_wrapper.httpx_client.request(
|
|
918
898
|
"PUT",
|
|
919
899
|
urllib.parse.urljoin(
|
|
920
|
-
f"{self._client_wrapper.get_base_url()}/",
|
|
921
|
-
f"api/v1/extractionv2/extraction-agents/{extraction_agent_id}",
|
|
900
|
+
f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/extraction-agents/{extraction_agent_id}"
|
|
922
901
|
),
|
|
923
|
-
json=jsonable_encoder(
|
|
902
|
+
json=jsonable_encoder(request),
|
|
924
903
|
headers=self._client_wrapper.get_headers(),
|
|
925
904
|
timeout=60,
|
|
926
905
|
)
|
|
@@ -951,8 +930,7 @@ class AsyncLlamaExtractClient:
|
|
|
951
930
|
_response = await self._client_wrapper.httpx_client.request(
|
|
952
931
|
"DELETE",
|
|
953
932
|
urllib.parse.urljoin(
|
|
954
|
-
f"{self._client_wrapper.get_base_url()}/",
|
|
955
|
-
f"api/v1/extractionv2/extraction-agents/{extraction_agent_id}",
|
|
933
|
+
f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/extraction-agents/{extraction_agent_id}"
|
|
956
934
|
),
|
|
957
935
|
headers=self._client_wrapper.get_headers(),
|
|
958
936
|
timeout=60,
|
|
@@ -983,7 +961,7 @@ class AsyncLlamaExtractClient:
|
|
|
983
961
|
"""
|
|
984
962
|
_response = await self._client_wrapper.httpx_client.request(
|
|
985
963
|
"GET",
|
|
986
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/
|
|
964
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/jobs"),
|
|
987
965
|
params=remove_none_from_dict({"extraction_agent_id": extraction_agent_id}),
|
|
988
966
|
headers=self._client_wrapper.get_headers(),
|
|
989
967
|
timeout=60,
|
|
@@ -1027,7 +1005,7 @@ class AsyncLlamaExtractClient:
|
|
|
1027
1005
|
"""
|
|
1028
1006
|
_response = await self._client_wrapper.httpx_client.request(
|
|
1029
1007
|
"POST",
|
|
1030
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/
|
|
1008
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/jobs"),
|
|
1031
1009
|
json=jsonable_encoder(request),
|
|
1032
1010
|
headers=self._client_wrapper.get_headers(),
|
|
1033
1011
|
timeout=60,
|
|
@@ -1058,7 +1036,7 @@ class AsyncLlamaExtractClient:
|
|
|
1058
1036
|
"""
|
|
1059
1037
|
_response = await self._client_wrapper.httpx_client.request(
|
|
1060
1038
|
"GET",
|
|
1061
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/
|
|
1039
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/jobs/{job_id}"),
|
|
1062
1040
|
headers=self._client_wrapper.get_headers(),
|
|
1063
1041
|
timeout=60,
|
|
1064
1042
|
)
|
|
@@ -1072,9 +1050,9 @@ class AsyncLlamaExtractClient:
|
|
|
1072
1050
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1073
1051
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1074
1052
|
|
|
1075
|
-
async def
|
|
1053
|
+
async def run_job_test_user(
|
|
1076
1054
|
self, *, job_create: ExtractJobCreate, extract_settings: typing.Optional[LlamaExtractSettings] = OMIT
|
|
1077
|
-
) ->
|
|
1055
|
+
) -> ExtractJob:
|
|
1078
1056
|
"""
|
|
1079
1057
|
Parameters:
|
|
1080
1058
|
- job_create: ExtractJobCreate.
|
|
@@ -1096,7 +1074,7 @@ class AsyncLlamaExtractClient:
|
|
|
1096
1074
|
client = AsyncLlamaCloud(
|
|
1097
1075
|
token="YOUR_TOKEN",
|
|
1098
1076
|
)
|
|
1099
|
-
await client.llama_extract.
|
|
1077
|
+
await client.llama_extract.run_job_test_user(
|
|
1100
1078
|
job_create=ExtractJobCreate(
|
|
1101
1079
|
extraction_agent_id="string",
|
|
1102
1080
|
file_id="string",
|
|
@@ -1118,13 +1096,13 @@ class AsyncLlamaExtractClient:
|
|
|
1118
1096
|
_request["extract_settings"] = extract_settings
|
|
1119
1097
|
_response = await self._client_wrapper.httpx_client.request(
|
|
1120
1098
|
"POST",
|
|
1121
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/
|
|
1099
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/jobs/test"),
|
|
1122
1100
|
json=jsonable_encoder(_request),
|
|
1123
1101
|
headers=self._client_wrapper.get_headers(),
|
|
1124
1102
|
timeout=60,
|
|
1125
1103
|
)
|
|
1126
1104
|
if 200 <= _response.status_code < 300:
|
|
1127
|
-
return pydantic.parse_obj_as(
|
|
1105
|
+
return pydantic.parse_obj_as(ExtractJob, _response.json()) # type: ignore
|
|
1128
1106
|
if _response.status_code == 422:
|
|
1129
1107
|
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
1130
1108
|
try:
|
|
@@ -1133,14 +1111,14 @@ class AsyncLlamaExtractClient:
|
|
|
1133
1111
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1134
1112
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1135
1113
|
|
|
1136
|
-
async def
|
|
1114
|
+
async def run_batch_jobs(self, *, request: ExtractJobCreateBatch) -> typing.List[ExtractJob]:
|
|
1137
1115
|
"""
|
|
1138
1116
|
Parameters:
|
|
1139
|
-
- request:
|
|
1117
|
+
- request: ExtractJobCreateBatch.
|
|
1140
1118
|
---
|
|
1141
1119
|
from llama_cloud import (
|
|
1142
1120
|
ExtractConfig,
|
|
1143
|
-
|
|
1121
|
+
ExtractJobCreateBatch,
|
|
1144
1122
|
ExtractMode,
|
|
1145
1123
|
ExtractTarget,
|
|
1146
1124
|
)
|
|
@@ -1149,10 +1127,10 @@ class AsyncLlamaExtractClient:
|
|
|
1149
1127
|
client = AsyncLlamaCloud(
|
|
1150
1128
|
token="YOUR_TOKEN",
|
|
1151
1129
|
)
|
|
1152
|
-
await client.llama_extract.
|
|
1153
|
-
request=
|
|
1130
|
+
await client.llama_extract.run_batch_jobs(
|
|
1131
|
+
request=ExtractJobCreateBatch(
|
|
1154
1132
|
extraction_agent_id="string",
|
|
1155
|
-
|
|
1133
|
+
file_ids=[],
|
|
1156
1134
|
config_override=ExtractConfig(
|
|
1157
1135
|
extraction_target=ExtractTarget.PER_DOC,
|
|
1158
1136
|
extraction_mode=ExtractMode.FAST,
|
|
@@ -1162,13 +1140,13 @@ class AsyncLlamaExtractClient:
|
|
|
1162
1140
|
"""
|
|
1163
1141
|
_response = await self._client_wrapper.httpx_client.request(
|
|
1164
1142
|
"POST",
|
|
1165
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/
|
|
1143
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/jobs/batch"),
|
|
1166
1144
|
json=jsonable_encoder(request),
|
|
1167
1145
|
headers=self._client_wrapper.get_headers(),
|
|
1168
1146
|
timeout=60,
|
|
1169
1147
|
)
|
|
1170
1148
|
if 200 <= _response.status_code < 300:
|
|
1171
|
-
return pydantic.parse_obj_as(
|
|
1149
|
+
return pydantic.parse_obj_as(typing.List[ExtractJob], _response.json()) # type: ignore
|
|
1172
1150
|
if _response.status_code == 422:
|
|
1173
1151
|
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
1174
1152
|
try:
|
|
@@ -1177,59 +1155,28 @@ class AsyncLlamaExtractClient:
|
|
|
1177
1155
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1178
1156
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1179
1157
|
|
|
1180
|
-
async def
|
|
1181
|
-
self, *, job_create: ExtractJobCreate, extract_settings: typing.Optional[LlamaExtractSettings] = OMIT
|
|
1182
|
-
) -> ExtractJob:
|
|
1158
|
+
async def get_job_result(self, job_id: str) -> ExtractResultset:
|
|
1183
1159
|
"""
|
|
1184
1160
|
Parameters:
|
|
1185
|
-
-
|
|
1186
|
-
|
|
1187
|
-
- extract_settings: typing.Optional[LlamaExtractSettings].
|
|
1161
|
+
- job_id: str.
|
|
1188
1162
|
---
|
|
1189
|
-
from llama_cloud import (
|
|
1190
|
-
ChunkMode,
|
|
1191
|
-
ExtractConfig,
|
|
1192
|
-
ExtractJobCreate,
|
|
1193
|
-
ExtractMode,
|
|
1194
|
-
ExtractTarget,
|
|
1195
|
-
LlamaExtractSettings,
|
|
1196
|
-
LlamaParseParameters,
|
|
1197
|
-
ParsingMode,
|
|
1198
|
-
)
|
|
1199
1163
|
from llama_cloud.client import AsyncLlamaCloud
|
|
1200
1164
|
|
|
1201
1165
|
client = AsyncLlamaCloud(
|
|
1202
1166
|
token="YOUR_TOKEN",
|
|
1203
1167
|
)
|
|
1204
|
-
await client.llama_extract.
|
|
1205
|
-
|
|
1206
|
-
extraction_agent_id="string",
|
|
1207
|
-
file_id="string",
|
|
1208
|
-
config_override=ExtractConfig(
|
|
1209
|
-
extraction_target=ExtractTarget.PER_DOC,
|
|
1210
|
-
extraction_mode=ExtractMode.FAST,
|
|
1211
|
-
),
|
|
1212
|
-
),
|
|
1213
|
-
extract_settings=LlamaExtractSettings(
|
|
1214
|
-
chunk_mode=ChunkMode.PAGE,
|
|
1215
|
-
llama_parse_params=LlamaParseParameters(
|
|
1216
|
-
parse_mode=ParsingMode.PARSE_PAGE_WITHOUT_LLM,
|
|
1217
|
-
),
|
|
1218
|
-
),
|
|
1168
|
+
await client.llama_extract.get_job_result(
|
|
1169
|
+
job_id="string",
|
|
1219
1170
|
)
|
|
1220
1171
|
"""
|
|
1221
|
-
_request: typing.Dict[str, typing.Any] = {"job_create": job_create}
|
|
1222
|
-
if extract_settings is not OMIT:
|
|
1223
|
-
_request["extract_settings"] = extract_settings
|
|
1224
1172
|
_response = await self._client_wrapper.httpx_client.request(
|
|
1225
|
-
"
|
|
1226
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/
|
|
1227
|
-
json=jsonable_encoder(_request),
|
|
1173
|
+
"GET",
|
|
1174
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/jobs/{job_id}/result"),
|
|
1228
1175
|
headers=self._client_wrapper.get_headers(),
|
|
1229
1176
|
timeout=60,
|
|
1230
1177
|
)
|
|
1231
1178
|
if 200 <= _response.status_code < 300:
|
|
1232
|
-
return pydantic.parse_obj_as(
|
|
1179
|
+
return pydantic.parse_obj_as(ExtractResultset, _response.json()) # type: ignore
|
|
1233
1180
|
if _response.status_code == 422:
|
|
1234
1181
|
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
1235
1182
|
try:
|
|
@@ -1238,30 +1185,35 @@ class AsyncLlamaExtractClient:
|
|
|
1238
1185
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1239
1186
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1240
1187
|
|
|
1241
|
-
async def
|
|
1188
|
+
async def list_extract_runs(
|
|
1189
|
+
self, *, extraction_agent_id: str, skip: typing.Optional[int] = None, limit: typing.Optional[int] = None
|
|
1190
|
+
) -> PaginatedExtractRunsResponse:
|
|
1242
1191
|
"""
|
|
1243
1192
|
Parameters:
|
|
1244
|
-
-
|
|
1193
|
+
- extraction_agent_id: str.
|
|
1194
|
+
|
|
1195
|
+
- skip: typing.Optional[int].
|
|
1196
|
+
|
|
1197
|
+
- limit: typing.Optional[int].
|
|
1245
1198
|
---
|
|
1246
1199
|
from llama_cloud.client import AsyncLlamaCloud
|
|
1247
1200
|
|
|
1248
1201
|
client = AsyncLlamaCloud(
|
|
1249
1202
|
token="YOUR_TOKEN",
|
|
1250
1203
|
)
|
|
1251
|
-
await client.llama_extract.
|
|
1252
|
-
|
|
1204
|
+
await client.llama_extract.list_extract_runs(
|
|
1205
|
+
extraction_agent_id="string",
|
|
1253
1206
|
)
|
|
1254
1207
|
"""
|
|
1255
1208
|
_response = await self._client_wrapper.httpx_client.request(
|
|
1256
1209
|
"GET",
|
|
1257
|
-
urllib.parse.urljoin(
|
|
1258
|
-
|
|
1259
|
-
),
|
|
1210
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/runs"),
|
|
1211
|
+
params=remove_none_from_dict({"extraction_agent_id": extraction_agent_id, "skip": skip, "limit": limit}),
|
|
1260
1212
|
headers=self._client_wrapper.get_headers(),
|
|
1261
1213
|
timeout=60,
|
|
1262
1214
|
)
|
|
1263
1215
|
if 200 <= _response.status_code < 300:
|
|
1264
|
-
return pydantic.parse_obj_as(
|
|
1216
|
+
return pydantic.parse_obj_as(PaginatedExtractRunsResponse, _response.json()) # type: ignore
|
|
1265
1217
|
if _response.status_code == 422:
|
|
1266
1218
|
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
1267
1219
|
try:
|
|
@@ -1270,29 +1222,28 @@ class AsyncLlamaExtractClient:
|
|
|
1270
1222
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1271
1223
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1272
1224
|
|
|
1273
|
-
async def
|
|
1225
|
+
async def get_run_by_job_id(self, job_id: str) -> ExtractRun:
|
|
1274
1226
|
"""
|
|
1275
1227
|
Parameters:
|
|
1276
|
-
-
|
|
1228
|
+
- job_id: str.
|
|
1277
1229
|
---
|
|
1278
1230
|
from llama_cloud.client import AsyncLlamaCloud
|
|
1279
1231
|
|
|
1280
1232
|
client = AsyncLlamaCloud(
|
|
1281
1233
|
token="YOUR_TOKEN",
|
|
1282
1234
|
)
|
|
1283
|
-
await client.llama_extract.
|
|
1284
|
-
|
|
1235
|
+
await client.llama_extract.get_run_by_job_id(
|
|
1236
|
+
job_id="string",
|
|
1285
1237
|
)
|
|
1286
1238
|
"""
|
|
1287
1239
|
_response = await self._client_wrapper.httpx_client.request(
|
|
1288
1240
|
"GET",
|
|
1289
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/
|
|
1290
|
-
params=remove_none_from_dict({"extraction_agent_id": extraction_agent_id}),
|
|
1241
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/runs/by-job/{job_id}"),
|
|
1291
1242
|
headers=self._client_wrapper.get_headers(),
|
|
1292
1243
|
timeout=60,
|
|
1293
1244
|
)
|
|
1294
1245
|
if 200 <= _response.status_code < 300:
|
|
1295
|
-
return pydantic.parse_obj_as(
|
|
1246
|
+
return pydantic.parse_obj_as(ExtractRun, _response.json()) # type: ignore
|
|
1296
1247
|
if _response.status_code == 422:
|
|
1297
1248
|
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
1298
1249
|
try:
|
|
@@ -1301,25 +1252,23 @@ class AsyncLlamaExtractClient:
|
|
|
1301
1252
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1302
1253
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1303
1254
|
|
|
1304
|
-
async def
|
|
1255
|
+
async def get_run(self, run_id: str) -> ExtractRun:
|
|
1305
1256
|
"""
|
|
1306
1257
|
Parameters:
|
|
1307
|
-
-
|
|
1258
|
+
- run_id: str.
|
|
1308
1259
|
---
|
|
1309
1260
|
from llama_cloud.client import AsyncLlamaCloud
|
|
1310
1261
|
|
|
1311
1262
|
client = AsyncLlamaCloud(
|
|
1312
1263
|
token="YOUR_TOKEN",
|
|
1313
1264
|
)
|
|
1314
|
-
await client.llama_extract.
|
|
1315
|
-
|
|
1265
|
+
await client.llama_extract.get_run(
|
|
1266
|
+
run_id="string",
|
|
1316
1267
|
)
|
|
1317
1268
|
"""
|
|
1318
1269
|
_response = await self._client_wrapper.httpx_client.request(
|
|
1319
1270
|
"GET",
|
|
1320
|
-
urllib.parse.urljoin(
|
|
1321
|
-
f"{self._client_wrapper.get_base_url()}/", f"api/v1/extractionv2/runs/by-job/{job_id}"
|
|
1322
|
-
),
|
|
1271
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/runs/{run_id}"),
|
|
1323
1272
|
headers=self._client_wrapper.get_headers(),
|
|
1324
1273
|
timeout=60,
|
|
1325
1274
|
)
|
|
@@ -1333,7 +1282,7 @@ class AsyncLlamaExtractClient:
|
|
|
1333
1282
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1334
1283
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1335
1284
|
|
|
1336
|
-
async def
|
|
1285
|
+
async def delete_extraction_run(self, run_id: str) -> typing.Any:
|
|
1337
1286
|
"""
|
|
1338
1287
|
Parameters:
|
|
1339
1288
|
- run_id: str.
|
|
@@ -1343,18 +1292,18 @@ class AsyncLlamaExtractClient:
|
|
|
1343
1292
|
client = AsyncLlamaCloud(
|
|
1344
1293
|
token="YOUR_TOKEN",
|
|
1345
1294
|
)
|
|
1346
|
-
await client.llama_extract.
|
|
1295
|
+
await client.llama_extract.delete_extraction_run(
|
|
1347
1296
|
run_id="string",
|
|
1348
1297
|
)
|
|
1349
1298
|
"""
|
|
1350
1299
|
_response = await self._client_wrapper.httpx_client.request(
|
|
1351
|
-
"
|
|
1352
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/
|
|
1300
|
+
"DELETE",
|
|
1301
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/runs/{run_id}"),
|
|
1353
1302
|
headers=self._client_wrapper.get_headers(),
|
|
1354
1303
|
timeout=60,
|
|
1355
1304
|
)
|
|
1356
1305
|
if 200 <= _response.status_code < 300:
|
|
1357
|
-
return pydantic.parse_obj_as(
|
|
1306
|
+
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
|
|
1358
1307
|
if _response.status_code == 422:
|
|
1359
1308
|
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
1360
1309
|
try:
|