llama-cloud 0.0.3__py3-none-any.whl → 0.0.5__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 +2 -8
- llama_cloud/client.py +16 -13
- llama_cloud/environment.py +7 -0
- llama_cloud/resources/__init__.py +1 -16
- llama_cloud/resources/component_definitions/client.py +0 -6
- llama_cloud/resources/data_sinks/client.py +0 -12
- llama_cloud/resources/data_sources/client.py +0 -12
- llama_cloud/resources/evals/client.py +0 -20
- llama_cloud/resources/files/client.py +0 -12
- llama_cloud/resources/parsing/client.py +0 -24
- llama_cloud/resources/pipelines/client.py +0 -58
- llama_cloud/resources/projects/client.py +0 -32
- llama_cloud/types/__init__.py +0 -2
- {llama_cloud-0.0.3.dist-info → llama_cloud-0.0.5.dist-info}/METADATA +1 -1
- {llama_cloud-0.0.3.dist-info → llama_cloud-0.0.5.dist-info}/RECORD +17 -23
- llama_cloud/resources/api_keys/__init__.py +0 -2
- llama_cloud/resources/api_keys/client.py +0 -305
- llama_cloud/resources/billing/__init__.py +0 -2
- llama_cloud/resources/billing/client.py +0 -237
- llama_cloud/resources/deprecated/__init__.py +0 -2
- llama_cloud/resources/deprecated/client.py +0 -985
- llama_cloud/types/api_key.py +0 -40
- {llama_cloud-0.0.3.dist-info → llama_cloud-0.0.5.dist-info}/LICENSE +0 -0
- {llama_cloud-0.0.3.dist-info → llama_cloud-0.0.5.dist-info}/WHEEL +0 -0
|
@@ -1,985 +0,0 @@
|
|
|
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 ...errors.unprocessable_entity_error import UnprocessableEntityError
|
|
11
|
-
from ...types.http_validation_error import HttpValidationError
|
|
12
|
-
from ...types.llama_parse_supported_file_extensions import LlamaParseSupportedFileExtensions
|
|
13
|
-
from ...types.parser_languages import ParserLanguages
|
|
14
|
-
from ...types.parsing_history_item import ParsingHistoryItem
|
|
15
|
-
from ...types.parsing_job import ParsingJob
|
|
16
|
-
from ...types.parsing_job_json_result import ParsingJobJsonResult
|
|
17
|
-
from ...types.parsing_job_markdown_result import ParsingJobMarkdownResult
|
|
18
|
-
from ...types.parsing_job_text_result import ParsingJobTextResult
|
|
19
|
-
from ...types.parsing_usage import ParsingUsage
|
|
20
|
-
from ...types.presigned_url import PresignedUrl
|
|
21
|
-
|
|
22
|
-
try:
|
|
23
|
-
import pydantic
|
|
24
|
-
if pydantic.__version__.startswith("1."):
|
|
25
|
-
raise ImportError
|
|
26
|
-
import pydantic.v1 as pydantic # type: ignore
|
|
27
|
-
except ImportError:
|
|
28
|
-
import pydantic # type: ignore
|
|
29
|
-
|
|
30
|
-
# this is used as the default value for optional parameters
|
|
31
|
-
OMIT = typing.cast(typing.Any, ...)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class DeprecatedClient:
|
|
35
|
-
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
36
|
-
self._client_wrapper = client_wrapper
|
|
37
|
-
|
|
38
|
-
def get_job_image_result(self, job_id: str, name: str) -> None:
|
|
39
|
-
"""
|
|
40
|
-
Get a job by id
|
|
41
|
-
|
|
42
|
-
Parameters:
|
|
43
|
-
- job_id: str.
|
|
44
|
-
|
|
45
|
-
- name: str.
|
|
46
|
-
---
|
|
47
|
-
from llama_cloud.client import LlamaCloud
|
|
48
|
-
|
|
49
|
-
client = LlamaCloud(
|
|
50
|
-
token="YOUR_TOKEN",
|
|
51
|
-
base_url="https://yourhost.com/path/to/api",
|
|
52
|
-
)
|
|
53
|
-
client.deprecated.get_job_image_result(
|
|
54
|
-
job_id="string",
|
|
55
|
-
name="string",
|
|
56
|
-
)
|
|
57
|
-
"""
|
|
58
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
59
|
-
"GET",
|
|
60
|
-
urllib.parse.urljoin(
|
|
61
|
-
f"{self._client_wrapper.get_base_url()}/", f"api/parsing/job/{job_id}/result/image/{name}"
|
|
62
|
-
),
|
|
63
|
-
headers=self._client_wrapper.get_headers(),
|
|
64
|
-
timeout=60,
|
|
65
|
-
)
|
|
66
|
-
if 200 <= _response.status_code < 300:
|
|
67
|
-
return
|
|
68
|
-
if _response.status_code == 422:
|
|
69
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
70
|
-
try:
|
|
71
|
-
_response_json = _response.json()
|
|
72
|
-
except JSONDecodeError:
|
|
73
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
74
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
75
|
-
|
|
76
|
-
def get_supported_file_extensions(self) -> typing.List[LlamaParseSupportedFileExtensions]:
|
|
77
|
-
"""
|
|
78
|
-
Get a list of supported file extensions
|
|
79
|
-
|
|
80
|
-
---
|
|
81
|
-
from llama_cloud.client import LlamaCloud
|
|
82
|
-
|
|
83
|
-
client = LlamaCloud(
|
|
84
|
-
token="YOUR_TOKEN",
|
|
85
|
-
base_url="https://yourhost.com/path/to/api",
|
|
86
|
-
)
|
|
87
|
-
client.deprecated.get_supported_file_extensions()
|
|
88
|
-
"""
|
|
89
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
90
|
-
"GET",
|
|
91
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/parsing/supported_file_extensions"),
|
|
92
|
-
headers=self._client_wrapper.get_headers(),
|
|
93
|
-
timeout=60,
|
|
94
|
-
)
|
|
95
|
-
if 200 <= _response.status_code < 300:
|
|
96
|
-
return pydantic.parse_obj_as(typing.List[LlamaParseSupportedFileExtensions], _response.json()) # type: ignore
|
|
97
|
-
try:
|
|
98
|
-
_response_json = _response.json()
|
|
99
|
-
except JSONDecodeError:
|
|
100
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
101
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
102
|
-
|
|
103
|
-
def upload_file(
|
|
104
|
-
self,
|
|
105
|
-
*,
|
|
106
|
-
language: typing.List[ParserLanguages],
|
|
107
|
-
parsing_instruction: str,
|
|
108
|
-
skip_diagonal_text: bool,
|
|
109
|
-
invalidate_cache: bool,
|
|
110
|
-
do_not_cache: bool,
|
|
111
|
-
gpt_4_o_mode: bool,
|
|
112
|
-
fast_mode: bool,
|
|
113
|
-
gpt_4_o_api_key: str,
|
|
114
|
-
do_not_unroll_columns: bool,
|
|
115
|
-
page_separator: str,
|
|
116
|
-
file: typing.IO,
|
|
117
|
-
) -> ParsingJob:
|
|
118
|
-
"""
|
|
119
|
-
Upload a file to s3 and create a job. return a job id
|
|
120
|
-
|
|
121
|
-
Parameters:
|
|
122
|
-
- language: typing.List[ParserLanguages].
|
|
123
|
-
|
|
124
|
-
- parsing_instruction: str.
|
|
125
|
-
|
|
126
|
-
- skip_diagonal_text: bool.
|
|
127
|
-
|
|
128
|
-
- invalidate_cache: bool.
|
|
129
|
-
|
|
130
|
-
- do_not_cache: bool.
|
|
131
|
-
|
|
132
|
-
- gpt_4_o_mode: bool.
|
|
133
|
-
|
|
134
|
-
- fast_mode: bool.
|
|
135
|
-
|
|
136
|
-
- gpt_4_o_api_key: str.
|
|
137
|
-
|
|
138
|
-
- do_not_unroll_columns: bool.
|
|
139
|
-
|
|
140
|
-
- page_separator: str.
|
|
141
|
-
|
|
142
|
-
- file: typing.IO.
|
|
143
|
-
"""
|
|
144
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
145
|
-
"POST",
|
|
146
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/parsing/upload"),
|
|
147
|
-
data=jsonable_encoder(
|
|
148
|
-
{
|
|
149
|
-
"language": language,
|
|
150
|
-
"parsing_instruction": parsing_instruction,
|
|
151
|
-
"skip_diagonal_text": skip_diagonal_text,
|
|
152
|
-
"invalidate_cache": invalidate_cache,
|
|
153
|
-
"do_not_cache": do_not_cache,
|
|
154
|
-
"gpt4o_mode": gpt_4_o_mode,
|
|
155
|
-
"fast_mode": fast_mode,
|
|
156
|
-
"gpt4o_api_key": gpt_4_o_api_key,
|
|
157
|
-
"do_not_unroll_columns": do_not_unroll_columns,
|
|
158
|
-
"page_separator": page_separator,
|
|
159
|
-
}
|
|
160
|
-
),
|
|
161
|
-
files={"file": file},
|
|
162
|
-
headers=self._client_wrapper.get_headers(),
|
|
163
|
-
timeout=60,
|
|
164
|
-
)
|
|
165
|
-
if 200 <= _response.status_code < 300:
|
|
166
|
-
return pydantic.parse_obj_as(ParsingJob, _response.json()) # type: ignore
|
|
167
|
-
if _response.status_code == 422:
|
|
168
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
169
|
-
try:
|
|
170
|
-
_response_json = _response.json()
|
|
171
|
-
except JSONDecodeError:
|
|
172
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
173
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
174
|
-
|
|
175
|
-
def usage(self) -> ParsingUsage:
|
|
176
|
-
"""
|
|
177
|
-
Get parsing usage for user
|
|
178
|
-
|
|
179
|
-
---
|
|
180
|
-
from llama_cloud.client import LlamaCloud
|
|
181
|
-
|
|
182
|
-
client = LlamaCloud(
|
|
183
|
-
token="YOUR_TOKEN",
|
|
184
|
-
base_url="https://yourhost.com/path/to/api",
|
|
185
|
-
)
|
|
186
|
-
client.deprecated.usage()
|
|
187
|
-
"""
|
|
188
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
189
|
-
"GET",
|
|
190
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/parsing/usage"),
|
|
191
|
-
headers=self._client_wrapper.get_headers(),
|
|
192
|
-
timeout=60,
|
|
193
|
-
)
|
|
194
|
-
if 200 <= _response.status_code < 300:
|
|
195
|
-
return pydantic.parse_obj_as(ParsingUsage, _response.json()) # type: ignore
|
|
196
|
-
if _response.status_code == 422:
|
|
197
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
198
|
-
try:
|
|
199
|
-
_response_json = _response.json()
|
|
200
|
-
except JSONDecodeError:
|
|
201
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
202
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
203
|
-
|
|
204
|
-
def get_job(self, job_id: str) -> ParsingJob:
|
|
205
|
-
"""
|
|
206
|
-
Get a job by id
|
|
207
|
-
|
|
208
|
-
Parameters:
|
|
209
|
-
- job_id: str.
|
|
210
|
-
---
|
|
211
|
-
from llama_cloud.client import LlamaCloud
|
|
212
|
-
|
|
213
|
-
client = LlamaCloud(
|
|
214
|
-
token="YOUR_TOKEN",
|
|
215
|
-
base_url="https://yourhost.com/path/to/api",
|
|
216
|
-
)
|
|
217
|
-
client.deprecated.get_job(
|
|
218
|
-
job_id="string",
|
|
219
|
-
)
|
|
220
|
-
"""
|
|
221
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
222
|
-
"GET",
|
|
223
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/parsing/job/{job_id}"),
|
|
224
|
-
headers=self._client_wrapper.get_headers(),
|
|
225
|
-
timeout=60,
|
|
226
|
-
)
|
|
227
|
-
if 200 <= _response.status_code < 300:
|
|
228
|
-
return pydantic.parse_obj_as(ParsingJob, _response.json()) # type: ignore
|
|
229
|
-
if _response.status_code == 422:
|
|
230
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
231
|
-
try:
|
|
232
|
-
_response_json = _response.json()
|
|
233
|
-
except JSONDecodeError:
|
|
234
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
235
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
236
|
-
|
|
237
|
-
def get_job_text_result(self, job_id: str) -> ParsingJobTextResult:
|
|
238
|
-
"""
|
|
239
|
-
Get a job by id
|
|
240
|
-
|
|
241
|
-
Parameters:
|
|
242
|
-
- job_id: str.
|
|
243
|
-
---
|
|
244
|
-
from llama_cloud.client import LlamaCloud
|
|
245
|
-
|
|
246
|
-
client = LlamaCloud(
|
|
247
|
-
token="YOUR_TOKEN",
|
|
248
|
-
base_url="https://yourhost.com/path/to/api",
|
|
249
|
-
)
|
|
250
|
-
client.deprecated.get_job_text_result(
|
|
251
|
-
job_id="string",
|
|
252
|
-
)
|
|
253
|
-
"""
|
|
254
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
255
|
-
"GET",
|
|
256
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/parsing/job/{job_id}/result/text"),
|
|
257
|
-
headers=self._client_wrapper.get_headers(),
|
|
258
|
-
timeout=60,
|
|
259
|
-
)
|
|
260
|
-
if 200 <= _response.status_code < 300:
|
|
261
|
-
return pydantic.parse_obj_as(ParsingJobTextResult, _response.json()) # type: ignore
|
|
262
|
-
if _response.status_code == 422:
|
|
263
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
264
|
-
try:
|
|
265
|
-
_response_json = _response.json()
|
|
266
|
-
except JSONDecodeError:
|
|
267
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
268
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
269
|
-
|
|
270
|
-
def get_job_raw_text_result(self, job_id: str) -> typing.Any:
|
|
271
|
-
"""
|
|
272
|
-
Get a job by id
|
|
273
|
-
|
|
274
|
-
Parameters:
|
|
275
|
-
- job_id: str.
|
|
276
|
-
---
|
|
277
|
-
from llama_cloud.client import LlamaCloud
|
|
278
|
-
|
|
279
|
-
client = LlamaCloud(
|
|
280
|
-
token="YOUR_TOKEN",
|
|
281
|
-
base_url="https://yourhost.com/path/to/api",
|
|
282
|
-
)
|
|
283
|
-
client.deprecated.get_job_raw_text_result(
|
|
284
|
-
job_id="string",
|
|
285
|
-
)
|
|
286
|
-
"""
|
|
287
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
288
|
-
"GET",
|
|
289
|
-
urllib.parse.urljoin(
|
|
290
|
-
f"{self._client_wrapper.get_base_url()}/", f"api/parsing/job/{job_id}/result/raw/text"
|
|
291
|
-
),
|
|
292
|
-
headers=self._client_wrapper.get_headers(),
|
|
293
|
-
timeout=60,
|
|
294
|
-
)
|
|
295
|
-
if 200 <= _response.status_code < 300:
|
|
296
|
-
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
|
|
297
|
-
if _response.status_code == 422:
|
|
298
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
299
|
-
try:
|
|
300
|
-
_response_json = _response.json()
|
|
301
|
-
except JSONDecodeError:
|
|
302
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
303
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
304
|
-
|
|
305
|
-
def get_job_result(self, job_id: str) -> ParsingJobMarkdownResult:
|
|
306
|
-
"""
|
|
307
|
-
Get a job by id
|
|
308
|
-
|
|
309
|
-
Parameters:
|
|
310
|
-
- job_id: str.
|
|
311
|
-
---
|
|
312
|
-
from llama_cloud.client import LlamaCloud
|
|
313
|
-
|
|
314
|
-
client = LlamaCloud(
|
|
315
|
-
token="YOUR_TOKEN",
|
|
316
|
-
base_url="https://yourhost.com/path/to/api",
|
|
317
|
-
)
|
|
318
|
-
client.deprecated.get_job_result(
|
|
319
|
-
job_id="string",
|
|
320
|
-
)
|
|
321
|
-
"""
|
|
322
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
323
|
-
"GET",
|
|
324
|
-
urllib.parse.urljoin(
|
|
325
|
-
f"{self._client_wrapper.get_base_url()}/", f"api/parsing/job/{job_id}/result/markdown"
|
|
326
|
-
),
|
|
327
|
-
headers=self._client_wrapper.get_headers(),
|
|
328
|
-
timeout=60,
|
|
329
|
-
)
|
|
330
|
-
if 200 <= _response.status_code < 300:
|
|
331
|
-
return pydantic.parse_obj_as(ParsingJobMarkdownResult, _response.json()) # type: ignore
|
|
332
|
-
if _response.status_code == 422:
|
|
333
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
334
|
-
try:
|
|
335
|
-
_response_json = _response.json()
|
|
336
|
-
except JSONDecodeError:
|
|
337
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
338
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
339
|
-
|
|
340
|
-
def get_job_raw_md_result(self, job_id: str) -> typing.Any:
|
|
341
|
-
"""
|
|
342
|
-
Get a job by id
|
|
343
|
-
|
|
344
|
-
Parameters:
|
|
345
|
-
- job_id: str.
|
|
346
|
-
---
|
|
347
|
-
from llama_cloud.client import LlamaCloud
|
|
348
|
-
|
|
349
|
-
client = LlamaCloud(
|
|
350
|
-
token="YOUR_TOKEN",
|
|
351
|
-
base_url="https://yourhost.com/path/to/api",
|
|
352
|
-
)
|
|
353
|
-
client.deprecated.get_job_raw_md_result(
|
|
354
|
-
job_id="string",
|
|
355
|
-
)
|
|
356
|
-
"""
|
|
357
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
358
|
-
"GET",
|
|
359
|
-
urllib.parse.urljoin(
|
|
360
|
-
f"{self._client_wrapper.get_base_url()}/", f"api/parsing/job/{job_id}/result/raw/markdown"
|
|
361
|
-
),
|
|
362
|
-
headers=self._client_wrapper.get_headers(),
|
|
363
|
-
timeout=60,
|
|
364
|
-
)
|
|
365
|
-
if 200 <= _response.status_code < 300:
|
|
366
|
-
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
|
|
367
|
-
if _response.status_code == 422:
|
|
368
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
369
|
-
try:
|
|
370
|
-
_response_json = _response.json()
|
|
371
|
-
except JSONDecodeError:
|
|
372
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
373
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
374
|
-
|
|
375
|
-
def get_job_json_result(self, job_id: str) -> ParsingJobJsonResult:
|
|
376
|
-
"""
|
|
377
|
-
Get a job by id
|
|
378
|
-
|
|
379
|
-
Parameters:
|
|
380
|
-
- job_id: str.
|
|
381
|
-
---
|
|
382
|
-
from llama_cloud.client import LlamaCloud
|
|
383
|
-
|
|
384
|
-
client = LlamaCloud(
|
|
385
|
-
token="YOUR_TOKEN",
|
|
386
|
-
base_url="https://yourhost.com/path/to/api",
|
|
387
|
-
)
|
|
388
|
-
client.deprecated.get_job_json_result(
|
|
389
|
-
job_id="string",
|
|
390
|
-
)
|
|
391
|
-
"""
|
|
392
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
393
|
-
"GET",
|
|
394
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/parsing/job/{job_id}/result/json"),
|
|
395
|
-
headers=self._client_wrapper.get_headers(),
|
|
396
|
-
timeout=60,
|
|
397
|
-
)
|
|
398
|
-
if 200 <= _response.status_code < 300:
|
|
399
|
-
return pydantic.parse_obj_as(ParsingJobJsonResult, _response.json()) # type: ignore
|
|
400
|
-
if _response.status_code == 422:
|
|
401
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
402
|
-
try:
|
|
403
|
-
_response_json = _response.json()
|
|
404
|
-
except JSONDecodeError:
|
|
405
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
406
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
407
|
-
|
|
408
|
-
def get_job_json_raw_result(self, job_id: str) -> typing.Any:
|
|
409
|
-
"""
|
|
410
|
-
Get a job by id
|
|
411
|
-
|
|
412
|
-
Parameters:
|
|
413
|
-
- job_id: str.
|
|
414
|
-
---
|
|
415
|
-
from llama_cloud.client import LlamaCloud
|
|
416
|
-
|
|
417
|
-
client = LlamaCloud(
|
|
418
|
-
token="YOUR_TOKEN",
|
|
419
|
-
base_url="https://yourhost.com/path/to/api",
|
|
420
|
-
)
|
|
421
|
-
client.deprecated.get_job_json_raw_result(
|
|
422
|
-
job_id="string",
|
|
423
|
-
)
|
|
424
|
-
"""
|
|
425
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
426
|
-
"GET",
|
|
427
|
-
urllib.parse.urljoin(
|
|
428
|
-
f"{self._client_wrapper.get_base_url()}/", f"api/parsing/job/{job_id}/result/raw/json"
|
|
429
|
-
),
|
|
430
|
-
headers=self._client_wrapper.get_headers(),
|
|
431
|
-
timeout=60,
|
|
432
|
-
)
|
|
433
|
-
if 200 <= _response.status_code < 300:
|
|
434
|
-
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
|
|
435
|
-
if _response.status_code == 422:
|
|
436
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
437
|
-
try:
|
|
438
|
-
_response_json = _response.json()
|
|
439
|
-
except JSONDecodeError:
|
|
440
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
441
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
442
|
-
|
|
443
|
-
def get_parsing_history_result(self) -> typing.List[ParsingHistoryItem]:
|
|
444
|
-
"""
|
|
445
|
-
Get parsing history for user
|
|
446
|
-
|
|
447
|
-
---
|
|
448
|
-
from llama_cloud.client import LlamaCloud
|
|
449
|
-
|
|
450
|
-
client = LlamaCloud(
|
|
451
|
-
token="YOUR_TOKEN",
|
|
452
|
-
base_url="https://yourhost.com/path/to/api",
|
|
453
|
-
)
|
|
454
|
-
client.deprecated.get_parsing_history_result()
|
|
455
|
-
"""
|
|
456
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
457
|
-
"GET",
|
|
458
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/parsing/history"),
|
|
459
|
-
headers=self._client_wrapper.get_headers(),
|
|
460
|
-
timeout=60,
|
|
461
|
-
)
|
|
462
|
-
if 200 <= _response.status_code < 300:
|
|
463
|
-
return pydantic.parse_obj_as(typing.List[ParsingHistoryItem], _response.json()) # type: ignore
|
|
464
|
-
if _response.status_code == 422:
|
|
465
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
466
|
-
try:
|
|
467
|
-
_response_json = _response.json()
|
|
468
|
-
except JSONDecodeError:
|
|
469
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
470
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
471
|
-
|
|
472
|
-
def generate_presigned_url(self, job_id: str, filename: str) -> PresignedUrl:
|
|
473
|
-
"""
|
|
474
|
-
Generate a presigned URL for a job
|
|
475
|
-
|
|
476
|
-
Parameters:
|
|
477
|
-
- job_id: str.
|
|
478
|
-
|
|
479
|
-
- filename: str.
|
|
480
|
-
---
|
|
481
|
-
from llama_cloud.client import LlamaCloud
|
|
482
|
-
|
|
483
|
-
client = LlamaCloud(
|
|
484
|
-
token="YOUR_TOKEN",
|
|
485
|
-
base_url="https://yourhost.com/path/to/api",
|
|
486
|
-
)
|
|
487
|
-
client.deprecated.generate_presigned_url(
|
|
488
|
-
job_id="string",
|
|
489
|
-
filename="string",
|
|
490
|
-
)
|
|
491
|
-
"""
|
|
492
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
493
|
-
"GET",
|
|
494
|
-
urllib.parse.urljoin(
|
|
495
|
-
f"{self._client_wrapper.get_base_url()}/", f"api/parsing/job/{job_id}/read/{filename}"
|
|
496
|
-
),
|
|
497
|
-
headers=self._client_wrapper.get_headers(),
|
|
498
|
-
timeout=60,
|
|
499
|
-
)
|
|
500
|
-
if 200 <= _response.status_code < 300:
|
|
501
|
-
return pydantic.parse_obj_as(PresignedUrl, _response.json()) # type: ignore
|
|
502
|
-
if _response.status_code == 422:
|
|
503
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
504
|
-
try:
|
|
505
|
-
_response_json = _response.json()
|
|
506
|
-
except JSONDecodeError:
|
|
507
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
508
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
class AsyncDeprecatedClient:
|
|
512
|
-
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
513
|
-
self._client_wrapper = client_wrapper
|
|
514
|
-
|
|
515
|
-
async def get_job_image_result(self, job_id: str, name: str) -> None:
|
|
516
|
-
"""
|
|
517
|
-
Get a job by id
|
|
518
|
-
|
|
519
|
-
Parameters:
|
|
520
|
-
- job_id: str.
|
|
521
|
-
|
|
522
|
-
- name: str.
|
|
523
|
-
---
|
|
524
|
-
from llama_cloud.client import AsyncLlamaCloud
|
|
525
|
-
|
|
526
|
-
client = AsyncLlamaCloud(
|
|
527
|
-
token="YOUR_TOKEN",
|
|
528
|
-
base_url="https://yourhost.com/path/to/api",
|
|
529
|
-
)
|
|
530
|
-
await client.deprecated.get_job_image_result(
|
|
531
|
-
job_id="string",
|
|
532
|
-
name="string",
|
|
533
|
-
)
|
|
534
|
-
"""
|
|
535
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
536
|
-
"GET",
|
|
537
|
-
urllib.parse.urljoin(
|
|
538
|
-
f"{self._client_wrapper.get_base_url()}/", f"api/parsing/job/{job_id}/result/image/{name}"
|
|
539
|
-
),
|
|
540
|
-
headers=self._client_wrapper.get_headers(),
|
|
541
|
-
timeout=60,
|
|
542
|
-
)
|
|
543
|
-
if 200 <= _response.status_code < 300:
|
|
544
|
-
return
|
|
545
|
-
if _response.status_code == 422:
|
|
546
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
547
|
-
try:
|
|
548
|
-
_response_json = _response.json()
|
|
549
|
-
except JSONDecodeError:
|
|
550
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
551
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
552
|
-
|
|
553
|
-
async def get_supported_file_extensions(self) -> typing.List[LlamaParseSupportedFileExtensions]:
|
|
554
|
-
"""
|
|
555
|
-
Get a list of supported file extensions
|
|
556
|
-
|
|
557
|
-
---
|
|
558
|
-
from llama_cloud.client import AsyncLlamaCloud
|
|
559
|
-
|
|
560
|
-
client = AsyncLlamaCloud(
|
|
561
|
-
token="YOUR_TOKEN",
|
|
562
|
-
base_url="https://yourhost.com/path/to/api",
|
|
563
|
-
)
|
|
564
|
-
await client.deprecated.get_supported_file_extensions()
|
|
565
|
-
"""
|
|
566
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
567
|
-
"GET",
|
|
568
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/parsing/supported_file_extensions"),
|
|
569
|
-
headers=self._client_wrapper.get_headers(),
|
|
570
|
-
timeout=60,
|
|
571
|
-
)
|
|
572
|
-
if 200 <= _response.status_code < 300:
|
|
573
|
-
return pydantic.parse_obj_as(typing.List[LlamaParseSupportedFileExtensions], _response.json()) # type: ignore
|
|
574
|
-
try:
|
|
575
|
-
_response_json = _response.json()
|
|
576
|
-
except JSONDecodeError:
|
|
577
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
578
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
579
|
-
|
|
580
|
-
async def upload_file(
|
|
581
|
-
self,
|
|
582
|
-
*,
|
|
583
|
-
language: typing.List[ParserLanguages],
|
|
584
|
-
parsing_instruction: str,
|
|
585
|
-
skip_diagonal_text: bool,
|
|
586
|
-
invalidate_cache: bool,
|
|
587
|
-
do_not_cache: bool,
|
|
588
|
-
gpt_4_o_mode: bool,
|
|
589
|
-
fast_mode: bool,
|
|
590
|
-
gpt_4_o_api_key: str,
|
|
591
|
-
do_not_unroll_columns: bool,
|
|
592
|
-
page_separator: str,
|
|
593
|
-
file: typing.IO,
|
|
594
|
-
) -> ParsingJob:
|
|
595
|
-
"""
|
|
596
|
-
Upload a file to s3 and create a job. return a job id
|
|
597
|
-
|
|
598
|
-
Parameters:
|
|
599
|
-
- language: typing.List[ParserLanguages].
|
|
600
|
-
|
|
601
|
-
- parsing_instruction: str.
|
|
602
|
-
|
|
603
|
-
- skip_diagonal_text: bool.
|
|
604
|
-
|
|
605
|
-
- invalidate_cache: bool.
|
|
606
|
-
|
|
607
|
-
- do_not_cache: bool.
|
|
608
|
-
|
|
609
|
-
- gpt_4_o_mode: bool.
|
|
610
|
-
|
|
611
|
-
- fast_mode: bool.
|
|
612
|
-
|
|
613
|
-
- gpt_4_o_api_key: str.
|
|
614
|
-
|
|
615
|
-
- do_not_unroll_columns: bool.
|
|
616
|
-
|
|
617
|
-
- page_separator: str.
|
|
618
|
-
|
|
619
|
-
- file: typing.IO.
|
|
620
|
-
"""
|
|
621
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
622
|
-
"POST",
|
|
623
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/parsing/upload"),
|
|
624
|
-
data=jsonable_encoder(
|
|
625
|
-
{
|
|
626
|
-
"language": language,
|
|
627
|
-
"parsing_instruction": parsing_instruction,
|
|
628
|
-
"skip_diagonal_text": skip_diagonal_text,
|
|
629
|
-
"invalidate_cache": invalidate_cache,
|
|
630
|
-
"do_not_cache": do_not_cache,
|
|
631
|
-
"gpt4o_mode": gpt_4_o_mode,
|
|
632
|
-
"fast_mode": fast_mode,
|
|
633
|
-
"gpt4o_api_key": gpt_4_o_api_key,
|
|
634
|
-
"do_not_unroll_columns": do_not_unroll_columns,
|
|
635
|
-
"page_separator": page_separator,
|
|
636
|
-
}
|
|
637
|
-
),
|
|
638
|
-
files={"file": file},
|
|
639
|
-
headers=self._client_wrapper.get_headers(),
|
|
640
|
-
timeout=60,
|
|
641
|
-
)
|
|
642
|
-
if 200 <= _response.status_code < 300:
|
|
643
|
-
return pydantic.parse_obj_as(ParsingJob, _response.json()) # type: ignore
|
|
644
|
-
if _response.status_code == 422:
|
|
645
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
646
|
-
try:
|
|
647
|
-
_response_json = _response.json()
|
|
648
|
-
except JSONDecodeError:
|
|
649
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
650
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
651
|
-
|
|
652
|
-
async def usage(self) -> ParsingUsage:
|
|
653
|
-
"""
|
|
654
|
-
Get parsing usage for user
|
|
655
|
-
|
|
656
|
-
---
|
|
657
|
-
from llama_cloud.client import AsyncLlamaCloud
|
|
658
|
-
|
|
659
|
-
client = AsyncLlamaCloud(
|
|
660
|
-
token="YOUR_TOKEN",
|
|
661
|
-
base_url="https://yourhost.com/path/to/api",
|
|
662
|
-
)
|
|
663
|
-
await client.deprecated.usage()
|
|
664
|
-
"""
|
|
665
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
666
|
-
"GET",
|
|
667
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/parsing/usage"),
|
|
668
|
-
headers=self._client_wrapper.get_headers(),
|
|
669
|
-
timeout=60,
|
|
670
|
-
)
|
|
671
|
-
if 200 <= _response.status_code < 300:
|
|
672
|
-
return pydantic.parse_obj_as(ParsingUsage, _response.json()) # type: ignore
|
|
673
|
-
if _response.status_code == 422:
|
|
674
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
675
|
-
try:
|
|
676
|
-
_response_json = _response.json()
|
|
677
|
-
except JSONDecodeError:
|
|
678
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
679
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
680
|
-
|
|
681
|
-
async def get_job(self, job_id: str) -> ParsingJob:
|
|
682
|
-
"""
|
|
683
|
-
Get a job by id
|
|
684
|
-
|
|
685
|
-
Parameters:
|
|
686
|
-
- job_id: str.
|
|
687
|
-
---
|
|
688
|
-
from llama_cloud.client import AsyncLlamaCloud
|
|
689
|
-
|
|
690
|
-
client = AsyncLlamaCloud(
|
|
691
|
-
token="YOUR_TOKEN",
|
|
692
|
-
base_url="https://yourhost.com/path/to/api",
|
|
693
|
-
)
|
|
694
|
-
await client.deprecated.get_job(
|
|
695
|
-
job_id="string",
|
|
696
|
-
)
|
|
697
|
-
"""
|
|
698
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
699
|
-
"GET",
|
|
700
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/parsing/job/{job_id}"),
|
|
701
|
-
headers=self._client_wrapper.get_headers(),
|
|
702
|
-
timeout=60,
|
|
703
|
-
)
|
|
704
|
-
if 200 <= _response.status_code < 300:
|
|
705
|
-
return pydantic.parse_obj_as(ParsingJob, _response.json()) # type: ignore
|
|
706
|
-
if _response.status_code == 422:
|
|
707
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
708
|
-
try:
|
|
709
|
-
_response_json = _response.json()
|
|
710
|
-
except JSONDecodeError:
|
|
711
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
712
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
713
|
-
|
|
714
|
-
async def get_job_text_result(self, job_id: str) -> ParsingJobTextResult:
|
|
715
|
-
"""
|
|
716
|
-
Get a job by id
|
|
717
|
-
|
|
718
|
-
Parameters:
|
|
719
|
-
- job_id: str.
|
|
720
|
-
---
|
|
721
|
-
from llama_cloud.client import AsyncLlamaCloud
|
|
722
|
-
|
|
723
|
-
client = AsyncLlamaCloud(
|
|
724
|
-
token="YOUR_TOKEN",
|
|
725
|
-
base_url="https://yourhost.com/path/to/api",
|
|
726
|
-
)
|
|
727
|
-
await client.deprecated.get_job_text_result(
|
|
728
|
-
job_id="string",
|
|
729
|
-
)
|
|
730
|
-
"""
|
|
731
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
732
|
-
"GET",
|
|
733
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/parsing/job/{job_id}/result/text"),
|
|
734
|
-
headers=self._client_wrapper.get_headers(),
|
|
735
|
-
timeout=60,
|
|
736
|
-
)
|
|
737
|
-
if 200 <= _response.status_code < 300:
|
|
738
|
-
return pydantic.parse_obj_as(ParsingJobTextResult, _response.json()) # type: ignore
|
|
739
|
-
if _response.status_code == 422:
|
|
740
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
741
|
-
try:
|
|
742
|
-
_response_json = _response.json()
|
|
743
|
-
except JSONDecodeError:
|
|
744
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
745
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
746
|
-
|
|
747
|
-
async def get_job_raw_text_result(self, job_id: str) -> typing.Any:
|
|
748
|
-
"""
|
|
749
|
-
Get a job by id
|
|
750
|
-
|
|
751
|
-
Parameters:
|
|
752
|
-
- job_id: str.
|
|
753
|
-
---
|
|
754
|
-
from llama_cloud.client import AsyncLlamaCloud
|
|
755
|
-
|
|
756
|
-
client = AsyncLlamaCloud(
|
|
757
|
-
token="YOUR_TOKEN",
|
|
758
|
-
base_url="https://yourhost.com/path/to/api",
|
|
759
|
-
)
|
|
760
|
-
await client.deprecated.get_job_raw_text_result(
|
|
761
|
-
job_id="string",
|
|
762
|
-
)
|
|
763
|
-
"""
|
|
764
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
765
|
-
"GET",
|
|
766
|
-
urllib.parse.urljoin(
|
|
767
|
-
f"{self._client_wrapper.get_base_url()}/", f"api/parsing/job/{job_id}/result/raw/text"
|
|
768
|
-
),
|
|
769
|
-
headers=self._client_wrapper.get_headers(),
|
|
770
|
-
timeout=60,
|
|
771
|
-
)
|
|
772
|
-
if 200 <= _response.status_code < 300:
|
|
773
|
-
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
|
|
774
|
-
if _response.status_code == 422:
|
|
775
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
776
|
-
try:
|
|
777
|
-
_response_json = _response.json()
|
|
778
|
-
except JSONDecodeError:
|
|
779
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
780
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
781
|
-
|
|
782
|
-
async def get_job_result(self, job_id: str) -> ParsingJobMarkdownResult:
|
|
783
|
-
"""
|
|
784
|
-
Get a job by id
|
|
785
|
-
|
|
786
|
-
Parameters:
|
|
787
|
-
- job_id: str.
|
|
788
|
-
---
|
|
789
|
-
from llama_cloud.client import AsyncLlamaCloud
|
|
790
|
-
|
|
791
|
-
client = AsyncLlamaCloud(
|
|
792
|
-
token="YOUR_TOKEN",
|
|
793
|
-
base_url="https://yourhost.com/path/to/api",
|
|
794
|
-
)
|
|
795
|
-
await client.deprecated.get_job_result(
|
|
796
|
-
job_id="string",
|
|
797
|
-
)
|
|
798
|
-
"""
|
|
799
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
800
|
-
"GET",
|
|
801
|
-
urllib.parse.urljoin(
|
|
802
|
-
f"{self._client_wrapper.get_base_url()}/", f"api/parsing/job/{job_id}/result/markdown"
|
|
803
|
-
),
|
|
804
|
-
headers=self._client_wrapper.get_headers(),
|
|
805
|
-
timeout=60,
|
|
806
|
-
)
|
|
807
|
-
if 200 <= _response.status_code < 300:
|
|
808
|
-
return pydantic.parse_obj_as(ParsingJobMarkdownResult, _response.json()) # type: ignore
|
|
809
|
-
if _response.status_code == 422:
|
|
810
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
811
|
-
try:
|
|
812
|
-
_response_json = _response.json()
|
|
813
|
-
except JSONDecodeError:
|
|
814
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
815
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
816
|
-
|
|
817
|
-
async def get_job_raw_md_result(self, job_id: str) -> typing.Any:
|
|
818
|
-
"""
|
|
819
|
-
Get a job by id
|
|
820
|
-
|
|
821
|
-
Parameters:
|
|
822
|
-
- job_id: str.
|
|
823
|
-
---
|
|
824
|
-
from llama_cloud.client import AsyncLlamaCloud
|
|
825
|
-
|
|
826
|
-
client = AsyncLlamaCloud(
|
|
827
|
-
token="YOUR_TOKEN",
|
|
828
|
-
base_url="https://yourhost.com/path/to/api",
|
|
829
|
-
)
|
|
830
|
-
await client.deprecated.get_job_raw_md_result(
|
|
831
|
-
job_id="string",
|
|
832
|
-
)
|
|
833
|
-
"""
|
|
834
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
835
|
-
"GET",
|
|
836
|
-
urllib.parse.urljoin(
|
|
837
|
-
f"{self._client_wrapper.get_base_url()}/", f"api/parsing/job/{job_id}/result/raw/markdown"
|
|
838
|
-
),
|
|
839
|
-
headers=self._client_wrapper.get_headers(),
|
|
840
|
-
timeout=60,
|
|
841
|
-
)
|
|
842
|
-
if 200 <= _response.status_code < 300:
|
|
843
|
-
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
|
|
844
|
-
if _response.status_code == 422:
|
|
845
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
846
|
-
try:
|
|
847
|
-
_response_json = _response.json()
|
|
848
|
-
except JSONDecodeError:
|
|
849
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
850
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
851
|
-
|
|
852
|
-
async def get_job_json_result(self, job_id: str) -> ParsingJobJsonResult:
|
|
853
|
-
"""
|
|
854
|
-
Get a job by id
|
|
855
|
-
|
|
856
|
-
Parameters:
|
|
857
|
-
- job_id: str.
|
|
858
|
-
---
|
|
859
|
-
from llama_cloud.client import AsyncLlamaCloud
|
|
860
|
-
|
|
861
|
-
client = AsyncLlamaCloud(
|
|
862
|
-
token="YOUR_TOKEN",
|
|
863
|
-
base_url="https://yourhost.com/path/to/api",
|
|
864
|
-
)
|
|
865
|
-
await client.deprecated.get_job_json_result(
|
|
866
|
-
job_id="string",
|
|
867
|
-
)
|
|
868
|
-
"""
|
|
869
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
870
|
-
"GET",
|
|
871
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/parsing/job/{job_id}/result/json"),
|
|
872
|
-
headers=self._client_wrapper.get_headers(),
|
|
873
|
-
timeout=60,
|
|
874
|
-
)
|
|
875
|
-
if 200 <= _response.status_code < 300:
|
|
876
|
-
return pydantic.parse_obj_as(ParsingJobJsonResult, _response.json()) # type: ignore
|
|
877
|
-
if _response.status_code == 422:
|
|
878
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
879
|
-
try:
|
|
880
|
-
_response_json = _response.json()
|
|
881
|
-
except JSONDecodeError:
|
|
882
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
883
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
884
|
-
|
|
885
|
-
async def get_job_json_raw_result(self, job_id: str) -> typing.Any:
|
|
886
|
-
"""
|
|
887
|
-
Get a job by id
|
|
888
|
-
|
|
889
|
-
Parameters:
|
|
890
|
-
- job_id: str.
|
|
891
|
-
---
|
|
892
|
-
from llama_cloud.client import AsyncLlamaCloud
|
|
893
|
-
|
|
894
|
-
client = AsyncLlamaCloud(
|
|
895
|
-
token="YOUR_TOKEN",
|
|
896
|
-
base_url="https://yourhost.com/path/to/api",
|
|
897
|
-
)
|
|
898
|
-
await client.deprecated.get_job_json_raw_result(
|
|
899
|
-
job_id="string",
|
|
900
|
-
)
|
|
901
|
-
"""
|
|
902
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
903
|
-
"GET",
|
|
904
|
-
urllib.parse.urljoin(
|
|
905
|
-
f"{self._client_wrapper.get_base_url()}/", f"api/parsing/job/{job_id}/result/raw/json"
|
|
906
|
-
),
|
|
907
|
-
headers=self._client_wrapper.get_headers(),
|
|
908
|
-
timeout=60,
|
|
909
|
-
)
|
|
910
|
-
if 200 <= _response.status_code < 300:
|
|
911
|
-
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
|
|
912
|
-
if _response.status_code == 422:
|
|
913
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
914
|
-
try:
|
|
915
|
-
_response_json = _response.json()
|
|
916
|
-
except JSONDecodeError:
|
|
917
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
918
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
919
|
-
|
|
920
|
-
async def get_parsing_history_result(self) -> typing.List[ParsingHistoryItem]:
|
|
921
|
-
"""
|
|
922
|
-
Get parsing history for user
|
|
923
|
-
|
|
924
|
-
---
|
|
925
|
-
from llama_cloud.client import AsyncLlamaCloud
|
|
926
|
-
|
|
927
|
-
client = AsyncLlamaCloud(
|
|
928
|
-
token="YOUR_TOKEN",
|
|
929
|
-
base_url="https://yourhost.com/path/to/api",
|
|
930
|
-
)
|
|
931
|
-
await client.deprecated.get_parsing_history_result()
|
|
932
|
-
"""
|
|
933
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
934
|
-
"GET",
|
|
935
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/parsing/history"),
|
|
936
|
-
headers=self._client_wrapper.get_headers(),
|
|
937
|
-
timeout=60,
|
|
938
|
-
)
|
|
939
|
-
if 200 <= _response.status_code < 300:
|
|
940
|
-
return pydantic.parse_obj_as(typing.List[ParsingHistoryItem], _response.json()) # type: ignore
|
|
941
|
-
if _response.status_code == 422:
|
|
942
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
943
|
-
try:
|
|
944
|
-
_response_json = _response.json()
|
|
945
|
-
except JSONDecodeError:
|
|
946
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
947
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
948
|
-
|
|
949
|
-
async def generate_presigned_url(self, job_id: str, filename: str) -> PresignedUrl:
|
|
950
|
-
"""
|
|
951
|
-
Generate a presigned URL for a job
|
|
952
|
-
|
|
953
|
-
Parameters:
|
|
954
|
-
- job_id: str.
|
|
955
|
-
|
|
956
|
-
- filename: str.
|
|
957
|
-
---
|
|
958
|
-
from llama_cloud.client import AsyncLlamaCloud
|
|
959
|
-
|
|
960
|
-
client = AsyncLlamaCloud(
|
|
961
|
-
token="YOUR_TOKEN",
|
|
962
|
-
base_url="https://yourhost.com/path/to/api",
|
|
963
|
-
)
|
|
964
|
-
await client.deprecated.generate_presigned_url(
|
|
965
|
-
job_id="string",
|
|
966
|
-
filename="string",
|
|
967
|
-
)
|
|
968
|
-
"""
|
|
969
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
970
|
-
"GET",
|
|
971
|
-
urllib.parse.urljoin(
|
|
972
|
-
f"{self._client_wrapper.get_base_url()}/", f"api/parsing/job/{job_id}/read/{filename}"
|
|
973
|
-
),
|
|
974
|
-
headers=self._client_wrapper.get_headers(),
|
|
975
|
-
timeout=60,
|
|
976
|
-
)
|
|
977
|
-
if 200 <= _response.status_code < 300:
|
|
978
|
-
return pydantic.parse_obj_as(PresignedUrl, _response.json()) # type: ignore
|
|
979
|
-
if _response.status_code == 422:
|
|
980
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
981
|
-
try:
|
|
982
|
-
_response_json = _response.json()
|
|
983
|
-
except JSONDecodeError:
|
|
984
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
985
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|