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.
Files changed (187) hide show
  1. mistralai/__init__.py +4 -0
  2. mistralai/_version.py +12 -0
  3. mistralai/agents.py +56 -22
  4. mistralai/batch.py +17 -0
  5. mistralai/chat.py +64 -30
  6. mistralai/classifiers.py +396 -0
  7. mistralai/embeddings.py +10 -6
  8. mistralai/files.py +252 -19
  9. mistralai/fim.py +40 -30
  10. mistralai/jobs.py +40 -20
  11. mistralai/mistral_jobs.py +733 -0
  12. mistralai/models/__init__.py +108 -18
  13. mistralai/models/agentscompletionrequest.py +27 -10
  14. mistralai/models/agentscompletionstreamrequest.py +27 -10
  15. mistralai/models/apiendpoint.py +9 -0
  16. mistralai/models/archiveftmodelout.py +11 -5
  17. mistralai/models/assistantmessage.py +11 -6
  18. mistralai/models/basemodelcard.py +22 -6
  19. mistralai/models/batcherror.py +17 -0
  20. mistralai/models/batchjobin.py +58 -0
  21. mistralai/models/batchjobout.py +117 -0
  22. mistralai/models/batchjobsout.py +30 -0
  23. mistralai/models/batchjobstatus.py +15 -0
  24. mistralai/models/chatclassificationrequest.py +104 -0
  25. mistralai/models/chatcompletionchoice.py +9 -4
  26. mistralai/models/chatcompletionrequest.py +32 -13
  27. mistralai/models/chatcompletionresponse.py +2 -2
  28. mistralai/models/chatcompletionstreamrequest.py +32 -13
  29. mistralai/models/checkpointout.py +1 -1
  30. mistralai/models/classificationobject.py +21 -0
  31. mistralai/models/classificationrequest.py +59 -0
  32. mistralai/models/classificationresponse.py +21 -0
  33. mistralai/models/completionchunk.py +2 -2
  34. mistralai/models/completionevent.py +1 -1
  35. mistralai/models/completionresponsestreamchoice.py +11 -5
  36. mistralai/models/delete_model_v1_models_model_id_deleteop.py +1 -2
  37. mistralai/models/deletefileout.py +1 -1
  38. mistralai/models/deletemodelout.py +2 -2
  39. mistralai/models/deltamessage.py +14 -7
  40. mistralai/models/detailedjobout.py +11 -5
  41. mistralai/models/embeddingrequest.py +5 -5
  42. mistralai/models/embeddingresponse.py +2 -1
  43. mistralai/models/embeddingresponsedata.py +2 -2
  44. mistralai/models/eventout.py +2 -2
  45. mistralai/models/filepurpose.py +8 -0
  46. mistralai/models/files_api_routes_delete_fileop.py +1 -2
  47. mistralai/models/files_api_routes_download_fileop.py +16 -0
  48. mistralai/models/files_api_routes_list_filesop.py +96 -0
  49. mistralai/models/files_api_routes_retrieve_fileop.py +1 -2
  50. mistralai/models/files_api_routes_upload_fileop.py +9 -9
  51. mistralai/models/fileschema.py +7 -21
  52. mistralai/models/fimcompletionrequest.py +20 -13
  53. mistralai/models/fimcompletionresponse.py +2 -2
  54. mistralai/models/fimcompletionstreamrequest.py +20 -13
  55. mistralai/models/ftmodelcapabilitiesout.py +2 -2
  56. mistralai/models/ftmodelcard.py +24 -6
  57. mistralai/models/ftmodelout.py +9 -5
  58. mistralai/models/function.py +2 -2
  59. mistralai/models/functioncall.py +2 -1
  60. mistralai/models/functionname.py +1 -1
  61. mistralai/models/githubrepositoryin.py +11 -5
  62. mistralai/models/githubrepositoryout.py +11 -5
  63. mistralai/models/httpvalidationerror.py +0 -2
  64. mistralai/models/imageurl.py +1 -2
  65. mistralai/models/imageurlchunk.py +11 -5
  66. mistralai/models/jobin.py +2 -2
  67. mistralai/models/jobmetadataout.py +1 -2
  68. mistralai/models/jobout.py +10 -5
  69. mistralai/models/jobs_api_routes_batch_cancel_batch_jobop.py +16 -0
  70. mistralai/models/jobs_api_routes_batch_get_batch_jobop.py +16 -0
  71. mistralai/models/jobs_api_routes_batch_get_batch_jobsop.py +95 -0
  72. mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +1 -2
  73. mistralai/models/jobs_api_routes_fine_tuning_cancel_fine_tuning_jobop.py +1 -2
  74. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobop.py +1 -2
  75. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +2 -2
  76. mistralai/models/jobs_api_routes_fine_tuning_start_fine_tuning_jobop.py +1 -2
  77. mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +1 -2
  78. mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +1 -2
  79. mistralai/models/jobsout.py +9 -5
  80. mistralai/models/legacyjobmetadataout.py +12 -5
  81. mistralai/models/listfilesout.py +5 -1
  82. mistralai/models/metricout.py +1 -2
  83. mistralai/models/modelcapabilities.py +2 -2
  84. mistralai/models/modellist.py +2 -2
  85. mistralai/models/responseformat.py +2 -2
  86. mistralai/models/retrieve_model_v1_models_model_id_getop.py +2 -2
  87. mistralai/models/retrievefileout.py +10 -21
  88. mistralai/models/sampletype.py +6 -2
  89. mistralai/models/security.py +2 -2
  90. mistralai/models/source.py +3 -2
  91. mistralai/models/systemmessage.py +6 -6
  92. mistralai/models/textchunk.py +9 -5
  93. mistralai/models/tool.py +2 -2
  94. mistralai/models/toolcall.py +2 -2
  95. mistralai/models/toolchoice.py +2 -2
  96. mistralai/models/toolmessage.py +2 -2
  97. mistralai/models/trainingfile.py +2 -2
  98. mistralai/models/trainingparameters.py +7 -2
  99. mistralai/models/trainingparametersin.py +7 -2
  100. mistralai/models/unarchiveftmodelout.py +11 -5
  101. mistralai/models/updateftmodelin.py +1 -2
  102. mistralai/models/uploadfileout.py +7 -21
  103. mistralai/models/usageinfo.py +1 -1
  104. mistralai/models/usermessage.py +36 -5
  105. mistralai/models/validationerror.py +2 -1
  106. mistralai/models/wandbintegration.py +11 -5
  107. mistralai/models/wandbintegrationout.py +12 -6
  108. mistralai/models_.py +48 -24
  109. mistralai/sdk.py +7 -0
  110. mistralai/sdkconfiguration.py +7 -7
  111. mistralai/utils/__init__.py +8 -0
  112. mistralai/utils/annotations.py +13 -2
  113. mistralai/utils/serializers.py +25 -0
  114. {mistralai-1.1.0.dist-info → mistralai-1.2.1.dist-info}/METADATA +90 -14
  115. mistralai-1.2.1.dist-info/RECORD +276 -0
  116. {mistralai-1.1.0.dist-info → mistralai-1.2.1.dist-info}/WHEEL +1 -1
  117. mistralai_azure/__init__.py +4 -0
  118. mistralai_azure/_version.py +12 -0
  119. mistralai_azure/chat.py +64 -30
  120. mistralai_azure/models/__init__.py +9 -3
  121. mistralai_azure/models/assistantmessage.py +11 -6
  122. mistralai_azure/models/chatcompletionchoice.py +10 -5
  123. mistralai_azure/models/chatcompletionrequest.py +32 -13
  124. mistralai_azure/models/chatcompletionresponse.py +2 -2
  125. mistralai_azure/models/chatcompletionstreamrequest.py +32 -13
  126. mistralai_azure/models/completionchunk.py +2 -2
  127. mistralai_azure/models/completionevent.py +1 -1
  128. mistralai_azure/models/completionresponsestreamchoice.py +9 -4
  129. mistralai_azure/models/deltamessage.py +14 -7
  130. mistralai_azure/models/function.py +2 -2
  131. mistralai_azure/models/functioncall.py +2 -1
  132. mistralai_azure/models/functionname.py +1 -1
  133. mistralai_azure/models/httpvalidationerror.py +0 -2
  134. mistralai_azure/models/responseformat.py +2 -2
  135. mistralai_azure/models/security.py +1 -2
  136. mistralai_azure/models/systemmessage.py +6 -6
  137. mistralai_azure/models/textchunk.py +9 -5
  138. mistralai_azure/models/tool.py +2 -2
  139. mistralai_azure/models/toolcall.py +2 -2
  140. mistralai_azure/models/toolchoice.py +2 -2
  141. mistralai_azure/models/toolmessage.py +2 -2
  142. mistralai_azure/models/usageinfo.py +1 -1
  143. mistralai_azure/models/usermessage.py +36 -5
  144. mistralai_azure/models/validationerror.py +2 -1
  145. mistralai_azure/sdkconfiguration.py +7 -7
  146. mistralai_azure/utils/__init__.py +8 -0
  147. mistralai_azure/utils/annotations.py +13 -2
  148. mistralai_azure/utils/serializers.py +25 -0
  149. mistralai_gcp/__init__.py +4 -0
  150. mistralai_gcp/_version.py +12 -0
  151. mistralai_gcp/chat.py +64 -30
  152. mistralai_gcp/fim.py +40 -30
  153. mistralai_gcp/models/__init__.py +9 -3
  154. mistralai_gcp/models/assistantmessage.py +11 -6
  155. mistralai_gcp/models/chatcompletionchoice.py +10 -5
  156. mistralai_gcp/models/chatcompletionrequest.py +32 -13
  157. mistralai_gcp/models/chatcompletionresponse.py +2 -2
  158. mistralai_gcp/models/chatcompletionstreamrequest.py +32 -13
  159. mistralai_gcp/models/completionchunk.py +2 -2
  160. mistralai_gcp/models/completionevent.py +1 -1
  161. mistralai_gcp/models/completionresponsestreamchoice.py +9 -4
  162. mistralai_gcp/models/deltamessage.py +14 -7
  163. mistralai_gcp/models/fimcompletionrequest.py +20 -13
  164. mistralai_gcp/models/fimcompletionresponse.py +2 -2
  165. mistralai_gcp/models/fimcompletionstreamrequest.py +20 -13
  166. mistralai_gcp/models/function.py +2 -2
  167. mistralai_gcp/models/functioncall.py +2 -1
  168. mistralai_gcp/models/functionname.py +1 -1
  169. mistralai_gcp/models/httpvalidationerror.py +0 -2
  170. mistralai_gcp/models/responseformat.py +2 -2
  171. mistralai_gcp/models/security.py +1 -2
  172. mistralai_gcp/models/systemmessage.py +6 -6
  173. mistralai_gcp/models/textchunk.py +9 -5
  174. mistralai_gcp/models/tool.py +2 -2
  175. mistralai_gcp/models/toolcall.py +2 -2
  176. mistralai_gcp/models/toolchoice.py +2 -2
  177. mistralai_gcp/models/toolmessage.py +2 -2
  178. mistralai_gcp/models/usageinfo.py +1 -1
  179. mistralai_gcp/models/usermessage.py +36 -5
  180. mistralai_gcp/models/validationerror.py +2 -1
  181. mistralai_gcp/sdk.py +20 -11
  182. mistralai_gcp/sdkconfiguration.py +7 -7
  183. mistralai_gcp/utils/__init__.py +8 -0
  184. mistralai_gcp/utils/annotations.py +13 -2
  185. mistralai_gcp/utils/serializers.py +25 -0
  186. mistralai-1.1.0.dist-info/RECORD +0 -254
  187. {mistralai-1.1.0.dist-info → mistralai-1.2.1.dist-info}/LICENSE +0 -0
@@ -2,10 +2,12 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
5
+ from mistralai.utils import validate_const
5
6
  import pydantic
6
7
  from pydantic import model_serializer
7
- from typing import Final, Literal, Optional, TypedDict
8
- from typing_extensions import Annotated, NotRequired
8
+ from pydantic.functional_validators import AfterValidator
9
+ from typing import Literal, Optional
10
+ from typing_extensions import Annotated, NotRequired, TypedDict
9
11
 
10
12
 
11
13
  WandbIntegrationType = Literal["wandb"]
@@ -16,6 +18,7 @@ class WandbIntegrationTypedDict(TypedDict):
16
18
  r"""The name of the project that the new run will be created under."""
17
19
  api_key: str
18
20
  r"""The WandB API key to use for authentication."""
21
+ type: WandbIntegrationType
19
22
  name: NotRequired[Nullable[str]]
20
23
  r"""A display name to set for the run. If not set, will use the job ID as the name."""
21
24
  run_name: NotRequired[Nullable[str]]
@@ -28,9 +31,12 @@ class WandbIntegration(BaseModel):
28
31
  api_key: str
29
32
  r"""The WandB API key to use for authentication."""
30
33
 
31
- # fmt: off
32
- TYPE: Annotated[Final[Optional[WandbIntegrationType]], pydantic.Field(alias="type")] = "wandb" # type: ignore
33
- # fmt: on
34
+ TYPE: Annotated[
35
+ Annotated[
36
+ Optional[WandbIntegrationType], AfterValidator(validate_const("wandb"))
37
+ ],
38
+ pydantic.Field(alias="type"),
39
+ ] = "wandb"
34
40
 
35
41
  name: OptionalNullable[str] = UNSET
36
42
  r"""A display name to set for the run. If not set, will use the job ID as the name."""
@@ -2,18 +2,21 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
5
+ from mistralai.utils import validate_const
5
6
  import pydantic
6
7
  from pydantic import model_serializer
7
- from typing import Final, Literal, Optional, TypedDict
8
- from typing_extensions import Annotated, NotRequired
8
+ from pydantic.functional_validators import AfterValidator
9
+ from typing import Literal, Optional
10
+ from typing_extensions import Annotated, NotRequired, TypedDict
9
11
 
10
12
 
11
- Type = Literal["wandb"]
13
+ WandbIntegrationOutType = Literal["wandb"]
12
14
 
13
15
 
14
16
  class WandbIntegrationOutTypedDict(TypedDict):
15
17
  project: str
16
18
  r"""The name of the project that the new run will be created under."""
19
+ type: WandbIntegrationOutType
17
20
  name: NotRequired[Nullable[str]]
18
21
  r"""A display name to set for the run. If not set, will use the job ID as the name."""
19
22
  run_name: NotRequired[Nullable[str]]
@@ -23,9 +26,12 @@ class WandbIntegrationOut(BaseModel):
23
26
  project: str
24
27
  r"""The name of the project that the new run will be created under."""
25
28
 
26
- # fmt: off
27
- TYPE: Annotated[Final[Optional[Type]], pydantic.Field(alias="type")] = "wandb" # type: ignore
28
- # fmt: on
29
+ TYPE: Annotated[
30
+ Annotated[
31
+ Optional[WandbIntegrationOutType], AfterValidator(validate_const("wandb"))
32
+ ],
33
+ pydantic.Field(alias="type"),
34
+ ] = "wandb"
29
35
 
30
36
  name: OptionalNullable[str] = UNSET
31
37
  r"""A display name to set for the run. If not set, will use the job ID as the name."""
mistralai/models_.py CHANGED
@@ -76,15 +76,17 @@ class Models(BaseSDK):
76
76
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
77
77
  raise models.HTTPValidationError(data=data)
78
78
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
79
+ http_res_text = utils.stream_to_text(http_res)
79
80
  raise models.SDKError(
80
- "API error occurred", http_res.status_code, http_res.text, http_res
81
+ "API error occurred", http_res.status_code, http_res_text, http_res
81
82
  )
82
83
 
83
84
  content_type = http_res.headers.get("Content-Type")
85
+ http_res_text = utils.stream_to_text(http_res)
84
86
  raise models.SDKError(
85
87
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
86
88
  http_res.status_code,
87
- http_res.text,
89
+ http_res_text,
88
90
  http_res,
89
91
  )
90
92
 
@@ -153,15 +155,17 @@ class Models(BaseSDK):
153
155
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
154
156
  raise models.HTTPValidationError(data=data)
155
157
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
158
+ http_res_text = await utils.stream_to_text_async(http_res)
156
159
  raise models.SDKError(
157
- "API error occurred", http_res.status_code, http_res.text, http_res
160
+ "API error occurred", http_res.status_code, http_res_text, http_res
158
161
  )
159
162
 
160
163
  content_type = http_res.headers.get("Content-Type")
164
+ http_res_text = await utils.stream_to_text_async(http_res)
161
165
  raise models.SDKError(
162
166
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
163
167
  http_res.status_code,
164
- http_res.text,
168
+ http_res_text,
165
169
  http_res,
166
170
  )
167
171
 
@@ -244,15 +248,17 @@ class Models(BaseSDK):
244
248
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
245
249
  raise models.HTTPValidationError(data=data)
246
250
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
251
+ http_res_text = utils.stream_to_text(http_res)
247
252
  raise models.SDKError(
248
- "API error occurred", http_res.status_code, http_res.text, http_res
253
+ "API error occurred", http_res.status_code, http_res_text, http_res
249
254
  )
250
255
 
251
256
  content_type = http_res.headers.get("Content-Type")
257
+ http_res_text = utils.stream_to_text(http_res)
252
258
  raise models.SDKError(
253
259
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
254
260
  http_res.status_code,
255
- http_res.text,
261
+ http_res_text,
256
262
  http_res,
257
263
  )
258
264
 
@@ -335,15 +341,17 @@ class Models(BaseSDK):
335
341
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
336
342
  raise models.HTTPValidationError(data=data)
337
343
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
344
+ http_res_text = await utils.stream_to_text_async(http_res)
338
345
  raise models.SDKError(
339
- "API error occurred", http_res.status_code, http_res.text, http_res
346
+ "API error occurred", http_res.status_code, http_res_text, http_res
340
347
  )
341
348
 
342
349
  content_type = http_res.headers.get("Content-Type")
350
+ http_res_text = await utils.stream_to_text_async(http_res)
343
351
  raise models.SDKError(
344
352
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
345
353
  http_res.status_code,
346
- http_res.text,
354
+ http_res_text,
347
355
  http_res,
348
356
  )
349
357
 
@@ -419,15 +427,17 @@ class Models(BaseSDK):
419
427
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
420
428
  raise models.HTTPValidationError(data=data)
421
429
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
430
+ http_res_text = utils.stream_to_text(http_res)
422
431
  raise models.SDKError(
423
- "API error occurred", http_res.status_code, http_res.text, http_res
432
+ "API error occurred", http_res.status_code, http_res_text, http_res
424
433
  )
425
434
 
426
435
  content_type = http_res.headers.get("Content-Type")
436
+ http_res_text = utils.stream_to_text(http_res)
427
437
  raise models.SDKError(
428
438
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
429
439
  http_res.status_code,
430
- http_res.text,
440
+ http_res_text,
431
441
  http_res,
432
442
  )
433
443
 
@@ -503,15 +513,17 @@ class Models(BaseSDK):
503
513
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
504
514
  raise models.HTTPValidationError(data=data)
505
515
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
516
+ http_res_text = await utils.stream_to_text_async(http_res)
506
517
  raise models.SDKError(
507
- "API error occurred", http_res.status_code, http_res.text, http_res
518
+ "API error occurred", http_res.status_code, http_res_text, http_res
508
519
  )
509
520
 
510
521
  content_type = http_res.headers.get("Content-Type")
522
+ http_res_text = await utils.stream_to_text_async(http_res)
511
523
  raise models.SDKError(
512
524
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
513
525
  http_res.status_code,
514
- http_res.text,
526
+ http_res_text,
515
527
  http_res,
516
528
  )
517
529
 
@@ -594,15 +606,17 @@ class Models(BaseSDK):
594
606
  if utils.match_response(http_res, "200", "application/json"):
595
607
  return utils.unmarshal_json(http_res.text, Optional[models.FTModelOut])
596
608
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
609
+ http_res_text = utils.stream_to_text(http_res)
597
610
  raise models.SDKError(
598
- "API error occurred", http_res.status_code, http_res.text, http_res
611
+ "API error occurred", http_res.status_code, http_res_text, http_res
599
612
  )
600
613
 
601
614
  content_type = http_res.headers.get("Content-Type")
615
+ http_res_text = utils.stream_to_text(http_res)
602
616
  raise models.SDKError(
603
617
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
604
618
  http_res.status_code,
605
- http_res.text,
619
+ http_res_text,
606
620
  http_res,
607
621
  )
608
622
 
@@ -685,15 +699,17 @@ class Models(BaseSDK):
685
699
  if utils.match_response(http_res, "200", "application/json"):
686
700
  return utils.unmarshal_json(http_res.text, Optional[models.FTModelOut])
687
701
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
702
+ http_res_text = await utils.stream_to_text_async(http_res)
688
703
  raise models.SDKError(
689
- "API error occurred", http_res.status_code, http_res.text, http_res
704
+ "API error occurred", http_res.status_code, http_res_text, http_res
690
705
  )
691
706
 
692
707
  content_type = http_res.headers.get("Content-Type")
708
+ http_res_text = await utils.stream_to_text_async(http_res)
693
709
  raise models.SDKError(
694
710
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
695
711
  http_res.status_code,
696
- http_res.text,
712
+ http_res_text,
697
713
  http_res,
698
714
  )
699
715
 
@@ -767,15 +783,17 @@ class Models(BaseSDK):
767
783
  http_res.text, Optional[models.ArchiveFTModelOut]
768
784
  )
769
785
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
786
+ http_res_text = utils.stream_to_text(http_res)
770
787
  raise models.SDKError(
771
- "API error occurred", http_res.status_code, http_res.text, http_res
788
+ "API error occurred", http_res.status_code, http_res_text, http_res
772
789
  )
773
790
 
774
791
  content_type = http_res.headers.get("Content-Type")
792
+ http_res_text = utils.stream_to_text(http_res)
775
793
  raise models.SDKError(
776
794
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
777
795
  http_res.status_code,
778
- http_res.text,
796
+ http_res_text,
779
797
  http_res,
780
798
  )
781
799
 
@@ -849,15 +867,17 @@ class Models(BaseSDK):
849
867
  http_res.text, Optional[models.ArchiveFTModelOut]
850
868
  )
851
869
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
870
+ http_res_text = await utils.stream_to_text_async(http_res)
852
871
  raise models.SDKError(
853
- "API error occurred", http_res.status_code, http_res.text, http_res
872
+ "API error occurred", http_res.status_code, http_res_text, http_res
854
873
  )
855
874
 
856
875
  content_type = http_res.headers.get("Content-Type")
876
+ http_res_text = await utils.stream_to_text_async(http_res)
857
877
  raise models.SDKError(
858
878
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
859
879
  http_res.status_code,
860
- http_res.text,
880
+ http_res_text,
861
881
  http_res,
862
882
  )
863
883
 
@@ -931,15 +951,17 @@ class Models(BaseSDK):
931
951
  http_res.text, Optional[models.UnarchiveFTModelOut]
932
952
  )
933
953
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
954
+ http_res_text = utils.stream_to_text(http_res)
934
955
  raise models.SDKError(
935
- "API error occurred", http_res.status_code, http_res.text, http_res
956
+ "API error occurred", http_res.status_code, http_res_text, http_res
936
957
  )
937
958
 
938
959
  content_type = http_res.headers.get("Content-Type")
960
+ http_res_text = utils.stream_to_text(http_res)
939
961
  raise models.SDKError(
940
962
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
941
963
  http_res.status_code,
942
- http_res.text,
964
+ http_res_text,
943
965
  http_res,
944
966
  )
945
967
 
@@ -1013,14 +1035,16 @@ class Models(BaseSDK):
1013
1035
  http_res.text, Optional[models.UnarchiveFTModelOut]
1014
1036
  )
1015
1037
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
1038
+ http_res_text = await utils.stream_to_text_async(http_res)
1016
1039
  raise models.SDKError(
1017
- "API error occurred", http_res.status_code, http_res.text, http_res
1040
+ "API error occurred", http_res.status_code, http_res_text, http_res
1018
1041
  )
1019
1042
 
1020
1043
  content_type = http_res.headers.get("Content-Type")
1044
+ http_res_text = await utils.stream_to_text_async(http_res)
1021
1045
  raise models.SDKError(
1022
1046
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1023
1047
  http_res.status_code,
1024
- http_res.text,
1048
+ http_res_text,
1025
1049
  http_res,
1026
1050
  )
mistralai/sdk.py CHANGED
@@ -9,7 +9,9 @@ import httpx
9
9
  from mistralai import models, utils
10
10
  from mistralai._hooks import SDKHooks
11
11
  from mistralai.agents import Agents
12
+ from mistralai.batch import Batch
12
13
  from mistralai.chat import Chat
14
+ from mistralai.classifiers import Classifiers
13
15
  from mistralai.embeddings import Embeddings
14
16
  from mistralai.files import Files
15
17
  from mistralai.fim import Fim
@@ -27,6 +29,7 @@ class Mistral(BaseSDK):
27
29
  files: Files
28
30
  r"""Files API"""
29
31
  fine_tuning: FineTuning
32
+ batch: Batch
30
33
  chat: Chat
31
34
  r"""Chat Completion API."""
32
35
  fim: Fim
@@ -35,6 +38,8 @@ class Mistral(BaseSDK):
35
38
  r"""Agents API."""
36
39
  embeddings: Embeddings
37
40
  r"""Embeddings API."""
41
+ classifiers: Classifiers
42
+ r"""Classifiers API."""
38
43
 
39
44
  def __init__(
40
45
  self,
@@ -118,7 +123,9 @@ class Mistral(BaseSDK):
118
123
  self.models = Models(self.sdk_configuration)
119
124
  self.files = Files(self.sdk_configuration)
120
125
  self.fine_tuning = FineTuning(self.sdk_configuration)
126
+ self.batch = Batch(self.sdk_configuration)
121
127
  self.chat = Chat(self.sdk_configuration)
122
128
  self.fim = Fim(self.sdk_configuration)
123
129
  self.agents = Agents(self.sdk_configuration)
124
130
  self.embeddings = Embeddings(self.sdk_configuration)
131
+ self.classifiers = Classifiers(self.sdk_configuration)
@@ -10,10 +10,10 @@ from pydantic import Field
10
10
  from typing import Callable, Dict, Optional, Tuple, Union
11
11
 
12
12
 
13
- SERVER_PROD = "prod"
14
- r"""Production server"""
13
+ SERVER_EU = "eu"
14
+ r"""EU Production server"""
15
15
  SERVERS = {
16
- SERVER_PROD: "https://api.mistral.ai",
16
+ SERVER_EU: "https://api.mistral.ai",
17
17
  }
18
18
  """Contains the list of servers available to the SDK"""
19
19
 
@@ -28,9 +28,9 @@ class SDKConfiguration:
28
28
  server: Optional[str] = ""
29
29
  language: str = "python"
30
30
  openapi_doc_version: str = "0.0.2"
31
- sdk_version: str = "1.1.0"
32
- gen_version: str = "2.415.8"
33
- user_agent: str = "speakeasy-sdk/python 1.1.0 2.415.8 0.0.2 mistralai"
31
+ sdk_version: str = "1.2.1"
32
+ gen_version: str = "2.452.0"
33
+ user_agent: str = "speakeasy-sdk/python 1.2.1 2.452.0 0.0.2 mistralai"
34
34
  retry_config: OptionalNullable[RetryConfig] = Field(default_factory=lambda: UNSET)
35
35
  timeout_ms: Optional[int] = None
36
36
 
@@ -41,7 +41,7 @@ class SDKConfiguration:
41
41
  if self.server_url is not None and self.server_url:
42
42
  return remove_suffix(self.server_url, "/"), {}
43
43
  if not self.server:
44
- self.server = SERVER_PROD
44
+ self.server = SERVER_EU
45
45
 
46
46
  if self.server not in SERVERS:
47
47
  raise ValueError(f'Invalid server "{self.server}"')
@@ -28,6 +28,10 @@ from .serializers import (
28
28
  serialize_float,
29
29
  serialize_int,
30
30
  stream_to_text,
31
+ stream_to_text_async,
32
+ stream_to_bytes,
33
+ stream_to_bytes_async,
34
+ validate_const,
31
35
  validate_decimal,
32
36
  validate_float,
33
37
  validate_int,
@@ -81,10 +85,14 @@ __all__ = [
81
85
  "serialize_request_body",
82
86
  "SerializedRequestBody",
83
87
  "stream_to_text",
88
+ "stream_to_text_async",
89
+ "stream_to_bytes",
90
+ "stream_to_bytes_async",
84
91
  "template_url",
85
92
  "unmarshal",
86
93
  "unmarshal_json",
87
94
  "validate_decimal",
95
+ "validate_const",
88
96
  "validate_float",
89
97
  "validate_int",
90
98
  "validate_open_enum",
@@ -1,5 +1,6 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
+ from enum import Enum
3
4
  from typing import Any
4
5
 
5
6
  def get_discriminator(model: Any, fieldname: str, key: str) -> str:
@@ -10,10 +11,20 @@ def get_discriminator(model: Any, fieldname: str, key: str) -> str:
10
11
  raise ValueError(f'Could not find discriminator key {key} in {model}') from e
11
12
 
12
13
  if hasattr(model, fieldname):
13
- return f'{getattr(model, fieldname)}'
14
+ attr = getattr(model, fieldname)
15
+
16
+ if isinstance(attr, Enum):
17
+ return f'{attr.value}'
18
+
19
+ return f'{attr}'
14
20
 
15
21
  fieldname = fieldname.upper()
16
22
  if hasattr(model, fieldname):
17
- return f'{getattr(model, fieldname)}'
23
+ attr = getattr(model, fieldname)
24
+
25
+ if isinstance(attr, Enum):
26
+ return f'{attr.value}'
27
+
28
+ return f'{attr}'
18
29
 
19
30
  raise ValueError(f'Could not find discriminator field {fieldname} in {model}')
@@ -116,6 +116,19 @@ def validate_open_enum(is_int: bool):
116
116
  return validate
117
117
 
118
118
 
119
+ def validate_const(v):
120
+ def validate(c):
121
+ if is_optional_type(type(c)) and c is None:
122
+ return None
123
+
124
+ if v != c:
125
+ raise ValueError(f"Expected {v}")
126
+
127
+ return c
128
+
129
+ return validate
130
+
131
+
119
132
  def unmarshal_json(raw, typ: Any) -> Any:
120
133
  return unmarshal(from_json(raw), typ)
121
134
 
@@ -172,6 +185,18 @@ def stream_to_text(stream: httpx.Response) -> str:
172
185
  return "".join(stream.iter_text())
173
186
 
174
187
 
188
+ async def stream_to_text_async(stream: httpx.Response) -> str:
189
+ return "".join([chunk async for chunk in stream.aiter_text()])
190
+
191
+
192
+ def stream_to_bytes(stream: httpx.Response) -> bytes:
193
+ return stream.content
194
+
195
+
196
+ async def stream_to_bytes_async(stream: httpx.Response) -> bytes:
197
+ return await stream.aread()
198
+
199
+
175
200
  def get_pydantic_model(data: Any, typ: Any) -> Any:
176
201
  if not _contains_pydantic_model(data):
177
202
  return unmarshal(data, typ)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mistralai
3
- Version: 1.1.0
3
+ Version: 1.2.1
4
4
  Summary: Python Client SDK for the Mistral AI API.
5
5
  Home-page: https://github.com/mistralai/client-python.git
6
6
  Author: Mistral
@@ -11,6 +11,7 @@ Classifier: Programming Language :: Python :: 3.9
11
11
  Classifier: Programming Language :: Python :: 3.10
12
12
  Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
14
15
  Provides-Extra: gcp
15
16
  Requires-Dist: eval-type-backport (>=0.2.0,<0.3.0)
16
17
  Requires-Dist: google-auth (==2.27.0) ; extra == "gcp"
@@ -205,7 +206,8 @@ s = Mistral(
205
206
 
206
207
  res = s.agents.complete(messages=[
207
208
  {
208
- "content": "<value>",
209
+ "content": "Who is the best French painter? Answer in one short sentence.",
210
+ "role": "user",
209
211
  },
210
212
  ], agent_id="<value>")
211
213
 
@@ -237,6 +239,53 @@ async def main():
237
239
  # handle response
238
240
  pass
239
241
 
242
+ asyncio.run(main())
243
+ ```
244
+
245
+ ### Create Embedding Request
246
+
247
+ This example shows how to create embedding request.
248
+
249
+ ```python
250
+ # Synchronous Example
251
+ from mistralai import Mistral
252
+ import os
253
+
254
+ s = Mistral(
255
+ api_key=os.getenv("MISTRAL_API_KEY", ""),
256
+ )
257
+
258
+ res = s.embeddings.create(inputs=[
259
+ "Embed this sentence.",
260
+ "As well as this one.",
261
+ ], model="Wrangler")
262
+
263
+ if res is not None:
264
+ # handle response
265
+ pass
266
+ ```
267
+
268
+ </br>
269
+
270
+ The same SDK client can also be used to make asychronous requests by importing asyncio.
271
+ ```python
272
+ # Asynchronous Example
273
+ import asyncio
274
+ from mistralai import Mistral
275
+ import os
276
+
277
+ async def main():
278
+ s = Mistral(
279
+ api_key=os.getenv("MISTRAL_API_KEY", ""),
280
+ )
281
+ res = await s.embeddings.create_async(inputs=[
282
+ "Embed this sentence.",
283
+ "As well as this one.",
284
+ ], model="Wrangler")
285
+ if res is not None:
286
+ # handle response
287
+ pass
288
+
240
289
  asyncio.run(main())
241
290
  ```
242
291
  <!-- End SDK Example Usage [usage] -->
@@ -347,11 +396,26 @@ The documentation for the GCP SDK is available [here](https://github.com/mistral
347
396
  * [complete](https://github.com/mistralai/client-python/blob/master/docs/sdks/agents/README.md#complete) - Agents Completion
348
397
  * [stream](https://github.com/mistralai/client-python/blob/master/docs/sdks/agents/README.md#stream) - Stream Agents completion
349
398
 
399
+ ### [batch](https://github.com/mistralai/client-python/blob/master/docs/sdks/batch/README.md)
400
+
401
+
402
+ #### [batch.jobs](https://github.com/mistralai/client-python/blob/master/docs/sdks/mistraljobs/README.md)
403
+
404
+ * [list](https://github.com/mistralai/client-python/blob/master/docs/sdks/mistraljobs/README.md#list) - Get Batch Jobs
405
+ * [create](https://github.com/mistralai/client-python/blob/master/docs/sdks/mistraljobs/README.md#create) - Create Batch Job
406
+ * [get](https://github.com/mistralai/client-python/blob/master/docs/sdks/mistraljobs/README.md#get) - Get Batch Job
407
+ * [cancel](https://github.com/mistralai/client-python/blob/master/docs/sdks/mistraljobs/README.md#cancel) - Cancel Batch Job
408
+
350
409
  ### [chat](https://github.com/mistralai/client-python/blob/master/docs/sdks/chat/README.md)
351
410
 
352
411
  * [complete](https://github.com/mistralai/client-python/blob/master/docs/sdks/chat/README.md#complete) - Chat Completion
353
412
  * [stream](https://github.com/mistralai/client-python/blob/master/docs/sdks/chat/README.md#stream) - Stream chat completion
354
413
 
414
+ ### [classifiers](https://github.com/mistralai/client-python/blob/master/docs/sdks/classifiers/README.md)
415
+
416
+ * [moderate](https://github.com/mistralai/client-python/blob/master/docs/sdks/classifiers/README.md#moderate) - Moderations
417
+ * [moderate_chat](https://github.com/mistralai/client-python/blob/master/docs/sdks/classifiers/README.md#moderate_chat) - Moderations Chat
418
+
355
419
  ### [embeddings](https://github.com/mistralai/client-python/blob/master/docs/sdks/embeddings/README.md)
356
420
 
357
421
  * [create](https://github.com/mistralai/client-python/blob/master/docs/sdks/embeddings/README.md#create) - Embeddings
@@ -362,6 +426,7 @@ The documentation for the GCP SDK is available [here](https://github.com/mistral
362
426
  * [list](https://github.com/mistralai/client-python/blob/master/docs/sdks/files/README.md#list) - List Files
363
427
  * [retrieve](https://github.com/mistralai/client-python/blob/master/docs/sdks/files/README.md#retrieve) - Retrieve File
364
428
  * [delete](https://github.com/mistralai/client-python/blob/master/docs/sdks/files/README.md#delete) - Delete File
429
+ * [download](https://github.com/mistralai/client-python/blob/master/docs/sdks/files/README.md#download) - Download File
365
430
 
366
431
  ### [fim](https://github.com/mistralai/client-python/blob/master/docs/sdks/fim/README.md)
367
432
 
@@ -504,12 +569,23 @@ if res is not None:
504
569
  <!-- Start Error Handling [errors] -->
505
570
  ## Error Handling
506
571
 
507
- Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an error. If Error objects are specified in your OpenAPI Spec, the SDK will raise the appropriate Error type.
572
+ Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception.
573
+
574
+ By default, an API error will raise a models.SDKError exception, which has the following properties:
575
+
576
+ | Property | Type | Description |
577
+ |-----------------|------------------|-----------------------|
578
+ | `.status_code` | *int* | The HTTP status code |
579
+ | `.message` | *str* | The error message |
580
+ | `.raw_response` | *httpx.Response* | The raw HTTP response |
581
+ | `.body` | *str* | The response content |
582
+
583
+ When custom error responses are specified for an operation, the SDK may also raise their associated exceptions. You can refer to respective *Errors* tables in SDK docs for more details on possible exception types for each operation. For example, the `list_async` method may raise the following exceptions:
508
584
 
509
- | Error Object | Status Code | Content Type |
510
- | -------------------------- | ----------- | ---------------- |
511
- | models.HTTPValidationError | 422 | application/json |
512
- | models.SDKError | 4xx-5xx | */* |
585
+ | Error Type | Status Code | Content Type |
586
+ | -------------------------- | -------------------------- | -------------------------- |
587
+ | models.HTTPValidationError | 422 | application/json |
588
+ | models.SDKError | 4XX, 5XX | \*/\* |
513
589
 
514
590
  ### Example
515
591
 
@@ -545,9 +621,9 @@ except models.SDKError as e:
545
621
 
546
622
  You can override the default server globally by passing a server name to the `server: str` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the names associated with the available servers:
547
623
 
548
- | Name | Server | Variables |
549
- | ------ | ------------------------ | --------- |
550
- | `prod` | `https://api.mistral.ai` | None |
624
+ | Name | Server | Variables |
625
+ | ----- | ------ | --------- |
626
+ | `eu` | `https://api.mistral.ai` | None |
551
627
 
552
628
  #### Example
553
629
 
@@ -556,7 +632,7 @@ from mistralai import Mistral
556
632
  import os
557
633
 
558
634
  s = Mistral(
559
- server="prod",
635
+ server="eu",
560
636
  api_key=os.getenv("MISTRAL_API_KEY", ""),
561
637
  )
562
638
 
@@ -678,9 +754,9 @@ s = Mistral(async_client=CustomClient(httpx.AsyncClient()))
678
754
 
679
755
  This SDK supports the following security scheme globally:
680
756
 
681
- | Name | Type | Scheme | Environment Variable |
682
- | --------- | ---- | ----------- | -------------------- |
683
- | `api_key` | http | HTTP Bearer | `MISTRAL_API_KEY` |
757
+ | Name | Type | Scheme | Environment Variable |
758
+ | -------------------- | -------------------- | -------------------- | -------------------- |
759
+ | `api_key` | http | HTTP Bearer | `MISTRAL_API_KEY` |
684
760
 
685
761
  To authenticate with the API the `api_key` parameter must be set when initializing the SDK client instance. For example:
686
762
  ```python