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/__init__.py CHANGED
@@ -1,9 +1,18 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
- from ._version import __title__, __version__
3
+ from ._version import (
4
+ __title__,
5
+ __version__,
6
+ __openapi_doc_version__,
7
+ __gen_version__,
8
+ __user_agent__,
9
+ )
4
10
  from .sdk import *
5
11
  from .sdkconfiguration import *
6
12
  from .models import *
7
13
 
8
14
 
9
15
  VERSION: str = __version__
16
+ OPENAPI_DOC_VERSION = __openapi_doc_version__
17
+ SPEAKEASY_GENERATOR_VERSION = __gen_version__
18
+ USER_AGENT = __user_agent__
mistralai/_version.py CHANGED
@@ -3,7 +3,10 @@
3
3
  import importlib.metadata
4
4
 
5
5
  __title__: str = "mistralai"
6
- __version__: str = "1.3.1"
6
+ __version__: str = "1.4.0"
7
+ __openapi_doc_version__: str = "0.0.2"
8
+ __gen_version__: str = "2.493.32"
9
+ __user_agent__: str = "speakeasy-sdk/python 1.4.0 2.493.32 0.0.2 mistralai"
7
10
 
8
11
  try:
9
12
  if __package__ is not None:
mistralai/agents.py CHANGED
@@ -43,11 +43,14 @@ class Agents(BaseSDK):
43
43
  presence_penalty: Optional[float] = None,
44
44
  frequency_penalty: Optional[float] = None,
45
45
  n: OptionalNullable[int] = UNSET,
46
+ prediction: Optional[
47
+ Union[models.Prediction, models.PredictionTypedDict]
48
+ ] = None,
46
49
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
47
50
  server_url: Optional[str] = None,
48
51
  timeout_ms: Optional[int] = None,
49
52
  http_headers: Optional[Mapping[str, str]] = None,
50
- ) -> Optional[models.ChatCompletionResponse]:
53
+ ) -> models.ChatCompletionResponse:
51
54
  r"""Agents Completion
52
55
 
53
56
  :param messages: The prompt(s) to generate completions for, encoded as a list of dict with role and content.
@@ -62,6 +65,7 @@ class Agents(BaseSDK):
62
65
  :param presence_penalty: presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative.
63
66
  :param frequency_penalty: frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition.
64
67
  :param n: Number of completions to return for each request, input tokens are only billed once.
68
+ :param prediction:
65
69
  :param retries: Override the default retry configuration for this method
66
70
  :param server_url: Override the default server URL for this method
67
71
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -93,6 +97,9 @@ class Agents(BaseSDK):
93
97
  presence_penalty=presence_penalty,
94
98
  frequency_penalty=frequency_penalty,
95
99
  n=n,
100
+ prediction=utils.get_pydantic_model(
101
+ prediction, Optional[models.Prediction]
102
+ ),
96
103
  agent_id=agent_id,
97
104
  )
98
105
 
@@ -138,13 +145,16 @@ class Agents(BaseSDK):
138
145
 
139
146
  data: Any = None
140
147
  if utils.match_response(http_res, "200", "application/json"):
141
- return utils.unmarshal_json(
142
- http_res.text, Optional[models.ChatCompletionResponse]
143
- )
148
+ return utils.unmarshal_json(http_res.text, models.ChatCompletionResponse)
144
149
  if utils.match_response(http_res, "422", "application/json"):
145
150
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
146
151
  raise models.HTTPValidationError(data=data)
147
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
152
+ if utils.match_response(http_res, "4XX", "*"):
153
+ http_res_text = utils.stream_to_text(http_res)
154
+ raise models.SDKError(
155
+ "API error occurred", http_res.status_code, http_res_text, http_res
156
+ )
157
+ if utils.match_response(http_res, "5XX", "*"):
148
158
  http_res_text = utils.stream_to_text(http_res)
149
159
  raise models.SDKError(
150
160
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -191,11 +201,14 @@ class Agents(BaseSDK):
191
201
  presence_penalty: Optional[float] = None,
192
202
  frequency_penalty: Optional[float] = None,
193
203
  n: OptionalNullable[int] = UNSET,
204
+ prediction: Optional[
205
+ Union[models.Prediction, models.PredictionTypedDict]
206
+ ] = None,
194
207
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
195
208
  server_url: Optional[str] = None,
196
209
  timeout_ms: Optional[int] = None,
197
210
  http_headers: Optional[Mapping[str, str]] = None,
198
- ) -> Optional[models.ChatCompletionResponse]:
211
+ ) -> models.ChatCompletionResponse:
199
212
  r"""Agents Completion
200
213
 
201
214
  :param messages: The prompt(s) to generate completions for, encoded as a list of dict with role and content.
@@ -210,6 +223,7 @@ class Agents(BaseSDK):
210
223
  :param presence_penalty: presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative.
211
224
  :param frequency_penalty: frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition.
212
225
  :param n: Number of completions to return for each request, input tokens are only billed once.
226
+ :param prediction:
213
227
  :param retries: Override the default retry configuration for this method
214
228
  :param server_url: Override the default server URL for this method
215
229
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -241,6 +255,9 @@ class Agents(BaseSDK):
241
255
  presence_penalty=presence_penalty,
242
256
  frequency_penalty=frequency_penalty,
243
257
  n=n,
258
+ prediction=utils.get_pydantic_model(
259
+ prediction, Optional[models.Prediction]
260
+ ),
244
261
  agent_id=agent_id,
245
262
  )
246
263
 
@@ -286,13 +303,16 @@ class Agents(BaseSDK):
286
303
 
287
304
  data: Any = None
288
305
  if utils.match_response(http_res, "200", "application/json"):
289
- return utils.unmarshal_json(
290
- http_res.text, Optional[models.ChatCompletionResponse]
291
- )
306
+ return utils.unmarshal_json(http_res.text, models.ChatCompletionResponse)
292
307
  if utils.match_response(http_res, "422", "application/json"):
293
308
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
294
309
  raise models.HTTPValidationError(data=data)
295
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
310
+ if utils.match_response(http_res, "4XX", "*"):
311
+ http_res_text = await utils.stream_to_text_async(http_res)
312
+ raise models.SDKError(
313
+ "API error occurred", http_res.status_code, http_res_text, http_res
314
+ )
315
+ if utils.match_response(http_res, "5XX", "*"):
296
316
  http_res_text = await utils.stream_to_text_async(http_res)
297
317
  raise models.SDKError(
298
318
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -339,11 +359,14 @@ class Agents(BaseSDK):
339
359
  presence_penalty: Optional[float] = None,
340
360
  frequency_penalty: Optional[float] = None,
341
361
  n: OptionalNullable[int] = UNSET,
362
+ prediction: Optional[
363
+ Union[models.Prediction, models.PredictionTypedDict]
364
+ ] = None,
342
365
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
343
366
  server_url: Optional[str] = None,
344
367
  timeout_ms: Optional[int] = None,
345
368
  http_headers: Optional[Mapping[str, str]] = None,
346
- ) -> Optional[eventstreaming.EventStream[models.CompletionEvent]]:
369
+ ) -> eventstreaming.EventStream[models.CompletionEvent]:
347
370
  r"""Stream Agents completion
348
371
 
349
372
  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.
@@ -360,6 +383,7 @@ class Agents(BaseSDK):
360
383
  :param presence_penalty: presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative.
361
384
  :param frequency_penalty: frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition.
362
385
  :param n: Number of completions to return for each request, input tokens are only billed once.
386
+ :param prediction:
363
387
  :param retries: Override the default retry configuration for this method
364
388
  :param server_url: Override the default server URL for this method
365
389
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -391,6 +415,9 @@ class Agents(BaseSDK):
391
415
  presence_penalty=presence_penalty,
392
416
  frequency_penalty=frequency_penalty,
393
417
  n=n,
418
+ prediction=utils.get_pydantic_model(
419
+ prediction, Optional[models.Prediction]
420
+ ),
394
421
  agent_id=agent_id,
395
422
  )
396
423
 
@@ -446,7 +473,12 @@ class Agents(BaseSDK):
446
473
  http_res_text = utils.stream_to_text(http_res)
447
474
  data = utils.unmarshal_json(http_res_text, models.HTTPValidationErrorData)
448
475
  raise models.HTTPValidationError(data=data)
449
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
476
+ if utils.match_response(http_res, "4XX", "*"):
477
+ http_res_text = utils.stream_to_text(http_res)
478
+ raise models.SDKError(
479
+ "API error occurred", http_res.status_code, http_res_text, http_res
480
+ )
481
+ if utils.match_response(http_res, "5XX", "*"):
450
482
  http_res_text = utils.stream_to_text(http_res)
451
483
  raise models.SDKError(
452
484
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -493,11 +525,14 @@ class Agents(BaseSDK):
493
525
  presence_penalty: Optional[float] = None,
494
526
  frequency_penalty: Optional[float] = None,
495
527
  n: OptionalNullable[int] = UNSET,
528
+ prediction: Optional[
529
+ Union[models.Prediction, models.PredictionTypedDict]
530
+ ] = None,
496
531
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
497
532
  server_url: Optional[str] = None,
498
533
  timeout_ms: Optional[int] = None,
499
534
  http_headers: Optional[Mapping[str, str]] = None,
500
- ) -> Optional[eventstreaming.EventStreamAsync[models.CompletionEvent]]:
535
+ ) -> eventstreaming.EventStreamAsync[models.CompletionEvent]:
501
536
  r"""Stream Agents completion
502
537
 
503
538
  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.
@@ -514,6 +549,7 @@ class Agents(BaseSDK):
514
549
  :param presence_penalty: presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative.
515
550
  :param frequency_penalty: frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition.
516
551
  :param n: Number of completions to return for each request, input tokens are only billed once.
552
+ :param prediction:
517
553
  :param retries: Override the default retry configuration for this method
518
554
  :param server_url: Override the default server URL for this method
519
555
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -545,6 +581,9 @@ class Agents(BaseSDK):
545
581
  presence_penalty=presence_penalty,
546
582
  frequency_penalty=frequency_penalty,
547
583
  n=n,
584
+ prediction=utils.get_pydantic_model(
585
+ prediction, Optional[models.Prediction]
586
+ ),
548
587
  agent_id=agent_id,
549
588
  )
550
589
 
@@ -600,7 +639,12 @@ class Agents(BaseSDK):
600
639
  http_res_text = await utils.stream_to_text_async(http_res)
601
640
  data = utils.unmarshal_json(http_res_text, models.HTTPValidationErrorData)
602
641
  raise models.HTTPValidationError(data=data)
603
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
642
+ if utils.match_response(http_res, "4XX", "*"):
643
+ http_res_text = await utils.stream_to_text_async(http_res)
644
+ raise models.SDKError(
645
+ "API error occurred", http_res.status_code, http_res_text, http_res
646
+ )
647
+ if utils.match_response(http_res, "5XX", "*"):
604
648
  http_res_text = await utils.stream_to_text_async(http_res)
605
649
  raise models.SDKError(
606
650
  "API error occurred", http_res.status_code, http_res_text, http_res
mistralai/chat.py CHANGED
@@ -37,12 +37,15 @@ class Chat(BaseSDK):
37
37
  presence_penalty: Optional[float] = None,
38
38
  frequency_penalty: Optional[float] = None,
39
39
  n: OptionalNullable[int] = UNSET,
40
+ prediction: Optional[
41
+ Union[models.Prediction, models.PredictionTypedDict]
42
+ ] = None,
40
43
  safe_prompt: Optional[bool] = None,
41
44
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
42
45
  server_url: Optional[str] = None,
43
46
  timeout_ms: Optional[int] = None,
44
47
  http_headers: Optional[Mapping[str, str]] = None,
45
- ) -> Optional[models.ChatCompletionResponse]:
48
+ ) -> models.ChatCompletionResponse:
46
49
  r"""Chat Completion
47
50
 
48
51
  :param model: ID of the model to use. You can use the [List Available Models](/api/#tag/models/operation/list_models_v1_models_get) API to see all of your available models, or see our [Model overview](/models) for model descriptions.
@@ -59,6 +62,7 @@ class Chat(BaseSDK):
59
62
  :param presence_penalty: presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative.
60
63
  :param frequency_penalty: frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition.
61
64
  :param n: Number of completions to return for each request, input tokens are only billed once.
65
+ :param prediction:
62
66
  :param safe_prompt: Whether to inject a safety prompt before all conversations.
63
67
  :param retries: Override the default retry configuration for this method
64
68
  :param server_url: Override the default server URL for this method
@@ -92,6 +96,9 @@ class Chat(BaseSDK):
92
96
  presence_penalty=presence_penalty,
93
97
  frequency_penalty=frequency_penalty,
94
98
  n=n,
99
+ prediction=utils.get_pydantic_model(
100
+ prediction, Optional[models.Prediction]
101
+ ),
95
102
  safe_prompt=safe_prompt,
96
103
  )
97
104
 
@@ -137,13 +144,16 @@ class Chat(BaseSDK):
137
144
 
138
145
  data: Any = None
139
146
  if utils.match_response(http_res, "200", "application/json"):
140
- return utils.unmarshal_json(
141
- http_res.text, Optional[models.ChatCompletionResponse]
142
- )
147
+ return utils.unmarshal_json(http_res.text, models.ChatCompletionResponse)
143
148
  if utils.match_response(http_res, "422", "application/json"):
144
149
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
145
150
  raise models.HTTPValidationError(data=data)
146
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
151
+ if utils.match_response(http_res, "4XX", "*"):
152
+ http_res_text = utils.stream_to_text(http_res)
153
+ raise models.SDKError(
154
+ "API error occurred", http_res.status_code, http_res_text, http_res
155
+ )
156
+ if utils.match_response(http_res, "5XX", "*"):
147
157
  http_res_text = utils.stream_to_text(http_res)
148
158
  raise models.SDKError(
149
159
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -184,12 +194,15 @@ class Chat(BaseSDK):
184
194
  presence_penalty: Optional[float] = None,
185
195
  frequency_penalty: Optional[float] = None,
186
196
  n: OptionalNullable[int] = UNSET,
197
+ prediction: Optional[
198
+ Union[models.Prediction, models.PredictionTypedDict]
199
+ ] = None,
187
200
  safe_prompt: Optional[bool] = None,
188
201
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
189
202
  server_url: Optional[str] = None,
190
203
  timeout_ms: Optional[int] = None,
191
204
  http_headers: Optional[Mapping[str, str]] = None,
192
- ) -> Optional[models.ChatCompletionResponse]:
205
+ ) -> models.ChatCompletionResponse:
193
206
  r"""Chat Completion
194
207
 
195
208
  :param model: ID of the model to use. You can use the [List Available Models](/api/#tag/models/operation/list_models_v1_models_get) API to see all of your available models, or see our [Model overview](/models) for model descriptions.
@@ -206,6 +219,7 @@ class Chat(BaseSDK):
206
219
  :param presence_penalty: presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative.
207
220
  :param frequency_penalty: frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition.
208
221
  :param n: Number of completions to return for each request, input tokens are only billed once.
222
+ :param prediction:
209
223
  :param safe_prompt: Whether to inject a safety prompt before all conversations.
210
224
  :param retries: Override the default retry configuration for this method
211
225
  :param server_url: Override the default server URL for this method
@@ -239,6 +253,9 @@ class Chat(BaseSDK):
239
253
  presence_penalty=presence_penalty,
240
254
  frequency_penalty=frequency_penalty,
241
255
  n=n,
256
+ prediction=utils.get_pydantic_model(
257
+ prediction, Optional[models.Prediction]
258
+ ),
242
259
  safe_prompt=safe_prompt,
243
260
  )
244
261
 
@@ -284,13 +301,16 @@ class Chat(BaseSDK):
284
301
 
285
302
  data: Any = None
286
303
  if utils.match_response(http_res, "200", "application/json"):
287
- return utils.unmarshal_json(
288
- http_res.text, Optional[models.ChatCompletionResponse]
289
- )
304
+ return utils.unmarshal_json(http_res.text, models.ChatCompletionResponse)
290
305
  if utils.match_response(http_res, "422", "application/json"):
291
306
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
292
307
  raise models.HTTPValidationError(data=data)
293
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
308
+ if utils.match_response(http_res, "4XX", "*"):
309
+ http_res_text = await utils.stream_to_text_async(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", "*"):
294
314
  http_res_text = await utils.stream_to_text_async(http_res)
295
315
  raise models.SDKError(
296
316
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -339,12 +359,15 @@ class Chat(BaseSDK):
339
359
  presence_penalty: Optional[float] = None,
340
360
  frequency_penalty: Optional[float] = None,
341
361
  n: OptionalNullable[int] = UNSET,
362
+ prediction: Optional[
363
+ Union[models.Prediction, models.PredictionTypedDict]
364
+ ] = None,
342
365
  safe_prompt: Optional[bool] = None,
343
366
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
344
367
  server_url: Optional[str] = None,
345
368
  timeout_ms: Optional[int] = None,
346
369
  http_headers: Optional[Mapping[str, str]] = None,
347
- ) -> Optional[eventstreaming.EventStream[models.CompletionEvent]]:
370
+ ) -> eventstreaming.EventStream[models.CompletionEvent]:
348
371
  r"""Stream chat completion
349
372
 
350
373
  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.
@@ -363,6 +386,7 @@ class Chat(BaseSDK):
363
386
  :param presence_penalty: presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative.
364
387
  :param frequency_penalty: frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition.
365
388
  :param n: Number of completions to return for each request, input tokens are only billed once.
389
+ :param prediction:
366
390
  :param safe_prompt: Whether to inject a safety prompt before all conversations.
367
391
  :param retries: Override the default retry configuration for this method
368
392
  :param server_url: Override the default server URL for this method
@@ -398,6 +422,9 @@ class Chat(BaseSDK):
398
422
  presence_penalty=presence_penalty,
399
423
  frequency_penalty=frequency_penalty,
400
424
  n=n,
425
+ prediction=utils.get_pydantic_model(
426
+ prediction, Optional[models.Prediction]
427
+ ),
401
428
  safe_prompt=safe_prompt,
402
429
  )
403
430
 
@@ -453,7 +480,12 @@ class Chat(BaseSDK):
453
480
  http_res_text = utils.stream_to_text(http_res)
454
481
  data = utils.unmarshal_json(http_res_text, models.HTTPValidationErrorData)
455
482
  raise models.HTTPValidationError(data=data)
456
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
483
+ if utils.match_response(http_res, "4XX", "*"):
484
+ http_res_text = utils.stream_to_text(http_res)
485
+ raise models.SDKError(
486
+ "API error occurred", http_res.status_code, http_res_text, http_res
487
+ )
488
+ if utils.match_response(http_res, "5XX", "*"):
457
489
  http_res_text = utils.stream_to_text(http_res)
458
490
  raise models.SDKError(
459
491
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -502,12 +534,15 @@ class Chat(BaseSDK):
502
534
  presence_penalty: Optional[float] = None,
503
535
  frequency_penalty: Optional[float] = None,
504
536
  n: OptionalNullable[int] = UNSET,
537
+ prediction: Optional[
538
+ Union[models.Prediction, models.PredictionTypedDict]
539
+ ] = None,
505
540
  safe_prompt: Optional[bool] = None,
506
541
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
507
542
  server_url: Optional[str] = None,
508
543
  timeout_ms: Optional[int] = None,
509
544
  http_headers: Optional[Mapping[str, str]] = None,
510
- ) -> Optional[eventstreaming.EventStreamAsync[models.CompletionEvent]]:
545
+ ) -> eventstreaming.EventStreamAsync[models.CompletionEvent]:
511
546
  r"""Stream chat completion
512
547
 
513
548
  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.
@@ -526,6 +561,7 @@ class Chat(BaseSDK):
526
561
  :param presence_penalty: presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative.
527
562
  :param frequency_penalty: frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition.
528
563
  :param n: Number of completions to return for each request, input tokens are only billed once.
564
+ :param prediction:
529
565
  :param safe_prompt: Whether to inject a safety prompt before all conversations.
530
566
  :param retries: Override the default retry configuration for this method
531
567
  :param server_url: Override the default server URL for this method
@@ -561,6 +597,9 @@ class Chat(BaseSDK):
561
597
  presence_penalty=presence_penalty,
562
598
  frequency_penalty=frequency_penalty,
563
599
  n=n,
600
+ prediction=utils.get_pydantic_model(
601
+ prediction, Optional[models.Prediction]
602
+ ),
564
603
  safe_prompt=safe_prompt,
565
604
  )
566
605
 
@@ -616,7 +655,12 @@ class Chat(BaseSDK):
616
655
  http_res_text = await utils.stream_to_text_async(http_res)
617
656
  data = utils.unmarshal_json(http_res_text, models.HTTPValidationErrorData)
618
657
  raise models.HTTPValidationError(data=data)
619
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
658
+ if utils.match_response(http_res, "4XX", "*"):
659
+ http_res_text = await utils.stream_to_text_async(http_res)
660
+ raise models.SDKError(
661
+ "API error occurred", http_res.status_code, http_res_text, http_res
662
+ )
663
+ if utils.match_response(http_res, "5XX", "*"):
620
664
  http_res_text = await utils.stream_to_text_async(http_res)
621
665
  raise models.SDKError(
622
666
  "API error occurred", http_res.status_code, http_res_text, http_res
mistralai/classifiers.py CHANGED
@@ -23,7 +23,7 @@ class Classifiers(BaseSDK):
23
23
  server_url: Optional[str] = None,
24
24
  timeout_ms: Optional[int] = None,
25
25
  http_headers: Optional[Mapping[str, str]] = None,
26
- ) -> Optional[models.ClassificationResponse]:
26
+ ) -> models.ClassificationResponse:
27
27
  r"""Moderations
28
28
 
29
29
  :param inputs: Text to classify.
@@ -88,13 +88,16 @@ class Classifiers(BaseSDK):
88
88
 
89
89
  data: Any = None
90
90
  if utils.match_response(http_res, "200", "application/json"):
91
- return utils.unmarshal_json(
92
- http_res.text, Optional[models.ClassificationResponse]
93
- )
91
+ return utils.unmarshal_json(http_res.text, models.ClassificationResponse)
94
92
  if utils.match_response(http_res, "422", "application/json"):
95
93
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
96
94
  raise models.HTTPValidationError(data=data)
97
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
95
+ if utils.match_response(http_res, "4XX", "*"):
96
+ http_res_text = utils.stream_to_text(http_res)
97
+ raise models.SDKError(
98
+ "API error occurred", http_res.status_code, http_res_text, http_res
99
+ )
100
+ if utils.match_response(http_res, "5XX", "*"):
98
101
  http_res_text = utils.stream_to_text(http_res)
99
102
  raise models.SDKError(
100
103
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -121,7 +124,7 @@ class Classifiers(BaseSDK):
121
124
  server_url: Optional[str] = None,
122
125
  timeout_ms: Optional[int] = None,
123
126
  http_headers: Optional[Mapping[str, str]] = None,
124
- ) -> Optional[models.ClassificationResponse]:
127
+ ) -> models.ClassificationResponse:
125
128
  r"""Moderations
126
129
 
127
130
  :param inputs: Text to classify.
@@ -186,13 +189,16 @@ class Classifiers(BaseSDK):
186
189
 
187
190
  data: Any = None
188
191
  if utils.match_response(http_res, "200", "application/json"):
189
- return utils.unmarshal_json(
190
- http_res.text, Optional[models.ClassificationResponse]
191
- )
192
+ return utils.unmarshal_json(http_res.text, models.ClassificationResponse)
192
193
  if utils.match_response(http_res, "422", "application/json"):
193
194
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
194
195
  raise models.HTTPValidationError(data=data)
195
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
196
+ if utils.match_response(http_res, "4XX", "*"):
197
+ http_res_text = await utils.stream_to_text_async(http_res)
198
+ raise models.SDKError(
199
+ "API error occurred", http_res.status_code, http_res_text, http_res
200
+ )
201
+ if utils.match_response(http_res, "5XX", "*"):
196
202
  http_res_text = await utils.stream_to_text_async(http_res)
197
203
  raise models.SDKError(
198
204
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -219,7 +225,7 @@ class Classifiers(BaseSDK):
219
225
  server_url: Optional[str] = None,
220
226
  timeout_ms: Optional[int] = None,
221
227
  http_headers: Optional[Mapping[str, str]] = None,
222
- ) -> Optional[models.ClassificationResponse]:
228
+ ) -> models.ClassificationResponse:
223
229
  r"""Moderations Chat
224
230
 
225
231
  :param inputs: Chat to classify
@@ -286,13 +292,16 @@ class Classifiers(BaseSDK):
286
292
 
287
293
  data: Any = None
288
294
  if utils.match_response(http_res, "200", "application/json"):
289
- return utils.unmarshal_json(
290
- http_res.text, Optional[models.ClassificationResponse]
291
- )
295
+ return utils.unmarshal_json(http_res.text, models.ClassificationResponse)
292
296
  if utils.match_response(http_res, "422", "application/json"):
293
297
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
294
298
  raise models.HTTPValidationError(data=data)
295
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
299
+ if utils.match_response(http_res, "4XX", "*"):
300
+ http_res_text = utils.stream_to_text(http_res)
301
+ raise models.SDKError(
302
+ "API error occurred", http_res.status_code, http_res_text, http_res
303
+ )
304
+ if utils.match_response(http_res, "5XX", "*"):
296
305
  http_res_text = utils.stream_to_text(http_res)
297
306
  raise models.SDKError(
298
307
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -319,7 +328,7 @@ class Classifiers(BaseSDK):
319
328
  server_url: Optional[str] = None,
320
329
  timeout_ms: Optional[int] = None,
321
330
  http_headers: Optional[Mapping[str, str]] = None,
322
- ) -> Optional[models.ClassificationResponse]:
331
+ ) -> models.ClassificationResponse:
323
332
  r"""Moderations Chat
324
333
 
325
334
  :param inputs: Chat to classify
@@ -386,13 +395,16 @@ class Classifiers(BaseSDK):
386
395
 
387
396
  data: Any = None
388
397
  if utils.match_response(http_res, "200", "application/json"):
389
- return utils.unmarshal_json(
390
- http_res.text, Optional[models.ClassificationResponse]
391
- )
398
+ return utils.unmarshal_json(http_res.text, models.ClassificationResponse)
392
399
  if utils.match_response(http_res, "422", "application/json"):
393
400
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
394
401
  raise models.HTTPValidationError(data=data)
395
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
402
+ if utils.match_response(http_res, "4XX", "*"):
403
+ http_res_text = await utils.stream_to_text_async(http_res)
404
+ raise models.SDKError(
405
+ "API error occurred", http_res.status_code, http_res_text, http_res
406
+ )
407
+ if utils.match_response(http_res, "5XX", "*"):
396
408
  http_res_text = await utils.stream_to_text_async(http_res)
397
409
  raise models.SDKError(
398
410
  "API error occurred", http_res.status_code, http_res_text, http_res
mistralai/embeddings.py CHANGED
@@ -21,7 +21,7 @@ class Embeddings(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.EmbeddingResponse]:
24
+ ) -> models.EmbeddingResponse:
25
25
  r"""Embeddings
26
26
 
27
27
  Embeddings
@@ -90,13 +90,16 @@ class Embeddings(BaseSDK):
90
90
 
91
91
  data: Any = None
92
92
  if utils.match_response(http_res, "200", "application/json"):
93
- return utils.unmarshal_json(
94
- http_res.text, Optional[models.EmbeddingResponse]
95
- )
93
+ return utils.unmarshal_json(http_res.text, models.EmbeddingResponse)
96
94
  if utils.match_response(http_res, "422", "application/json"):
97
95
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
98
96
  raise models.HTTPValidationError(data=data)
99
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
97
+ if utils.match_response(http_res, "4XX", "*"):
98
+ http_res_text = utils.stream_to_text(http_res)
99
+ raise models.SDKError(
100
+ "API error occurred", http_res.status_code, http_res_text, http_res
101
+ )
102
+ if utils.match_response(http_res, "5XX", "*"):
100
103
  http_res_text = utils.stream_to_text(http_res)
101
104
  raise models.SDKError(
102
105
  "API error occurred", http_res.status_code, http_res_text, http_res
@@ -121,7 +124,7 @@ class Embeddings(BaseSDK):
121
124
  server_url: Optional[str] = None,
122
125
  timeout_ms: Optional[int] = None,
123
126
  http_headers: Optional[Mapping[str, str]] = None,
124
- ) -> Optional[models.EmbeddingResponse]:
127
+ ) -> models.EmbeddingResponse:
125
128
  r"""Embeddings
126
129
 
127
130
  Embeddings
@@ -190,13 +193,16 @@ class Embeddings(BaseSDK):
190
193
 
191
194
  data: Any = None
192
195
  if utils.match_response(http_res, "200", "application/json"):
193
- return utils.unmarshal_json(
194
- http_res.text, Optional[models.EmbeddingResponse]
195
- )
196
+ return utils.unmarshal_json(http_res.text, models.EmbeddingResponse)
196
197
  if utils.match_response(http_res, "422", "application/json"):
197
198
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
198
199
  raise models.HTTPValidationError(data=data)
199
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
200
+ if utils.match_response(http_res, "4XX", "*"):
201
+ http_res_text = await utils.stream_to_text_async(http_res)
202
+ raise models.SDKError(
203
+ "API error occurred", http_res.status_code, http_res_text, http_res
204
+ )
205
+ if utils.match_response(http_res, "5XX", "*"):
200
206
  http_res_text = await utils.stream_to_text_async(http_res)
201
207
  raise models.SDKError(
202
208
  "API error occurred", http_res.status_code, http_res_text, http_res