mistralai 1.1.0__py3-none-any.whl → 1.2.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.
- mistralai/__init__.py +4 -0
- mistralai/_version.py +12 -0
- mistralai/agents.py +56 -22
- mistralai/batch.py +17 -0
- mistralai/chat.py +64 -30
- mistralai/classifiers.py +396 -0
- mistralai/embeddings.py +10 -6
- mistralai/files.py +252 -19
- mistralai/fim.py +40 -30
- mistralai/jobs.py +40 -20
- mistralai/mistral_jobs.py +733 -0
- mistralai/models/__init__.py +108 -18
- mistralai/models/agentscompletionrequest.py +27 -10
- mistralai/models/agentscompletionstreamrequest.py +27 -10
- mistralai/models/apiendpoint.py +9 -0
- mistralai/models/archiveftmodelout.py +11 -5
- mistralai/models/assistantmessage.py +11 -6
- mistralai/models/basemodelcard.py +22 -6
- mistralai/models/batcherror.py +17 -0
- mistralai/models/batchjobin.py +58 -0
- mistralai/models/batchjobout.py +117 -0
- mistralai/models/batchjobsout.py +30 -0
- mistralai/models/batchjobstatus.py +15 -0
- mistralai/models/chatclassificationrequest.py +104 -0
- mistralai/models/chatcompletionchoice.py +9 -4
- mistralai/models/chatcompletionrequest.py +32 -13
- mistralai/models/chatcompletionresponse.py +2 -2
- mistralai/models/chatcompletionstreamrequest.py +32 -13
- mistralai/models/checkpointout.py +1 -1
- mistralai/models/classificationobject.py +21 -0
- mistralai/models/classificationrequest.py +59 -0
- mistralai/models/classificationresponse.py +21 -0
- mistralai/models/completionchunk.py +2 -2
- mistralai/models/completionevent.py +1 -1
- mistralai/models/completionresponsestreamchoice.py +11 -5
- mistralai/models/delete_model_v1_models_model_id_deleteop.py +1 -2
- mistralai/models/deletefileout.py +1 -1
- mistralai/models/deletemodelout.py +2 -2
- mistralai/models/deltamessage.py +14 -7
- mistralai/models/detailedjobout.py +11 -5
- mistralai/models/embeddingrequest.py +5 -5
- mistralai/models/embeddingresponse.py +2 -1
- mistralai/models/embeddingresponsedata.py +2 -2
- mistralai/models/eventout.py +2 -2
- mistralai/models/filepurpose.py +8 -0
- mistralai/models/files_api_routes_delete_fileop.py +1 -2
- mistralai/models/files_api_routes_download_fileop.py +16 -0
- mistralai/models/files_api_routes_list_filesop.py +96 -0
- mistralai/models/files_api_routes_retrieve_fileop.py +1 -2
- mistralai/models/files_api_routes_upload_fileop.py +9 -9
- mistralai/models/fileschema.py +7 -21
- mistralai/models/fimcompletionrequest.py +20 -13
- mistralai/models/fimcompletionresponse.py +2 -2
- mistralai/models/fimcompletionstreamrequest.py +20 -13
- mistralai/models/ftmodelcapabilitiesout.py +2 -2
- mistralai/models/ftmodelcard.py +24 -6
- mistralai/models/ftmodelout.py +9 -5
- mistralai/models/function.py +2 -2
- mistralai/models/functioncall.py +2 -1
- mistralai/models/functionname.py +1 -1
- mistralai/models/githubrepositoryin.py +11 -5
- mistralai/models/githubrepositoryout.py +11 -5
- mistralai/models/httpvalidationerror.py +0 -2
- mistralai/models/imageurl.py +1 -2
- mistralai/models/imageurlchunk.py +11 -5
- mistralai/models/jobin.py +2 -2
- mistralai/models/jobmetadataout.py +1 -2
- mistralai/models/jobout.py +10 -5
- mistralai/models/jobs_api_routes_batch_cancel_batch_jobop.py +16 -0
- mistralai/models/jobs_api_routes_batch_get_batch_jobop.py +16 -0
- mistralai/models/jobs_api_routes_batch_get_batch_jobsop.py +95 -0
- mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +1 -2
- mistralai/models/jobs_api_routes_fine_tuning_cancel_fine_tuning_jobop.py +1 -2
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobop.py +1 -2
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +2 -2
- mistralai/models/jobs_api_routes_fine_tuning_start_fine_tuning_jobop.py +1 -2
- mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +1 -2
- mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +1 -2
- mistralai/models/jobsout.py +9 -5
- mistralai/models/legacyjobmetadataout.py +12 -5
- mistralai/models/listfilesout.py +5 -1
- mistralai/models/metricout.py +1 -2
- mistralai/models/modelcapabilities.py +2 -2
- mistralai/models/modellist.py +2 -2
- mistralai/models/responseformat.py +2 -2
- mistralai/models/retrieve_model_v1_models_model_id_getop.py +2 -2
- mistralai/models/retrievefileout.py +10 -21
- mistralai/models/sampletype.py +6 -2
- mistralai/models/security.py +2 -2
- mistralai/models/source.py +3 -2
- mistralai/models/systemmessage.py +6 -6
- mistralai/models/textchunk.py +9 -5
- mistralai/models/tool.py +2 -2
- mistralai/models/toolcall.py +2 -2
- mistralai/models/toolchoice.py +2 -2
- mistralai/models/toolmessage.py +2 -2
- mistralai/models/trainingfile.py +2 -2
- mistralai/models/trainingparameters.py +7 -2
- mistralai/models/trainingparametersin.py +7 -2
- mistralai/models/unarchiveftmodelout.py +11 -5
- mistralai/models/updateftmodelin.py +1 -2
- mistralai/models/uploadfileout.py +7 -21
- mistralai/models/usageinfo.py +1 -1
- mistralai/models/usermessage.py +36 -5
- mistralai/models/validationerror.py +2 -1
- mistralai/models/wandbintegration.py +11 -5
- mistralai/models/wandbintegrationout.py +12 -6
- mistralai/models_.py +48 -24
- mistralai/sdk.py +7 -0
- mistralai/sdkconfiguration.py +7 -7
- mistralai/utils/__init__.py +8 -0
- mistralai/utils/annotations.py +13 -2
- mistralai/utils/serializers.py +25 -0
- {mistralai-1.1.0.dist-info → mistralai-1.2.1.dist-info}/METADATA +90 -14
- mistralai-1.2.1.dist-info/RECORD +276 -0
- {mistralai-1.1.0.dist-info → mistralai-1.2.1.dist-info}/WHEEL +1 -1
- mistralai_azure/__init__.py +4 -0
- mistralai_azure/_version.py +12 -0
- mistralai_azure/chat.py +64 -30
- mistralai_azure/models/__init__.py +9 -3
- mistralai_azure/models/assistantmessage.py +11 -6
- mistralai_azure/models/chatcompletionchoice.py +10 -5
- mistralai_azure/models/chatcompletionrequest.py +32 -13
- mistralai_azure/models/chatcompletionresponse.py +2 -2
- mistralai_azure/models/chatcompletionstreamrequest.py +32 -13
- mistralai_azure/models/completionchunk.py +2 -2
- mistralai_azure/models/completionevent.py +1 -1
- mistralai_azure/models/completionresponsestreamchoice.py +9 -4
- mistralai_azure/models/deltamessage.py +14 -7
- mistralai_azure/models/function.py +2 -2
- mistralai_azure/models/functioncall.py +2 -1
- mistralai_azure/models/functionname.py +1 -1
- mistralai_azure/models/httpvalidationerror.py +0 -2
- mistralai_azure/models/responseformat.py +2 -2
- mistralai_azure/models/security.py +1 -2
- mistralai_azure/models/systemmessage.py +6 -6
- mistralai_azure/models/textchunk.py +9 -5
- mistralai_azure/models/tool.py +2 -2
- mistralai_azure/models/toolcall.py +2 -2
- mistralai_azure/models/toolchoice.py +2 -2
- mistralai_azure/models/toolmessage.py +2 -2
- mistralai_azure/models/usageinfo.py +1 -1
- mistralai_azure/models/usermessage.py +36 -5
- mistralai_azure/models/validationerror.py +2 -1
- mistralai_azure/sdkconfiguration.py +7 -7
- mistralai_azure/utils/__init__.py +8 -0
- mistralai_azure/utils/annotations.py +13 -2
- mistralai_azure/utils/serializers.py +25 -0
- mistralai_gcp/__init__.py +4 -0
- mistralai_gcp/_version.py +12 -0
- mistralai_gcp/chat.py +64 -30
- mistralai_gcp/fim.py +40 -30
- mistralai_gcp/models/__init__.py +9 -3
- mistralai_gcp/models/assistantmessage.py +11 -6
- mistralai_gcp/models/chatcompletionchoice.py +10 -5
- mistralai_gcp/models/chatcompletionrequest.py +32 -13
- mistralai_gcp/models/chatcompletionresponse.py +2 -2
- mistralai_gcp/models/chatcompletionstreamrequest.py +32 -13
- mistralai_gcp/models/completionchunk.py +2 -2
- mistralai_gcp/models/completionevent.py +1 -1
- mistralai_gcp/models/completionresponsestreamchoice.py +9 -4
- mistralai_gcp/models/deltamessage.py +14 -7
- mistralai_gcp/models/fimcompletionrequest.py +20 -13
- mistralai_gcp/models/fimcompletionresponse.py +2 -2
- mistralai_gcp/models/fimcompletionstreamrequest.py +20 -13
- mistralai_gcp/models/function.py +2 -2
- mistralai_gcp/models/functioncall.py +2 -1
- mistralai_gcp/models/functionname.py +1 -1
- mistralai_gcp/models/httpvalidationerror.py +0 -2
- mistralai_gcp/models/responseformat.py +2 -2
- mistralai_gcp/models/security.py +1 -2
- mistralai_gcp/models/systemmessage.py +6 -6
- mistralai_gcp/models/textchunk.py +9 -5
- mistralai_gcp/models/tool.py +2 -2
- mistralai_gcp/models/toolcall.py +2 -2
- mistralai_gcp/models/toolchoice.py +2 -2
- mistralai_gcp/models/toolmessage.py +2 -2
- mistralai_gcp/models/usageinfo.py +1 -1
- mistralai_gcp/models/usermessage.py +36 -5
- mistralai_gcp/models/validationerror.py +2 -1
- mistralai_gcp/sdk.py +20 -11
- mistralai_gcp/sdkconfiguration.py +7 -7
- mistralai_gcp/utils/__init__.py +8 -0
- mistralai_gcp/utils/annotations.py +13 -2
- mistralai_gcp/utils/serializers.py +25 -0
- mistralai-1.1.0.dist-info/RECORD +0 -254
- {mistralai-1.1.0.dist-info → mistralai-1.2.1.dist-info}/LICENSE +0 -0
mistralai/files.py
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from .basesdk import BaseSDK
|
|
4
|
+
import httpx
|
|
4
5
|
from mistralai import models, utils
|
|
5
6
|
from mistralai._hooks import HookContext
|
|
6
7
|
from mistralai.types import OptionalNullable, UNSET
|
|
7
8
|
from mistralai.utils import get_security_from_env
|
|
8
|
-
from typing import Optional, Union
|
|
9
|
+
from typing import List, Optional, Union
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class Files(BaseSDK):
|
|
@@ -15,6 +16,7 @@ class Files(BaseSDK):
|
|
|
15
16
|
self,
|
|
16
17
|
*,
|
|
17
18
|
file: Union[models.File, models.FileTypedDict],
|
|
19
|
+
purpose: Optional[models.FilePurpose] = None,
|
|
18
20
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
19
21
|
server_url: Optional[str] = None,
|
|
20
22
|
timeout_ms: Optional[int] = None,
|
|
@@ -28,6 +30,7 @@ class Files(BaseSDK):
|
|
|
28
30
|
Please contact us if you need to increase these storage limits.
|
|
29
31
|
|
|
30
32
|
:param file: The File object (not file name) to be uploaded. To upload a file and specify a custom file name you should format your request as such: ```bash file=@path/to/your/file.jsonl;filename=custom_name.jsonl ``` Otherwise, you can just keep the original file name: ```bash file=@path/to/your/file.jsonl ```
|
|
33
|
+
:param purpose:
|
|
31
34
|
:param retries: Override the default retry configuration for this method
|
|
32
35
|
:param server_url: Override the default server URL for this method
|
|
33
36
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -42,6 +45,7 @@ class Files(BaseSDK):
|
|
|
42
45
|
|
|
43
46
|
request = models.FilesAPIRoutesUploadFileMultiPartBodyParams(
|
|
44
47
|
file=utils.get_pydantic_model(file, models.File),
|
|
48
|
+
purpose=purpose,
|
|
45
49
|
)
|
|
46
50
|
|
|
47
51
|
req = self.build_request(
|
|
@@ -90,15 +94,17 @@ class Files(BaseSDK):
|
|
|
90
94
|
if utils.match_response(http_res, "200", "application/json"):
|
|
91
95
|
return utils.unmarshal_json(http_res.text, Optional[models.UploadFileOut])
|
|
92
96
|
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
97
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
93
98
|
raise models.SDKError(
|
|
94
|
-
"API error occurred", http_res.status_code,
|
|
99
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
95
100
|
)
|
|
96
101
|
|
|
97
102
|
content_type = http_res.headers.get("Content-Type")
|
|
103
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
98
104
|
raise models.SDKError(
|
|
99
105
|
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
100
106
|
http_res.status_code,
|
|
101
|
-
|
|
107
|
+
http_res_text,
|
|
102
108
|
http_res,
|
|
103
109
|
)
|
|
104
110
|
|
|
@@ -106,6 +112,7 @@ class Files(BaseSDK):
|
|
|
106
112
|
self,
|
|
107
113
|
*,
|
|
108
114
|
file: Union[models.File, models.FileTypedDict],
|
|
115
|
+
purpose: Optional[models.FilePurpose] = None,
|
|
109
116
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
110
117
|
server_url: Optional[str] = None,
|
|
111
118
|
timeout_ms: Optional[int] = None,
|
|
@@ -119,6 +126,7 @@ class Files(BaseSDK):
|
|
|
119
126
|
Please contact us if you need to increase these storage limits.
|
|
120
127
|
|
|
121
128
|
:param file: The File object (not file name) to be uploaded. To upload a file and specify a custom file name you should format your request as such: ```bash file=@path/to/your/file.jsonl;filename=custom_name.jsonl ``` Otherwise, you can just keep the original file name: ```bash file=@path/to/your/file.jsonl ```
|
|
129
|
+
:param purpose:
|
|
122
130
|
:param retries: Override the default retry configuration for this method
|
|
123
131
|
:param server_url: Override the default server URL for this method
|
|
124
132
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -133,6 +141,7 @@ class Files(BaseSDK):
|
|
|
133
141
|
|
|
134
142
|
request = models.FilesAPIRoutesUploadFileMultiPartBodyParams(
|
|
135
143
|
file=utils.get_pydantic_model(file, models.File),
|
|
144
|
+
purpose=purpose,
|
|
136
145
|
)
|
|
137
146
|
|
|
138
147
|
req = self.build_request_async(
|
|
@@ -181,21 +190,29 @@ class Files(BaseSDK):
|
|
|
181
190
|
if utils.match_response(http_res, "200", "application/json"):
|
|
182
191
|
return utils.unmarshal_json(http_res.text, Optional[models.UploadFileOut])
|
|
183
192
|
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
193
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
184
194
|
raise models.SDKError(
|
|
185
|
-
"API error occurred", http_res.status_code,
|
|
195
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
186
196
|
)
|
|
187
197
|
|
|
188
198
|
content_type = http_res.headers.get("Content-Type")
|
|
199
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
189
200
|
raise models.SDKError(
|
|
190
201
|
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
191
202
|
http_res.status_code,
|
|
192
|
-
|
|
203
|
+
http_res_text,
|
|
193
204
|
http_res,
|
|
194
205
|
)
|
|
195
206
|
|
|
196
207
|
def list(
|
|
197
208
|
self,
|
|
198
209
|
*,
|
|
210
|
+
page: Optional[int] = 0,
|
|
211
|
+
page_size: Optional[int] = 100,
|
|
212
|
+
sample_type: OptionalNullable[List[models.SampleType]] = UNSET,
|
|
213
|
+
source: OptionalNullable[List[models.Source]] = UNSET,
|
|
214
|
+
search: OptionalNullable[str] = UNSET,
|
|
215
|
+
purpose: OptionalNullable[models.FilePurpose] = UNSET,
|
|
199
216
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
200
217
|
server_url: Optional[str] = None,
|
|
201
218
|
timeout_ms: Optional[int] = None,
|
|
@@ -204,6 +221,12 @@ class Files(BaseSDK):
|
|
|
204
221
|
|
|
205
222
|
Returns a list of files that belong to the user's organization.
|
|
206
223
|
|
|
224
|
+
:param page:
|
|
225
|
+
:param page_size:
|
|
226
|
+
:param sample_type:
|
|
227
|
+
:param source:
|
|
228
|
+
:param search:
|
|
229
|
+
:param purpose:
|
|
207
230
|
:param retries: Override the default retry configuration for this method
|
|
208
231
|
:param server_url: Override the default server URL for this method
|
|
209
232
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -215,12 +238,22 @@ class Files(BaseSDK):
|
|
|
215
238
|
|
|
216
239
|
if server_url is not None:
|
|
217
240
|
base_url = server_url
|
|
241
|
+
|
|
242
|
+
request = models.FilesAPIRoutesListFilesRequest(
|
|
243
|
+
page=page,
|
|
244
|
+
page_size=page_size,
|
|
245
|
+
sample_type=sample_type,
|
|
246
|
+
source=source,
|
|
247
|
+
search=search,
|
|
248
|
+
purpose=purpose,
|
|
249
|
+
)
|
|
250
|
+
|
|
218
251
|
req = self.build_request(
|
|
219
252
|
method="GET",
|
|
220
253
|
path="/v1/files",
|
|
221
254
|
base_url=base_url,
|
|
222
255
|
url_variables=url_variables,
|
|
223
|
-
request=
|
|
256
|
+
request=request,
|
|
224
257
|
request_body_required=False,
|
|
225
258
|
request_has_path_params=False,
|
|
226
259
|
request_has_query_params=True,
|
|
@@ -254,21 +287,29 @@ class Files(BaseSDK):
|
|
|
254
287
|
if utils.match_response(http_res, "200", "application/json"):
|
|
255
288
|
return utils.unmarshal_json(http_res.text, Optional[models.ListFilesOut])
|
|
256
289
|
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
290
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
257
291
|
raise models.SDKError(
|
|
258
|
-
"API error occurred", http_res.status_code,
|
|
292
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
259
293
|
)
|
|
260
294
|
|
|
261
295
|
content_type = http_res.headers.get("Content-Type")
|
|
296
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
262
297
|
raise models.SDKError(
|
|
263
298
|
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
264
299
|
http_res.status_code,
|
|
265
|
-
|
|
300
|
+
http_res_text,
|
|
266
301
|
http_res,
|
|
267
302
|
)
|
|
268
303
|
|
|
269
304
|
async def list_async(
|
|
270
305
|
self,
|
|
271
306
|
*,
|
|
307
|
+
page: Optional[int] = 0,
|
|
308
|
+
page_size: Optional[int] = 100,
|
|
309
|
+
sample_type: OptionalNullable[List[models.SampleType]] = UNSET,
|
|
310
|
+
source: OptionalNullable[List[models.Source]] = UNSET,
|
|
311
|
+
search: OptionalNullable[str] = UNSET,
|
|
312
|
+
purpose: OptionalNullable[models.FilePurpose] = UNSET,
|
|
272
313
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
273
314
|
server_url: Optional[str] = None,
|
|
274
315
|
timeout_ms: Optional[int] = None,
|
|
@@ -277,6 +318,12 @@ class Files(BaseSDK):
|
|
|
277
318
|
|
|
278
319
|
Returns a list of files that belong to the user's organization.
|
|
279
320
|
|
|
321
|
+
:param page:
|
|
322
|
+
:param page_size:
|
|
323
|
+
:param sample_type:
|
|
324
|
+
:param source:
|
|
325
|
+
:param search:
|
|
326
|
+
:param purpose:
|
|
280
327
|
:param retries: Override the default retry configuration for this method
|
|
281
328
|
:param server_url: Override the default server URL for this method
|
|
282
329
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -288,12 +335,22 @@ class Files(BaseSDK):
|
|
|
288
335
|
|
|
289
336
|
if server_url is not None:
|
|
290
337
|
base_url = server_url
|
|
338
|
+
|
|
339
|
+
request = models.FilesAPIRoutesListFilesRequest(
|
|
340
|
+
page=page,
|
|
341
|
+
page_size=page_size,
|
|
342
|
+
sample_type=sample_type,
|
|
343
|
+
source=source,
|
|
344
|
+
search=search,
|
|
345
|
+
purpose=purpose,
|
|
346
|
+
)
|
|
347
|
+
|
|
291
348
|
req = self.build_request_async(
|
|
292
349
|
method="GET",
|
|
293
350
|
path="/v1/files",
|
|
294
351
|
base_url=base_url,
|
|
295
352
|
url_variables=url_variables,
|
|
296
|
-
request=
|
|
353
|
+
request=request,
|
|
297
354
|
request_body_required=False,
|
|
298
355
|
request_has_path_params=False,
|
|
299
356
|
request_has_query_params=True,
|
|
@@ -327,15 +384,17 @@ class Files(BaseSDK):
|
|
|
327
384
|
if utils.match_response(http_res, "200", "application/json"):
|
|
328
385
|
return utils.unmarshal_json(http_res.text, Optional[models.ListFilesOut])
|
|
329
386
|
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
387
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
330
388
|
raise models.SDKError(
|
|
331
|
-
"API error occurred", http_res.status_code,
|
|
389
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
332
390
|
)
|
|
333
391
|
|
|
334
392
|
content_type = http_res.headers.get("Content-Type")
|
|
393
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
335
394
|
raise models.SDKError(
|
|
336
395
|
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
337
396
|
http_res.status_code,
|
|
338
|
-
|
|
397
|
+
http_res_text,
|
|
339
398
|
http_res,
|
|
340
399
|
)
|
|
341
400
|
|
|
@@ -407,15 +466,17 @@ class Files(BaseSDK):
|
|
|
407
466
|
if utils.match_response(http_res, "200", "application/json"):
|
|
408
467
|
return utils.unmarshal_json(http_res.text, Optional[models.RetrieveFileOut])
|
|
409
468
|
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
469
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
410
470
|
raise models.SDKError(
|
|
411
|
-
"API error occurred", http_res.status_code,
|
|
471
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
412
472
|
)
|
|
413
473
|
|
|
414
474
|
content_type = http_res.headers.get("Content-Type")
|
|
475
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
415
476
|
raise models.SDKError(
|
|
416
477
|
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
417
478
|
http_res.status_code,
|
|
418
|
-
|
|
479
|
+
http_res_text,
|
|
419
480
|
http_res,
|
|
420
481
|
)
|
|
421
482
|
|
|
@@ -487,15 +548,17 @@ class Files(BaseSDK):
|
|
|
487
548
|
if utils.match_response(http_res, "200", "application/json"):
|
|
488
549
|
return utils.unmarshal_json(http_res.text, Optional[models.RetrieveFileOut])
|
|
489
550
|
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
551
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
490
552
|
raise models.SDKError(
|
|
491
|
-
"API error occurred", http_res.status_code,
|
|
553
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
492
554
|
)
|
|
493
555
|
|
|
494
556
|
content_type = http_res.headers.get("Content-Type")
|
|
557
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
495
558
|
raise models.SDKError(
|
|
496
559
|
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
497
560
|
http_res.status_code,
|
|
498
|
-
|
|
561
|
+
http_res_text,
|
|
499
562
|
http_res,
|
|
500
563
|
)
|
|
501
564
|
|
|
@@ -567,15 +630,17 @@ class Files(BaseSDK):
|
|
|
567
630
|
if utils.match_response(http_res, "200", "application/json"):
|
|
568
631
|
return utils.unmarshal_json(http_res.text, Optional[models.DeleteFileOut])
|
|
569
632
|
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
633
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
570
634
|
raise models.SDKError(
|
|
571
|
-
"API error occurred", http_res.status_code,
|
|
635
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
572
636
|
)
|
|
573
637
|
|
|
574
638
|
content_type = http_res.headers.get("Content-Type")
|
|
639
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
575
640
|
raise models.SDKError(
|
|
576
641
|
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
577
642
|
http_res.status_code,
|
|
578
|
-
|
|
643
|
+
http_res_text,
|
|
579
644
|
http_res,
|
|
580
645
|
)
|
|
581
646
|
|
|
@@ -647,14 +712,182 @@ class Files(BaseSDK):
|
|
|
647
712
|
if utils.match_response(http_res, "200", "application/json"):
|
|
648
713
|
return utils.unmarshal_json(http_res.text, Optional[models.DeleteFileOut])
|
|
649
714
|
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
715
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
716
|
+
raise models.SDKError(
|
|
717
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
718
|
+
)
|
|
719
|
+
|
|
720
|
+
content_type = http_res.headers.get("Content-Type")
|
|
721
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
722
|
+
raise models.SDKError(
|
|
723
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
724
|
+
http_res.status_code,
|
|
725
|
+
http_res_text,
|
|
726
|
+
http_res,
|
|
727
|
+
)
|
|
728
|
+
|
|
729
|
+
def download(
|
|
730
|
+
self,
|
|
731
|
+
*,
|
|
732
|
+
file_id: str,
|
|
733
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
734
|
+
server_url: Optional[str] = None,
|
|
735
|
+
timeout_ms: Optional[int] = None,
|
|
736
|
+
) -> Optional[httpx.Response]:
|
|
737
|
+
r"""Download File
|
|
738
|
+
|
|
739
|
+
Download a file
|
|
740
|
+
|
|
741
|
+
:param file_id:
|
|
742
|
+
:param retries: Override the default retry configuration for this method
|
|
743
|
+
:param server_url: Override the default server URL for this method
|
|
744
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
745
|
+
"""
|
|
746
|
+
base_url = None
|
|
747
|
+
url_variables = None
|
|
748
|
+
if timeout_ms is None:
|
|
749
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
750
|
+
|
|
751
|
+
if server_url is not None:
|
|
752
|
+
base_url = server_url
|
|
753
|
+
|
|
754
|
+
request = models.FilesAPIRoutesDownloadFileRequest(
|
|
755
|
+
file_id=file_id,
|
|
756
|
+
)
|
|
757
|
+
|
|
758
|
+
req = self.build_request(
|
|
759
|
+
method="GET",
|
|
760
|
+
path="/v1/files/{file_id}/content",
|
|
761
|
+
base_url=base_url,
|
|
762
|
+
url_variables=url_variables,
|
|
763
|
+
request=request,
|
|
764
|
+
request_body_required=False,
|
|
765
|
+
request_has_path_params=True,
|
|
766
|
+
request_has_query_params=True,
|
|
767
|
+
user_agent_header="user-agent",
|
|
768
|
+
accept_header_value="application/octet-stream",
|
|
769
|
+
security=self.sdk_configuration.security,
|
|
770
|
+
timeout_ms=timeout_ms,
|
|
771
|
+
)
|
|
772
|
+
|
|
773
|
+
if retries == UNSET:
|
|
774
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
775
|
+
retries = self.sdk_configuration.retry_config
|
|
776
|
+
|
|
777
|
+
retry_config = None
|
|
778
|
+
if isinstance(retries, utils.RetryConfig):
|
|
779
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
780
|
+
|
|
781
|
+
http_res = self.do_request(
|
|
782
|
+
hook_ctx=HookContext(
|
|
783
|
+
operation_id="files_api_routes_download_file",
|
|
784
|
+
oauth2_scopes=[],
|
|
785
|
+
security_source=get_security_from_env(
|
|
786
|
+
self.sdk_configuration.security, models.Security
|
|
787
|
+
),
|
|
788
|
+
),
|
|
789
|
+
request=req,
|
|
790
|
+
error_status_codes=["4XX", "5XX"],
|
|
791
|
+
stream=True,
|
|
792
|
+
retry_config=retry_config,
|
|
793
|
+
)
|
|
794
|
+
|
|
795
|
+
if utils.match_response(http_res, "200", "application/octet-stream"):
|
|
796
|
+
return http_res
|
|
797
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
798
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
799
|
+
raise models.SDKError(
|
|
800
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
801
|
+
)
|
|
802
|
+
|
|
803
|
+
content_type = http_res.headers.get("Content-Type")
|
|
804
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
805
|
+
raise models.SDKError(
|
|
806
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
807
|
+
http_res.status_code,
|
|
808
|
+
http_res_text,
|
|
809
|
+
http_res,
|
|
810
|
+
)
|
|
811
|
+
|
|
812
|
+
async def download_async(
|
|
813
|
+
self,
|
|
814
|
+
*,
|
|
815
|
+
file_id: str,
|
|
816
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
817
|
+
server_url: Optional[str] = None,
|
|
818
|
+
timeout_ms: Optional[int] = None,
|
|
819
|
+
) -> Optional[httpx.Response]:
|
|
820
|
+
r"""Download File
|
|
821
|
+
|
|
822
|
+
Download a file
|
|
823
|
+
|
|
824
|
+
:param file_id:
|
|
825
|
+
:param retries: Override the default retry configuration for this method
|
|
826
|
+
:param server_url: Override the default server URL for this method
|
|
827
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
828
|
+
"""
|
|
829
|
+
base_url = None
|
|
830
|
+
url_variables = None
|
|
831
|
+
if timeout_ms is None:
|
|
832
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
833
|
+
|
|
834
|
+
if server_url is not None:
|
|
835
|
+
base_url = server_url
|
|
836
|
+
|
|
837
|
+
request = models.FilesAPIRoutesDownloadFileRequest(
|
|
838
|
+
file_id=file_id,
|
|
839
|
+
)
|
|
840
|
+
|
|
841
|
+
req = self.build_request_async(
|
|
842
|
+
method="GET",
|
|
843
|
+
path="/v1/files/{file_id}/content",
|
|
844
|
+
base_url=base_url,
|
|
845
|
+
url_variables=url_variables,
|
|
846
|
+
request=request,
|
|
847
|
+
request_body_required=False,
|
|
848
|
+
request_has_path_params=True,
|
|
849
|
+
request_has_query_params=True,
|
|
850
|
+
user_agent_header="user-agent",
|
|
851
|
+
accept_header_value="application/octet-stream",
|
|
852
|
+
security=self.sdk_configuration.security,
|
|
853
|
+
timeout_ms=timeout_ms,
|
|
854
|
+
)
|
|
855
|
+
|
|
856
|
+
if retries == UNSET:
|
|
857
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
858
|
+
retries = self.sdk_configuration.retry_config
|
|
859
|
+
|
|
860
|
+
retry_config = None
|
|
861
|
+
if isinstance(retries, utils.RetryConfig):
|
|
862
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
863
|
+
|
|
864
|
+
http_res = await self.do_request_async(
|
|
865
|
+
hook_ctx=HookContext(
|
|
866
|
+
operation_id="files_api_routes_download_file",
|
|
867
|
+
oauth2_scopes=[],
|
|
868
|
+
security_source=get_security_from_env(
|
|
869
|
+
self.sdk_configuration.security, models.Security
|
|
870
|
+
),
|
|
871
|
+
),
|
|
872
|
+
request=req,
|
|
873
|
+
error_status_codes=["4XX", "5XX"],
|
|
874
|
+
stream=True,
|
|
875
|
+
retry_config=retry_config,
|
|
876
|
+
)
|
|
877
|
+
|
|
878
|
+
if utils.match_response(http_res, "200", "application/octet-stream"):
|
|
879
|
+
return http_res
|
|
880
|
+
if utils.match_response(http_res, ["4XX", "5XX"], "*"):
|
|
881
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
650
882
|
raise models.SDKError(
|
|
651
|
-
"API error occurred", http_res.status_code,
|
|
883
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
652
884
|
)
|
|
653
885
|
|
|
654
886
|
content_type = http_res.headers.get("Content-Type")
|
|
887
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
655
888
|
raise models.SDKError(
|
|
656
889
|
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
657
890
|
http_res.status_code,
|
|
658
|
-
|
|
891
|
+
http_res_text,
|
|
659
892
|
http_res,
|
|
660
893
|
)
|