mistralai 1.3.1__py3-none-any.whl → 1.4.0__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/files.py CHANGED
@@ -21,7 +21,7 @@ class Files(BaseSDK):
21
21
  server_url: Optional[str] = None,
22
22
  timeout_ms: Optional[int] = None,
23
23
  http_headers: Optional[Mapping[str, str]] = None,
24
- ) -> Optional[models.UploadFileOut]:
24
+ ) -> models.UploadFileOut:
25
25
  r"""Upload File
26
26
 
27
27
  Upload a file that can be used across various endpoints.
@@ -95,8 +95,13 @@ class Files(BaseSDK):
95
95
  )
96
96
 
97
97
  if utils.match_response(http_res, "200", "application/json"):
98
- return utils.unmarshal_json(http_res.text, Optional[models.UploadFileOut])
99
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
98
+ return utils.unmarshal_json(http_res.text, models.UploadFileOut)
99
+ if utils.match_response(http_res, "4XX", "*"):
100
+ http_res_text = utils.stream_to_text(http_res)
101
+ raise models.SDKError(
102
+ "API error occurred", http_res.status_code, http_res_text, http_res
103
+ )
104
+ if utils.match_response(http_res, "5XX", "*"):
100
105
  http_res_text = utils.stream_to_text(http_res)
101
106
  raise models.SDKError(
102
107
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -120,7 +125,7 @@ class Files(BaseSDK):
120
125
  server_url: Optional[str] = None,
121
126
  timeout_ms: Optional[int] = None,
122
127
  http_headers: Optional[Mapping[str, str]] = None,
123
- ) -> Optional[models.UploadFileOut]:
128
+ ) -> models.UploadFileOut:
124
129
  r"""Upload File
125
130
 
126
131
  Upload a file that can be used across various endpoints.
@@ -194,8 +199,13 @@ class Files(BaseSDK):
194
199
  )
195
200
 
196
201
  if utils.match_response(http_res, "200", "application/json"):
197
- return utils.unmarshal_json(http_res.text, Optional[models.UploadFileOut])
198
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
202
+ return utils.unmarshal_json(http_res.text, models.UploadFileOut)
203
+ if utils.match_response(http_res, "4XX", "*"):
204
+ http_res_text = await utils.stream_to_text_async(http_res)
205
+ raise models.SDKError(
206
+ "API error occurred", http_res.status_code, http_res_text, http_res
207
+ )
208
+ if utils.match_response(http_res, "5XX", "*"):
199
209
  http_res_text = await utils.stream_to_text_async(http_res)
200
210
  raise models.SDKError(
201
211
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -223,7 +233,7 @@ class Files(BaseSDK):
223
233
  server_url: Optional[str] = None,
224
234
  timeout_ms: Optional[int] = None,
225
235
  http_headers: Optional[Mapping[str, str]] = None,
226
- ) -> Optional[models.ListFilesOut]:
236
+ ) -> models.ListFilesOut:
227
237
  r"""List Files
228
238
 
229
239
  Returns a list of files that belong to the user's organization.
@@ -294,8 +304,13 @@ class Files(BaseSDK):
294
304
  )
295
305
 
296
306
  if utils.match_response(http_res, "200", "application/json"):
297
- return utils.unmarshal_json(http_res.text, Optional[models.ListFilesOut])
298
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
307
+ return utils.unmarshal_json(http_res.text, models.ListFilesOut)
308
+ if utils.match_response(http_res, "4XX", "*"):
309
+ http_res_text = utils.stream_to_text(http_res)
310
+ raise models.SDKError(
311
+ "API error occurred", http_res.status_code, http_res_text, http_res
312
+ )
313
+ if utils.match_response(http_res, "5XX", "*"):
299
314
  http_res_text = utils.stream_to_text(http_res)
300
315
  raise models.SDKError(
301
316
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -323,7 +338,7 @@ class Files(BaseSDK):
323
338
  server_url: Optional[str] = None,
324
339
  timeout_ms: Optional[int] = None,
325
340
  http_headers: Optional[Mapping[str, str]] = None,
326
- ) -> Optional[models.ListFilesOut]:
341
+ ) -> models.ListFilesOut:
327
342
  r"""List Files
328
343
 
329
344
  Returns a list of files that belong to the user's organization.
@@ -394,8 +409,13 @@ class Files(BaseSDK):
394
409
  )
395
410
 
396
411
  if utils.match_response(http_res, "200", "application/json"):
397
- return utils.unmarshal_json(http_res.text, Optional[models.ListFilesOut])
398
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
412
+ return utils.unmarshal_json(http_res.text, models.ListFilesOut)
413
+ if utils.match_response(http_res, "4XX", "*"):
414
+ http_res_text = await utils.stream_to_text_async(http_res)
415
+ raise models.SDKError(
416
+ "API error occurred", http_res.status_code, http_res_text, http_res
417
+ )
418
+ if utils.match_response(http_res, "5XX", "*"):
399
419
  http_res_text = await utils.stream_to_text_async(http_res)
400
420
  raise models.SDKError(
401
421
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -418,7 +438,7 @@ class Files(BaseSDK):
418
438
  server_url: Optional[str] = None,
419
439
  timeout_ms: Optional[int] = None,
420
440
  http_headers: Optional[Mapping[str, str]] = None,
421
- ) -> Optional[models.RetrieveFileOut]:
441
+ ) -> models.RetrieveFileOut:
422
442
  r"""Retrieve File
423
443
 
424
444
  Returns information about a specific file.
@@ -479,8 +499,13 @@ class Files(BaseSDK):
479
499
  )
480
500
 
481
501
  if utils.match_response(http_res, "200", "application/json"):
482
- return utils.unmarshal_json(http_res.text, Optional[models.RetrieveFileOut])
483
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
502
+ return utils.unmarshal_json(http_res.text, models.RetrieveFileOut)
503
+ if utils.match_response(http_res, "4XX", "*"):
504
+ http_res_text = utils.stream_to_text(http_res)
505
+ raise models.SDKError(
506
+ "API error occurred", http_res.status_code, http_res_text, http_res
507
+ )
508
+ if utils.match_response(http_res, "5XX", "*"):
484
509
  http_res_text = utils.stream_to_text(http_res)
485
510
  raise models.SDKError(
486
511
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -503,7 +528,7 @@ class Files(BaseSDK):
503
528
  server_url: Optional[str] = None,
504
529
  timeout_ms: Optional[int] = None,
505
530
  http_headers: Optional[Mapping[str, str]] = None,
506
- ) -> Optional[models.RetrieveFileOut]:
531
+ ) -> models.RetrieveFileOut:
507
532
  r"""Retrieve File
508
533
 
509
534
  Returns information about a specific file.
@@ -564,8 +589,13 @@ class Files(BaseSDK):
564
589
  )
565
590
 
566
591
  if utils.match_response(http_res, "200", "application/json"):
567
- return utils.unmarshal_json(http_res.text, Optional[models.RetrieveFileOut])
568
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
592
+ return utils.unmarshal_json(http_res.text, models.RetrieveFileOut)
593
+ if utils.match_response(http_res, "4XX", "*"):
594
+ http_res_text = await utils.stream_to_text_async(http_res)
595
+ raise models.SDKError(
596
+ "API error occurred", http_res.status_code, http_res_text, http_res
597
+ )
598
+ if utils.match_response(http_res, "5XX", "*"):
569
599
  http_res_text = await utils.stream_to_text_async(http_res)
570
600
  raise models.SDKError(
571
601
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -588,7 +618,7 @@ class Files(BaseSDK):
588
618
  server_url: Optional[str] = None,
589
619
  timeout_ms: Optional[int] = None,
590
620
  http_headers: Optional[Mapping[str, str]] = None,
591
- ) -> Optional[models.DeleteFileOut]:
621
+ ) -> models.DeleteFileOut:
592
622
  r"""Delete File
593
623
 
594
624
  Delete a file.
@@ -649,8 +679,13 @@ class Files(BaseSDK):
649
679
  )
650
680
 
651
681
  if utils.match_response(http_res, "200", "application/json"):
652
- return utils.unmarshal_json(http_res.text, Optional[models.DeleteFileOut])
653
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
682
+ return utils.unmarshal_json(http_res.text, models.DeleteFileOut)
683
+ if utils.match_response(http_res, "4XX", "*"):
684
+ http_res_text = utils.stream_to_text(http_res)
685
+ raise models.SDKError(
686
+ "API error occurred", http_res.status_code, http_res_text, http_res
687
+ )
688
+ if utils.match_response(http_res, "5XX", "*"):
654
689
  http_res_text = utils.stream_to_text(http_res)
655
690
  raise models.SDKError(
656
691
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -673,7 +708,7 @@ class Files(BaseSDK):
673
708
  server_url: Optional[str] = None,
674
709
  timeout_ms: Optional[int] = None,
675
710
  http_headers: Optional[Mapping[str, str]] = None,
676
- ) -> Optional[models.DeleteFileOut]:
711
+ ) -> models.DeleteFileOut:
677
712
  r"""Delete File
678
713
 
679
714
  Delete a file.
@@ -734,8 +769,13 @@ class Files(BaseSDK):
734
769
  )
735
770
 
736
771
  if utils.match_response(http_res, "200", "application/json"):
737
- return utils.unmarshal_json(http_res.text, Optional[models.DeleteFileOut])
738
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
772
+ return utils.unmarshal_json(http_res.text, models.DeleteFileOut)
773
+ if utils.match_response(http_res, "4XX", "*"):
774
+ http_res_text = await utils.stream_to_text_async(http_res)
775
+ raise models.SDKError(
776
+ "API error occurred", http_res.status_code, http_res_text, http_res
777
+ )
778
+ if utils.match_response(http_res, "5XX", "*"):
739
779
  http_res_text = await utils.stream_to_text_async(http_res)
740
780
  raise models.SDKError(
741
781
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -758,7 +798,7 @@ class Files(BaseSDK):
758
798
  server_url: Optional[str] = None,
759
799
  timeout_ms: Optional[int] = None,
760
800
  http_headers: Optional[Mapping[str, str]] = None,
761
- ) -> Optional[httpx.Response]:
801
+ ) -> httpx.Response:
762
802
  r"""Download File
763
803
 
764
804
  Download a file
@@ -821,7 +861,12 @@ class Files(BaseSDK):
821
861
 
822
862
  if utils.match_response(http_res, "200", "application/octet-stream"):
823
863
  return http_res
824
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
864
+ if utils.match_response(http_res, "4XX", "*"):
865
+ http_res_text = utils.stream_to_text(http_res)
866
+ raise models.SDKError(
867
+ "API error occurred", http_res.status_code, http_res_text, http_res
868
+ )
869
+ if utils.match_response(http_res, "5XX", "*"):
825
870
  http_res_text = utils.stream_to_text(http_res)
826
871
  raise models.SDKError(
827
872
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -844,7 +889,7 @@ class Files(BaseSDK):
844
889
  server_url: Optional[str] = None,
845
890
  timeout_ms: Optional[int] = None,
846
891
  http_headers: Optional[Mapping[str, str]] = None,
847
- ) -> Optional[httpx.Response]:
892
+ ) -> httpx.Response:
848
893
  r"""Download File
849
894
 
850
895
  Download a file
@@ -907,7 +952,12 @@ class Files(BaseSDK):
907
952
 
908
953
  if utils.match_response(http_res, "200", "application/octet-stream"):
909
954
  return http_res
910
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
955
+ if utils.match_response(http_res, "4XX", "*"):
956
+ http_res_text = await utils.stream_to_text_async(http_res)
957
+ raise models.SDKError(
958
+ "API error occurred", http_res.status_code, http_res_text, http_res
959
+ )
960
+ if utils.match_response(http_res, "5XX", "*"):
911
961
  http_res_text = await utils.stream_to_text_async(http_res)
912
962
  raise models.SDKError(
913
963
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -931,7 +981,7 @@ class Files(BaseSDK):
931
981
  server_url: Optional[str] = None,
932
982
  timeout_ms: Optional[int] = None,
933
983
  http_headers: Optional[Mapping[str, str]] = None,
934
- ) -> Optional[models.FileSignedURL]:
984
+ ) -> models.FileSignedURL:
935
985
  r"""Get Signed Url
936
986
 
937
987
  :param file_id:
@@ -992,8 +1042,13 @@ class Files(BaseSDK):
992
1042
  )
993
1043
 
994
1044
  if utils.match_response(http_res, "200", "application/json"):
995
- return utils.unmarshal_json(http_res.text, Optional[models.FileSignedURL])
996
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
1045
+ return utils.unmarshal_json(http_res.text, models.FileSignedURL)
1046
+ if utils.match_response(http_res, "4XX", "*"):
1047
+ http_res_text = utils.stream_to_text(http_res)
1048
+ raise models.SDKError(
1049
+ "API error occurred", http_res.status_code, http_res_text, http_res
1050
+ )
1051
+ if utils.match_response(http_res, "5XX", "*"):
997
1052
  http_res_text = utils.stream_to_text(http_res)
998
1053
  raise models.SDKError(
999
1054
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -1017,7 +1072,7 @@ class Files(BaseSDK):
1017
1072
  server_url: Optional[str] = None,
1018
1073
  timeout_ms: Optional[int] = None,
1019
1074
  http_headers: Optional[Mapping[str, str]] = None,
1020
- ) -> Optional[models.FileSignedURL]:
1075
+ ) -> models.FileSignedURL:
1021
1076
  r"""Get Signed Url
1022
1077
 
1023
1078
  :param file_id:
@@ -1078,8 +1133,13 @@ class Files(BaseSDK):
1078
1133
  )
1079
1134
 
1080
1135
  if utils.match_response(http_res, "200", "application/json"):
1081
- return utils.unmarshal_json(http_res.text, Optional[models.FileSignedURL])
1082
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
1136
+ return utils.unmarshal_json(http_res.text, models.FileSignedURL)
1137
+ if utils.match_response(http_res, "4XX", "*"):
1138
+ http_res_text = await utils.stream_to_text_async(http_res)
1139
+ raise models.SDKError(
1140
+ "API error occurred", http_res.status_code, http_res_text, http_res
1141
+ )
1142
+ if utils.match_response(http_res, "5XX", "*"):
1083
1143
  http_res_text = await utils.stream_to_text_async(http_res)
1084
1144
  raise models.SDKError(
1085
1145
  "API error occurred", http_res.status_code, http_res_text, http_res
mistralai/fim.py CHANGED
@@ -33,7 +33,7 @@ class Fim(BaseSDK):
33
33
  server_url: Optional[str] = None,
34
34
  timeout_ms: Optional[int] = None,
35
35
  http_headers: Optional[Mapping[str, str]] = None,
36
- ) -> Optional[models.FIMCompletionResponse]:
36
+ ) -> models.FIMCompletionResponse:
37
37
  r"""Fim Completion
38
38
 
39
39
  FIM completion.
@@ -116,13 +116,16 @@ class Fim(BaseSDK):
116
116
 
117
117
  data: Any = None
118
118
  if utils.match_response(http_res, "200", "application/json"):
119
- return utils.unmarshal_json(
120
- http_res.text, Optional[models.FIMCompletionResponse]
121
- )
119
+ return utils.unmarshal_json(http_res.text, models.FIMCompletionResponse)
122
120
  if utils.match_response(http_res, "422", "application/json"):
123
121
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
124
122
  raise models.HTTPValidationError(data=data)
125
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
123
+ if utils.match_response(http_res, "4XX", "*"):
124
+ http_res_text = utils.stream_to_text(http_res)
125
+ raise models.SDKError(
126
+ "API error occurred", http_res.status_code, http_res_text, http_res
127
+ )
128
+ if utils.match_response(http_res, "5XX", "*"):
126
129
  http_res_text = utils.stream_to_text(http_res)
127
130
  raise models.SDKError(
128
131
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -159,7 +162,7 @@ class Fim(BaseSDK):
159
162
  server_url: Optional[str] = None,
160
163
  timeout_ms: Optional[int] = None,
161
164
  http_headers: Optional[Mapping[str, str]] = None,
162
- ) -> Optional[models.FIMCompletionResponse]:
165
+ ) -> models.FIMCompletionResponse:
163
166
  r"""Fim Completion
164
167
 
165
168
  FIM completion.
@@ -242,13 +245,16 @@ class Fim(BaseSDK):
242
245
 
243
246
  data: Any = None
244
247
  if utils.match_response(http_res, "200", "application/json"):
245
- return utils.unmarshal_json(
246
- http_res.text, Optional[models.FIMCompletionResponse]
247
- )
248
+ return utils.unmarshal_json(http_res.text, models.FIMCompletionResponse)
248
249
  if utils.match_response(http_res, "422", "application/json"):
249
250
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
250
251
  raise models.HTTPValidationError(data=data)
251
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
252
+ if utils.match_response(http_res, "4XX", "*"):
253
+ http_res_text = await utils.stream_to_text_async(http_res)
254
+ raise models.SDKError(
255
+ "API error occurred", http_res.status_code, http_res_text, http_res
256
+ )
257
+ if utils.match_response(http_res, "5XX", "*"):
252
258
  http_res_text = await utils.stream_to_text_async(http_res)
253
259
  raise models.SDKError(
254
260
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -285,7 +291,7 @@ class Fim(BaseSDK):
285
291
  server_url: Optional[str] = None,
286
292
  timeout_ms: Optional[int] = None,
287
293
  http_headers: Optional[Mapping[str, str]] = None,
288
- ) -> Optional[eventstreaming.EventStream[models.CompletionEvent]]:
294
+ ) -> eventstreaming.EventStream[models.CompletionEvent]:
289
295
  r"""Stream fim completion
290
296
 
291
297
  Mistral AI provides the ability to stream responses back to a client in order to allow partial results for certain requests. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON.
@@ -378,7 +384,12 @@ class Fim(BaseSDK):
378
384
  http_res_text = utils.stream_to_text(http_res)
379
385
  data = utils.unmarshal_json(http_res_text, models.HTTPValidationErrorData)
380
386
  raise models.HTTPValidationError(data=data)
381
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
387
+ if utils.match_response(http_res, "4XX", "*"):
388
+ http_res_text = utils.stream_to_text(http_res)
389
+ raise models.SDKError(
390
+ "API error occurred", http_res.status_code, http_res_text, http_res
391
+ )
392
+ if utils.match_response(http_res, "5XX", "*"):
382
393
  http_res_text = utils.stream_to_text(http_res)
383
394
  raise models.SDKError(
384
395
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -415,7 +426,7 @@ class Fim(BaseSDK):
415
426
  server_url: Optional[str] = None,
416
427
  timeout_ms: Optional[int] = None,
417
428
  http_headers: Optional[Mapping[str, str]] = None,
418
- ) -> Optional[eventstreaming.EventStreamAsync[models.CompletionEvent]]:
429
+ ) -> eventstreaming.EventStreamAsync[models.CompletionEvent]:
419
430
  r"""Stream fim completion
420
431
 
421
432
  Mistral AI provides the ability to stream responses back to a client in order to allow partial results for certain requests. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON.
@@ -508,7 +519,12 @@ class Fim(BaseSDK):
508
519
  http_res_text = await utils.stream_to_text_async(http_res)
509
520
  data = utils.unmarshal_json(http_res_text, models.HTTPValidationErrorData)
510
521
  raise models.HTTPValidationError(data=data)
511
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
522
+ if utils.match_response(http_res, "4XX", "*"):
523
+ http_res_text = await utils.stream_to_text_async(http_res)
524
+ raise models.SDKError(
525
+ "API error occurred", http_res.status_code, http_res_text, http_res
526
+ )
527
+ if utils.match_response(http_res, "5XX", "*"):
512
528
  http_res_text = await utils.stream_to_text_async(http_res)
513
529
  raise models.SDKError(
514
530
  "API error occurred", http_res.status_code, http_res_text, http_res
mistralai/jobs.py CHANGED
@@ -26,7 +26,7 @@ class Jobs(BaseSDK):
26
26
  server_url: Optional[str] = None,
27
27
  timeout_ms: Optional[int] = None,
28
28
  http_headers: Optional[Mapping[str, str]] = None,
29
- ) -> Optional[models.JobsOut]:
29
+ ) -> models.JobsOut:
30
30
  r"""Get Fine Tuning Jobs
31
31
 
32
32
  Get a list of fine-tuning jobs for your organization and user.
@@ -103,8 +103,13 @@ class Jobs(BaseSDK):
103
103
  )
104
104
 
105
105
  if utils.match_response(http_res, "200", "application/json"):
106
- return utils.unmarshal_json(http_res.text, Optional[models.JobsOut])
107
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
106
+ return utils.unmarshal_json(http_res.text, models.JobsOut)
107
+ if utils.match_response(http_res, "4XX", "*"):
108
+ http_res_text = utils.stream_to_text(http_res)
109
+ raise models.SDKError(
110
+ "API error occurred", http_res.status_code, http_res_text, http_res
111
+ )
112
+ if utils.match_response(http_res, "5XX", "*"):
108
113
  http_res_text = utils.stream_to_text(http_res)
109
114
  raise models.SDKError(
110
115
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -135,7 +140,7 @@ class Jobs(BaseSDK):
135
140
  server_url: Optional[str] = None,
136
141
  timeout_ms: Optional[int] = None,
137
142
  http_headers: Optional[Mapping[str, str]] = None,
138
- ) -> Optional[models.JobsOut]:
143
+ ) -> models.JobsOut:
139
144
  r"""Get Fine Tuning Jobs
140
145
 
141
146
  Get a list of fine-tuning jobs for your organization and user.
@@ -212,8 +217,13 @@ class Jobs(BaseSDK):
212
217
  )
213
218
 
214
219
  if utils.match_response(http_res, "200", "application/json"):
215
- return utils.unmarshal_json(http_res.text, Optional[models.JobsOut])
216
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
220
+ return utils.unmarshal_json(http_res.text, models.JobsOut)
221
+ if utils.match_response(http_res, "4XX", "*"):
222
+ http_res_text = await utils.stream_to_text_async(http_res)
223
+ raise models.SDKError(
224
+ "API error occurred", http_res.status_code, http_res_text, http_res
225
+ )
226
+ if utils.match_response(http_res, "5XX", "*"):
217
227
  http_res_text = await utils.stream_to_text_async(http_res)
218
228
  raise models.SDKError(
219
229
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -255,7 +265,7 @@ class Jobs(BaseSDK):
255
265
  server_url: Optional[str] = None,
256
266
  timeout_ms: Optional[int] = None,
257
267
  http_headers: Optional[Mapping[str, str]] = None,
258
- ) -> Optional[models.JobsAPIRoutesFineTuningCreateFineTuningJobResponse]:
268
+ ) -> models.JobsAPIRoutesFineTuningCreateFineTuningJobResponse:
259
269
  r"""Create Fine Tuning Job
260
270
 
261
271
  Create a new fine-tuning job, it will be queued for processing.
@@ -342,10 +352,14 @@ class Jobs(BaseSDK):
342
352
 
343
353
  if utils.match_response(http_res, "200", "application/json"):
344
354
  return utils.unmarshal_json(
345
- http_res.text,
346
- Optional[models.JobsAPIRoutesFineTuningCreateFineTuningJobResponse],
355
+ http_res.text, models.JobsAPIRoutesFineTuningCreateFineTuningJobResponse
356
+ )
357
+ if utils.match_response(http_res, "4XX", "*"):
358
+ http_res_text = utils.stream_to_text(http_res)
359
+ raise models.SDKError(
360
+ "API error occurred", http_res.status_code, http_res_text, http_res
347
361
  )
348
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
362
+ if utils.match_response(http_res, "5XX", "*"):
349
363
  http_res_text = utils.stream_to_text(http_res)
350
364
  raise models.SDKError(
351
365
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -387,7 +401,7 @@ class Jobs(BaseSDK):
387
401
  server_url: Optional[str] = None,
388
402
  timeout_ms: Optional[int] = None,
389
403
  http_headers: Optional[Mapping[str, str]] = None,
390
- ) -> Optional[models.JobsAPIRoutesFineTuningCreateFineTuningJobResponse]:
404
+ ) -> models.JobsAPIRoutesFineTuningCreateFineTuningJobResponse:
391
405
  r"""Create Fine Tuning Job
392
406
 
393
407
  Create a new fine-tuning job, it will be queued for processing.
@@ -474,10 +488,14 @@ class Jobs(BaseSDK):
474
488
 
475
489
  if utils.match_response(http_res, "200", "application/json"):
476
490
  return utils.unmarshal_json(
477
- http_res.text,
478
- Optional[models.JobsAPIRoutesFineTuningCreateFineTuningJobResponse],
491
+ http_res.text, models.JobsAPIRoutesFineTuningCreateFineTuningJobResponse
492
+ )
493
+ if utils.match_response(http_res, "4XX", "*"):
494
+ http_res_text = await utils.stream_to_text_async(http_res)
495
+ raise models.SDKError(
496
+ "API error occurred", http_res.status_code, http_res_text, http_res
479
497
  )
480
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
498
+ if utils.match_response(http_res, "5XX", "*"):
481
499
  http_res_text = await utils.stream_to_text_async(http_res)
482
500
  raise models.SDKError(
483
501
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -500,7 +518,7 @@ class Jobs(BaseSDK):
500
518
  server_url: Optional[str] = None,
501
519
  timeout_ms: Optional[int] = None,
502
520
  http_headers: Optional[Mapping[str, str]] = None,
503
- ) -> Optional[models.DetailedJobOut]:
521
+ ) -> models.DetailedJobOut:
504
522
  r"""Get Fine Tuning Job
505
523
 
506
524
  Get a fine-tuned job details by its UUID.
@@ -561,8 +579,13 @@ class Jobs(BaseSDK):
561
579
  )
562
580
 
563
581
  if utils.match_response(http_res, "200", "application/json"):
564
- return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
565
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
582
+ return utils.unmarshal_json(http_res.text, models.DetailedJobOut)
583
+ if utils.match_response(http_res, "4XX", "*"):
584
+ http_res_text = utils.stream_to_text(http_res)
585
+ raise models.SDKError(
586
+ "API error occurred", http_res.status_code, http_res_text, http_res
587
+ )
588
+ if utils.match_response(http_res, "5XX", "*"):
566
589
  http_res_text = utils.stream_to_text(http_res)
567
590
  raise models.SDKError(
568
591
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -585,7 +608,7 @@ class Jobs(BaseSDK):
585
608
  server_url: Optional[str] = None,
586
609
  timeout_ms: Optional[int] = None,
587
610
  http_headers: Optional[Mapping[str, str]] = None,
588
- ) -> Optional[models.DetailedJobOut]:
611
+ ) -> models.DetailedJobOut:
589
612
  r"""Get Fine Tuning Job
590
613
 
591
614
  Get a fine-tuned job details by its UUID.
@@ -646,8 +669,13 @@ class Jobs(BaseSDK):
646
669
  )
647
670
 
648
671
  if utils.match_response(http_res, "200", "application/json"):
649
- return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
650
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
672
+ return utils.unmarshal_json(http_res.text, models.DetailedJobOut)
673
+ if utils.match_response(http_res, "4XX", "*"):
674
+ http_res_text = await utils.stream_to_text_async(http_res)
675
+ raise models.SDKError(
676
+ "API error occurred", http_res.status_code, http_res_text, http_res
677
+ )
678
+ if utils.match_response(http_res, "5XX", "*"):
651
679
  http_res_text = await utils.stream_to_text_async(http_res)
652
680
  raise models.SDKError(
653
681
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -670,7 +698,7 @@ class Jobs(BaseSDK):
670
698
  server_url: Optional[str] = None,
671
699
  timeout_ms: Optional[int] = None,
672
700
  http_headers: Optional[Mapping[str, str]] = None,
673
- ) -> Optional[models.DetailedJobOut]:
701
+ ) -> models.DetailedJobOut:
674
702
  r"""Cancel Fine Tuning Job
675
703
 
676
704
  Request the cancellation of a fine tuning job.
@@ -731,8 +759,13 @@ class Jobs(BaseSDK):
731
759
  )
732
760
 
733
761
  if utils.match_response(http_res, "200", "application/json"):
734
- return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
735
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
762
+ return utils.unmarshal_json(http_res.text, models.DetailedJobOut)
763
+ if utils.match_response(http_res, "4XX", "*"):
764
+ http_res_text = utils.stream_to_text(http_res)
765
+ raise models.SDKError(
766
+ "API error occurred", http_res.status_code, http_res_text, http_res
767
+ )
768
+ if utils.match_response(http_res, "5XX", "*"):
736
769
  http_res_text = utils.stream_to_text(http_res)
737
770
  raise models.SDKError(
738
771
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -755,7 +788,7 @@ class Jobs(BaseSDK):
755
788
  server_url: Optional[str] = None,
756
789
  timeout_ms: Optional[int] = None,
757
790
  http_headers: Optional[Mapping[str, str]] = None,
758
- ) -> Optional[models.DetailedJobOut]:
791
+ ) -> models.DetailedJobOut:
759
792
  r"""Cancel Fine Tuning Job
760
793
 
761
794
  Request the cancellation of a fine tuning job.
@@ -816,8 +849,13 @@ class Jobs(BaseSDK):
816
849
  )
817
850
 
818
851
  if utils.match_response(http_res, "200", "application/json"):
819
- return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
820
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
852
+ return utils.unmarshal_json(http_res.text, models.DetailedJobOut)
853
+ if utils.match_response(http_res, "4XX", "*"):
854
+ http_res_text = await utils.stream_to_text_async(http_res)
855
+ raise models.SDKError(
856
+ "API error occurred", http_res.status_code, http_res_text, http_res
857
+ )
858
+ if utils.match_response(http_res, "5XX", "*"):
821
859
  http_res_text = await utils.stream_to_text_async(http_res)
822
860
  raise models.SDKError(
823
861
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -840,7 +878,7 @@ class Jobs(BaseSDK):
840
878
  server_url: Optional[str] = None,
841
879
  timeout_ms: Optional[int] = None,
842
880
  http_headers: Optional[Mapping[str, str]] = None,
843
- ) -> Optional[models.DetailedJobOut]:
881
+ ) -> models.DetailedJobOut:
844
882
  r"""Start Fine Tuning Job
845
883
 
846
884
  Request the start of a validated fine tuning job.
@@ -901,8 +939,13 @@ class Jobs(BaseSDK):
901
939
  )
902
940
 
903
941
  if utils.match_response(http_res, "200", "application/json"):
904
- return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
905
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
942
+ return utils.unmarshal_json(http_res.text, models.DetailedJobOut)
943
+ if utils.match_response(http_res, "4XX", "*"):
944
+ http_res_text = utils.stream_to_text(http_res)
945
+ raise models.SDKError(
946
+ "API error occurred", http_res.status_code, http_res_text, http_res
947
+ )
948
+ if utils.match_response(http_res, "5XX", "*"):
906
949
  http_res_text = utils.stream_to_text(http_res)
907
950
  raise models.SDKError(
908
951
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -925,7 +968,7 @@ class Jobs(BaseSDK):
925
968
  server_url: Optional[str] = None,
926
969
  timeout_ms: Optional[int] = None,
927
970
  http_headers: Optional[Mapping[str, str]] = None,
928
- ) -> Optional[models.DetailedJobOut]:
971
+ ) -> models.DetailedJobOut:
929
972
  r"""Start Fine Tuning Job
930
973
 
931
974
  Request the start of a validated fine tuning job.
@@ -986,8 +1029,13 @@ class Jobs(BaseSDK):
986
1029
  )
987
1030
 
988
1031
  if utils.match_response(http_res, "200", "application/json"):
989
- return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
990
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
1032
+ return utils.unmarshal_json(http_res.text, models.DetailedJobOut)
1033
+ if utils.match_response(http_res, "4XX", "*"):
1034
+ http_res_text = await utils.stream_to_text_async(http_res)
1035
+ raise models.SDKError(
1036
+ "API error occurred", http_res.status_code, http_res_text, http_res
1037
+ )
1038
+ if utils.match_response(http_res, "5XX", "*"):
991
1039
  http_res_text = await utils.stream_to_text_async(http_res)
992
1040
  raise models.SDKError(
993
1041
  "API error occurred", http_res.status_code, http_res_text, http_res