llama-cloud 0.0.6__py3-none-any.whl → 0.0.8__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 (42) hide show
  1. llama_cloud/__init__.py +18 -4
  2. llama_cloud/client.py +3 -0
  3. llama_cloud/resources/__init__.py +4 -1
  4. llama_cloud/resources/component_definitions/client.py +18 -18
  5. llama_cloud/resources/data_sinks/client.py +2 -2
  6. llama_cloud/resources/data_sinks/types/data_sink_update_component_one.py +2 -0
  7. llama_cloud/resources/data_sources/client.py +2 -2
  8. llama_cloud/resources/data_sources/types/data_source_update_component_one.py +4 -4
  9. llama_cloud/resources/evals/client.py +12 -12
  10. llama_cloud/resources/extraction/__init__.py +5 -0
  11. llama_cloud/resources/extraction/client.py +648 -0
  12. llama_cloud/resources/extraction/types/__init__.py +5 -0
  13. llama_cloud/resources/extraction/types/extraction_schema_update_data_schema_value.py +7 -0
  14. llama_cloud/resources/files/client.py +8 -8
  15. llama_cloud/resources/parsing/client.py +16 -0
  16. llama_cloud/resources/pipelines/client.py +156 -12
  17. llama_cloud/resources/projects/client.py +24 -24
  18. llama_cloud/types/__init__.py +14 -4
  19. llama_cloud/types/azure_open_ai_embedding.py +3 -0
  20. llama_cloud/types/{cloud_gcs_data_source.py → cloud_azure_ai_search_vector_store.py} +9 -7
  21. llama_cloud/types/{cloud_google_drive_data_source.py → cloud_notion_page_data_source.py} +4 -5
  22. llama_cloud/types/cloud_slack_data_source.py +42 -0
  23. llama_cloud/types/configurable_data_sink_names.py +4 -0
  24. llama_cloud/types/configurable_data_source_names.py +8 -8
  25. llama_cloud/types/data_sink_component_one.py +2 -0
  26. llama_cloud/types/data_sink_create_component_one.py +2 -0
  27. llama_cloud/types/data_source_component_one.py +4 -4
  28. llama_cloud/types/data_source_create_component_one.py +4 -4
  29. llama_cloud/types/eval_dataset_job_record.py +1 -1
  30. llama_cloud/types/extraction_result.py +42 -0
  31. llama_cloud/types/extraction_result_data_value.py +5 -0
  32. llama_cloud/types/extraction_schema.py +44 -0
  33. llama_cloud/types/extraction_schema_data_schema_value.py +7 -0
  34. llama_cloud/types/llama_parse_parameters.py +2 -0
  35. llama_cloud/types/llama_parse_supported_file_extensions.py +124 -0
  36. llama_cloud/types/pipeline.py +0 -4
  37. llama_cloud/types/pipeline_data_source_component_one.py +4 -4
  38. llama_cloud/types/text_node.py +1 -0
  39. {llama_cloud-0.0.6.dist-info → llama_cloud-0.0.8.dist-info}/METADATA +1 -2
  40. {llama_cloud-0.0.6.dist-info → llama_cloud-0.0.8.dist-info}/RECORD +42 -33
  41. {llama_cloud-0.0.6.dist-info → llama_cloud-0.0.8.dist-info}/WHEEL +1 -1
  42. {llama_cloud-0.0.6.dist-info → llama_cloud-0.0.8.dist-info}/LICENSE +0 -0
@@ -0,0 +1,648 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ import urllib.parse
5
+ from json.decoder import JSONDecodeError
6
+
7
+ from ...core.api_error import ApiError
8
+ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
+ from ...core.jsonable_encoder import jsonable_encoder
10
+ from ...core.remove_none_from_dict import remove_none_from_dict
11
+ from ...errors.unprocessable_entity_error import UnprocessableEntityError
12
+ from ...types.extraction_result import ExtractionResult
13
+ from ...types.extraction_schema import ExtractionSchema
14
+ from ...types.http_validation_error import HttpValidationError
15
+ from .types.extraction_schema_update_data_schema_value import ExtractionSchemaUpdateDataSchemaValue
16
+
17
+ try:
18
+ import pydantic
19
+ if pydantic.__version__.startswith("1."):
20
+ raise ImportError
21
+ import pydantic.v1 as pydantic # type: ignore
22
+ except ImportError:
23
+ import pydantic # type: ignore
24
+
25
+ # this is used as the default value for optional parameters
26
+ OMIT = typing.cast(typing.Any, ...)
27
+
28
+
29
+ class ExtractionClient:
30
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
31
+ self._client_wrapper = client_wrapper
32
+
33
+ def infer_schema(
34
+ self, *, name: str, project_id: typing.Optional[str] = OMIT, file_ids: typing.List[str], openai_api_key: str
35
+ ) -> ExtractionSchema:
36
+ """
37
+ Parameters:
38
+ - name: str. The name of the extraction schema
39
+
40
+ - project_id: typing.Optional[str]. The ID of the project that the extraction schema belongs to
41
+
42
+ - file_ids: typing.List[str]. The IDs of the files that the extraction schema contains
43
+
44
+ - openai_api_key: str. The API key for the OpenAI API
45
+ ---
46
+ from llama_cloud.client import LlamaCloud
47
+
48
+ client = LlamaCloud(
49
+ token="YOUR_TOKEN",
50
+ )
51
+ client.extraction.infer_schema(
52
+ name="string",
53
+ file_ids=[],
54
+ openai_api_key="string",
55
+ )
56
+ """
57
+ _request: typing.Dict[str, typing.Any] = {"name": name, "file_ids": file_ids, "openai_api_key": openai_api_key}
58
+ if project_id is not OMIT:
59
+ _request["project_id"] = project_id
60
+ _response = self._client_wrapper.httpx_client.request(
61
+ "POST",
62
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/schemas/infer"),
63
+ json=jsonable_encoder(_request),
64
+ headers=self._client_wrapper.get_headers(),
65
+ timeout=60,
66
+ )
67
+ if 200 <= _response.status_code < 300:
68
+ return pydantic.parse_obj_as(ExtractionSchema, _response.json()) # type: ignore
69
+ if _response.status_code == 422:
70
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
71
+ try:
72
+ _response_json = _response.json()
73
+ except JSONDecodeError:
74
+ raise ApiError(status_code=_response.status_code, body=_response.text)
75
+ raise ApiError(status_code=_response.status_code, body=_response_json)
76
+
77
+ def list_schemas(self, *, project_id: typing.Optional[str] = None) -> typing.List[ExtractionSchema]:
78
+ """
79
+ Parameters:
80
+ - project_id: typing.Optional[str].
81
+ ---
82
+ from llama_cloud.client import LlamaCloud
83
+
84
+ client = LlamaCloud(
85
+ token="YOUR_TOKEN",
86
+ )
87
+ client.extraction.list_schemas()
88
+ """
89
+ _response = self._client_wrapper.httpx_client.request(
90
+ "GET",
91
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/schemas"),
92
+ params=remove_none_from_dict({"project_id": project_id}),
93
+ headers=self._client_wrapper.get_headers(),
94
+ timeout=60,
95
+ )
96
+ if 200 <= _response.status_code < 300:
97
+ return pydantic.parse_obj_as(typing.List[ExtractionSchema], _response.json()) # type: ignore
98
+ if _response.status_code == 422:
99
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
100
+ try:
101
+ _response_json = _response.json()
102
+ except JSONDecodeError:
103
+ raise ApiError(status_code=_response.status_code, body=_response.text)
104
+ raise ApiError(status_code=_response.status_code, body=_response_json)
105
+
106
+ def get_schema(self, schema_id: str) -> ExtractionSchema:
107
+ """
108
+ Parameters:
109
+ - schema_id: str.
110
+ ---
111
+ from llama_cloud.client import LlamaCloud
112
+
113
+ client = LlamaCloud(
114
+ token="YOUR_TOKEN",
115
+ )
116
+ client.extraction.get_schema(
117
+ schema_id="string",
118
+ )
119
+ """
120
+ _response = self._client_wrapper.httpx_client.request(
121
+ "GET",
122
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/schemas/{schema_id}"),
123
+ headers=self._client_wrapper.get_headers(),
124
+ timeout=60,
125
+ )
126
+ if 200 <= _response.status_code < 300:
127
+ return pydantic.parse_obj_as(ExtractionSchema, _response.json()) # type: ignore
128
+ if _response.status_code == 422:
129
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
130
+ try:
131
+ _response_json = _response.json()
132
+ except JSONDecodeError:
133
+ raise ApiError(status_code=_response.status_code, body=_response.text)
134
+ raise ApiError(status_code=_response.status_code, body=_response_json)
135
+
136
+ def update_schema(
137
+ self,
138
+ schema_id: str,
139
+ *,
140
+ data_schema: typing.Optional[typing.Dict[str, ExtractionSchemaUpdateDataSchemaValue]] = OMIT,
141
+ openai_api_key: typing.Optional[str] = OMIT,
142
+ ) -> ExtractionSchema:
143
+ """
144
+ Parameters:
145
+ - schema_id: str.
146
+
147
+ - data_schema: typing.Optional[typing.Dict[str, ExtractionSchemaUpdateDataSchemaValue]]. The schema of the data
148
+
149
+ - openai_api_key: typing.Optional[str]. The API key for the OpenAI API
150
+ ---
151
+ from llama_cloud.client import LlamaCloud
152
+
153
+ client = LlamaCloud(
154
+ token="YOUR_TOKEN",
155
+ )
156
+ client.extraction.update_schema(
157
+ schema_id="string",
158
+ )
159
+ """
160
+ _request: typing.Dict[str, typing.Any] = {}
161
+ if data_schema is not OMIT:
162
+ _request["data_schema"] = data_schema
163
+ if openai_api_key is not OMIT:
164
+ _request["openai_api_key"] = openai_api_key
165
+ _response = self._client_wrapper.httpx_client.request(
166
+ "PUT",
167
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/schemas/{schema_id}"),
168
+ json=jsonable_encoder(_request),
169
+ headers=self._client_wrapper.get_headers(),
170
+ timeout=60,
171
+ )
172
+ if 200 <= _response.status_code < 300:
173
+ return pydantic.parse_obj_as(ExtractionSchema, _response.json()) # type: ignore
174
+ if _response.status_code == 422:
175
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
176
+ try:
177
+ _response_json = _response.json()
178
+ except JSONDecodeError:
179
+ raise ApiError(status_code=_response.status_code, body=_response.text)
180
+ raise ApiError(status_code=_response.status_code, body=_response_json)
181
+
182
+ def list_jobs(self, *, schema_id: typing.Optional[str] = None) -> typing.List[ExtractionResult]:
183
+ """
184
+ Parameters:
185
+ - schema_id: typing.Optional[str].
186
+ ---
187
+ from llama_cloud.client import LlamaCloud
188
+
189
+ client = LlamaCloud(
190
+ token="YOUR_TOKEN",
191
+ )
192
+ client.extraction.list_jobs()
193
+ """
194
+ _response = self._client_wrapper.httpx_client.request(
195
+ "GET",
196
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/jobs"),
197
+ params=remove_none_from_dict({"schema_id": schema_id}),
198
+ headers=self._client_wrapper.get_headers(),
199
+ timeout=60,
200
+ )
201
+ if 200 <= _response.status_code < 300:
202
+ return pydantic.parse_obj_as(typing.List[ExtractionResult], _response.json()) # type: ignore
203
+ if _response.status_code == 422:
204
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
205
+ try:
206
+ _response_json = _response.json()
207
+ except JSONDecodeError:
208
+ raise ApiError(status_code=_response.status_code, body=_response.text)
209
+ raise ApiError(status_code=_response.status_code, body=_response_json)
210
+
211
+ def run_job(self, *, schema_id: str, file_id: str) -> ExtractionResult:
212
+ """
213
+ Parameters:
214
+ - schema_id: str. The id of the schema
215
+
216
+ - file_id: str. The id of the file
217
+ ---
218
+ from llama_cloud.client import LlamaCloud
219
+
220
+ client = LlamaCloud(
221
+ token="YOUR_TOKEN",
222
+ )
223
+ client.extraction.run_job(
224
+ schema_id="string",
225
+ file_id="string",
226
+ )
227
+ """
228
+ _response = self._client_wrapper.httpx_client.request(
229
+ "POST",
230
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/jobs"),
231
+ json=jsonable_encoder({"schema_id": schema_id, "file_id": file_id}),
232
+ headers=self._client_wrapper.get_headers(),
233
+ timeout=60,
234
+ )
235
+ if 200 <= _response.status_code < 300:
236
+ return pydantic.parse_obj_as(ExtractionResult, _response.json()) # type: ignore
237
+ if _response.status_code == 422:
238
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
239
+ try:
240
+ _response_json = _response.json()
241
+ except JSONDecodeError:
242
+ raise ApiError(status_code=_response.status_code, body=_response.text)
243
+ raise ApiError(status_code=_response.status_code, body=_response_json)
244
+
245
+ def get_job(self, job_id: str) -> ExtractionResult:
246
+ """
247
+ Parameters:
248
+ - job_id: str.
249
+ ---
250
+ from llama_cloud.client import LlamaCloud
251
+
252
+ client = LlamaCloud(
253
+ token="YOUR_TOKEN",
254
+ )
255
+ client.extraction.get_job(
256
+ job_id="string",
257
+ )
258
+ """
259
+ _response = self._client_wrapper.httpx_client.request(
260
+ "GET",
261
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/jobs/{job_id}"),
262
+ headers=self._client_wrapper.get_headers(),
263
+ timeout=60,
264
+ )
265
+ if 200 <= _response.status_code < 300:
266
+ return pydantic.parse_obj_as(ExtractionResult, _response.json()) # type: ignore
267
+ if _response.status_code == 422:
268
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
269
+ try:
270
+ _response_json = _response.json()
271
+ except JSONDecodeError:
272
+ raise ApiError(status_code=_response.status_code, body=_response.text)
273
+ raise ApiError(status_code=_response.status_code, body=_response_json)
274
+
275
+ def run_jobs_in_batch(self, *, schema_id: str, file_ids: typing.List[str]) -> typing.List[ExtractionResult]:
276
+ """
277
+ Parameters:
278
+ - schema_id: str. The id of the schema
279
+
280
+ - file_ids: typing.List[str]. The ids of the files
281
+ ---
282
+ from llama_cloud.client import LlamaCloud
283
+
284
+ client = LlamaCloud(
285
+ token="YOUR_TOKEN",
286
+ )
287
+ client.extraction.run_jobs_in_batch(
288
+ schema_id="string",
289
+ file_ids=[],
290
+ )
291
+ """
292
+ _response = self._client_wrapper.httpx_client.request(
293
+ "POST",
294
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/jobs/batch"),
295
+ json=jsonable_encoder({"schema_id": schema_id, "file_ids": file_ids}),
296
+ headers=self._client_wrapper.get_headers(),
297
+ timeout=60,
298
+ )
299
+ if 200 <= _response.status_code < 300:
300
+ return pydantic.parse_obj_as(typing.List[ExtractionResult], _response.json()) # type: ignore
301
+ if _response.status_code == 422:
302
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
303
+ try:
304
+ _response_json = _response.json()
305
+ except JSONDecodeError:
306
+ raise ApiError(status_code=_response.status_code, body=_response.text)
307
+ raise ApiError(status_code=_response.status_code, body=_response_json)
308
+
309
+ def get_job_result(self, job_id: str) -> ExtractionResult:
310
+ """
311
+ Parameters:
312
+ - job_id: str.
313
+ ---
314
+ from llama_cloud.client import LlamaCloud
315
+
316
+ client = LlamaCloud(
317
+ token="YOUR_TOKEN",
318
+ )
319
+ client.extraction.get_job_result(
320
+ job_id="string",
321
+ )
322
+ """
323
+ _response = self._client_wrapper.httpx_client.request(
324
+ "GET",
325
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/jobs/{job_id}/result"),
326
+ headers=self._client_wrapper.get_headers(),
327
+ timeout=60,
328
+ )
329
+ if 200 <= _response.status_code < 300:
330
+ return pydantic.parse_obj_as(ExtractionResult, _response.json()) # type: ignore
331
+ if _response.status_code == 422:
332
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
333
+ try:
334
+ _response_json = _response.json()
335
+ except JSONDecodeError:
336
+ raise ApiError(status_code=_response.status_code, body=_response.text)
337
+ raise ApiError(status_code=_response.status_code, body=_response_json)
338
+
339
+
340
+ class AsyncExtractionClient:
341
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
342
+ self._client_wrapper = client_wrapper
343
+
344
+ async def infer_schema(
345
+ self, *, name: str, project_id: typing.Optional[str] = OMIT, file_ids: typing.List[str], openai_api_key: str
346
+ ) -> ExtractionSchema:
347
+ """
348
+ Parameters:
349
+ - name: str. The name of the extraction schema
350
+
351
+ - project_id: typing.Optional[str]. The ID of the project that the extraction schema belongs to
352
+
353
+ - file_ids: typing.List[str]. The IDs of the files that the extraction schema contains
354
+
355
+ - openai_api_key: str. The API key for the OpenAI API
356
+ ---
357
+ from llama_cloud.client import AsyncLlamaCloud
358
+
359
+ client = AsyncLlamaCloud(
360
+ token="YOUR_TOKEN",
361
+ )
362
+ await client.extraction.infer_schema(
363
+ name="string",
364
+ file_ids=[],
365
+ openai_api_key="string",
366
+ )
367
+ """
368
+ _request: typing.Dict[str, typing.Any] = {"name": name, "file_ids": file_ids, "openai_api_key": openai_api_key}
369
+ if project_id is not OMIT:
370
+ _request["project_id"] = project_id
371
+ _response = await self._client_wrapper.httpx_client.request(
372
+ "POST",
373
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/schemas/infer"),
374
+ json=jsonable_encoder(_request),
375
+ headers=self._client_wrapper.get_headers(),
376
+ timeout=60,
377
+ )
378
+ if 200 <= _response.status_code < 300:
379
+ return pydantic.parse_obj_as(ExtractionSchema, _response.json()) # type: ignore
380
+ if _response.status_code == 422:
381
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
382
+ try:
383
+ _response_json = _response.json()
384
+ except JSONDecodeError:
385
+ raise ApiError(status_code=_response.status_code, body=_response.text)
386
+ raise ApiError(status_code=_response.status_code, body=_response_json)
387
+
388
+ async def list_schemas(self, *, project_id: typing.Optional[str] = None) -> typing.List[ExtractionSchema]:
389
+ """
390
+ Parameters:
391
+ - project_id: typing.Optional[str].
392
+ ---
393
+ from llama_cloud.client import AsyncLlamaCloud
394
+
395
+ client = AsyncLlamaCloud(
396
+ token="YOUR_TOKEN",
397
+ )
398
+ await client.extraction.list_schemas()
399
+ """
400
+ _response = await self._client_wrapper.httpx_client.request(
401
+ "GET",
402
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/schemas"),
403
+ params=remove_none_from_dict({"project_id": project_id}),
404
+ headers=self._client_wrapper.get_headers(),
405
+ timeout=60,
406
+ )
407
+ if 200 <= _response.status_code < 300:
408
+ return pydantic.parse_obj_as(typing.List[ExtractionSchema], _response.json()) # type: ignore
409
+ if _response.status_code == 422:
410
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
411
+ try:
412
+ _response_json = _response.json()
413
+ except JSONDecodeError:
414
+ raise ApiError(status_code=_response.status_code, body=_response.text)
415
+ raise ApiError(status_code=_response.status_code, body=_response_json)
416
+
417
+ async def get_schema(self, schema_id: str) -> ExtractionSchema:
418
+ """
419
+ Parameters:
420
+ - schema_id: str.
421
+ ---
422
+ from llama_cloud.client import AsyncLlamaCloud
423
+
424
+ client = AsyncLlamaCloud(
425
+ token="YOUR_TOKEN",
426
+ )
427
+ await client.extraction.get_schema(
428
+ schema_id="string",
429
+ )
430
+ """
431
+ _response = await self._client_wrapper.httpx_client.request(
432
+ "GET",
433
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/schemas/{schema_id}"),
434
+ headers=self._client_wrapper.get_headers(),
435
+ timeout=60,
436
+ )
437
+ if 200 <= _response.status_code < 300:
438
+ return pydantic.parse_obj_as(ExtractionSchema, _response.json()) # type: ignore
439
+ if _response.status_code == 422:
440
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
441
+ try:
442
+ _response_json = _response.json()
443
+ except JSONDecodeError:
444
+ raise ApiError(status_code=_response.status_code, body=_response.text)
445
+ raise ApiError(status_code=_response.status_code, body=_response_json)
446
+
447
+ async def update_schema(
448
+ self,
449
+ schema_id: str,
450
+ *,
451
+ data_schema: typing.Optional[typing.Dict[str, ExtractionSchemaUpdateDataSchemaValue]] = OMIT,
452
+ openai_api_key: typing.Optional[str] = OMIT,
453
+ ) -> ExtractionSchema:
454
+ """
455
+ Parameters:
456
+ - schema_id: str.
457
+
458
+ - data_schema: typing.Optional[typing.Dict[str, ExtractionSchemaUpdateDataSchemaValue]]. The schema of the data
459
+
460
+ - openai_api_key: typing.Optional[str]. The API key for the OpenAI API
461
+ ---
462
+ from llama_cloud.client import AsyncLlamaCloud
463
+
464
+ client = AsyncLlamaCloud(
465
+ token="YOUR_TOKEN",
466
+ )
467
+ await client.extraction.update_schema(
468
+ schema_id="string",
469
+ )
470
+ """
471
+ _request: typing.Dict[str, typing.Any] = {}
472
+ if data_schema is not OMIT:
473
+ _request["data_schema"] = data_schema
474
+ if openai_api_key is not OMIT:
475
+ _request["openai_api_key"] = openai_api_key
476
+ _response = await self._client_wrapper.httpx_client.request(
477
+ "PUT",
478
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/schemas/{schema_id}"),
479
+ json=jsonable_encoder(_request),
480
+ headers=self._client_wrapper.get_headers(),
481
+ timeout=60,
482
+ )
483
+ if 200 <= _response.status_code < 300:
484
+ return pydantic.parse_obj_as(ExtractionSchema, _response.json()) # type: ignore
485
+ if _response.status_code == 422:
486
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
487
+ try:
488
+ _response_json = _response.json()
489
+ except JSONDecodeError:
490
+ raise ApiError(status_code=_response.status_code, body=_response.text)
491
+ raise ApiError(status_code=_response.status_code, body=_response_json)
492
+
493
+ async def list_jobs(self, *, schema_id: typing.Optional[str] = None) -> typing.List[ExtractionResult]:
494
+ """
495
+ Parameters:
496
+ - schema_id: typing.Optional[str].
497
+ ---
498
+ from llama_cloud.client import AsyncLlamaCloud
499
+
500
+ client = AsyncLlamaCloud(
501
+ token="YOUR_TOKEN",
502
+ )
503
+ await client.extraction.list_jobs()
504
+ """
505
+ _response = await self._client_wrapper.httpx_client.request(
506
+ "GET",
507
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/jobs"),
508
+ params=remove_none_from_dict({"schema_id": schema_id}),
509
+ headers=self._client_wrapper.get_headers(),
510
+ timeout=60,
511
+ )
512
+ if 200 <= _response.status_code < 300:
513
+ return pydantic.parse_obj_as(typing.List[ExtractionResult], _response.json()) # type: ignore
514
+ if _response.status_code == 422:
515
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
516
+ try:
517
+ _response_json = _response.json()
518
+ except JSONDecodeError:
519
+ raise ApiError(status_code=_response.status_code, body=_response.text)
520
+ raise ApiError(status_code=_response.status_code, body=_response_json)
521
+
522
+ async def run_job(self, *, schema_id: str, file_id: str) -> ExtractionResult:
523
+ """
524
+ Parameters:
525
+ - schema_id: str. The id of the schema
526
+
527
+ - file_id: str. The id of the file
528
+ ---
529
+ from llama_cloud.client import AsyncLlamaCloud
530
+
531
+ client = AsyncLlamaCloud(
532
+ token="YOUR_TOKEN",
533
+ )
534
+ await client.extraction.run_job(
535
+ schema_id="string",
536
+ file_id="string",
537
+ )
538
+ """
539
+ _response = await self._client_wrapper.httpx_client.request(
540
+ "POST",
541
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/jobs"),
542
+ json=jsonable_encoder({"schema_id": schema_id, "file_id": file_id}),
543
+ headers=self._client_wrapper.get_headers(),
544
+ timeout=60,
545
+ )
546
+ if 200 <= _response.status_code < 300:
547
+ return pydantic.parse_obj_as(ExtractionResult, _response.json()) # type: ignore
548
+ if _response.status_code == 422:
549
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
550
+ try:
551
+ _response_json = _response.json()
552
+ except JSONDecodeError:
553
+ raise ApiError(status_code=_response.status_code, body=_response.text)
554
+ raise ApiError(status_code=_response.status_code, body=_response_json)
555
+
556
+ async def get_job(self, job_id: str) -> ExtractionResult:
557
+ """
558
+ Parameters:
559
+ - job_id: str.
560
+ ---
561
+ from llama_cloud.client import AsyncLlamaCloud
562
+
563
+ client = AsyncLlamaCloud(
564
+ token="YOUR_TOKEN",
565
+ )
566
+ await client.extraction.get_job(
567
+ job_id="string",
568
+ )
569
+ """
570
+ _response = await self._client_wrapper.httpx_client.request(
571
+ "GET",
572
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/jobs/{job_id}"),
573
+ headers=self._client_wrapper.get_headers(),
574
+ timeout=60,
575
+ )
576
+ if 200 <= _response.status_code < 300:
577
+ return pydantic.parse_obj_as(ExtractionResult, _response.json()) # type: ignore
578
+ if _response.status_code == 422:
579
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
580
+ try:
581
+ _response_json = _response.json()
582
+ except JSONDecodeError:
583
+ raise ApiError(status_code=_response.status_code, body=_response.text)
584
+ raise ApiError(status_code=_response.status_code, body=_response_json)
585
+
586
+ async def run_jobs_in_batch(self, *, schema_id: str, file_ids: typing.List[str]) -> typing.List[ExtractionResult]:
587
+ """
588
+ Parameters:
589
+ - schema_id: str. The id of the schema
590
+
591
+ - file_ids: typing.List[str]. The ids of the files
592
+ ---
593
+ from llama_cloud.client import AsyncLlamaCloud
594
+
595
+ client = AsyncLlamaCloud(
596
+ token="YOUR_TOKEN",
597
+ )
598
+ await client.extraction.run_jobs_in_batch(
599
+ schema_id="string",
600
+ file_ids=[],
601
+ )
602
+ """
603
+ _response = await self._client_wrapper.httpx_client.request(
604
+ "POST",
605
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/jobs/batch"),
606
+ json=jsonable_encoder({"schema_id": schema_id, "file_ids": file_ids}),
607
+ headers=self._client_wrapper.get_headers(),
608
+ timeout=60,
609
+ )
610
+ if 200 <= _response.status_code < 300:
611
+ return pydantic.parse_obj_as(typing.List[ExtractionResult], _response.json()) # type: ignore
612
+ if _response.status_code == 422:
613
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
614
+ try:
615
+ _response_json = _response.json()
616
+ except JSONDecodeError:
617
+ raise ApiError(status_code=_response.status_code, body=_response.text)
618
+ raise ApiError(status_code=_response.status_code, body=_response_json)
619
+
620
+ async def get_job_result(self, job_id: str) -> ExtractionResult:
621
+ """
622
+ Parameters:
623
+ - job_id: str.
624
+ ---
625
+ from llama_cloud.client import AsyncLlamaCloud
626
+
627
+ client = AsyncLlamaCloud(
628
+ token="YOUR_TOKEN",
629
+ )
630
+ await client.extraction.get_job_result(
631
+ job_id="string",
632
+ )
633
+ """
634
+ _response = await self._client_wrapper.httpx_client.request(
635
+ "GET",
636
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/extraction/jobs/{job_id}/result"),
637
+ headers=self._client_wrapper.get_headers(),
638
+ timeout=60,
639
+ )
640
+ if 200 <= _response.status_code < 300:
641
+ return pydantic.parse_obj_as(ExtractionResult, _response.json()) # type: ignore
642
+ if _response.status_code == 422:
643
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
644
+ try:
645
+ _response_json = _response.json()
646
+ except JSONDecodeError:
647
+ raise ApiError(status_code=_response.status_code, body=_response.text)
648
+ raise ApiError(status_code=_response.status_code, body=_response_json)
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from .extraction_schema_update_data_schema_value import ExtractionSchemaUpdateDataSchemaValue
4
+
5
+ __all__ = ["ExtractionSchemaUpdateDataSchemaValue"]
@@ -0,0 +1,7 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ ExtractionSchemaUpdateDataSchemaValue = typing.Union[
6
+ typing.Dict[str, typing.Any], typing.List[typing.Any], str, int, float, bool
7
+ ]