mistralai 1.2.3__py3-none-any.whl → 1.2.4__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 (85) hide show
  1. mistralai/_version.py +1 -1
  2. mistralai/agents.py +5 -5
  3. mistralai/chat.py +5 -5
  4. mistralai/files.py +166 -0
  5. mistralai/fim.py +5 -5
  6. mistralai/httpclient.py +6 -0
  7. mistralai/jobs.py +2 -2
  8. mistralai/models/__init__.py +9 -2
  9. mistralai/models/agentscompletionrequest.py +23 -11
  10. mistralai/models/agentscompletionstreamrequest.py +23 -13
  11. mistralai/models/apiendpoint.py +11 -3
  12. mistralai/models/assistantmessage.py +7 -3
  13. mistralai/models/batchjobin.py +4 -2
  14. mistralai/models/chatclassificationrequest.py +26 -17
  15. mistralai/models/chatcompletionrequest.py +19 -11
  16. mistralai/models/chatcompletionstreamrequest.py +23 -13
  17. mistralai/models/classificationrequest.py +7 -3
  18. mistralai/models/contentchunk.py +5 -4
  19. mistralai/models/deltamessage.py +5 -3
  20. mistralai/models/detailedjobout.py +2 -3
  21. mistralai/models/embeddingrequest.py +3 -3
  22. mistralai/models/files_api_routes_get_signed_urlop.py +25 -0
  23. mistralai/models/filesignedurl.py +13 -0
  24. mistralai/models/fimcompletionrequest.py +7 -3
  25. mistralai/models/fimcompletionstreamrequest.py +7 -3
  26. mistralai/models/functioncall.py +3 -3
  27. mistralai/models/imageurlchunk.py +9 -14
  28. mistralai/models/jobin.py +2 -3
  29. mistralai/models/jobout.py +2 -3
  30. mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +9 -4
  31. mistralai/models/modellist.py +4 -2
  32. mistralai/models/referencechunk.py +3 -11
  33. mistralai/models/retrieve_model_v1_models_model_id_getop.py +5 -4
  34. mistralai/models/systemmessage.py +7 -3
  35. mistralai/models/textchunk.py +3 -9
  36. mistralai/models/toolmessage.py +5 -3
  37. mistralai/models/usermessage.py +5 -3
  38. mistralai/models/validationerror.py +3 -3
  39. mistralai/sdk.py +14 -0
  40. mistralai/sdkconfiguration.py +3 -3
  41. mistralai/utils/annotations.py +42 -17
  42. mistralai/utils/eventstreaming.py +61 -1
  43. {mistralai-1.2.3.dist-info → mistralai-1.2.4.dist-info}/METADATA +181 -176
  44. {mistralai-1.2.3.dist-info → mistralai-1.2.4.dist-info}/RECORD +84 -83
  45. mistralai_azure/chat.py +5 -5
  46. mistralai_azure/httpclient.py +6 -0
  47. mistralai_azure/models/assistantmessage.py +7 -3
  48. mistralai_azure/models/chatcompletionrequest.py +23 -11
  49. mistralai_azure/models/chatcompletionstreamrequest.py +19 -13
  50. mistralai_azure/models/contentchunk.py +4 -2
  51. mistralai_azure/models/deltamessage.py +5 -3
  52. mistralai_azure/models/functioncall.py +3 -3
  53. mistralai_azure/models/referencechunk.py +3 -11
  54. mistralai_azure/models/systemmessage.py +7 -3
  55. mistralai_azure/models/textchunk.py +3 -9
  56. mistralai_azure/models/toolmessage.py +5 -3
  57. mistralai_azure/models/usermessage.py +5 -3
  58. mistralai_azure/models/validationerror.py +3 -3
  59. mistralai_azure/sdkconfiguration.py +2 -2
  60. mistralai_azure/utils/annotations.py +42 -17
  61. mistralai_azure/utils/eventstreaming.py +61 -1
  62. mistralai_gcp/chat.py +5 -5
  63. mistralai_gcp/fim.py +5 -5
  64. mistralai_gcp/httpclient.py +6 -0
  65. mistralai_gcp/models/assistantmessage.py +7 -3
  66. mistralai_gcp/models/chatcompletionrequest.py +23 -11
  67. mistralai_gcp/models/chatcompletionstreamrequest.py +19 -13
  68. mistralai_gcp/models/contentchunk.py +4 -2
  69. mistralai_gcp/models/deltamessage.py +5 -3
  70. mistralai_gcp/models/fimcompletionrequest.py +7 -3
  71. mistralai_gcp/models/fimcompletionstreamrequest.py +7 -3
  72. mistralai_gcp/models/functioncall.py +3 -3
  73. mistralai_gcp/models/referencechunk.py +3 -11
  74. mistralai_gcp/models/systemmessage.py +7 -3
  75. mistralai_gcp/models/textchunk.py +3 -9
  76. mistralai_gcp/models/toolmessage.py +5 -3
  77. mistralai_gcp/models/usermessage.py +5 -3
  78. mistralai_gcp/models/validationerror.py +3 -3
  79. mistralai_gcp/sdk.py +5 -4
  80. mistralai_gcp/sdkconfiguration.py +2 -2
  81. mistralai_gcp/utils/annotations.py +42 -17
  82. mistralai_gcp/utils/eventstreaming.py +61 -1
  83. mistralai/models/finetuneablemodel.py +0 -14
  84. {mistralai-1.2.3.dist-info → mistralai-1.2.4.dist-info}/LICENSE +0 -0
  85. {mistralai-1.2.3.dist-info → mistralai-1.2.4.dist-info}/WHEEL +0 -0
mistralai/_version.py CHANGED
@@ -3,7 +3,7 @@
3
3
  import importlib.metadata
4
4
 
5
5
  __title__: str = "mistralai"
6
- __version__: str = "1.2.3"
6
+ __version__: str = "1.2.4"
7
7
 
8
8
  try:
9
9
  if __package__ is not None:
mistralai/agents.py CHANGED
@@ -5,7 +5,7 @@ from mistralai import models, utils
5
5
  from mistralai._hooks import HookContext
6
6
  from mistralai.types import OptionalNullable, UNSET
7
7
  from mistralai.utils import eventstreaming, get_security_from_env
8
- from typing import Any, AsyncGenerator, Generator, List, Optional, Union
8
+ from typing import Any, List, Optional, Union
9
9
 
10
10
 
11
11
  class Agents(BaseSDK):
@@ -336,7 +336,7 @@ class Agents(BaseSDK):
336
336
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
337
337
  server_url: Optional[str] = None,
338
338
  timeout_ms: Optional[int] = None,
339
- ) -> Optional[Generator[models.CompletionEvent, None, None]]:
339
+ ) -> Optional[eventstreaming.EventStream[models.CompletionEvent]]:
340
340
  r"""Stream Agents completion
341
341
 
342
342
  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.
@@ -428,7 +428,7 @@ class Agents(BaseSDK):
428
428
 
429
429
  data: Any = None
430
430
  if utils.match_response(http_res, "200", "text/event-stream"):
431
- return eventstreaming.stream_events(
431
+ return eventstreaming.EventStream(
432
432
  http_res,
433
433
  lambda raw: utils.unmarshal_json(raw, models.CompletionEvent),
434
434
  sentinel="[DONE]",
@@ -487,7 +487,7 @@ class Agents(BaseSDK):
487
487
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
488
488
  server_url: Optional[str] = None,
489
489
  timeout_ms: Optional[int] = None,
490
- ) -> Optional[AsyncGenerator[models.CompletionEvent, None]]:
490
+ ) -> Optional[eventstreaming.EventStreamAsync[models.CompletionEvent]]:
491
491
  r"""Stream Agents completion
492
492
 
493
493
  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.
@@ -579,7 +579,7 @@ class Agents(BaseSDK):
579
579
 
580
580
  data: Any = None
581
581
  if utils.match_response(http_res, "200", "text/event-stream"):
582
- return eventstreaming.stream_events_async(
582
+ return eventstreaming.EventStreamAsync(
583
583
  http_res,
584
584
  lambda raw: utils.unmarshal_json(raw, models.CompletionEvent),
585
585
  sentinel="[DONE]",
mistralai/chat.py CHANGED
@@ -5,7 +5,7 @@ from mistralai import models, utils
5
5
  from mistralai._hooks import HookContext
6
6
  from mistralai.types import Nullable, OptionalNullable, UNSET
7
7
  from mistralai.utils import eventstreaming, get_security_from_env
8
- from typing import Any, AsyncGenerator, Generator, List, Optional, Union
8
+ from typing import Any, List, Optional, Union
9
9
 
10
10
 
11
11
  class Chat(BaseSDK):
@@ -337,7 +337,7 @@ class Chat(BaseSDK):
337
337
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
338
338
  server_url: Optional[str] = None,
339
339
  timeout_ms: Optional[int] = None,
340
- ) -> Optional[Generator[models.CompletionEvent, None, None]]:
340
+ ) -> Optional[eventstreaming.EventStream[models.CompletionEvent]]:
341
341
  r"""Stream chat completion
342
342
 
343
343
  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.
@@ -435,7 +435,7 @@ class Chat(BaseSDK):
435
435
 
436
436
  data: Any = None
437
437
  if utils.match_response(http_res, "200", "text/event-stream"):
438
- return eventstreaming.stream_events(
438
+ return eventstreaming.EventStream(
439
439
  http_res,
440
440
  lambda raw: utils.unmarshal_json(raw, models.CompletionEvent),
441
441
  sentinel="[DONE]",
@@ -497,7 +497,7 @@ class Chat(BaseSDK):
497
497
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
498
498
  server_url: Optional[str] = None,
499
499
  timeout_ms: Optional[int] = None,
500
- ) -> Optional[AsyncGenerator[models.CompletionEvent, None]]:
500
+ ) -> Optional[eventstreaming.EventStreamAsync[models.CompletionEvent]]:
501
501
  r"""Stream chat completion
502
502
 
503
503
  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.
@@ -595,7 +595,7 @@ class Chat(BaseSDK):
595
595
 
596
596
  data: Any = None
597
597
  if utils.match_response(http_res, "200", "text/event-stream"):
598
- return eventstreaming.stream_events_async(
598
+ return eventstreaming.EventStreamAsync(
599
599
  http_res,
600
600
  lambda raw: utils.unmarshal_json(raw, models.CompletionEvent),
601
601
  sentinel="[DONE]",
mistralai/files.py CHANGED
@@ -891,3 +891,169 @@ class Files(BaseSDK):
891
891
  http_res_text,
892
892
  http_res,
893
893
  )
894
+
895
+ def get_signed_url(
896
+ self,
897
+ *,
898
+ file_id: str,
899
+ expiry: Optional[int] = 24,
900
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
901
+ server_url: Optional[str] = None,
902
+ timeout_ms: Optional[int] = None,
903
+ ) -> Optional[models.FileSignedURL]:
904
+ r"""Get Signed Url
905
+
906
+ :param file_id:
907
+ :param expiry: Number of hours before the url becomes invalid. Defaults to 24h
908
+ :param retries: Override the default retry configuration for this method
909
+ :param server_url: Override the default server URL for this method
910
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
911
+ """
912
+ base_url = None
913
+ url_variables = None
914
+ if timeout_ms is None:
915
+ timeout_ms = self.sdk_configuration.timeout_ms
916
+
917
+ if server_url is not None:
918
+ base_url = server_url
919
+
920
+ request = models.FilesAPIRoutesGetSignedURLRequest(
921
+ file_id=file_id,
922
+ expiry=expiry,
923
+ )
924
+
925
+ req = self.build_request(
926
+ method="GET",
927
+ path="/v1/files/{file_id}/url",
928
+ base_url=base_url,
929
+ url_variables=url_variables,
930
+ request=request,
931
+ request_body_required=False,
932
+ request_has_path_params=True,
933
+ request_has_query_params=True,
934
+ user_agent_header="user-agent",
935
+ accept_header_value="application/json",
936
+ security=self.sdk_configuration.security,
937
+ timeout_ms=timeout_ms,
938
+ )
939
+
940
+ if retries == UNSET:
941
+ if self.sdk_configuration.retry_config is not UNSET:
942
+ retries = self.sdk_configuration.retry_config
943
+
944
+ retry_config = None
945
+ if isinstance(retries, utils.RetryConfig):
946
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
947
+
948
+ http_res = self.do_request(
949
+ hook_ctx=HookContext(
950
+ operation_id="files_api_routes_get_signed_url",
951
+ oauth2_scopes=[],
952
+ security_source=get_security_from_env(
953
+ self.sdk_configuration.security, models.Security
954
+ ),
955
+ ),
956
+ request=req,
957
+ error_status_codes=["4XX", "5XX"],
958
+ retry_config=retry_config,
959
+ )
960
+
961
+ if utils.match_response(http_res, "200", "application/json"):
962
+ return utils.unmarshal_json(http_res.text, Optional[models.FileSignedURL])
963
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
964
+ http_res_text = utils.stream_to_text(http_res)
965
+ raise models.SDKError(
966
+ "API error occurred", http_res.status_code, http_res_text, http_res
967
+ )
968
+
969
+ content_type = http_res.headers.get("Content-Type")
970
+ http_res_text = utils.stream_to_text(http_res)
971
+ raise models.SDKError(
972
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
973
+ http_res.status_code,
974
+ http_res_text,
975
+ http_res,
976
+ )
977
+
978
+ async def get_signed_url_async(
979
+ self,
980
+ *,
981
+ file_id: str,
982
+ expiry: Optional[int] = 24,
983
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
984
+ server_url: Optional[str] = None,
985
+ timeout_ms: Optional[int] = None,
986
+ ) -> Optional[models.FileSignedURL]:
987
+ r"""Get Signed Url
988
+
989
+ :param file_id:
990
+ :param expiry: Number of hours before the url becomes invalid. Defaults to 24h
991
+ :param retries: Override the default retry configuration for this method
992
+ :param server_url: Override the default server URL for this method
993
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
994
+ """
995
+ base_url = None
996
+ url_variables = None
997
+ if timeout_ms is None:
998
+ timeout_ms = self.sdk_configuration.timeout_ms
999
+
1000
+ if server_url is not None:
1001
+ base_url = server_url
1002
+
1003
+ request = models.FilesAPIRoutesGetSignedURLRequest(
1004
+ file_id=file_id,
1005
+ expiry=expiry,
1006
+ )
1007
+
1008
+ req = self.build_request_async(
1009
+ method="GET",
1010
+ path="/v1/files/{file_id}/url",
1011
+ base_url=base_url,
1012
+ url_variables=url_variables,
1013
+ request=request,
1014
+ request_body_required=False,
1015
+ request_has_path_params=True,
1016
+ request_has_query_params=True,
1017
+ user_agent_header="user-agent",
1018
+ accept_header_value="application/json",
1019
+ security=self.sdk_configuration.security,
1020
+ timeout_ms=timeout_ms,
1021
+ )
1022
+
1023
+ if retries == UNSET:
1024
+ if self.sdk_configuration.retry_config is not UNSET:
1025
+ retries = self.sdk_configuration.retry_config
1026
+
1027
+ retry_config = None
1028
+ if isinstance(retries, utils.RetryConfig):
1029
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
1030
+
1031
+ http_res = await self.do_request_async(
1032
+ hook_ctx=HookContext(
1033
+ operation_id="files_api_routes_get_signed_url",
1034
+ oauth2_scopes=[],
1035
+ security_source=get_security_from_env(
1036
+ self.sdk_configuration.security, models.Security
1037
+ ),
1038
+ ),
1039
+ request=req,
1040
+ error_status_codes=["4XX", "5XX"],
1041
+ retry_config=retry_config,
1042
+ )
1043
+
1044
+ if utils.match_response(http_res, "200", "application/json"):
1045
+ return utils.unmarshal_json(http_res.text, Optional[models.FileSignedURL])
1046
+ if utils.match_response(http_res, ["4XX", "5XX"], "*"):
1047
+ http_res_text = await utils.stream_to_text_async(http_res)
1048
+ raise models.SDKError(
1049
+ "API error occurred", http_res.status_code, http_res_text, http_res
1050
+ )
1051
+
1052
+ content_type = http_res.headers.get("Content-Type")
1053
+ http_res_text = await utils.stream_to_text_async(http_res)
1054
+ raise models.SDKError(
1055
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1056
+ http_res.status_code,
1057
+ http_res_text,
1058
+ http_res,
1059
+ )
mistralai/fim.py CHANGED
@@ -5,7 +5,7 @@ from mistralai import models, utils
5
5
  from mistralai._hooks import HookContext
6
6
  from mistralai.types import Nullable, OptionalNullable, UNSET
7
7
  from mistralai.utils import eventstreaming, get_security_from_env
8
- from typing import Any, AsyncGenerator, Generator, Optional, Union
8
+ from typing import Any, Optional, Union
9
9
 
10
10
 
11
11
  class Fim(BaseSDK):
@@ -278,7 +278,7 @@ class Fim(BaseSDK):
278
278
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
279
279
  server_url: Optional[str] = None,
280
280
  timeout_ms: Optional[int] = None,
281
- ) -> Optional[Generator[models.CompletionEvent, None, None]]:
281
+ ) -> Optional[eventstreaming.EventStream[models.CompletionEvent]]:
282
282
  r"""Stream fim completion
283
283
 
284
284
  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,7 +360,7 @@ class Fim(BaseSDK):
360
360
 
361
361
  data: Any = None
362
362
  if utils.match_response(http_res, "200", "text/event-stream"):
363
- return eventstreaming.stream_events(
363
+ return eventstreaming.EventStream(
364
364
  http_res,
365
365
  lambda raw: utils.unmarshal_json(raw, models.CompletionEvent),
366
366
  sentinel="[DONE]",
@@ -405,7 +405,7 @@ class Fim(BaseSDK):
405
405
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
406
406
  server_url: Optional[str] = None,
407
407
  timeout_ms: Optional[int] = None,
408
- ) -> Optional[AsyncGenerator[models.CompletionEvent, None]]:
408
+ ) -> Optional[eventstreaming.EventStreamAsync[models.CompletionEvent]]:
409
409
  r"""Stream fim completion
410
410
 
411
411
  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.
@@ -487,7 +487,7 @@ class Fim(BaseSDK):
487
487
 
488
488
  data: Any = None
489
489
  if utils.match_response(http_res, "200", "text/event-stream"):
490
- return eventstreaming.stream_events_async(
490
+ return eventstreaming.EventStreamAsync(
491
491
  http_res,
492
492
  lambda raw: utils.unmarshal_json(raw, models.CompletionEvent),
493
493
  sentinel="[DONE]",
mistralai/httpclient.py CHANGED
@@ -41,6 +41,9 @@ class HttpClient(Protocol):
41
41
  ) -> httpx.Request:
42
42
  pass
43
43
 
44
+ def close(self) -> None:
45
+ pass
46
+
44
47
 
45
48
  @runtime_checkable
46
49
  class AsyncHttpClient(Protocol):
@@ -76,3 +79,6 @@ class AsyncHttpClient(Protocol):
76
79
  extensions: Optional[httpx._types.RequestExtensions] = None,
77
80
  ) -> httpx.Request:
78
81
  pass
82
+
83
+ async def aclose(self) -> None:
84
+ pass
mistralai/jobs.py CHANGED
@@ -225,7 +225,7 @@ class Jobs(BaseSDK):
225
225
  def create(
226
226
  self,
227
227
  *,
228
- model: models.FineTuneableModel,
228
+ model: str,
229
229
  hyperparameters: Union[
230
230
  models.TrainingParametersIn, models.TrainingParametersInTypedDict
231
231
  ],
@@ -354,7 +354,7 @@ class Jobs(BaseSDK):
354
354
  async def create_async(
355
355
  self,
356
356
  *,
357
- model: models.FineTuneableModel,
357
+ model: str,
358
358
  hyperparameters: Union[
359
359
  models.TrainingParametersIn, models.TrainingParametersInTypedDict
360
360
  ],
@@ -133,6 +133,10 @@ from .files_api_routes_download_fileop import (
133
133
  FilesAPIRoutesDownloadFileRequest,
134
134
  FilesAPIRoutesDownloadFileRequestTypedDict,
135
135
  )
136
+ from .files_api_routes_get_signed_urlop import (
137
+ FilesAPIRoutesGetSignedURLRequest,
138
+ FilesAPIRoutesGetSignedURLRequestTypedDict,
139
+ )
136
140
  from .files_api_routes_list_filesop import (
137
141
  FilesAPIRoutesListFilesRequest,
138
142
  FilesAPIRoutesListFilesRequestTypedDict,
@@ -148,6 +152,7 @@ from .files_api_routes_upload_fileop import (
148
152
  FilesAPIRoutesUploadFileMultiPartBodyParamsTypedDict,
149
153
  )
150
154
  from .fileschema import FileSchema, FileSchemaTypedDict
155
+ from .filesignedurl import FileSignedURL, FileSignedURLTypedDict
151
156
  from .fimcompletionrequest import (
152
157
  FIMCompletionRequest,
153
158
  FIMCompletionRequestStop,
@@ -161,7 +166,6 @@ from .fimcompletionstreamrequest import (
161
166
  FIMCompletionStreamRequestStopTypedDict,
162
167
  FIMCompletionStreamRequestTypedDict,
163
168
  )
164
- from .finetuneablemodel import FineTuneableModel
165
169
  from .ftmodelcapabilitiesout import (
166
170
  FTModelCapabilitiesOut,
167
171
  FTModelCapabilitiesOutTypedDict,
@@ -468,18 +472,21 @@ __all__ = [
468
472
  "FilePurpose",
469
473
  "FileSchema",
470
474
  "FileSchemaTypedDict",
475
+ "FileSignedURL",
476
+ "FileSignedURLTypedDict",
471
477
  "FileTypedDict",
472
478
  "FilesAPIRoutesDeleteFileRequest",
473
479
  "FilesAPIRoutesDeleteFileRequestTypedDict",
474
480
  "FilesAPIRoutesDownloadFileRequest",
475
481
  "FilesAPIRoutesDownloadFileRequestTypedDict",
482
+ "FilesAPIRoutesGetSignedURLRequest",
483
+ "FilesAPIRoutesGetSignedURLRequestTypedDict",
476
484
  "FilesAPIRoutesListFilesRequest",
477
485
  "FilesAPIRoutesListFilesRequestTypedDict",
478
486
  "FilesAPIRoutesRetrieveFileRequest",
479
487
  "FilesAPIRoutesRetrieveFileRequestTypedDict",
480
488
  "FilesAPIRoutesUploadFileMultiPartBodyParams",
481
489
  "FilesAPIRoutesUploadFileMultiPartBodyParamsTypedDict",
482
- "FineTuneableModel",
483
490
  "FinishReason",
484
491
  "Function",
485
492
  "FunctionCall",
@@ -13,23 +13,30 @@ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_
13
13
  from mistralai.utils import get_discriminator
14
14
  from pydantic import Discriminator, Tag, model_serializer
15
15
  from typing import List, Optional, Union
16
- from typing_extensions import Annotated, NotRequired, TypedDict
16
+ from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
17
17
 
18
18
 
19
- AgentsCompletionRequestStopTypedDict = Union[str, List[str]]
19
+ AgentsCompletionRequestStopTypedDict = TypeAliasType(
20
+ "AgentsCompletionRequestStopTypedDict", Union[str, List[str]]
21
+ )
20
22
  r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
21
23
 
22
24
 
23
- AgentsCompletionRequestStop = Union[str, List[str]]
25
+ AgentsCompletionRequestStop = TypeAliasType(
26
+ "AgentsCompletionRequestStop", Union[str, List[str]]
27
+ )
24
28
  r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
25
29
 
26
30
 
27
- AgentsCompletionRequestMessagesTypedDict = Union[
28
- SystemMessageTypedDict,
29
- UserMessageTypedDict,
30
- AssistantMessageTypedDict,
31
- ToolMessageTypedDict,
32
- ]
31
+ AgentsCompletionRequestMessagesTypedDict = TypeAliasType(
32
+ "AgentsCompletionRequestMessagesTypedDict",
33
+ Union[
34
+ SystemMessageTypedDict,
35
+ UserMessageTypedDict,
36
+ AssistantMessageTypedDict,
37
+ ToolMessageTypedDict,
38
+ ],
39
+ )
33
40
 
34
41
 
35
42
  AgentsCompletionRequestMessages = Annotated[
@@ -43,10 +50,15 @@ AgentsCompletionRequestMessages = Annotated[
43
50
  ]
44
51
 
45
52
 
46
- AgentsCompletionRequestToolChoiceTypedDict = Union[ToolChoiceTypedDict, ToolChoiceEnum]
53
+ AgentsCompletionRequestToolChoiceTypedDict = TypeAliasType(
54
+ "AgentsCompletionRequestToolChoiceTypedDict",
55
+ Union[ToolChoiceTypedDict, ToolChoiceEnum],
56
+ )
47
57
 
48
58
 
49
- AgentsCompletionRequestToolChoice = Union[ToolChoice, ToolChoiceEnum]
59
+ AgentsCompletionRequestToolChoice = TypeAliasType(
60
+ "AgentsCompletionRequestToolChoice", Union[ToolChoice, ToolChoiceEnum]
61
+ )
50
62
 
51
63
 
52
64
  class AgentsCompletionRequestTypedDict(TypedDict):
@@ -13,23 +13,30 @@ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_
13
13
  from mistralai.utils import get_discriminator
14
14
  from pydantic import Discriminator, Tag, model_serializer
15
15
  from typing import List, Optional, Union
16
- from typing_extensions import Annotated, NotRequired, TypedDict
16
+ from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
17
17
 
18
18
 
19
- AgentsCompletionStreamRequestStopTypedDict = Union[str, List[str]]
19
+ AgentsCompletionStreamRequestStopTypedDict = TypeAliasType(
20
+ "AgentsCompletionStreamRequestStopTypedDict", Union[str, List[str]]
21
+ )
20
22
  r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
21
23
 
22
24
 
23
- AgentsCompletionStreamRequestStop = Union[str, List[str]]
25
+ AgentsCompletionStreamRequestStop = TypeAliasType(
26
+ "AgentsCompletionStreamRequestStop", Union[str, List[str]]
27
+ )
24
28
  r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
25
29
 
26
30
 
27
- AgentsCompletionStreamRequestMessagesTypedDict = Union[
28
- SystemMessageTypedDict,
29
- UserMessageTypedDict,
30
- AssistantMessageTypedDict,
31
- ToolMessageTypedDict,
32
- ]
31
+ AgentsCompletionStreamRequestMessagesTypedDict = TypeAliasType(
32
+ "AgentsCompletionStreamRequestMessagesTypedDict",
33
+ Union[
34
+ SystemMessageTypedDict,
35
+ UserMessageTypedDict,
36
+ AssistantMessageTypedDict,
37
+ ToolMessageTypedDict,
38
+ ],
39
+ )
33
40
 
34
41
 
35
42
  AgentsCompletionStreamRequestMessages = Annotated[
@@ -43,12 +50,15 @@ AgentsCompletionStreamRequestMessages = Annotated[
43
50
  ]
44
51
 
45
52
 
46
- AgentsCompletionStreamRequestToolChoiceTypedDict = Union[
47
- ToolChoiceTypedDict, ToolChoiceEnum
48
- ]
53
+ AgentsCompletionStreamRequestToolChoiceTypedDict = TypeAliasType(
54
+ "AgentsCompletionStreamRequestToolChoiceTypedDict",
55
+ Union[ToolChoiceTypedDict, ToolChoiceEnum],
56
+ )
49
57
 
50
58
 
51
- AgentsCompletionStreamRequestToolChoice = Union[ToolChoice, ToolChoiceEnum]
59
+ AgentsCompletionStreamRequestToolChoice = TypeAliasType(
60
+ "AgentsCompletionStreamRequestToolChoice", Union[ToolChoice, ToolChoiceEnum]
61
+ )
52
62
 
53
63
 
54
64
  class AgentsCompletionStreamRequestTypedDict(TypedDict):
@@ -1,9 +1,17 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from typing import Literal
4
+ from mistralai.types import UnrecognizedStr
5
+ from typing import Literal, Union
5
6
 
6
7
 
7
- APIEndpoint = Literal[
8
- "/v1/chat/completions", "/v1/embeddings", "/v1/fim/completions", "/v1/moderations"
8
+ APIEndpoint = Union[
9
+ Literal[
10
+ "/v1/chat/completions",
11
+ "/v1/embeddings",
12
+ "/v1/fim/completions",
13
+ "/v1/moderations",
14
+ "/v1/chat/moderations",
15
+ ],
16
+ UnrecognizedStr,
9
17
  ]
@@ -6,13 +6,17 @@ from .toolcall import ToolCall, ToolCallTypedDict
6
6
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
7
7
  from pydantic import model_serializer
8
8
  from typing import List, Literal, Optional, Union
9
- from typing_extensions import NotRequired, TypedDict
9
+ from typing_extensions import NotRequired, TypeAliasType, TypedDict
10
10
 
11
11
 
12
- AssistantMessageContentTypedDict = Union[str, List[ContentChunkTypedDict]]
12
+ AssistantMessageContentTypedDict = TypeAliasType(
13
+ "AssistantMessageContentTypedDict", Union[str, List[ContentChunkTypedDict]]
14
+ )
13
15
 
14
16
 
15
- AssistantMessageContent = Union[str, List[ContentChunk]]
17
+ AssistantMessageContent = TypeAliasType(
18
+ "AssistantMessageContent", Union[str, List[ContentChunk]]
19
+ )
16
20
 
17
21
 
18
22
  AssistantMessageRole = Literal["assistant"]
@@ -3,9 +3,11 @@
3
3
  from __future__ import annotations
4
4
  from .apiendpoint import APIEndpoint
5
5
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
6
+ from mistralai.utils import validate_open_enum
6
7
  from pydantic import model_serializer
8
+ from pydantic.functional_validators import PlainValidator
7
9
  from typing import Dict, List, Optional
8
- from typing_extensions import NotRequired, TypedDict
10
+ from typing_extensions import Annotated, NotRequired, TypedDict
9
11
 
10
12
 
11
13
  class BatchJobInTypedDict(TypedDict):
@@ -19,7 +21,7 @@ class BatchJobInTypedDict(TypedDict):
19
21
  class BatchJobIn(BaseModel):
20
22
  input_files: List[str]
21
23
 
22
- endpoint: APIEndpoint
24
+ endpoint: Annotated[APIEndpoint, PlainValidator(validate_open_enum(False))]
23
25
 
24
26
  model: str
25
27
 
@@ -10,15 +10,18 @@ from mistralai.utils import get_discriminator
10
10
  import pydantic
11
11
  from pydantic import Discriminator, Tag, model_serializer
12
12
  from typing import List, Union
13
- from typing_extensions import Annotated, TypedDict
13
+ from typing_extensions import Annotated, TypeAliasType, TypedDict
14
14
 
15
15
 
16
- TwoTypedDict = Union[
17
- SystemMessageTypedDict,
18
- UserMessageTypedDict,
19
- AssistantMessageTypedDict,
20
- ToolMessageTypedDict,
21
- ]
16
+ TwoTypedDict = TypeAliasType(
17
+ "TwoTypedDict",
18
+ Union[
19
+ SystemMessageTypedDict,
20
+ UserMessageTypedDict,
21
+ AssistantMessageTypedDict,
22
+ ToolMessageTypedDict,
23
+ ],
24
+ )
22
25
 
23
26
 
24
27
  Two = Annotated[
@@ -32,12 +35,15 @@ Two = Annotated[
32
35
  ]
33
36
 
34
37
 
35
- OneTypedDict = Union[
36
- SystemMessageTypedDict,
37
- UserMessageTypedDict,
38
- AssistantMessageTypedDict,
39
- ToolMessageTypedDict,
40
- ]
38
+ OneTypedDict = TypeAliasType(
39
+ "OneTypedDict",
40
+ Union[
41
+ SystemMessageTypedDict,
42
+ UserMessageTypedDict,
43
+ AssistantMessageTypedDict,
44
+ ToolMessageTypedDict,
45
+ ],
46
+ )
41
47
 
42
48
 
43
49
  One = Annotated[
@@ -51,13 +57,16 @@ One = Annotated[
51
57
  ]
52
58
 
53
59
 
54
- ChatClassificationRequestInputsTypedDict = Union[
55
- List[OneTypedDict], List[List[TwoTypedDict]]
56
- ]
60
+ ChatClassificationRequestInputsTypedDict = TypeAliasType(
61
+ "ChatClassificationRequestInputsTypedDict",
62
+ Union[List[OneTypedDict], List[List[TwoTypedDict]]],
63
+ )
57
64
  r"""Chat to classify"""
58
65
 
59
66
 
60
- ChatClassificationRequestInputs = Union[List[One], List[List[Two]]]
67
+ ChatClassificationRequestInputs = TypeAliasType(
68
+ "ChatClassificationRequestInputs", Union[List[One], List[List[Two]]]
69
+ )
61
70
  r"""Chat to classify"""
62
71
 
63
72