llama-cloud 0.0.1__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 +295 -0
- llama_cloud/client.py +72 -0
- llama_cloud/core/__init__.py +17 -0
- llama_cloud/core/api_error.py +15 -0
- llama_cloud/core/client_wrapper.py +51 -0
- llama_cloud/core/datetime_utils.py +28 -0
- llama_cloud/core/jsonable_encoder.py +103 -0
- llama_cloud/core/remove_none_from_dict.py +11 -0
- llama_cloud/errors/__init__.py +5 -0
- llama_cloud/errors/unprocessable_entity_error.py +9 -0
- llama_cloud/resources/__init__.py +40 -0
- llama_cloud/resources/api_keys/__init__.py +2 -0
- llama_cloud/resources/api_keys/client.py +302 -0
- llama_cloud/resources/billing/__init__.py +2 -0
- llama_cloud/resources/billing/client.py +234 -0
- llama_cloud/resources/component_definitions/__init__.py +2 -0
- llama_cloud/resources/component_definitions/client.py +192 -0
- llama_cloud/resources/data_sinks/__init__.py +5 -0
- llama_cloud/resources/data_sinks/client.py +506 -0
- llama_cloud/resources/data_sinks/types/__init__.py +6 -0
- llama_cloud/resources/data_sinks/types/data_sink_update_component.py +7 -0
- llama_cloud/resources/data_sinks/types/data_sink_update_component_one.py +17 -0
- llama_cloud/resources/data_sources/__init__.py +5 -0
- llama_cloud/resources/data_sources/client.py +521 -0
- llama_cloud/resources/data_sources/types/__init__.py +7 -0
- llama_cloud/resources/data_sources/types/data_source_update_component.py +7 -0
- llama_cloud/resources/data_sources/types/data_source_update_component_one.py +19 -0
- llama_cloud/resources/data_sources/types/data_source_update_custom_metadata_value.py +7 -0
- llama_cloud/resources/deprecated/__init__.py +2 -0
- llama_cloud/resources/deprecated/client.py +982 -0
- llama_cloud/resources/evals/__init__.py +2 -0
- llama_cloud/resources/evals/client.py +745 -0
- llama_cloud/resources/files/__init__.py +5 -0
- llama_cloud/resources/files/client.py +560 -0
- llama_cloud/resources/files/types/__init__.py +5 -0
- llama_cloud/resources/files/types/file_create_resource_info_value.py +5 -0
- llama_cloud/resources/parsing/__init__.py +2 -0
- llama_cloud/resources/parsing/client.py +982 -0
- llama_cloud/resources/pipelines/__init__.py +5 -0
- llama_cloud/resources/pipelines/client.py +2599 -0
- llama_cloud/resources/pipelines/types/__init__.py +5 -0
- llama_cloud/resources/pipelines/types/pipeline_file_update_custom_metadata_value.py +7 -0
- llama_cloud/resources/projects/__init__.py +2 -0
- llama_cloud/resources/projects/client.py +1231 -0
- llama_cloud/types/__init__.py +253 -0
- llama_cloud/types/api_key.py +37 -0
- llama_cloud/types/azure_open_ai_embedding.py +75 -0
- llama_cloud/types/base.py +26 -0
- llama_cloud/types/base_prompt_template.py +44 -0
- llama_cloud/types/bedrock_embedding.py +56 -0
- llama_cloud/types/chat_message.py +35 -0
- llama_cloud/types/cloud_az_storage_blob_data_source.py +40 -0
- llama_cloud/types/cloud_chroma_vector_store.py +40 -0
- llama_cloud/types/cloud_document.py +36 -0
- llama_cloud/types/cloud_document_create.py +36 -0
- llama_cloud/types/cloud_gcs_data_source.py +37 -0
- llama_cloud/types/cloud_google_drive_data_source.py +36 -0
- llama_cloud/types/cloud_one_drive_data_source.py +38 -0
- llama_cloud/types/cloud_pinecone_vector_store.py +46 -0
- llama_cloud/types/cloud_postgres_vector_store.py +44 -0
- llama_cloud/types/cloud_qdrant_vector_store.py +48 -0
- llama_cloud/types/cloud_s_3_data_source.py +42 -0
- llama_cloud/types/cloud_sharepoint_data_source.py +38 -0
- llama_cloud/types/cloud_weaviate_vector_store.py +38 -0
- llama_cloud/types/code_splitter.py +46 -0
- llama_cloud/types/cohere_embedding.py +46 -0
- llama_cloud/types/configurable_data_sink_names.py +37 -0
- llama_cloud/types/configurable_data_source_names.py +41 -0
- llama_cloud/types/configurable_transformation_definition.py +45 -0
- llama_cloud/types/configurable_transformation_names.py +73 -0
- llama_cloud/types/configured_transformation_item.py +43 -0
- llama_cloud/types/configured_transformation_item_component.py +9 -0
- llama_cloud/types/configured_transformation_item_component_one.py +35 -0
- llama_cloud/types/data_sink.py +40 -0
- llama_cloud/types/data_sink_component.py +7 -0
- llama_cloud/types/data_sink_component_one.py +17 -0
- llama_cloud/types/data_sink_create.py +36 -0
- llama_cloud/types/data_sink_create_component.py +7 -0
- llama_cloud/types/data_sink_create_component_one.py +17 -0
- llama_cloud/types/data_sink_definition.py +41 -0
- llama_cloud/types/data_source.py +44 -0
- llama_cloud/types/data_source_component.py +7 -0
- llama_cloud/types/data_source_component_one.py +19 -0
- llama_cloud/types/data_source_create.py +40 -0
- llama_cloud/types/data_source_create_component.py +7 -0
- llama_cloud/types/data_source_create_component_one.py +19 -0
- llama_cloud/types/data_source_create_custom_metadata_value.py +7 -0
- llama_cloud/types/data_source_custom_metadata_value.py +7 -0
- llama_cloud/types/data_source_definition.py +41 -0
- llama_cloud/types/eval_dataset.py +37 -0
- llama_cloud/types/eval_dataset_job_params.py +36 -0
- llama_cloud/types/eval_dataset_job_record.py +59 -0
- llama_cloud/types/eval_execution_params.py +38 -0
- llama_cloud/types/eval_execution_params_override.py +38 -0
- llama_cloud/types/eval_llm_model_data.py +33 -0
- llama_cloud/types/eval_question.py +39 -0
- llama_cloud/types/eval_question_create.py +28 -0
- llama_cloud/types/eval_question_result.py +49 -0
- llama_cloud/types/file.py +46 -0
- llama_cloud/types/file_resource_info_value.py +5 -0
- llama_cloud/types/filter_condition.py +21 -0
- llama_cloud/types/filter_operator.py +65 -0
- llama_cloud/types/gemini_embedding.py +51 -0
- llama_cloud/types/html_node_parser.py +44 -0
- llama_cloud/types/http_validation_error.py +29 -0
- llama_cloud/types/hugging_face_inference_api_embedding.py +68 -0
- llama_cloud/types/hugging_face_inference_api_embedding_token.py +5 -0
- llama_cloud/types/json_node_parser.py +43 -0
- llama_cloud/types/llama_parse_supported_file_extensions.py +161 -0
- llama_cloud/types/llm.py +55 -0
- llama_cloud/types/local_eval.py +46 -0
- llama_cloud/types/local_eval_results.py +37 -0
- llama_cloud/types/local_eval_sets.py +30 -0
- llama_cloud/types/managed_ingestion_status.py +37 -0
- llama_cloud/types/markdown_element_node_parser.py +49 -0
- llama_cloud/types/markdown_node_parser.py +43 -0
- llama_cloud/types/message_role.py +45 -0
- llama_cloud/types/metadata_filter.py +41 -0
- llama_cloud/types/metadata_filter_value.py +5 -0
- llama_cloud/types/metadata_filters.py +41 -0
- llama_cloud/types/metadata_filters_filters_item.py +8 -0
- llama_cloud/types/metric_result.py +30 -0
- llama_cloud/types/node_parser.py +37 -0
- llama_cloud/types/object_type.py +33 -0
- llama_cloud/types/open_ai_embedding.py +73 -0
- llama_cloud/types/parser_languages.py +361 -0
- llama_cloud/types/parsing_history_item.py +36 -0
- llama_cloud/types/parsing_job.py +30 -0
- llama_cloud/types/parsing_job_json_result.py +29 -0
- llama_cloud/types/parsing_job_markdown_result.py +29 -0
- llama_cloud/types/parsing_job_text_result.py +29 -0
- llama_cloud/types/parsing_usage.py +29 -0
- llama_cloud/types/pipeline.py +64 -0
- llama_cloud/types/pipeline_create.py +61 -0
- llama_cloud/types/pipeline_data_source.py +46 -0
- llama_cloud/types/pipeline_data_source_component.py +7 -0
- llama_cloud/types/pipeline_data_source_component_one.py +19 -0
- llama_cloud/types/pipeline_data_source_create.py +32 -0
- llama_cloud/types/pipeline_data_source_custom_metadata_value.py +7 -0
- llama_cloud/types/pipeline_deployment.py +38 -0
- llama_cloud/types/pipeline_file.py +52 -0
- llama_cloud/types/pipeline_file_create.py +36 -0
- llama_cloud/types/pipeline_file_create_custom_metadata_value.py +7 -0
- llama_cloud/types/pipeline_file_custom_metadata_value.py +7 -0
- llama_cloud/types/pipeline_file_resource_info_value.py +7 -0
- llama_cloud/types/pipeline_file_status_response.py +35 -0
- llama_cloud/types/pipeline_type.py +21 -0
- llama_cloud/types/pooling.py +29 -0
- llama_cloud/types/preset_retrieval_params.py +40 -0
- llama_cloud/types/presigned_url.py +36 -0
- llama_cloud/types/project.py +42 -0
- llama_cloud/types/project_create.py +32 -0
- llama_cloud/types/prompt_mixin_prompts.py +36 -0
- llama_cloud/types/prompt_spec.py +35 -0
- llama_cloud/types/pydantic_program_mode.py +41 -0
- llama_cloud/types/related_node_info.py +37 -0
- llama_cloud/types/retrieve_results.py +40 -0
- llama_cloud/types/sentence_splitter.py +48 -0
- llama_cloud/types/simple_file_node_parser.py +44 -0
- llama_cloud/types/status_enum.py +33 -0
- llama_cloud/types/supported_eval_llm_model.py +35 -0
- llama_cloud/types/supported_eval_llm_model_names.py +29 -0
- llama_cloud/types/text_node.py +62 -0
- llama_cloud/types/text_node_relationships_value.py +7 -0
- llama_cloud/types/text_node_with_score.py +36 -0
- llama_cloud/types/token_text_splitter.py +43 -0
- llama_cloud/types/transformation_category_names.py +21 -0
- llama_cloud/types/validation_error.py +31 -0
- llama_cloud/types/validation_error_loc_item.py +5 -0
- llama_cloud-0.0.1.dist-info/LICENSE +21 -0
- llama_cloud-0.0.1.dist-info/METADATA +25 -0
- llama_cloud-0.0.1.dist-info/RECORD +173 -0
- llama_cloud-0.0.1.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,745 @@
|
|
|
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.eval_dataset import EvalDataset
|
|
12
|
+
from ...types.eval_question import EvalQuestion
|
|
13
|
+
from ...types.eval_question_create import EvalQuestionCreate
|
|
14
|
+
from ...types.http_validation_error import HttpValidationError
|
|
15
|
+
from ...types.supported_eval_llm_model import SupportedEvalLlmModel
|
|
16
|
+
|
|
17
|
+
try:
|
|
18
|
+
import pydantic.v1 as pydantic # type: ignore
|
|
19
|
+
except ImportError:
|
|
20
|
+
import pydantic # type: ignore
|
|
21
|
+
|
|
22
|
+
# this is used as the default value for optional parameters
|
|
23
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class EvalsClient:
|
|
27
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
28
|
+
self._client_wrapper = client_wrapper
|
|
29
|
+
|
|
30
|
+
def get_dataset(self, dataset_id: str) -> EvalDataset:
|
|
31
|
+
"""
|
|
32
|
+
Get a dataset by ID.
|
|
33
|
+
|
|
34
|
+
Parameters:
|
|
35
|
+
- dataset_id: str.
|
|
36
|
+
---
|
|
37
|
+
from platform.client import PlatformApi
|
|
38
|
+
|
|
39
|
+
client = PlatformApi(
|
|
40
|
+
token="YOUR_TOKEN",
|
|
41
|
+
base_url="https://yourhost.com/path/to/api",
|
|
42
|
+
)
|
|
43
|
+
client.evals.get_dataset(
|
|
44
|
+
dataset_id="string",
|
|
45
|
+
)
|
|
46
|
+
"""
|
|
47
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
48
|
+
"GET",
|
|
49
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/evals/datasets/{dataset_id}"),
|
|
50
|
+
headers=self._client_wrapper.get_headers(),
|
|
51
|
+
timeout=60,
|
|
52
|
+
)
|
|
53
|
+
if 200 <= _response.status_code < 300:
|
|
54
|
+
return pydantic.parse_obj_as(EvalDataset, _response.json()) # type: ignore
|
|
55
|
+
if _response.status_code == 422:
|
|
56
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
57
|
+
try:
|
|
58
|
+
_response_json = _response.json()
|
|
59
|
+
except JSONDecodeError:
|
|
60
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
61
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
62
|
+
|
|
63
|
+
def update_dataset(self, dataset_id: str, *, name: str) -> EvalDataset:
|
|
64
|
+
"""
|
|
65
|
+
Update a dataset.
|
|
66
|
+
|
|
67
|
+
Parameters:
|
|
68
|
+
- dataset_id: str.
|
|
69
|
+
|
|
70
|
+
- name: str. The name of the EvalDataset.
|
|
71
|
+
---
|
|
72
|
+
from platform.client import PlatformApi
|
|
73
|
+
|
|
74
|
+
client = PlatformApi(
|
|
75
|
+
token="YOUR_TOKEN",
|
|
76
|
+
base_url="https://yourhost.com/path/to/api",
|
|
77
|
+
)
|
|
78
|
+
client.evals.update_dataset(
|
|
79
|
+
dataset_id="string",
|
|
80
|
+
name="string",
|
|
81
|
+
)
|
|
82
|
+
"""
|
|
83
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
84
|
+
"PUT",
|
|
85
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/evals/datasets/{dataset_id}"),
|
|
86
|
+
json=jsonable_encoder({"name": name}),
|
|
87
|
+
headers=self._client_wrapper.get_headers(),
|
|
88
|
+
timeout=60,
|
|
89
|
+
)
|
|
90
|
+
if 200 <= _response.status_code < 300:
|
|
91
|
+
return pydantic.parse_obj_as(EvalDataset, _response.json()) # type: ignore
|
|
92
|
+
if _response.status_code == 422:
|
|
93
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
94
|
+
try:
|
|
95
|
+
_response_json = _response.json()
|
|
96
|
+
except JSONDecodeError:
|
|
97
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
98
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
99
|
+
|
|
100
|
+
def delete_dataset(self, dataset_id: str) -> None:
|
|
101
|
+
"""
|
|
102
|
+
Delete a dataset.
|
|
103
|
+
|
|
104
|
+
Parameters:
|
|
105
|
+
- dataset_id: str.
|
|
106
|
+
---
|
|
107
|
+
from platform.client import PlatformApi
|
|
108
|
+
|
|
109
|
+
client = PlatformApi(
|
|
110
|
+
token="YOUR_TOKEN",
|
|
111
|
+
base_url="https://yourhost.com/path/to/api",
|
|
112
|
+
)
|
|
113
|
+
client.evals.delete_dataset(
|
|
114
|
+
dataset_id="string",
|
|
115
|
+
)
|
|
116
|
+
"""
|
|
117
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
118
|
+
"DELETE",
|
|
119
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/evals/datasets/{dataset_id}"),
|
|
120
|
+
headers=self._client_wrapper.get_headers(),
|
|
121
|
+
timeout=60,
|
|
122
|
+
)
|
|
123
|
+
if 200 <= _response.status_code < 300:
|
|
124
|
+
return
|
|
125
|
+
if _response.status_code == 422:
|
|
126
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
127
|
+
try:
|
|
128
|
+
_response_json = _response.json()
|
|
129
|
+
except JSONDecodeError:
|
|
130
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
131
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
132
|
+
|
|
133
|
+
def get_questions(self, dataset_id: str) -> typing.List[EvalQuestion]:
|
|
134
|
+
"""
|
|
135
|
+
Get all questions for a dataset.
|
|
136
|
+
|
|
137
|
+
Parameters:
|
|
138
|
+
- dataset_id: str.
|
|
139
|
+
---
|
|
140
|
+
from platform.client import PlatformApi
|
|
141
|
+
|
|
142
|
+
client = PlatformApi(
|
|
143
|
+
token="YOUR_TOKEN",
|
|
144
|
+
base_url="https://yourhost.com/path/to/api",
|
|
145
|
+
)
|
|
146
|
+
client.evals.get_questions(
|
|
147
|
+
dataset_id="string",
|
|
148
|
+
)
|
|
149
|
+
"""
|
|
150
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
151
|
+
"GET",
|
|
152
|
+
urllib.parse.urljoin(
|
|
153
|
+
f"{self._client_wrapper.get_base_url()}/", f"api/v1/evals/datasets/{dataset_id}/question"
|
|
154
|
+
),
|
|
155
|
+
headers=self._client_wrapper.get_headers(),
|
|
156
|
+
timeout=60,
|
|
157
|
+
)
|
|
158
|
+
if 200 <= _response.status_code < 300:
|
|
159
|
+
return pydantic.parse_obj_as(typing.List[EvalQuestion], _response.json()) # type: ignore
|
|
160
|
+
if _response.status_code == 422:
|
|
161
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
162
|
+
try:
|
|
163
|
+
_response_json = _response.json()
|
|
164
|
+
except JSONDecodeError:
|
|
165
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
166
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
167
|
+
|
|
168
|
+
def create_question(self, dataset_id: str, *, request: EvalQuestionCreate) -> EvalQuestion:
|
|
169
|
+
"""
|
|
170
|
+
Create a new question.
|
|
171
|
+
|
|
172
|
+
Parameters:
|
|
173
|
+
- dataset_id: str.
|
|
174
|
+
|
|
175
|
+
- request: EvalQuestionCreate.
|
|
176
|
+
---
|
|
177
|
+
from platform import EvalQuestionCreate
|
|
178
|
+
from platform.client import PlatformApi
|
|
179
|
+
|
|
180
|
+
client = PlatformApi(
|
|
181
|
+
token="YOUR_TOKEN",
|
|
182
|
+
base_url="https://yourhost.com/path/to/api",
|
|
183
|
+
)
|
|
184
|
+
client.evals.create_question(
|
|
185
|
+
dataset_id="string",
|
|
186
|
+
request=EvalQuestionCreate(
|
|
187
|
+
content="string",
|
|
188
|
+
),
|
|
189
|
+
)
|
|
190
|
+
"""
|
|
191
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
192
|
+
"POST",
|
|
193
|
+
urllib.parse.urljoin(
|
|
194
|
+
f"{self._client_wrapper.get_base_url()}/", f"api/v1/evals/datasets/{dataset_id}/question"
|
|
195
|
+
),
|
|
196
|
+
json=jsonable_encoder(request),
|
|
197
|
+
headers=self._client_wrapper.get_headers(),
|
|
198
|
+
timeout=60,
|
|
199
|
+
)
|
|
200
|
+
if 200 <= _response.status_code < 300:
|
|
201
|
+
return pydantic.parse_obj_as(EvalQuestion, _response.json()) # type: ignore
|
|
202
|
+
if _response.status_code == 422:
|
|
203
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
204
|
+
try:
|
|
205
|
+
_response_json = _response.json()
|
|
206
|
+
except JSONDecodeError:
|
|
207
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
208
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
209
|
+
|
|
210
|
+
def create_questions(
|
|
211
|
+
self, dataset_id: str, *, request: typing.List[EvalQuestionCreate]
|
|
212
|
+
) -> typing.List[EvalQuestion]:
|
|
213
|
+
"""
|
|
214
|
+
Create a new question.
|
|
215
|
+
|
|
216
|
+
Parameters:
|
|
217
|
+
- dataset_id: str.
|
|
218
|
+
|
|
219
|
+
- request: typing.List[EvalQuestionCreate].
|
|
220
|
+
---
|
|
221
|
+
from platform.client import PlatformApi
|
|
222
|
+
|
|
223
|
+
client = PlatformApi(
|
|
224
|
+
token="YOUR_TOKEN",
|
|
225
|
+
base_url="https://yourhost.com/path/to/api",
|
|
226
|
+
)
|
|
227
|
+
client.evals.create_questions(
|
|
228
|
+
dataset_id="string",
|
|
229
|
+
request=[],
|
|
230
|
+
)
|
|
231
|
+
"""
|
|
232
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
233
|
+
"POST",
|
|
234
|
+
urllib.parse.urljoin(
|
|
235
|
+
f"{self._client_wrapper.get_base_url()}/", f"api/v1/evals/datasets/{dataset_id}/questions"
|
|
236
|
+
),
|
|
237
|
+
json=jsonable_encoder(request),
|
|
238
|
+
headers=self._client_wrapper.get_headers(),
|
|
239
|
+
timeout=60,
|
|
240
|
+
)
|
|
241
|
+
if 200 <= _response.status_code < 300:
|
|
242
|
+
return pydantic.parse_obj_as(typing.List[EvalQuestion], _response.json()) # type: ignore
|
|
243
|
+
if _response.status_code == 422:
|
|
244
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
245
|
+
try:
|
|
246
|
+
_response_json = _response.json()
|
|
247
|
+
except JSONDecodeError:
|
|
248
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
249
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
250
|
+
|
|
251
|
+
def get_question(self, question_id: str) -> EvalQuestion:
|
|
252
|
+
"""
|
|
253
|
+
Get a question by ID.
|
|
254
|
+
|
|
255
|
+
Parameters:
|
|
256
|
+
- question_id: str.
|
|
257
|
+
---
|
|
258
|
+
from platform.client import PlatformApi
|
|
259
|
+
|
|
260
|
+
client = PlatformApi(
|
|
261
|
+
token="YOUR_TOKEN",
|
|
262
|
+
base_url="https://yourhost.com/path/to/api",
|
|
263
|
+
)
|
|
264
|
+
client.evals.get_question(
|
|
265
|
+
question_id="string",
|
|
266
|
+
)
|
|
267
|
+
"""
|
|
268
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
269
|
+
"GET",
|
|
270
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/evals/questions/{question_id}"),
|
|
271
|
+
headers=self._client_wrapper.get_headers(),
|
|
272
|
+
timeout=60,
|
|
273
|
+
)
|
|
274
|
+
if 200 <= _response.status_code < 300:
|
|
275
|
+
return pydantic.parse_obj_as(EvalQuestion, _response.json()) # type: ignore
|
|
276
|
+
if _response.status_code == 422:
|
|
277
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
278
|
+
try:
|
|
279
|
+
_response_json = _response.json()
|
|
280
|
+
except JSONDecodeError:
|
|
281
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
282
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
283
|
+
|
|
284
|
+
def replace_question(self, question_id: str, *, request: EvalQuestionCreate) -> EvalQuestion:
|
|
285
|
+
"""
|
|
286
|
+
Replace a question.
|
|
287
|
+
|
|
288
|
+
Parameters:
|
|
289
|
+
- question_id: str.
|
|
290
|
+
|
|
291
|
+
- request: EvalQuestionCreate.
|
|
292
|
+
---
|
|
293
|
+
from platform import EvalQuestionCreate
|
|
294
|
+
from platform.client import PlatformApi
|
|
295
|
+
|
|
296
|
+
client = PlatformApi(
|
|
297
|
+
token="YOUR_TOKEN",
|
|
298
|
+
base_url="https://yourhost.com/path/to/api",
|
|
299
|
+
)
|
|
300
|
+
client.evals.replace_question(
|
|
301
|
+
question_id="string",
|
|
302
|
+
request=EvalQuestionCreate(
|
|
303
|
+
content="string",
|
|
304
|
+
),
|
|
305
|
+
)
|
|
306
|
+
"""
|
|
307
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
308
|
+
"PUT",
|
|
309
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/evals/questions/{question_id}"),
|
|
310
|
+
json=jsonable_encoder(request),
|
|
311
|
+
headers=self._client_wrapper.get_headers(),
|
|
312
|
+
timeout=60,
|
|
313
|
+
)
|
|
314
|
+
if 200 <= _response.status_code < 300:
|
|
315
|
+
return pydantic.parse_obj_as(EvalQuestion, _response.json()) # type: ignore
|
|
316
|
+
if _response.status_code == 422:
|
|
317
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
318
|
+
try:
|
|
319
|
+
_response_json = _response.json()
|
|
320
|
+
except JSONDecodeError:
|
|
321
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
322
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
323
|
+
|
|
324
|
+
def delete_question(self, question_id: str) -> None:
|
|
325
|
+
"""
|
|
326
|
+
Delete a question.
|
|
327
|
+
|
|
328
|
+
Parameters:
|
|
329
|
+
- question_id: str.
|
|
330
|
+
---
|
|
331
|
+
from platform.client import PlatformApi
|
|
332
|
+
|
|
333
|
+
client = PlatformApi(
|
|
334
|
+
token="YOUR_TOKEN",
|
|
335
|
+
base_url="https://yourhost.com/path/to/api",
|
|
336
|
+
)
|
|
337
|
+
client.evals.delete_question(
|
|
338
|
+
question_id="string",
|
|
339
|
+
)
|
|
340
|
+
"""
|
|
341
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
342
|
+
"DELETE",
|
|
343
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/evals/questions/{question_id}"),
|
|
344
|
+
headers=self._client_wrapper.get_headers(),
|
|
345
|
+
timeout=60,
|
|
346
|
+
)
|
|
347
|
+
if 200 <= _response.status_code < 300:
|
|
348
|
+
return
|
|
349
|
+
if _response.status_code == 422:
|
|
350
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
351
|
+
try:
|
|
352
|
+
_response_json = _response.json()
|
|
353
|
+
except JSONDecodeError:
|
|
354
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
355
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
356
|
+
|
|
357
|
+
def get_supported_models(self) -> typing.List[SupportedEvalLlmModel]:
|
|
358
|
+
"""
|
|
359
|
+
Get all supported models.
|
|
360
|
+
|
|
361
|
+
---
|
|
362
|
+
from platform.client import PlatformApi
|
|
363
|
+
|
|
364
|
+
client = PlatformApi(
|
|
365
|
+
token="YOUR_TOKEN",
|
|
366
|
+
base_url="https://yourhost.com/path/to/api",
|
|
367
|
+
)
|
|
368
|
+
client.evals.get_supported_models()
|
|
369
|
+
"""
|
|
370
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
371
|
+
"GET",
|
|
372
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/evals/models"),
|
|
373
|
+
headers=self._client_wrapper.get_headers(),
|
|
374
|
+
timeout=60,
|
|
375
|
+
)
|
|
376
|
+
if 200 <= _response.status_code < 300:
|
|
377
|
+
return pydantic.parse_obj_as(typing.List[SupportedEvalLlmModel], _response.json()) # type: ignore
|
|
378
|
+
if _response.status_code == 422:
|
|
379
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
380
|
+
try:
|
|
381
|
+
_response_json = _response.json()
|
|
382
|
+
except JSONDecodeError:
|
|
383
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
384
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
class AsyncEvalsClient:
|
|
388
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
389
|
+
self._client_wrapper = client_wrapper
|
|
390
|
+
|
|
391
|
+
async def get_dataset(self, dataset_id: str) -> EvalDataset:
|
|
392
|
+
"""
|
|
393
|
+
Get a dataset by ID.
|
|
394
|
+
|
|
395
|
+
Parameters:
|
|
396
|
+
- dataset_id: str.
|
|
397
|
+
---
|
|
398
|
+
from platform.client import AsyncPlatformApi
|
|
399
|
+
|
|
400
|
+
client = AsyncPlatformApi(
|
|
401
|
+
token="YOUR_TOKEN",
|
|
402
|
+
base_url="https://yourhost.com/path/to/api",
|
|
403
|
+
)
|
|
404
|
+
await client.evals.get_dataset(
|
|
405
|
+
dataset_id="string",
|
|
406
|
+
)
|
|
407
|
+
"""
|
|
408
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
409
|
+
"GET",
|
|
410
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/evals/datasets/{dataset_id}"),
|
|
411
|
+
headers=self._client_wrapper.get_headers(),
|
|
412
|
+
timeout=60,
|
|
413
|
+
)
|
|
414
|
+
if 200 <= _response.status_code < 300:
|
|
415
|
+
return pydantic.parse_obj_as(EvalDataset, _response.json()) # type: ignore
|
|
416
|
+
if _response.status_code == 422:
|
|
417
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
418
|
+
try:
|
|
419
|
+
_response_json = _response.json()
|
|
420
|
+
except JSONDecodeError:
|
|
421
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
422
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
423
|
+
|
|
424
|
+
async def update_dataset(self, dataset_id: str, *, name: str) -> EvalDataset:
|
|
425
|
+
"""
|
|
426
|
+
Update a dataset.
|
|
427
|
+
|
|
428
|
+
Parameters:
|
|
429
|
+
- dataset_id: str.
|
|
430
|
+
|
|
431
|
+
- name: str. The name of the EvalDataset.
|
|
432
|
+
---
|
|
433
|
+
from platform.client import AsyncPlatformApi
|
|
434
|
+
|
|
435
|
+
client = AsyncPlatformApi(
|
|
436
|
+
token="YOUR_TOKEN",
|
|
437
|
+
base_url="https://yourhost.com/path/to/api",
|
|
438
|
+
)
|
|
439
|
+
await client.evals.update_dataset(
|
|
440
|
+
dataset_id="string",
|
|
441
|
+
name="string",
|
|
442
|
+
)
|
|
443
|
+
"""
|
|
444
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
445
|
+
"PUT",
|
|
446
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/evals/datasets/{dataset_id}"),
|
|
447
|
+
json=jsonable_encoder({"name": name}),
|
|
448
|
+
headers=self._client_wrapper.get_headers(),
|
|
449
|
+
timeout=60,
|
|
450
|
+
)
|
|
451
|
+
if 200 <= _response.status_code < 300:
|
|
452
|
+
return pydantic.parse_obj_as(EvalDataset, _response.json()) # type: ignore
|
|
453
|
+
if _response.status_code == 422:
|
|
454
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
455
|
+
try:
|
|
456
|
+
_response_json = _response.json()
|
|
457
|
+
except JSONDecodeError:
|
|
458
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
459
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
460
|
+
|
|
461
|
+
async def delete_dataset(self, dataset_id: str) -> None:
|
|
462
|
+
"""
|
|
463
|
+
Delete a dataset.
|
|
464
|
+
|
|
465
|
+
Parameters:
|
|
466
|
+
- dataset_id: str.
|
|
467
|
+
---
|
|
468
|
+
from platform.client import AsyncPlatformApi
|
|
469
|
+
|
|
470
|
+
client = AsyncPlatformApi(
|
|
471
|
+
token="YOUR_TOKEN",
|
|
472
|
+
base_url="https://yourhost.com/path/to/api",
|
|
473
|
+
)
|
|
474
|
+
await client.evals.delete_dataset(
|
|
475
|
+
dataset_id="string",
|
|
476
|
+
)
|
|
477
|
+
"""
|
|
478
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
479
|
+
"DELETE",
|
|
480
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/evals/datasets/{dataset_id}"),
|
|
481
|
+
headers=self._client_wrapper.get_headers(),
|
|
482
|
+
timeout=60,
|
|
483
|
+
)
|
|
484
|
+
if 200 <= _response.status_code < 300:
|
|
485
|
+
return
|
|
486
|
+
if _response.status_code == 422:
|
|
487
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
488
|
+
try:
|
|
489
|
+
_response_json = _response.json()
|
|
490
|
+
except JSONDecodeError:
|
|
491
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
492
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
493
|
+
|
|
494
|
+
async def get_questions(self, dataset_id: str) -> typing.List[EvalQuestion]:
|
|
495
|
+
"""
|
|
496
|
+
Get all questions for a dataset.
|
|
497
|
+
|
|
498
|
+
Parameters:
|
|
499
|
+
- dataset_id: str.
|
|
500
|
+
---
|
|
501
|
+
from platform.client import AsyncPlatformApi
|
|
502
|
+
|
|
503
|
+
client = AsyncPlatformApi(
|
|
504
|
+
token="YOUR_TOKEN",
|
|
505
|
+
base_url="https://yourhost.com/path/to/api",
|
|
506
|
+
)
|
|
507
|
+
await client.evals.get_questions(
|
|
508
|
+
dataset_id="string",
|
|
509
|
+
)
|
|
510
|
+
"""
|
|
511
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
512
|
+
"GET",
|
|
513
|
+
urllib.parse.urljoin(
|
|
514
|
+
f"{self._client_wrapper.get_base_url()}/", f"api/v1/evals/datasets/{dataset_id}/question"
|
|
515
|
+
),
|
|
516
|
+
headers=self._client_wrapper.get_headers(),
|
|
517
|
+
timeout=60,
|
|
518
|
+
)
|
|
519
|
+
if 200 <= _response.status_code < 300:
|
|
520
|
+
return pydantic.parse_obj_as(typing.List[EvalQuestion], _response.json()) # type: ignore
|
|
521
|
+
if _response.status_code == 422:
|
|
522
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
523
|
+
try:
|
|
524
|
+
_response_json = _response.json()
|
|
525
|
+
except JSONDecodeError:
|
|
526
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
527
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
528
|
+
|
|
529
|
+
async def create_question(self, dataset_id: str, *, request: EvalQuestionCreate) -> EvalQuestion:
|
|
530
|
+
"""
|
|
531
|
+
Create a new question.
|
|
532
|
+
|
|
533
|
+
Parameters:
|
|
534
|
+
- dataset_id: str.
|
|
535
|
+
|
|
536
|
+
- request: EvalQuestionCreate.
|
|
537
|
+
---
|
|
538
|
+
from platform import EvalQuestionCreate
|
|
539
|
+
from platform.client import AsyncPlatformApi
|
|
540
|
+
|
|
541
|
+
client = AsyncPlatformApi(
|
|
542
|
+
token="YOUR_TOKEN",
|
|
543
|
+
base_url="https://yourhost.com/path/to/api",
|
|
544
|
+
)
|
|
545
|
+
await client.evals.create_question(
|
|
546
|
+
dataset_id="string",
|
|
547
|
+
request=EvalQuestionCreate(
|
|
548
|
+
content="string",
|
|
549
|
+
),
|
|
550
|
+
)
|
|
551
|
+
"""
|
|
552
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
553
|
+
"POST",
|
|
554
|
+
urllib.parse.urljoin(
|
|
555
|
+
f"{self._client_wrapper.get_base_url()}/", f"api/v1/evals/datasets/{dataset_id}/question"
|
|
556
|
+
),
|
|
557
|
+
json=jsonable_encoder(request),
|
|
558
|
+
headers=self._client_wrapper.get_headers(),
|
|
559
|
+
timeout=60,
|
|
560
|
+
)
|
|
561
|
+
if 200 <= _response.status_code < 300:
|
|
562
|
+
return pydantic.parse_obj_as(EvalQuestion, _response.json()) # type: ignore
|
|
563
|
+
if _response.status_code == 422:
|
|
564
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
565
|
+
try:
|
|
566
|
+
_response_json = _response.json()
|
|
567
|
+
except JSONDecodeError:
|
|
568
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
569
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
570
|
+
|
|
571
|
+
async def create_questions(
|
|
572
|
+
self, dataset_id: str, *, request: typing.List[EvalQuestionCreate]
|
|
573
|
+
) -> typing.List[EvalQuestion]:
|
|
574
|
+
"""
|
|
575
|
+
Create a new question.
|
|
576
|
+
|
|
577
|
+
Parameters:
|
|
578
|
+
- dataset_id: str.
|
|
579
|
+
|
|
580
|
+
- request: typing.List[EvalQuestionCreate].
|
|
581
|
+
---
|
|
582
|
+
from platform.client import AsyncPlatformApi
|
|
583
|
+
|
|
584
|
+
client = AsyncPlatformApi(
|
|
585
|
+
token="YOUR_TOKEN",
|
|
586
|
+
base_url="https://yourhost.com/path/to/api",
|
|
587
|
+
)
|
|
588
|
+
await client.evals.create_questions(
|
|
589
|
+
dataset_id="string",
|
|
590
|
+
request=[],
|
|
591
|
+
)
|
|
592
|
+
"""
|
|
593
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
594
|
+
"POST",
|
|
595
|
+
urllib.parse.urljoin(
|
|
596
|
+
f"{self._client_wrapper.get_base_url()}/", f"api/v1/evals/datasets/{dataset_id}/questions"
|
|
597
|
+
),
|
|
598
|
+
json=jsonable_encoder(request),
|
|
599
|
+
headers=self._client_wrapper.get_headers(),
|
|
600
|
+
timeout=60,
|
|
601
|
+
)
|
|
602
|
+
if 200 <= _response.status_code < 300:
|
|
603
|
+
return pydantic.parse_obj_as(typing.List[EvalQuestion], _response.json()) # type: ignore
|
|
604
|
+
if _response.status_code == 422:
|
|
605
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
606
|
+
try:
|
|
607
|
+
_response_json = _response.json()
|
|
608
|
+
except JSONDecodeError:
|
|
609
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
610
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
611
|
+
|
|
612
|
+
async def get_question(self, question_id: str) -> EvalQuestion:
|
|
613
|
+
"""
|
|
614
|
+
Get a question by ID.
|
|
615
|
+
|
|
616
|
+
Parameters:
|
|
617
|
+
- question_id: str.
|
|
618
|
+
---
|
|
619
|
+
from platform.client import AsyncPlatformApi
|
|
620
|
+
|
|
621
|
+
client = AsyncPlatformApi(
|
|
622
|
+
token="YOUR_TOKEN",
|
|
623
|
+
base_url="https://yourhost.com/path/to/api",
|
|
624
|
+
)
|
|
625
|
+
await client.evals.get_question(
|
|
626
|
+
question_id="string",
|
|
627
|
+
)
|
|
628
|
+
"""
|
|
629
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
630
|
+
"GET",
|
|
631
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/evals/questions/{question_id}"),
|
|
632
|
+
headers=self._client_wrapper.get_headers(),
|
|
633
|
+
timeout=60,
|
|
634
|
+
)
|
|
635
|
+
if 200 <= _response.status_code < 300:
|
|
636
|
+
return pydantic.parse_obj_as(EvalQuestion, _response.json()) # type: ignore
|
|
637
|
+
if _response.status_code == 422:
|
|
638
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
639
|
+
try:
|
|
640
|
+
_response_json = _response.json()
|
|
641
|
+
except JSONDecodeError:
|
|
642
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
643
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
644
|
+
|
|
645
|
+
async def replace_question(self, question_id: str, *, request: EvalQuestionCreate) -> EvalQuestion:
|
|
646
|
+
"""
|
|
647
|
+
Replace a question.
|
|
648
|
+
|
|
649
|
+
Parameters:
|
|
650
|
+
- question_id: str.
|
|
651
|
+
|
|
652
|
+
- request: EvalQuestionCreate.
|
|
653
|
+
---
|
|
654
|
+
from platform import EvalQuestionCreate
|
|
655
|
+
from platform.client import AsyncPlatformApi
|
|
656
|
+
|
|
657
|
+
client = AsyncPlatformApi(
|
|
658
|
+
token="YOUR_TOKEN",
|
|
659
|
+
base_url="https://yourhost.com/path/to/api",
|
|
660
|
+
)
|
|
661
|
+
await client.evals.replace_question(
|
|
662
|
+
question_id="string",
|
|
663
|
+
request=EvalQuestionCreate(
|
|
664
|
+
content="string",
|
|
665
|
+
),
|
|
666
|
+
)
|
|
667
|
+
"""
|
|
668
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
669
|
+
"PUT",
|
|
670
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/evals/questions/{question_id}"),
|
|
671
|
+
json=jsonable_encoder(request),
|
|
672
|
+
headers=self._client_wrapper.get_headers(),
|
|
673
|
+
timeout=60,
|
|
674
|
+
)
|
|
675
|
+
if 200 <= _response.status_code < 300:
|
|
676
|
+
return pydantic.parse_obj_as(EvalQuestion, _response.json()) # type: ignore
|
|
677
|
+
if _response.status_code == 422:
|
|
678
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
679
|
+
try:
|
|
680
|
+
_response_json = _response.json()
|
|
681
|
+
except JSONDecodeError:
|
|
682
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
683
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
684
|
+
|
|
685
|
+
async def delete_question(self, question_id: str) -> None:
|
|
686
|
+
"""
|
|
687
|
+
Delete a question.
|
|
688
|
+
|
|
689
|
+
Parameters:
|
|
690
|
+
- question_id: str.
|
|
691
|
+
---
|
|
692
|
+
from platform.client import AsyncPlatformApi
|
|
693
|
+
|
|
694
|
+
client = AsyncPlatformApi(
|
|
695
|
+
token="YOUR_TOKEN",
|
|
696
|
+
base_url="https://yourhost.com/path/to/api",
|
|
697
|
+
)
|
|
698
|
+
await client.evals.delete_question(
|
|
699
|
+
question_id="string",
|
|
700
|
+
)
|
|
701
|
+
"""
|
|
702
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
703
|
+
"DELETE",
|
|
704
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/evals/questions/{question_id}"),
|
|
705
|
+
headers=self._client_wrapper.get_headers(),
|
|
706
|
+
timeout=60,
|
|
707
|
+
)
|
|
708
|
+
if 200 <= _response.status_code < 300:
|
|
709
|
+
return
|
|
710
|
+
if _response.status_code == 422:
|
|
711
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
712
|
+
try:
|
|
713
|
+
_response_json = _response.json()
|
|
714
|
+
except JSONDecodeError:
|
|
715
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
716
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
717
|
+
|
|
718
|
+
async def get_supported_models(self) -> typing.List[SupportedEvalLlmModel]:
|
|
719
|
+
"""
|
|
720
|
+
Get all supported models.
|
|
721
|
+
|
|
722
|
+
---
|
|
723
|
+
from platform.client import AsyncPlatformApi
|
|
724
|
+
|
|
725
|
+
client = AsyncPlatformApi(
|
|
726
|
+
token="YOUR_TOKEN",
|
|
727
|
+
base_url="https://yourhost.com/path/to/api",
|
|
728
|
+
)
|
|
729
|
+
await client.evals.get_supported_models()
|
|
730
|
+
"""
|
|
731
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
732
|
+
"GET",
|
|
733
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/evals/models"),
|
|
734
|
+
headers=self._client_wrapper.get_headers(),
|
|
735
|
+
timeout=60,
|
|
736
|
+
)
|
|
737
|
+
if 200 <= _response.status_code < 300:
|
|
738
|
+
return pydantic.parse_obj_as(typing.List[SupportedEvalLlmModel], _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)
|