llama-cloud 0.1.5__py3-none-any.whl → 0.1.7a1__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 +138 -2
- llama_cloud/client.py +15 -0
- llama_cloud/resources/__init__.py +17 -1
- llama_cloud/resources/chat_apps/__init__.py +2 -0
- llama_cloud/resources/chat_apps/client.py +620 -0
- llama_cloud/resources/data_sinks/client.py +2 -2
- llama_cloud/resources/data_sources/client.py +2 -2
- llama_cloud/resources/embedding_model_configs/client.py +4 -4
- llama_cloud/resources/files/__init__.py +2 -2
- llama_cloud/resources/files/client.py +21 -0
- llama_cloud/resources/files/types/__init__.py +2 -1
- llama_cloud/resources/files/types/file_create_permission_info_value.py +7 -0
- llama_cloud/resources/jobs/__init__.py +2 -0
- llama_cloud/resources/jobs/client.py +148 -0
- llama_cloud/resources/llama_extract/__init__.py +5 -0
- llama_cloud/resources/llama_extract/client.py +1038 -0
- llama_cloud/resources/llama_extract/types/__init__.py +6 -0
- llama_cloud/resources/llama_extract/types/extract_agent_create_data_schema_value.py +7 -0
- llama_cloud/resources/llama_extract/types/extract_agent_update_data_schema_value.py +7 -0
- llama_cloud/resources/organizations/client.py +14 -14
- llama_cloud/resources/parsing/client.py +480 -229
- llama_cloud/resources/pipelines/client.py +182 -126
- llama_cloud/resources/projects/client.py +210 -102
- llama_cloud/resources/reports/__init__.py +5 -0
- llama_cloud/resources/reports/client.py +1198 -0
- llama_cloud/resources/reports/types/__init__.py +7 -0
- llama_cloud/resources/reports/types/update_report_plan_api_v_1_reports_report_id_plan_patch_request_action.py +25 -0
- llama_cloud/resources/retrievers/__init__.py +2 -0
- llama_cloud/resources/retrievers/client.py +654 -0
- llama_cloud/types/__init__.py +124 -2
- llama_cloud/types/{chat_message.py → app_schema_chat_chat_message.py} +2 -2
- llama_cloud/types/chat_app.py +44 -0
- llama_cloud/types/chat_app_response.py +41 -0
- llama_cloud/types/cloud_az_storage_blob_data_source.py +1 -0
- llama_cloud/types/cloud_box_data_source.py +1 -0
- llama_cloud/types/cloud_confluence_data_source.py +1 -0
- llama_cloud/types/cloud_google_drive_data_source.py +1 -0
- llama_cloud/types/cloud_jira_data_source.py +1 -0
- llama_cloud/types/cloud_notion_page_data_source.py +1 -0
- llama_cloud/types/cloud_one_drive_data_source.py +1 -0
- llama_cloud/types/cloud_postgres_vector_store.py +1 -0
- llama_cloud/types/cloud_s_3_data_source.py +1 -0
- llama_cloud/types/cloud_sharepoint_data_source.py +1 -0
- llama_cloud/types/cloud_slack_data_source.py +1 -0
- llama_cloud/types/composite_retrieval_mode.py +21 -0
- llama_cloud/types/composite_retrieval_result.py +38 -0
- llama_cloud/types/composite_retrieved_text_node.py +42 -0
- llama_cloud/types/data_sink.py +1 -1
- llama_cloud/types/data_sink_create.py +1 -1
- llama_cloud/types/data_source.py +1 -1
- llama_cloud/types/data_source_create.py +1 -1
- llama_cloud/types/edit_suggestion.py +39 -0
- llama_cloud/types/eval_dataset_job_record.py +1 -0
- llama_cloud/types/extract_agent.py +45 -0
- llama_cloud/types/extract_agent_data_schema_value.py +5 -0
- llama_cloud/types/extract_config.py +40 -0
- llama_cloud/types/extract_job.py +35 -0
- llama_cloud/types/extract_job_create.py +40 -0
- llama_cloud/types/extract_job_create_data_schema_override_value.py +7 -0
- llama_cloud/types/extract_mode.py +17 -0
- llama_cloud/types/extract_resultset.py +46 -0
- llama_cloud/types/extract_resultset_data.py +11 -0
- llama_cloud/types/extract_resultset_data_item_value.py +7 -0
- llama_cloud/types/extract_resultset_data_zero_value.py +7 -0
- llama_cloud/types/extract_resultset_extraction_metadata_value.py +7 -0
- llama_cloud/types/file.py +3 -0
- llama_cloud/types/file_permission_info_value.py +5 -0
- llama_cloud/types/filter_condition.py +9 -1
- llama_cloud/types/filter_operator.py +4 -0
- llama_cloud/types/image_block.py +35 -0
- llama_cloud/types/input_message.py +1 -1
- llama_cloud/types/job_name_mapping.py +4 -0
- llama_cloud/types/job_names.py +89 -0
- llama_cloud/types/job_record.py +57 -0
- llama_cloud/types/job_record_with_usage_metrics.py +36 -0
- llama_cloud/types/llama_index_core_base_llms_types_chat_message.py +39 -0
- llama_cloud/types/llama_index_core_base_llms_types_chat_message_blocks_item.py +33 -0
- llama_cloud/types/llama_parse_parameters.py +15 -0
- llama_cloud/types/llm.py +1 -0
- llama_cloud/types/llm_model_data.py +1 -0
- llama_cloud/types/llm_parameters.py +1 -0
- llama_cloud/types/managed_ingestion_status.py +4 -0
- llama_cloud/types/managed_ingestion_status_response.py +1 -0
- llama_cloud/types/object_type.py +4 -0
- llama_cloud/types/organization.py +5 -0
- llama_cloud/types/paginated_jobs_history_with_metrics.py +35 -0
- llama_cloud/types/paginated_report_response.py +35 -0
- llama_cloud/types/parse_plan_level.py +21 -0
- llama_cloud/types/parsing_job_structured_result.py +32 -0
- llama_cloud/types/pipeline_create.py +3 -1
- llama_cloud/types/pipeline_data_source.py +1 -1
- llama_cloud/types/pipeline_file.py +3 -0
- llama_cloud/types/pipeline_file_permission_info_value.py +7 -0
- llama_cloud/types/playground_session.py +2 -2
- llama_cloud/types/preset_retrieval_params.py +1 -0
- llama_cloud/types/progress_event.py +44 -0
- llama_cloud/types/progress_event_status.py +33 -0
- llama_cloud/types/prompt_spec.py +2 -2
- llama_cloud/types/related_node_info.py +2 -2
- llama_cloud/types/related_node_info_node_type.py +7 -0
- llama_cloud/types/report.py +33 -0
- llama_cloud/types/report_block.py +34 -0
- llama_cloud/types/report_block_dependency.py +29 -0
- llama_cloud/types/report_create_response.py +31 -0
- llama_cloud/types/report_event_item.py +40 -0
- llama_cloud/types/report_event_item_event_data.py +45 -0
- llama_cloud/types/report_event_type.py +37 -0
- llama_cloud/types/report_metadata.py +39 -0
- llama_cloud/types/report_plan.py +36 -0
- llama_cloud/types/report_plan_block.py +36 -0
- llama_cloud/types/report_query.py +33 -0
- llama_cloud/types/report_response.py +41 -0
- llama_cloud/types/report_state.py +37 -0
- llama_cloud/types/report_state_event.py +38 -0
- llama_cloud/types/report_update_event.py +38 -0
- llama_cloud/types/retrieve_results.py +1 -1
- llama_cloud/types/retriever.py +45 -0
- llama_cloud/types/retriever_create.py +37 -0
- llama_cloud/types/retriever_pipeline.py +37 -0
- llama_cloud/types/status_enum.py +4 -0
- llama_cloud/types/supported_llm_model_names.py +4 -0
- llama_cloud/types/text_block.py +31 -0
- llama_cloud/types/text_node.py +13 -6
- llama_cloud/types/usage_metric_response.py +34 -0
- llama_cloud/types/user_job_record.py +32 -0
- {llama_cloud-0.1.5.dist-info → llama_cloud-0.1.7a1.dist-info}/METADATA +3 -1
- {llama_cloud-0.1.5.dist-info → llama_cloud-0.1.7a1.dist-info}/RECORD +129 -59
- {llama_cloud-0.1.5.dist-info → llama_cloud-0.1.7a1.dist-info}/WHEEL +1 -1
- {llama_cloud-0.1.5.dist-info → llama_cloud-0.1.7a1.dist-info}/LICENSE +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
from .update_report_plan_api_v_1_reports_report_id_plan_patch_request_action import (
|
|
4
|
+
UpdateReportPlanApiV1ReportsReportIdPlanPatchRequestAction,
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
__all__ = ["UpdateReportPlanApiV1ReportsReportIdPlanPatchRequestAction"]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import enum
|
|
4
|
+
import typing
|
|
5
|
+
|
|
6
|
+
T_Result = typing.TypeVar("T_Result")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class UpdateReportPlanApiV1ReportsReportIdPlanPatchRequestAction(str, enum.Enum):
|
|
10
|
+
APPROVE = "approve"
|
|
11
|
+
REJECT = "reject"
|
|
12
|
+
EDIT = "edit"
|
|
13
|
+
|
|
14
|
+
def visit(
|
|
15
|
+
self,
|
|
16
|
+
approve: typing.Callable[[], T_Result],
|
|
17
|
+
reject: typing.Callable[[], T_Result],
|
|
18
|
+
edit: typing.Callable[[], T_Result],
|
|
19
|
+
) -> T_Result:
|
|
20
|
+
if self is UpdateReportPlanApiV1ReportsReportIdPlanPatchRequestAction.APPROVE:
|
|
21
|
+
return approve()
|
|
22
|
+
if self is UpdateReportPlanApiV1ReportsReportIdPlanPatchRequestAction.REJECT:
|
|
23
|
+
return reject()
|
|
24
|
+
if self is UpdateReportPlanApiV1ReportsReportIdPlanPatchRequestAction.EDIT:
|
|
25
|
+
return edit()
|
|
@@ -0,0 +1,654 @@
|
|
|
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.composite_retrieval_mode import CompositeRetrievalMode
|
|
13
|
+
from ...types.composite_retrieval_result import CompositeRetrievalResult
|
|
14
|
+
from ...types.http_validation_error import HttpValidationError
|
|
15
|
+
from ...types.retriever import Retriever
|
|
16
|
+
from ...types.retriever_create import RetrieverCreate
|
|
17
|
+
from ...types.retriever_pipeline import RetrieverPipeline
|
|
18
|
+
|
|
19
|
+
try:
|
|
20
|
+
import pydantic
|
|
21
|
+
if pydantic.__version__.startswith("1."):
|
|
22
|
+
raise ImportError
|
|
23
|
+
import pydantic.v1 as pydantic # type: ignore
|
|
24
|
+
except ImportError:
|
|
25
|
+
import pydantic # type: ignore
|
|
26
|
+
|
|
27
|
+
# this is used as the default value for optional parameters
|
|
28
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class RetrieversClient:
|
|
32
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
33
|
+
self._client_wrapper = client_wrapper
|
|
34
|
+
|
|
35
|
+
def list_retrievers(
|
|
36
|
+
self, *, project_id: typing.Optional[str] = None, organization_id: typing.Optional[str] = None
|
|
37
|
+
) -> typing.List[Retriever]:
|
|
38
|
+
"""
|
|
39
|
+
List Retrievers for a project.
|
|
40
|
+
|
|
41
|
+
Parameters:
|
|
42
|
+
- project_id: typing.Optional[str].
|
|
43
|
+
|
|
44
|
+
- organization_id: typing.Optional[str].
|
|
45
|
+
---
|
|
46
|
+
from llama_cloud.client import LlamaCloud
|
|
47
|
+
|
|
48
|
+
client = LlamaCloud(
|
|
49
|
+
token="YOUR_TOKEN",
|
|
50
|
+
)
|
|
51
|
+
client.retrievers.list_retrievers()
|
|
52
|
+
"""
|
|
53
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
54
|
+
"GET",
|
|
55
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/retrievers"),
|
|
56
|
+
params=remove_none_from_dict({"project_id": project_id, "organization_id": organization_id}),
|
|
57
|
+
headers=self._client_wrapper.get_headers(),
|
|
58
|
+
timeout=60,
|
|
59
|
+
)
|
|
60
|
+
if 200 <= _response.status_code < 300:
|
|
61
|
+
return pydantic.parse_obj_as(typing.List[Retriever], _response.json()) # type: ignore
|
|
62
|
+
if _response.status_code == 422:
|
|
63
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
64
|
+
try:
|
|
65
|
+
_response_json = _response.json()
|
|
66
|
+
except JSONDecodeError:
|
|
67
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
68
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
69
|
+
|
|
70
|
+
def create_retriever(
|
|
71
|
+
self,
|
|
72
|
+
*,
|
|
73
|
+
project_id: typing.Optional[str] = None,
|
|
74
|
+
organization_id: typing.Optional[str] = None,
|
|
75
|
+
request: RetrieverCreate,
|
|
76
|
+
) -> Retriever:
|
|
77
|
+
"""
|
|
78
|
+
Create a new Retriever.
|
|
79
|
+
|
|
80
|
+
Parameters:
|
|
81
|
+
- project_id: typing.Optional[str].
|
|
82
|
+
|
|
83
|
+
- organization_id: typing.Optional[str].
|
|
84
|
+
|
|
85
|
+
- request: RetrieverCreate.
|
|
86
|
+
---
|
|
87
|
+
from llama_cloud import RetrieverCreate
|
|
88
|
+
from llama_cloud.client import LlamaCloud
|
|
89
|
+
|
|
90
|
+
client = LlamaCloud(
|
|
91
|
+
token="YOUR_TOKEN",
|
|
92
|
+
)
|
|
93
|
+
client.retrievers.create_retriever(
|
|
94
|
+
request=RetrieverCreate(
|
|
95
|
+
name="string",
|
|
96
|
+
),
|
|
97
|
+
)
|
|
98
|
+
"""
|
|
99
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
100
|
+
"POST",
|
|
101
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/retrievers"),
|
|
102
|
+
params=remove_none_from_dict({"project_id": project_id, "organization_id": organization_id}),
|
|
103
|
+
json=jsonable_encoder(request),
|
|
104
|
+
headers=self._client_wrapper.get_headers(),
|
|
105
|
+
timeout=60,
|
|
106
|
+
)
|
|
107
|
+
if 200 <= _response.status_code < 300:
|
|
108
|
+
return pydantic.parse_obj_as(Retriever, _response.json()) # type: ignore
|
|
109
|
+
if _response.status_code == 422:
|
|
110
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
111
|
+
try:
|
|
112
|
+
_response_json = _response.json()
|
|
113
|
+
except JSONDecodeError:
|
|
114
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
115
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
116
|
+
|
|
117
|
+
def upsert_retriever(
|
|
118
|
+
self,
|
|
119
|
+
*,
|
|
120
|
+
project_id: typing.Optional[str] = None,
|
|
121
|
+
organization_id: typing.Optional[str] = None,
|
|
122
|
+
request: RetrieverCreate,
|
|
123
|
+
) -> Retriever:
|
|
124
|
+
"""
|
|
125
|
+
Upsert a new Retriever.
|
|
126
|
+
|
|
127
|
+
Parameters:
|
|
128
|
+
- project_id: typing.Optional[str].
|
|
129
|
+
|
|
130
|
+
- organization_id: typing.Optional[str].
|
|
131
|
+
|
|
132
|
+
- request: RetrieverCreate.
|
|
133
|
+
---
|
|
134
|
+
from llama_cloud import RetrieverCreate
|
|
135
|
+
from llama_cloud.client import LlamaCloud
|
|
136
|
+
|
|
137
|
+
client = LlamaCloud(
|
|
138
|
+
token="YOUR_TOKEN",
|
|
139
|
+
)
|
|
140
|
+
client.retrievers.upsert_retriever(
|
|
141
|
+
request=RetrieverCreate(
|
|
142
|
+
name="string",
|
|
143
|
+
),
|
|
144
|
+
)
|
|
145
|
+
"""
|
|
146
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
147
|
+
"PUT",
|
|
148
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/retrievers"),
|
|
149
|
+
params=remove_none_from_dict({"project_id": project_id, "organization_id": organization_id}),
|
|
150
|
+
json=jsonable_encoder(request),
|
|
151
|
+
headers=self._client_wrapper.get_headers(),
|
|
152
|
+
timeout=60,
|
|
153
|
+
)
|
|
154
|
+
if 200 <= _response.status_code < 300:
|
|
155
|
+
return pydantic.parse_obj_as(Retriever, _response.json()) # type: ignore
|
|
156
|
+
if _response.status_code == 422:
|
|
157
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
158
|
+
try:
|
|
159
|
+
_response_json = _response.json()
|
|
160
|
+
except JSONDecodeError:
|
|
161
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
162
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
163
|
+
|
|
164
|
+
def get_retriever(
|
|
165
|
+
self,
|
|
166
|
+
retriever_id: str,
|
|
167
|
+
*,
|
|
168
|
+
project_id: typing.Optional[str] = None,
|
|
169
|
+
organization_id: typing.Optional[str] = None,
|
|
170
|
+
) -> Retriever:
|
|
171
|
+
"""
|
|
172
|
+
Get a Retriever by ID.
|
|
173
|
+
|
|
174
|
+
Parameters:
|
|
175
|
+
- retriever_id: str.
|
|
176
|
+
|
|
177
|
+
- project_id: typing.Optional[str].
|
|
178
|
+
|
|
179
|
+
- organization_id: typing.Optional[str].
|
|
180
|
+
---
|
|
181
|
+
from llama_cloud.client import LlamaCloud
|
|
182
|
+
|
|
183
|
+
client = LlamaCloud(
|
|
184
|
+
token="YOUR_TOKEN",
|
|
185
|
+
)
|
|
186
|
+
client.retrievers.get_retriever(
|
|
187
|
+
retriever_id="string",
|
|
188
|
+
)
|
|
189
|
+
"""
|
|
190
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
191
|
+
"GET",
|
|
192
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/retrievers/{retriever_id}"),
|
|
193
|
+
params=remove_none_from_dict({"project_id": project_id, "organization_id": organization_id}),
|
|
194
|
+
headers=self._client_wrapper.get_headers(),
|
|
195
|
+
timeout=60,
|
|
196
|
+
)
|
|
197
|
+
if 200 <= _response.status_code < 300:
|
|
198
|
+
return pydantic.parse_obj_as(Retriever, _response.json()) # type: ignore
|
|
199
|
+
if _response.status_code == 422:
|
|
200
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
201
|
+
try:
|
|
202
|
+
_response_json = _response.json()
|
|
203
|
+
except JSONDecodeError:
|
|
204
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
205
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
206
|
+
|
|
207
|
+
def update_retriever(
|
|
208
|
+
self,
|
|
209
|
+
retriever_id: str,
|
|
210
|
+
*,
|
|
211
|
+
name: typing.Optional[str] = OMIT,
|
|
212
|
+
pipelines: typing.Optional[typing.List[RetrieverPipeline]] = OMIT,
|
|
213
|
+
) -> Retriever:
|
|
214
|
+
"""
|
|
215
|
+
Update an existing Retriever.
|
|
216
|
+
|
|
217
|
+
Parameters:
|
|
218
|
+
- retriever_id: str.
|
|
219
|
+
|
|
220
|
+
- name: typing.Optional[str].
|
|
221
|
+
|
|
222
|
+
- pipelines: typing.Optional[typing.List[RetrieverPipeline]].
|
|
223
|
+
---
|
|
224
|
+
from llama_cloud.client import LlamaCloud
|
|
225
|
+
|
|
226
|
+
client = LlamaCloud(
|
|
227
|
+
token="YOUR_TOKEN",
|
|
228
|
+
)
|
|
229
|
+
client.retrievers.update_retriever(
|
|
230
|
+
retriever_id="string",
|
|
231
|
+
)
|
|
232
|
+
"""
|
|
233
|
+
_request: typing.Dict[str, typing.Any] = {}
|
|
234
|
+
if name is not OMIT:
|
|
235
|
+
_request["name"] = name
|
|
236
|
+
if pipelines is not OMIT:
|
|
237
|
+
_request["pipelines"] = pipelines
|
|
238
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
239
|
+
"PUT",
|
|
240
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/retrievers/{retriever_id}"),
|
|
241
|
+
json=jsonable_encoder(_request),
|
|
242
|
+
headers=self._client_wrapper.get_headers(),
|
|
243
|
+
timeout=60,
|
|
244
|
+
)
|
|
245
|
+
if 200 <= _response.status_code < 300:
|
|
246
|
+
return pydantic.parse_obj_as(Retriever, _response.json()) # type: ignore
|
|
247
|
+
if _response.status_code == 422:
|
|
248
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
249
|
+
try:
|
|
250
|
+
_response_json = _response.json()
|
|
251
|
+
except JSONDecodeError:
|
|
252
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
253
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
254
|
+
|
|
255
|
+
def delete_retriever(self, retriever_id: str) -> None:
|
|
256
|
+
"""
|
|
257
|
+
Delete a Retriever by ID.
|
|
258
|
+
|
|
259
|
+
Parameters:
|
|
260
|
+
- retriever_id: str.
|
|
261
|
+
---
|
|
262
|
+
from llama_cloud.client import LlamaCloud
|
|
263
|
+
|
|
264
|
+
client = LlamaCloud(
|
|
265
|
+
token="YOUR_TOKEN",
|
|
266
|
+
)
|
|
267
|
+
client.retrievers.delete_retriever(
|
|
268
|
+
retriever_id="string",
|
|
269
|
+
)
|
|
270
|
+
"""
|
|
271
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
272
|
+
"DELETE",
|
|
273
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/retrievers/{retriever_id}"),
|
|
274
|
+
headers=self._client_wrapper.get_headers(),
|
|
275
|
+
timeout=60,
|
|
276
|
+
)
|
|
277
|
+
if 200 <= _response.status_code < 300:
|
|
278
|
+
return
|
|
279
|
+
if _response.status_code == 422:
|
|
280
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
281
|
+
try:
|
|
282
|
+
_response_json = _response.json()
|
|
283
|
+
except JSONDecodeError:
|
|
284
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
285
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
286
|
+
|
|
287
|
+
def retrieve(
|
|
288
|
+
self,
|
|
289
|
+
retriever_id: str,
|
|
290
|
+
*,
|
|
291
|
+
mode: typing.Optional[CompositeRetrievalMode] = OMIT,
|
|
292
|
+
rerank_top_n: typing.Optional[int] = OMIT,
|
|
293
|
+
query: str,
|
|
294
|
+
) -> CompositeRetrievalResult:
|
|
295
|
+
"""
|
|
296
|
+
Retrieve data using a Retriever.
|
|
297
|
+
|
|
298
|
+
Parameters:
|
|
299
|
+
- retriever_id: str.
|
|
300
|
+
|
|
301
|
+
- mode: typing.Optional[CompositeRetrievalMode]. The mode of composite retrieval.
|
|
302
|
+
|
|
303
|
+
- rerank_top_n: typing.Optional[int]. The number of nodes to retrieve after reranking over retrieved nodes from all retrieval tools.
|
|
304
|
+
|
|
305
|
+
- query: str. The query to retrieve against.
|
|
306
|
+
---
|
|
307
|
+
from llama_cloud import CompositeRetrievalMode
|
|
308
|
+
from llama_cloud.client import LlamaCloud
|
|
309
|
+
|
|
310
|
+
client = LlamaCloud(
|
|
311
|
+
token="YOUR_TOKEN",
|
|
312
|
+
)
|
|
313
|
+
client.retrievers.retrieve(
|
|
314
|
+
retriever_id="string",
|
|
315
|
+
mode=CompositeRetrievalMode.ROUTING,
|
|
316
|
+
query="string",
|
|
317
|
+
)
|
|
318
|
+
"""
|
|
319
|
+
_request: typing.Dict[str, typing.Any] = {"query": query}
|
|
320
|
+
if mode is not OMIT:
|
|
321
|
+
_request["mode"] = mode
|
|
322
|
+
if rerank_top_n is not OMIT:
|
|
323
|
+
_request["rerank_top_n"] = rerank_top_n
|
|
324
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
325
|
+
"POST",
|
|
326
|
+
urllib.parse.urljoin(
|
|
327
|
+
f"{self._client_wrapper.get_base_url()}/", f"api/v1/retrievers/{retriever_id}/retrieve"
|
|
328
|
+
),
|
|
329
|
+
json=jsonable_encoder(_request),
|
|
330
|
+
headers=self._client_wrapper.get_headers(),
|
|
331
|
+
timeout=60,
|
|
332
|
+
)
|
|
333
|
+
if 200 <= _response.status_code < 300:
|
|
334
|
+
return pydantic.parse_obj_as(CompositeRetrievalResult, _response.json()) # type: ignore
|
|
335
|
+
if _response.status_code == 422:
|
|
336
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
337
|
+
try:
|
|
338
|
+
_response_json = _response.json()
|
|
339
|
+
except JSONDecodeError:
|
|
340
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
341
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
class AsyncRetrieversClient:
|
|
345
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
346
|
+
self._client_wrapper = client_wrapper
|
|
347
|
+
|
|
348
|
+
async def list_retrievers(
|
|
349
|
+
self, *, project_id: typing.Optional[str] = None, organization_id: typing.Optional[str] = None
|
|
350
|
+
) -> typing.List[Retriever]:
|
|
351
|
+
"""
|
|
352
|
+
List Retrievers for a project.
|
|
353
|
+
|
|
354
|
+
Parameters:
|
|
355
|
+
- project_id: typing.Optional[str].
|
|
356
|
+
|
|
357
|
+
- organization_id: typing.Optional[str].
|
|
358
|
+
---
|
|
359
|
+
from llama_cloud.client import AsyncLlamaCloud
|
|
360
|
+
|
|
361
|
+
client = AsyncLlamaCloud(
|
|
362
|
+
token="YOUR_TOKEN",
|
|
363
|
+
)
|
|
364
|
+
await client.retrievers.list_retrievers()
|
|
365
|
+
"""
|
|
366
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
367
|
+
"GET",
|
|
368
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/retrievers"),
|
|
369
|
+
params=remove_none_from_dict({"project_id": project_id, "organization_id": organization_id}),
|
|
370
|
+
headers=self._client_wrapper.get_headers(),
|
|
371
|
+
timeout=60,
|
|
372
|
+
)
|
|
373
|
+
if 200 <= _response.status_code < 300:
|
|
374
|
+
return pydantic.parse_obj_as(typing.List[Retriever], _response.json()) # type: ignore
|
|
375
|
+
if _response.status_code == 422:
|
|
376
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
377
|
+
try:
|
|
378
|
+
_response_json = _response.json()
|
|
379
|
+
except JSONDecodeError:
|
|
380
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
381
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
382
|
+
|
|
383
|
+
async def create_retriever(
|
|
384
|
+
self,
|
|
385
|
+
*,
|
|
386
|
+
project_id: typing.Optional[str] = None,
|
|
387
|
+
organization_id: typing.Optional[str] = None,
|
|
388
|
+
request: RetrieverCreate,
|
|
389
|
+
) -> Retriever:
|
|
390
|
+
"""
|
|
391
|
+
Create a new Retriever.
|
|
392
|
+
|
|
393
|
+
Parameters:
|
|
394
|
+
- project_id: typing.Optional[str].
|
|
395
|
+
|
|
396
|
+
- organization_id: typing.Optional[str].
|
|
397
|
+
|
|
398
|
+
- request: RetrieverCreate.
|
|
399
|
+
---
|
|
400
|
+
from llama_cloud import RetrieverCreate
|
|
401
|
+
from llama_cloud.client import AsyncLlamaCloud
|
|
402
|
+
|
|
403
|
+
client = AsyncLlamaCloud(
|
|
404
|
+
token="YOUR_TOKEN",
|
|
405
|
+
)
|
|
406
|
+
await client.retrievers.create_retriever(
|
|
407
|
+
request=RetrieverCreate(
|
|
408
|
+
name="string",
|
|
409
|
+
),
|
|
410
|
+
)
|
|
411
|
+
"""
|
|
412
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
413
|
+
"POST",
|
|
414
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/retrievers"),
|
|
415
|
+
params=remove_none_from_dict({"project_id": project_id, "organization_id": organization_id}),
|
|
416
|
+
json=jsonable_encoder(request),
|
|
417
|
+
headers=self._client_wrapper.get_headers(),
|
|
418
|
+
timeout=60,
|
|
419
|
+
)
|
|
420
|
+
if 200 <= _response.status_code < 300:
|
|
421
|
+
return pydantic.parse_obj_as(Retriever, _response.json()) # type: ignore
|
|
422
|
+
if _response.status_code == 422:
|
|
423
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
424
|
+
try:
|
|
425
|
+
_response_json = _response.json()
|
|
426
|
+
except JSONDecodeError:
|
|
427
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
428
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
429
|
+
|
|
430
|
+
async def upsert_retriever(
|
|
431
|
+
self,
|
|
432
|
+
*,
|
|
433
|
+
project_id: typing.Optional[str] = None,
|
|
434
|
+
organization_id: typing.Optional[str] = None,
|
|
435
|
+
request: RetrieverCreate,
|
|
436
|
+
) -> Retriever:
|
|
437
|
+
"""
|
|
438
|
+
Upsert a new Retriever.
|
|
439
|
+
|
|
440
|
+
Parameters:
|
|
441
|
+
- project_id: typing.Optional[str].
|
|
442
|
+
|
|
443
|
+
- organization_id: typing.Optional[str].
|
|
444
|
+
|
|
445
|
+
- request: RetrieverCreate.
|
|
446
|
+
---
|
|
447
|
+
from llama_cloud import RetrieverCreate
|
|
448
|
+
from llama_cloud.client import AsyncLlamaCloud
|
|
449
|
+
|
|
450
|
+
client = AsyncLlamaCloud(
|
|
451
|
+
token="YOUR_TOKEN",
|
|
452
|
+
)
|
|
453
|
+
await client.retrievers.upsert_retriever(
|
|
454
|
+
request=RetrieverCreate(
|
|
455
|
+
name="string",
|
|
456
|
+
),
|
|
457
|
+
)
|
|
458
|
+
"""
|
|
459
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
460
|
+
"PUT",
|
|
461
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/retrievers"),
|
|
462
|
+
params=remove_none_from_dict({"project_id": project_id, "organization_id": organization_id}),
|
|
463
|
+
json=jsonable_encoder(request),
|
|
464
|
+
headers=self._client_wrapper.get_headers(),
|
|
465
|
+
timeout=60,
|
|
466
|
+
)
|
|
467
|
+
if 200 <= _response.status_code < 300:
|
|
468
|
+
return pydantic.parse_obj_as(Retriever, _response.json()) # type: ignore
|
|
469
|
+
if _response.status_code == 422:
|
|
470
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
471
|
+
try:
|
|
472
|
+
_response_json = _response.json()
|
|
473
|
+
except JSONDecodeError:
|
|
474
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
475
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
476
|
+
|
|
477
|
+
async def get_retriever(
|
|
478
|
+
self,
|
|
479
|
+
retriever_id: str,
|
|
480
|
+
*,
|
|
481
|
+
project_id: typing.Optional[str] = None,
|
|
482
|
+
organization_id: typing.Optional[str] = None,
|
|
483
|
+
) -> Retriever:
|
|
484
|
+
"""
|
|
485
|
+
Get a Retriever by ID.
|
|
486
|
+
|
|
487
|
+
Parameters:
|
|
488
|
+
- retriever_id: str.
|
|
489
|
+
|
|
490
|
+
- project_id: typing.Optional[str].
|
|
491
|
+
|
|
492
|
+
- organization_id: typing.Optional[str].
|
|
493
|
+
---
|
|
494
|
+
from llama_cloud.client import AsyncLlamaCloud
|
|
495
|
+
|
|
496
|
+
client = AsyncLlamaCloud(
|
|
497
|
+
token="YOUR_TOKEN",
|
|
498
|
+
)
|
|
499
|
+
await client.retrievers.get_retriever(
|
|
500
|
+
retriever_id="string",
|
|
501
|
+
)
|
|
502
|
+
"""
|
|
503
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
504
|
+
"GET",
|
|
505
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/retrievers/{retriever_id}"),
|
|
506
|
+
params=remove_none_from_dict({"project_id": project_id, "organization_id": organization_id}),
|
|
507
|
+
headers=self._client_wrapper.get_headers(),
|
|
508
|
+
timeout=60,
|
|
509
|
+
)
|
|
510
|
+
if 200 <= _response.status_code < 300:
|
|
511
|
+
return pydantic.parse_obj_as(Retriever, _response.json()) # type: ignore
|
|
512
|
+
if _response.status_code == 422:
|
|
513
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
514
|
+
try:
|
|
515
|
+
_response_json = _response.json()
|
|
516
|
+
except JSONDecodeError:
|
|
517
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
518
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
519
|
+
|
|
520
|
+
async def update_retriever(
|
|
521
|
+
self,
|
|
522
|
+
retriever_id: str,
|
|
523
|
+
*,
|
|
524
|
+
name: typing.Optional[str] = OMIT,
|
|
525
|
+
pipelines: typing.Optional[typing.List[RetrieverPipeline]] = OMIT,
|
|
526
|
+
) -> Retriever:
|
|
527
|
+
"""
|
|
528
|
+
Update an existing Retriever.
|
|
529
|
+
|
|
530
|
+
Parameters:
|
|
531
|
+
- retriever_id: str.
|
|
532
|
+
|
|
533
|
+
- name: typing.Optional[str].
|
|
534
|
+
|
|
535
|
+
- pipelines: typing.Optional[typing.List[RetrieverPipeline]].
|
|
536
|
+
---
|
|
537
|
+
from llama_cloud.client import AsyncLlamaCloud
|
|
538
|
+
|
|
539
|
+
client = AsyncLlamaCloud(
|
|
540
|
+
token="YOUR_TOKEN",
|
|
541
|
+
)
|
|
542
|
+
await client.retrievers.update_retriever(
|
|
543
|
+
retriever_id="string",
|
|
544
|
+
)
|
|
545
|
+
"""
|
|
546
|
+
_request: typing.Dict[str, typing.Any] = {}
|
|
547
|
+
if name is not OMIT:
|
|
548
|
+
_request["name"] = name
|
|
549
|
+
if pipelines is not OMIT:
|
|
550
|
+
_request["pipelines"] = pipelines
|
|
551
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
552
|
+
"PUT",
|
|
553
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/retrievers/{retriever_id}"),
|
|
554
|
+
json=jsonable_encoder(_request),
|
|
555
|
+
headers=self._client_wrapper.get_headers(),
|
|
556
|
+
timeout=60,
|
|
557
|
+
)
|
|
558
|
+
if 200 <= _response.status_code < 300:
|
|
559
|
+
return pydantic.parse_obj_as(Retriever, _response.json()) # type: ignore
|
|
560
|
+
if _response.status_code == 422:
|
|
561
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
562
|
+
try:
|
|
563
|
+
_response_json = _response.json()
|
|
564
|
+
except JSONDecodeError:
|
|
565
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
566
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
567
|
+
|
|
568
|
+
async def delete_retriever(self, retriever_id: str) -> None:
|
|
569
|
+
"""
|
|
570
|
+
Delete a Retriever by ID.
|
|
571
|
+
|
|
572
|
+
Parameters:
|
|
573
|
+
- retriever_id: str.
|
|
574
|
+
---
|
|
575
|
+
from llama_cloud.client import AsyncLlamaCloud
|
|
576
|
+
|
|
577
|
+
client = AsyncLlamaCloud(
|
|
578
|
+
token="YOUR_TOKEN",
|
|
579
|
+
)
|
|
580
|
+
await client.retrievers.delete_retriever(
|
|
581
|
+
retriever_id="string",
|
|
582
|
+
)
|
|
583
|
+
"""
|
|
584
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
585
|
+
"DELETE",
|
|
586
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/retrievers/{retriever_id}"),
|
|
587
|
+
headers=self._client_wrapper.get_headers(),
|
|
588
|
+
timeout=60,
|
|
589
|
+
)
|
|
590
|
+
if 200 <= _response.status_code < 300:
|
|
591
|
+
return
|
|
592
|
+
if _response.status_code == 422:
|
|
593
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
594
|
+
try:
|
|
595
|
+
_response_json = _response.json()
|
|
596
|
+
except JSONDecodeError:
|
|
597
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
598
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
599
|
+
|
|
600
|
+
async def retrieve(
|
|
601
|
+
self,
|
|
602
|
+
retriever_id: str,
|
|
603
|
+
*,
|
|
604
|
+
mode: typing.Optional[CompositeRetrievalMode] = OMIT,
|
|
605
|
+
rerank_top_n: typing.Optional[int] = OMIT,
|
|
606
|
+
query: str,
|
|
607
|
+
) -> CompositeRetrievalResult:
|
|
608
|
+
"""
|
|
609
|
+
Retrieve data using a Retriever.
|
|
610
|
+
|
|
611
|
+
Parameters:
|
|
612
|
+
- retriever_id: str.
|
|
613
|
+
|
|
614
|
+
- mode: typing.Optional[CompositeRetrievalMode]. The mode of composite retrieval.
|
|
615
|
+
|
|
616
|
+
- rerank_top_n: typing.Optional[int]. The number of nodes to retrieve after reranking over retrieved nodes from all retrieval tools.
|
|
617
|
+
|
|
618
|
+
- query: str. The query to retrieve against.
|
|
619
|
+
---
|
|
620
|
+
from llama_cloud import CompositeRetrievalMode
|
|
621
|
+
from llama_cloud.client import AsyncLlamaCloud
|
|
622
|
+
|
|
623
|
+
client = AsyncLlamaCloud(
|
|
624
|
+
token="YOUR_TOKEN",
|
|
625
|
+
)
|
|
626
|
+
await client.retrievers.retrieve(
|
|
627
|
+
retriever_id="string",
|
|
628
|
+
mode=CompositeRetrievalMode.ROUTING,
|
|
629
|
+
query="string",
|
|
630
|
+
)
|
|
631
|
+
"""
|
|
632
|
+
_request: typing.Dict[str, typing.Any] = {"query": query}
|
|
633
|
+
if mode is not OMIT:
|
|
634
|
+
_request["mode"] = mode
|
|
635
|
+
if rerank_top_n is not OMIT:
|
|
636
|
+
_request["rerank_top_n"] = rerank_top_n
|
|
637
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
638
|
+
"POST",
|
|
639
|
+
urllib.parse.urljoin(
|
|
640
|
+
f"{self._client_wrapper.get_base_url()}/", f"api/v1/retrievers/{retriever_id}/retrieve"
|
|
641
|
+
),
|
|
642
|
+
json=jsonable_encoder(_request),
|
|
643
|
+
headers=self._client_wrapper.get_headers(),
|
|
644
|
+
timeout=60,
|
|
645
|
+
)
|
|
646
|
+
if 200 <= _response.status_code < 300:
|
|
647
|
+
return pydantic.parse_obj_as(CompositeRetrievalResult, _response.json()) # type: ignore
|
|
648
|
+
if _response.status_code == 422:
|
|
649
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
650
|
+
try:
|
|
651
|
+
_response_json = _response.json()
|
|
652
|
+
except JSONDecodeError:
|
|
653
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
654
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|