llama-cloud 0.0.9__py3-none-any.whl → 0.0.11__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 +22 -2
- llama_cloud/resources/__init__.py +2 -1
- llama_cloud/resources/data_sources/types/data_source_update_component_one.py +2 -0
- llama_cloud/resources/extraction/__init__.py +2 -2
- llama_cloud/resources/extraction/client.py +172 -48
- llama_cloud/resources/extraction/types/__init__.py +2 -1
- llama_cloud/resources/extraction/types/extraction_schema_create_data_schema_value.py +7 -0
- llama_cloud/resources/organizations/client.py +81 -0
- llama_cloud/resources/parsing/client.py +104 -0
- llama_cloud/resources/pipelines/client.py +315 -43
- llama_cloud/types/__init__.py +20 -2
- llama_cloud/types/auto_transform_config.py +32 -0
- llama_cloud/types/{chat_params.py → chat_data.py} +3 -3
- llama_cloud/types/cloud_azure_ai_search_vector_store.py +1 -1
- llama_cloud/types/cloud_confluence_data_source.py +45 -0
- llama_cloud/types/configurable_data_source_names.py +4 -0
- llama_cloud/types/data_source_component_one.py +2 -0
- llama_cloud/types/data_source_create_component_one.py +2 -0
- llama_cloud/types/embedding_config.py +36 -0
- llama_cloud/types/embedding_config_component.py +19 -0
- llama_cloud/types/embedding_config_type.py +41 -0
- llama_cloud/types/extraction_job.py +35 -0
- llama_cloud/types/extraction_schema.py +1 -1
- llama_cloud/types/llama_parse_parameters.py +5 -0
- llama_cloud/types/pipeline.py +0 -3
- llama_cloud/types/pipeline_create.py +8 -3
- llama_cloud/types/pipeline_data_source_component_one.py +2 -0
- llama_cloud/types/transform_config.py +36 -0
- llama_cloud/types/transform_config_mode.py +21 -0
- llama_cloud/types/user_organization.py +10 -1
- llama_cloud/types/user_organization_delete.py +36 -0
- {llama_cloud-0.0.9.dist-info → llama_cloud-0.0.11.dist-info}/METADATA +1 -1
- {llama_cloud-0.0.9.dist-info → llama_cloud-0.0.11.dist-info}/RECORD +35 -25
- {llama_cloud-0.0.9.dist-info → llama_cloud-0.0.11.dist-info}/WHEEL +1 -1
- {llama_cloud-0.0.9.dist-info → llama_cloud-0.0.11.dist-info}/LICENSE +0 -0
llama_cloud/__init__.py
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
3
|
from .types import (
|
|
4
|
+
AutoTransformConfig,
|
|
4
5
|
AzureOpenAiEmbedding,
|
|
5
6
|
Base,
|
|
6
7
|
BasePromptTemplate,
|
|
7
8
|
BedrockEmbedding,
|
|
9
|
+
ChatData,
|
|
8
10
|
ChatMessage,
|
|
9
|
-
ChatParams,
|
|
10
11
|
CloudAzStorageBlobDataSource,
|
|
11
12
|
CloudAzureAiSearchVectorStore,
|
|
12
13
|
CloudChromaVectorStore,
|
|
14
|
+
CloudConfluenceDataSource,
|
|
13
15
|
CloudDocument,
|
|
14
16
|
CloudDocumentCreate,
|
|
15
17
|
CloudJiraDataSource,
|
|
@@ -47,6 +49,9 @@ from .types import (
|
|
|
47
49
|
DataSourceCreateCustomMetadataValue,
|
|
48
50
|
DataSourceCustomMetadataValue,
|
|
49
51
|
DataSourceDefinition,
|
|
52
|
+
EmbeddingConfig,
|
|
53
|
+
EmbeddingConfigComponent,
|
|
54
|
+
EmbeddingConfigType,
|
|
50
55
|
EvalDataset,
|
|
51
56
|
EvalDatasetJobParams,
|
|
52
57
|
EvalDatasetJobRecord,
|
|
@@ -56,6 +61,7 @@ from .types import (
|
|
|
56
61
|
EvalQuestion,
|
|
57
62
|
EvalQuestionCreate,
|
|
58
63
|
EvalQuestionResult,
|
|
64
|
+
ExtractionJob,
|
|
59
65
|
ExtractionResult,
|
|
60
66
|
ExtractionResultDataValue,
|
|
61
67
|
ExtractionSchema,
|
|
@@ -132,9 +138,12 @@ from .types import (
|
|
|
132
138
|
TextNodeRelationshipsValue,
|
|
133
139
|
TextNodeWithScore,
|
|
134
140
|
TokenTextSplitter,
|
|
141
|
+
TransformConfig,
|
|
142
|
+
TransformConfigMode,
|
|
135
143
|
TransformationCategoryNames,
|
|
136
144
|
UserOrganization,
|
|
137
145
|
UserOrganizationCreate,
|
|
146
|
+
UserOrganizationDelete,
|
|
138
147
|
ValidationError,
|
|
139
148
|
ValidationErrorLocItem,
|
|
140
149
|
)
|
|
@@ -145,6 +154,7 @@ from .resources import (
|
|
|
145
154
|
DataSourceUpdateComponent,
|
|
146
155
|
DataSourceUpdateComponentOne,
|
|
147
156
|
DataSourceUpdateCustomMetadataValue,
|
|
157
|
+
ExtractionSchemaCreateDataSchemaValue,
|
|
148
158
|
ExtractionSchemaUpdateDataSchemaValue,
|
|
149
159
|
FileCreateResourceInfoValue,
|
|
150
160
|
PipelineFileUpdateCustomMetadataValue,
|
|
@@ -162,15 +172,17 @@ from .resources import (
|
|
|
162
172
|
from .environment import LlamaCloudEnvironment
|
|
163
173
|
|
|
164
174
|
__all__ = [
|
|
175
|
+
"AutoTransformConfig",
|
|
165
176
|
"AzureOpenAiEmbedding",
|
|
166
177
|
"Base",
|
|
167
178
|
"BasePromptTemplate",
|
|
168
179
|
"BedrockEmbedding",
|
|
180
|
+
"ChatData",
|
|
169
181
|
"ChatMessage",
|
|
170
|
-
"ChatParams",
|
|
171
182
|
"CloudAzStorageBlobDataSource",
|
|
172
183
|
"CloudAzureAiSearchVectorStore",
|
|
173
184
|
"CloudChromaVectorStore",
|
|
185
|
+
"CloudConfluenceDataSource",
|
|
174
186
|
"CloudDocument",
|
|
175
187
|
"CloudDocumentCreate",
|
|
176
188
|
"CloudJiraDataSource",
|
|
@@ -213,6 +225,9 @@ __all__ = [
|
|
|
213
225
|
"DataSourceUpdateComponent",
|
|
214
226
|
"DataSourceUpdateComponentOne",
|
|
215
227
|
"DataSourceUpdateCustomMetadataValue",
|
|
228
|
+
"EmbeddingConfig",
|
|
229
|
+
"EmbeddingConfigComponent",
|
|
230
|
+
"EmbeddingConfigType",
|
|
216
231
|
"EvalDataset",
|
|
217
232
|
"EvalDatasetJobParams",
|
|
218
233
|
"EvalDatasetJobRecord",
|
|
@@ -222,9 +237,11 @@ __all__ = [
|
|
|
222
237
|
"EvalQuestion",
|
|
223
238
|
"EvalQuestionCreate",
|
|
224
239
|
"EvalQuestionResult",
|
|
240
|
+
"ExtractionJob",
|
|
225
241
|
"ExtractionResult",
|
|
226
242
|
"ExtractionResultDataValue",
|
|
227
243
|
"ExtractionSchema",
|
|
244
|
+
"ExtractionSchemaCreateDataSchemaValue",
|
|
228
245
|
"ExtractionSchemaDataSchemaValue",
|
|
229
246
|
"ExtractionSchemaUpdateDataSchemaValue",
|
|
230
247
|
"File",
|
|
@@ -302,10 +319,13 @@ __all__ = [
|
|
|
302
319
|
"TextNodeRelationshipsValue",
|
|
303
320
|
"TextNodeWithScore",
|
|
304
321
|
"TokenTextSplitter",
|
|
322
|
+
"TransformConfig",
|
|
323
|
+
"TransformConfigMode",
|
|
305
324
|
"TransformationCategoryNames",
|
|
306
325
|
"UnprocessableEntityError",
|
|
307
326
|
"UserOrganization",
|
|
308
327
|
"UserOrganizationCreate",
|
|
328
|
+
"UserOrganizationDelete",
|
|
309
329
|
"ValidationError",
|
|
310
330
|
"ValidationErrorLocItem",
|
|
311
331
|
"component_definitions",
|
|
@@ -14,7 +14,7 @@ from . import (
|
|
|
14
14
|
)
|
|
15
15
|
from .data_sinks import DataSinkUpdateComponent, DataSinkUpdateComponentOne
|
|
16
16
|
from .data_sources import DataSourceUpdateComponent, DataSourceUpdateComponentOne, DataSourceUpdateCustomMetadataValue
|
|
17
|
-
from .extraction import ExtractionSchemaUpdateDataSchemaValue
|
|
17
|
+
from .extraction import ExtractionSchemaCreateDataSchemaValue, ExtractionSchemaUpdateDataSchemaValue
|
|
18
18
|
from .files import FileCreateResourceInfoValue
|
|
19
19
|
from .pipelines import PipelineFileUpdateCustomMetadataValue
|
|
20
20
|
|
|
@@ -24,6 +24,7 @@ __all__ = [
|
|
|
24
24
|
"DataSourceUpdateComponent",
|
|
25
25
|
"DataSourceUpdateComponentOne",
|
|
26
26
|
"DataSourceUpdateCustomMetadataValue",
|
|
27
|
+
"ExtractionSchemaCreateDataSchemaValue",
|
|
27
28
|
"ExtractionSchemaUpdateDataSchemaValue",
|
|
28
29
|
"FileCreateResourceInfoValue",
|
|
29
30
|
"PipelineFileUpdateCustomMetadataValue",
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import typing
|
|
4
4
|
|
|
5
5
|
from ....types.cloud_az_storage_blob_data_source import CloudAzStorageBlobDataSource
|
|
6
|
+
from ....types.cloud_confluence_data_source import CloudConfluenceDataSource
|
|
6
7
|
from ....types.cloud_jira_data_source import CloudJiraDataSource
|
|
7
8
|
from ....types.cloud_notion_page_data_source import CloudNotionPageDataSource
|
|
8
9
|
from ....types.cloud_one_drive_data_source import CloudOneDriveDataSource
|
|
@@ -17,5 +18,6 @@ DataSourceUpdateComponentOne = typing.Union[
|
|
|
17
18
|
CloudSharepointDataSource,
|
|
18
19
|
CloudSlackDataSource,
|
|
19
20
|
CloudNotionPageDataSource,
|
|
21
|
+
CloudConfluenceDataSource,
|
|
20
22
|
CloudJiraDataSource,
|
|
21
23
|
]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
-
from .types import ExtractionSchemaUpdateDataSchemaValue
|
|
3
|
+
from .types import ExtractionSchemaCreateDataSchemaValue, ExtractionSchemaUpdateDataSchemaValue
|
|
4
4
|
|
|
5
|
-
__all__ = ["ExtractionSchemaUpdateDataSchemaValue"]
|
|
5
|
+
__all__ = ["ExtractionSchemaCreateDataSchemaValue", "ExtractionSchemaUpdateDataSchemaValue"]
|
|
@@ -9,9 +9,11 @@ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
|
9
9
|
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
|
+
from ...types.extraction_job import ExtractionJob
|
|
12
13
|
from ...types.extraction_result import ExtractionResult
|
|
13
14
|
from ...types.extraction_schema import ExtractionSchema
|
|
14
15
|
from ...types.http_validation_error import HttpValidationError
|
|
16
|
+
from .types.extraction_schema_create_data_schema_value import ExtractionSchemaCreateDataSchemaValue
|
|
15
17
|
from .types.extraction_schema_update_data_schema_value import ExtractionSchemaUpdateDataSchemaValue
|
|
16
18
|
|
|
17
19
|
try:
|
|
@@ -30,8 +32,41 @@ class ExtractionClient:
|
|
|
30
32
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
31
33
|
self._client_wrapper = client_wrapper
|
|
32
34
|
|
|
33
|
-
def
|
|
34
|
-
|
|
35
|
+
def list_schemas(self, *, project_id: typing.Optional[str] = None) -> typing.List[ExtractionSchema]:
|
|
36
|
+
"""
|
|
37
|
+
Parameters:
|
|
38
|
+
- project_id: typing.Optional[str].
|
|
39
|
+
---
|
|
40
|
+
from llama_cloud.client import LlamaCloud
|
|
41
|
+
|
|
42
|
+
client = LlamaCloud(
|
|
43
|
+
token="YOUR_TOKEN",
|
|
44
|
+
)
|
|
45
|
+
client.extraction.list_schemas()
|
|
46
|
+
"""
|
|
47
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
48
|
+
"GET",
|
|
49
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/schemas"),
|
|
50
|
+
params=remove_none_from_dict({"project_id": project_id}),
|
|
51
|
+
headers=self._client_wrapper.get_headers(),
|
|
52
|
+
timeout=60,
|
|
53
|
+
)
|
|
54
|
+
if 200 <= _response.status_code < 300:
|
|
55
|
+
return pydantic.parse_obj_as(typing.List[ExtractionSchema], _response.json()) # type: ignore
|
|
56
|
+
if _response.status_code == 422:
|
|
57
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
58
|
+
try:
|
|
59
|
+
_response_json = _response.json()
|
|
60
|
+
except JSONDecodeError:
|
|
61
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
62
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
63
|
+
|
|
64
|
+
def create_schema(
|
|
65
|
+
self,
|
|
66
|
+
*,
|
|
67
|
+
name: str,
|
|
68
|
+
project_id: typing.Optional[str] = OMIT,
|
|
69
|
+
data_schema: typing.Dict[str, ExtractionSchemaCreateDataSchemaValue],
|
|
35
70
|
) -> ExtractionSchema:
|
|
36
71
|
"""
|
|
37
72
|
Parameters:
|
|
@@ -39,24 +74,24 @@ class ExtractionClient:
|
|
|
39
74
|
|
|
40
75
|
- project_id: typing.Optional[str]. The ID of the project that the extraction schema belongs to
|
|
41
76
|
|
|
42
|
-
-
|
|
77
|
+
- data_schema: typing.Dict[str, ExtractionSchemaCreateDataSchemaValue]. The schema of the data
|
|
43
78
|
---
|
|
44
79
|
from llama_cloud.client import LlamaCloud
|
|
45
80
|
|
|
46
81
|
client = LlamaCloud(
|
|
47
82
|
token="YOUR_TOKEN",
|
|
48
83
|
)
|
|
49
|
-
client.extraction.
|
|
84
|
+
client.extraction.create_schema(
|
|
50
85
|
name="string",
|
|
51
|
-
|
|
86
|
+
data_schema={},
|
|
52
87
|
)
|
|
53
88
|
"""
|
|
54
|
-
_request: typing.Dict[str, typing.Any] = {"name": name, "
|
|
89
|
+
_request: typing.Dict[str, typing.Any] = {"name": name, "data_schema": data_schema}
|
|
55
90
|
if project_id is not OMIT:
|
|
56
91
|
_request["project_id"] = project_id
|
|
57
92
|
_response = self._client_wrapper.httpx_client.request(
|
|
58
93
|
"POST",
|
|
59
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/schemas
|
|
94
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/schemas"),
|
|
60
95
|
json=jsonable_encoder(_request),
|
|
61
96
|
headers=self._client_wrapper.get_headers(),
|
|
62
97
|
timeout=60,
|
|
@@ -71,27 +106,53 @@ class ExtractionClient:
|
|
|
71
106
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
72
107
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
73
108
|
|
|
74
|
-
def
|
|
109
|
+
def infer_schema(
|
|
110
|
+
self,
|
|
111
|
+
*,
|
|
112
|
+
schema_id: typing.Optional[str] = OMIT,
|
|
113
|
+
name: str,
|
|
114
|
+
project_id: typing.Optional[str] = OMIT,
|
|
115
|
+
file_ids: typing.List[str],
|
|
116
|
+
stream: typing.Optional[bool] = OMIT,
|
|
117
|
+
) -> ExtractionSchema:
|
|
75
118
|
"""
|
|
76
119
|
Parameters:
|
|
77
|
-
-
|
|
120
|
+
- schema_id: typing.Optional[str]. The ID of a schema to update with the new schema
|
|
121
|
+
|
|
122
|
+
- name: str. The name of the extraction schema
|
|
123
|
+
|
|
124
|
+
- project_id: typing.Optional[str]. The ID of the project that the extraction schema belongs to
|
|
125
|
+
|
|
126
|
+
- file_ids: typing.List[str]. The IDs of the files that the extraction schema contains
|
|
127
|
+
|
|
128
|
+
- stream: typing.Optional[bool]. Whether to stream the results of the extraction schema
|
|
78
129
|
---
|
|
79
130
|
from llama_cloud.client import LlamaCloud
|
|
80
131
|
|
|
81
132
|
client = LlamaCloud(
|
|
82
133
|
token="YOUR_TOKEN",
|
|
83
134
|
)
|
|
84
|
-
client.extraction.
|
|
135
|
+
client.extraction.infer_schema(
|
|
136
|
+
name="string",
|
|
137
|
+
file_ids=[],
|
|
138
|
+
)
|
|
85
139
|
"""
|
|
140
|
+
_request: typing.Dict[str, typing.Any] = {"name": name, "file_ids": file_ids}
|
|
141
|
+
if schema_id is not OMIT:
|
|
142
|
+
_request["schema_id"] = schema_id
|
|
143
|
+
if project_id is not OMIT:
|
|
144
|
+
_request["project_id"] = project_id
|
|
145
|
+
if stream is not OMIT:
|
|
146
|
+
_request["stream"] = stream
|
|
86
147
|
_response = self._client_wrapper.httpx_client.request(
|
|
87
|
-
"
|
|
88
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/schemas"),
|
|
89
|
-
|
|
148
|
+
"POST",
|
|
149
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/schemas/infer"),
|
|
150
|
+
json=jsonable_encoder(_request),
|
|
90
151
|
headers=self._client_wrapper.get_headers(),
|
|
91
152
|
timeout=60,
|
|
92
153
|
)
|
|
93
154
|
if 200 <= _response.status_code < 300:
|
|
94
|
-
return pydantic.parse_obj_as(
|
|
155
|
+
return pydantic.parse_obj_as(ExtractionSchema, _response.json()) # type: ignore
|
|
95
156
|
if _response.status_code == 422:
|
|
96
157
|
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
97
158
|
try:
|
|
@@ -171,17 +232,19 @@ class ExtractionClient:
|
|
|
171
232
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
172
233
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
173
234
|
|
|
174
|
-
def list_jobs(self, *, schema_id:
|
|
235
|
+
def list_jobs(self, *, schema_id: str) -> typing.List[ExtractionJob]:
|
|
175
236
|
"""
|
|
176
237
|
Parameters:
|
|
177
|
-
- schema_id:
|
|
238
|
+
- schema_id: str.
|
|
178
239
|
---
|
|
179
240
|
from llama_cloud.client import LlamaCloud
|
|
180
241
|
|
|
181
242
|
client = LlamaCloud(
|
|
182
243
|
token="YOUR_TOKEN",
|
|
183
244
|
)
|
|
184
|
-
client.extraction.list_jobs(
|
|
245
|
+
client.extraction.list_jobs(
|
|
246
|
+
schema_id="string",
|
|
247
|
+
)
|
|
185
248
|
"""
|
|
186
249
|
_response = self._client_wrapper.httpx_client.request(
|
|
187
250
|
"GET",
|
|
@@ -191,7 +254,7 @@ class ExtractionClient:
|
|
|
191
254
|
timeout=60,
|
|
192
255
|
)
|
|
193
256
|
if 200 <= _response.status_code < 300:
|
|
194
|
-
return pydantic.parse_obj_as(typing.List[
|
|
257
|
+
return pydantic.parse_obj_as(typing.List[ExtractionJob], _response.json()) # type: ignore
|
|
195
258
|
if _response.status_code == 422:
|
|
196
259
|
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
197
260
|
try:
|
|
@@ -200,7 +263,7 @@ class ExtractionClient:
|
|
|
200
263
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
201
264
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
202
265
|
|
|
203
|
-
def run_job(self, *, schema_id: str, file_id: str) ->
|
|
266
|
+
def run_job(self, *, schema_id: str, file_id: str) -> ExtractionJob:
|
|
204
267
|
"""
|
|
205
268
|
Parameters:
|
|
206
269
|
- schema_id: str. The id of the schema
|
|
@@ -225,7 +288,7 @@ class ExtractionClient:
|
|
|
225
288
|
timeout=60,
|
|
226
289
|
)
|
|
227
290
|
if 200 <= _response.status_code < 300:
|
|
228
|
-
return pydantic.parse_obj_as(
|
|
291
|
+
return pydantic.parse_obj_as(ExtractionJob, _response.json()) # type: ignore
|
|
229
292
|
if _response.status_code == 422:
|
|
230
293
|
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
231
294
|
try:
|
|
@@ -234,7 +297,7 @@ class ExtractionClient:
|
|
|
234
297
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
235
298
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
236
299
|
|
|
237
|
-
def get_job(self, job_id: str) ->
|
|
300
|
+
def get_job(self, job_id: str) -> ExtractionJob:
|
|
238
301
|
"""
|
|
239
302
|
Parameters:
|
|
240
303
|
- job_id: str.
|
|
@@ -255,7 +318,7 @@ class ExtractionClient:
|
|
|
255
318
|
timeout=60,
|
|
256
319
|
)
|
|
257
320
|
if 200 <= _response.status_code < 300:
|
|
258
|
-
return pydantic.parse_obj_as(
|
|
321
|
+
return pydantic.parse_obj_as(ExtractionJob, _response.json()) # type: ignore
|
|
259
322
|
if _response.status_code == 422:
|
|
260
323
|
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
261
324
|
try:
|
|
@@ -264,7 +327,7 @@ class ExtractionClient:
|
|
|
264
327
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
265
328
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
266
329
|
|
|
267
|
-
def run_jobs_in_batch(self, *, schema_id: str, file_ids: typing.List[str]) -> typing.List[
|
|
330
|
+
def run_jobs_in_batch(self, *, schema_id: str, file_ids: typing.List[str]) -> typing.List[ExtractionJob]:
|
|
268
331
|
"""
|
|
269
332
|
Parameters:
|
|
270
333
|
- schema_id: str. The id of the schema
|
|
@@ -289,7 +352,7 @@ class ExtractionClient:
|
|
|
289
352
|
timeout=60,
|
|
290
353
|
)
|
|
291
354
|
if 200 <= _response.status_code < 300:
|
|
292
|
-
return pydantic.parse_obj_as(typing.List[
|
|
355
|
+
return pydantic.parse_obj_as(typing.List[ExtractionJob], _response.json()) # type: ignore
|
|
293
356
|
if _response.status_code == 422:
|
|
294
357
|
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
295
358
|
try:
|
|
@@ -333,8 +396,41 @@ class AsyncExtractionClient:
|
|
|
333
396
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
334
397
|
self._client_wrapper = client_wrapper
|
|
335
398
|
|
|
336
|
-
async def
|
|
337
|
-
|
|
399
|
+
async def list_schemas(self, *, project_id: typing.Optional[str] = None) -> typing.List[ExtractionSchema]:
|
|
400
|
+
"""
|
|
401
|
+
Parameters:
|
|
402
|
+
- project_id: typing.Optional[str].
|
|
403
|
+
---
|
|
404
|
+
from llama_cloud.client import AsyncLlamaCloud
|
|
405
|
+
|
|
406
|
+
client = AsyncLlamaCloud(
|
|
407
|
+
token="YOUR_TOKEN",
|
|
408
|
+
)
|
|
409
|
+
await client.extraction.list_schemas()
|
|
410
|
+
"""
|
|
411
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
412
|
+
"GET",
|
|
413
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/schemas"),
|
|
414
|
+
params=remove_none_from_dict({"project_id": project_id}),
|
|
415
|
+
headers=self._client_wrapper.get_headers(),
|
|
416
|
+
timeout=60,
|
|
417
|
+
)
|
|
418
|
+
if 200 <= _response.status_code < 300:
|
|
419
|
+
return pydantic.parse_obj_as(typing.List[ExtractionSchema], _response.json()) # type: ignore
|
|
420
|
+
if _response.status_code == 422:
|
|
421
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
422
|
+
try:
|
|
423
|
+
_response_json = _response.json()
|
|
424
|
+
except JSONDecodeError:
|
|
425
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
426
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
427
|
+
|
|
428
|
+
async def create_schema(
|
|
429
|
+
self,
|
|
430
|
+
*,
|
|
431
|
+
name: str,
|
|
432
|
+
project_id: typing.Optional[str] = OMIT,
|
|
433
|
+
data_schema: typing.Dict[str, ExtractionSchemaCreateDataSchemaValue],
|
|
338
434
|
) -> ExtractionSchema:
|
|
339
435
|
"""
|
|
340
436
|
Parameters:
|
|
@@ -342,24 +438,24 @@ class AsyncExtractionClient:
|
|
|
342
438
|
|
|
343
439
|
- project_id: typing.Optional[str]. The ID of the project that the extraction schema belongs to
|
|
344
440
|
|
|
345
|
-
-
|
|
441
|
+
- data_schema: typing.Dict[str, ExtractionSchemaCreateDataSchemaValue]. The schema of the data
|
|
346
442
|
---
|
|
347
443
|
from llama_cloud.client import AsyncLlamaCloud
|
|
348
444
|
|
|
349
445
|
client = AsyncLlamaCloud(
|
|
350
446
|
token="YOUR_TOKEN",
|
|
351
447
|
)
|
|
352
|
-
await client.extraction.
|
|
448
|
+
await client.extraction.create_schema(
|
|
353
449
|
name="string",
|
|
354
|
-
|
|
450
|
+
data_schema={},
|
|
355
451
|
)
|
|
356
452
|
"""
|
|
357
|
-
_request: typing.Dict[str, typing.Any] = {"name": name, "
|
|
453
|
+
_request: typing.Dict[str, typing.Any] = {"name": name, "data_schema": data_schema}
|
|
358
454
|
if project_id is not OMIT:
|
|
359
455
|
_request["project_id"] = project_id
|
|
360
456
|
_response = await self._client_wrapper.httpx_client.request(
|
|
361
457
|
"POST",
|
|
362
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/schemas
|
|
458
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/schemas"),
|
|
363
459
|
json=jsonable_encoder(_request),
|
|
364
460
|
headers=self._client_wrapper.get_headers(),
|
|
365
461
|
timeout=60,
|
|
@@ -374,27 +470,53 @@ class AsyncExtractionClient:
|
|
|
374
470
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
375
471
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
376
472
|
|
|
377
|
-
async def
|
|
473
|
+
async def infer_schema(
|
|
474
|
+
self,
|
|
475
|
+
*,
|
|
476
|
+
schema_id: typing.Optional[str] = OMIT,
|
|
477
|
+
name: str,
|
|
478
|
+
project_id: typing.Optional[str] = OMIT,
|
|
479
|
+
file_ids: typing.List[str],
|
|
480
|
+
stream: typing.Optional[bool] = OMIT,
|
|
481
|
+
) -> ExtractionSchema:
|
|
378
482
|
"""
|
|
379
483
|
Parameters:
|
|
380
|
-
-
|
|
484
|
+
- schema_id: typing.Optional[str]. The ID of a schema to update with the new schema
|
|
485
|
+
|
|
486
|
+
- name: str. The name of the extraction schema
|
|
487
|
+
|
|
488
|
+
- project_id: typing.Optional[str]. The ID of the project that the extraction schema belongs to
|
|
489
|
+
|
|
490
|
+
- file_ids: typing.List[str]. The IDs of the files that the extraction schema contains
|
|
491
|
+
|
|
492
|
+
- stream: typing.Optional[bool]. Whether to stream the results of the extraction schema
|
|
381
493
|
---
|
|
382
494
|
from llama_cloud.client import AsyncLlamaCloud
|
|
383
495
|
|
|
384
496
|
client = AsyncLlamaCloud(
|
|
385
497
|
token="YOUR_TOKEN",
|
|
386
498
|
)
|
|
387
|
-
await client.extraction.
|
|
499
|
+
await client.extraction.infer_schema(
|
|
500
|
+
name="string",
|
|
501
|
+
file_ids=[],
|
|
502
|
+
)
|
|
388
503
|
"""
|
|
504
|
+
_request: typing.Dict[str, typing.Any] = {"name": name, "file_ids": file_ids}
|
|
505
|
+
if schema_id is not OMIT:
|
|
506
|
+
_request["schema_id"] = schema_id
|
|
507
|
+
if project_id is not OMIT:
|
|
508
|
+
_request["project_id"] = project_id
|
|
509
|
+
if stream is not OMIT:
|
|
510
|
+
_request["stream"] = stream
|
|
389
511
|
_response = await self._client_wrapper.httpx_client.request(
|
|
390
|
-
"
|
|
391
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/schemas"),
|
|
392
|
-
|
|
512
|
+
"POST",
|
|
513
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/extraction/schemas/infer"),
|
|
514
|
+
json=jsonable_encoder(_request),
|
|
393
515
|
headers=self._client_wrapper.get_headers(),
|
|
394
516
|
timeout=60,
|
|
395
517
|
)
|
|
396
518
|
if 200 <= _response.status_code < 300:
|
|
397
|
-
return pydantic.parse_obj_as(
|
|
519
|
+
return pydantic.parse_obj_as(ExtractionSchema, _response.json()) # type: ignore
|
|
398
520
|
if _response.status_code == 422:
|
|
399
521
|
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
400
522
|
try:
|
|
@@ -474,17 +596,19 @@ class AsyncExtractionClient:
|
|
|
474
596
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
475
597
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
476
598
|
|
|
477
|
-
async def list_jobs(self, *, schema_id:
|
|
599
|
+
async def list_jobs(self, *, schema_id: str) -> typing.List[ExtractionJob]:
|
|
478
600
|
"""
|
|
479
601
|
Parameters:
|
|
480
|
-
- schema_id:
|
|
602
|
+
- schema_id: str.
|
|
481
603
|
---
|
|
482
604
|
from llama_cloud.client import AsyncLlamaCloud
|
|
483
605
|
|
|
484
606
|
client = AsyncLlamaCloud(
|
|
485
607
|
token="YOUR_TOKEN",
|
|
486
608
|
)
|
|
487
|
-
await client.extraction.list_jobs(
|
|
609
|
+
await client.extraction.list_jobs(
|
|
610
|
+
schema_id="string",
|
|
611
|
+
)
|
|
488
612
|
"""
|
|
489
613
|
_response = await self._client_wrapper.httpx_client.request(
|
|
490
614
|
"GET",
|
|
@@ -494,7 +618,7 @@ class AsyncExtractionClient:
|
|
|
494
618
|
timeout=60,
|
|
495
619
|
)
|
|
496
620
|
if 200 <= _response.status_code < 300:
|
|
497
|
-
return pydantic.parse_obj_as(typing.List[
|
|
621
|
+
return pydantic.parse_obj_as(typing.List[ExtractionJob], _response.json()) # type: ignore
|
|
498
622
|
if _response.status_code == 422:
|
|
499
623
|
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
500
624
|
try:
|
|
@@ -503,7 +627,7 @@ class AsyncExtractionClient:
|
|
|
503
627
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
504
628
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
505
629
|
|
|
506
|
-
async def run_job(self, *, schema_id: str, file_id: str) ->
|
|
630
|
+
async def run_job(self, *, schema_id: str, file_id: str) -> ExtractionJob:
|
|
507
631
|
"""
|
|
508
632
|
Parameters:
|
|
509
633
|
- schema_id: str. The id of the schema
|
|
@@ -528,7 +652,7 @@ class AsyncExtractionClient:
|
|
|
528
652
|
timeout=60,
|
|
529
653
|
)
|
|
530
654
|
if 200 <= _response.status_code < 300:
|
|
531
|
-
return pydantic.parse_obj_as(
|
|
655
|
+
return pydantic.parse_obj_as(ExtractionJob, _response.json()) # type: ignore
|
|
532
656
|
if _response.status_code == 422:
|
|
533
657
|
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
534
658
|
try:
|
|
@@ -537,7 +661,7 @@ class AsyncExtractionClient:
|
|
|
537
661
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
538
662
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
539
663
|
|
|
540
|
-
async def get_job(self, job_id: str) ->
|
|
664
|
+
async def get_job(self, job_id: str) -> ExtractionJob:
|
|
541
665
|
"""
|
|
542
666
|
Parameters:
|
|
543
667
|
- job_id: str.
|
|
@@ -558,7 +682,7 @@ class AsyncExtractionClient:
|
|
|
558
682
|
timeout=60,
|
|
559
683
|
)
|
|
560
684
|
if 200 <= _response.status_code < 300:
|
|
561
|
-
return pydantic.parse_obj_as(
|
|
685
|
+
return pydantic.parse_obj_as(ExtractionJob, _response.json()) # type: ignore
|
|
562
686
|
if _response.status_code == 422:
|
|
563
687
|
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
564
688
|
try:
|
|
@@ -567,7 +691,7 @@ class AsyncExtractionClient:
|
|
|
567
691
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
568
692
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
569
693
|
|
|
570
|
-
async def run_jobs_in_batch(self, *, schema_id: str, file_ids: typing.List[str]) -> typing.List[
|
|
694
|
+
async def run_jobs_in_batch(self, *, schema_id: str, file_ids: typing.List[str]) -> typing.List[ExtractionJob]:
|
|
571
695
|
"""
|
|
572
696
|
Parameters:
|
|
573
697
|
- schema_id: str. The id of the schema
|
|
@@ -592,7 +716,7 @@ class AsyncExtractionClient:
|
|
|
592
716
|
timeout=60,
|
|
593
717
|
)
|
|
594
718
|
if 200 <= _response.status_code < 300:
|
|
595
|
-
return pydantic.parse_obj_as(typing.List[
|
|
719
|
+
return pydantic.parse_obj_as(typing.List[ExtractionJob], _response.json()) # type: ignore
|
|
596
720
|
if _response.status_code == 422:
|
|
597
721
|
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
598
722
|
try:
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
+
from .extraction_schema_create_data_schema_value import ExtractionSchemaCreateDataSchemaValue
|
|
3
4
|
from .extraction_schema_update_data_schema_value import ExtractionSchemaUpdateDataSchemaValue
|
|
4
5
|
|
|
5
|
-
__all__ = ["ExtractionSchemaUpdateDataSchemaValue"]
|
|
6
|
+
__all__ = ["ExtractionSchemaCreateDataSchemaValue", "ExtractionSchemaUpdateDataSchemaValue"]
|