mistralai 1.0.3__py3-none-any.whl → 1.2.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.
Files changed (230) hide show
  1. mistralai/__init__.py +4 -0
  2. mistralai/_hooks/sdkhooks.py +23 -4
  3. mistralai/_hooks/types.py +27 -9
  4. mistralai/_version.py +12 -0
  5. mistralai/agents.py +334 -164
  6. mistralai/basesdk.py +90 -5
  7. mistralai/batch.py +17 -0
  8. mistralai/chat.py +316 -166
  9. mistralai/classifiers.py +396 -0
  10. mistralai/embeddings.py +79 -55
  11. mistralai/files.py +487 -194
  12. mistralai/fim.py +206 -132
  13. mistralai/fine_tuning.py +3 -2
  14. mistralai/jobs.py +392 -263
  15. mistralai/mistral_jobs.py +733 -0
  16. mistralai/models/__init__.py +593 -50
  17. mistralai/models/agentscompletionrequest.py +70 -17
  18. mistralai/models/agentscompletionstreamrequest.py +72 -17
  19. mistralai/models/apiendpoint.py +9 -0
  20. mistralai/models/archiveftmodelout.py +15 -5
  21. mistralai/models/assistantmessage.py +22 -10
  22. mistralai/models/{modelcard.py → basemodelcard.py} +53 -14
  23. mistralai/models/batcherror.py +17 -0
  24. mistralai/models/batchjobin.py +58 -0
  25. mistralai/models/batchjobout.py +117 -0
  26. mistralai/models/batchjobsout.py +30 -0
  27. mistralai/models/batchjobstatus.py +15 -0
  28. mistralai/models/chatclassificationrequest.py +104 -0
  29. mistralai/models/chatcompletionchoice.py +13 -6
  30. mistralai/models/chatcompletionrequest.py +86 -21
  31. mistralai/models/chatcompletionresponse.py +8 -4
  32. mistralai/models/chatcompletionstreamrequest.py +88 -21
  33. mistralai/models/checkpointout.py +4 -3
  34. mistralai/models/classificationobject.py +21 -0
  35. mistralai/models/classificationrequest.py +59 -0
  36. mistralai/models/classificationresponse.py +21 -0
  37. mistralai/models/completionchunk.py +12 -5
  38. mistralai/models/completionevent.py +2 -3
  39. mistralai/models/completionresponsestreamchoice.py +22 -8
  40. mistralai/models/contentchunk.py +13 -10
  41. mistralai/models/delete_model_v1_models_model_id_deleteop.py +5 -5
  42. mistralai/models/deletefileout.py +4 -3
  43. mistralai/models/deletemodelout.py +5 -4
  44. mistralai/models/deltamessage.py +23 -11
  45. mistralai/models/detailedjobout.py +70 -12
  46. mistralai/models/embeddingrequest.py +14 -9
  47. mistralai/models/embeddingresponse.py +7 -3
  48. mistralai/models/embeddingresponsedata.py +5 -4
  49. mistralai/models/eventout.py +11 -6
  50. mistralai/models/filepurpose.py +8 -0
  51. mistralai/models/files_api_routes_delete_fileop.py +5 -5
  52. mistralai/models/files_api_routes_download_fileop.py +16 -0
  53. mistralai/models/files_api_routes_list_filesop.py +96 -0
  54. mistralai/models/files_api_routes_retrieve_fileop.py +5 -5
  55. mistralai/models/files_api_routes_upload_fileop.py +33 -14
  56. mistralai/models/fileschema.py +22 -15
  57. mistralai/models/fimcompletionrequest.py +44 -16
  58. mistralai/models/fimcompletionresponse.py +8 -4
  59. mistralai/models/fimcompletionstreamrequest.py +44 -16
  60. mistralai/models/finetuneablemodel.py +7 -1
  61. mistralai/models/ftmodelcapabilitiesout.py +6 -4
  62. mistralai/models/ftmodelcard.py +121 -0
  63. mistralai/models/ftmodelout.py +39 -9
  64. mistralai/models/function.py +5 -4
  65. mistralai/models/functioncall.py +4 -3
  66. mistralai/models/functionname.py +17 -0
  67. mistralai/models/githubrepositoryin.py +24 -7
  68. mistralai/models/githubrepositoryout.py +24 -7
  69. mistralai/models/httpvalidationerror.py +1 -3
  70. mistralai/models/imageurl.py +47 -0
  71. mistralai/models/imageurlchunk.py +38 -0
  72. mistralai/models/jobin.py +24 -7
  73. mistralai/models/jobmetadataout.py +32 -8
  74. mistralai/models/jobout.py +65 -12
  75. mistralai/models/jobs_api_routes_batch_cancel_batch_jobop.py +16 -0
  76. mistralai/models/jobs_api_routes_batch_get_batch_jobop.py +16 -0
  77. mistralai/models/jobs_api_routes_batch_get_batch_jobsop.py +95 -0
  78. mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +5 -5
  79. mistralai/models/jobs_api_routes_fine_tuning_cancel_fine_tuning_jobop.py +5 -5
  80. mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +3 -2
  81. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobop.py +5 -5
  82. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +85 -18
  83. mistralai/models/jobs_api_routes_fine_tuning_start_fine_tuning_jobop.py +5 -5
  84. mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +5 -5
  85. mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +10 -6
  86. mistralai/models/jobsout.py +13 -5
  87. mistralai/models/legacyjobmetadataout.py +55 -9
  88. mistralai/models/listfilesout.py +7 -3
  89. mistralai/models/metricout.py +12 -8
  90. mistralai/models/modelcapabilities.py +9 -4
  91. mistralai/models/modellist.py +21 -7
  92. mistralai/models/responseformat.py +7 -8
  93. mistralai/models/responseformats.py +8 -0
  94. mistralai/models/retrieve_model_v1_models_model_id_getop.py +25 -6
  95. mistralai/models/retrievefileout.py +25 -15
  96. mistralai/models/sampletype.py +6 -2
  97. mistralai/models/security.py +14 -5
  98. mistralai/models/source.py +3 -2
  99. mistralai/models/systemmessage.py +10 -9
  100. mistralai/models/textchunk.py +14 -5
  101. mistralai/models/tool.py +10 -9
  102. mistralai/models/toolcall.py +10 -8
  103. mistralai/models/toolchoice.py +29 -0
  104. mistralai/models/toolchoiceenum.py +7 -0
  105. mistralai/models/toolmessage.py +13 -6
  106. mistralai/models/tooltypes.py +8 -0
  107. mistralai/models/trainingfile.py +4 -4
  108. mistralai/models/trainingparameters.py +34 -8
  109. mistralai/models/trainingparametersin.py +36 -10
  110. mistralai/models/unarchiveftmodelout.py +15 -5
  111. mistralai/models/updateftmodelin.py +9 -6
  112. mistralai/models/uploadfileout.py +22 -15
  113. mistralai/models/usageinfo.py +4 -3
  114. mistralai/models/usermessage.py +42 -10
  115. mistralai/models/validationerror.py +5 -3
  116. mistralai/models/wandbintegration.py +23 -7
  117. mistralai/models/wandbintegrationout.py +23 -8
  118. mistralai/models_.py +416 -294
  119. mistralai/sdk.py +31 -19
  120. mistralai/sdkconfiguration.py +9 -11
  121. mistralai/utils/__init__.py +14 -1
  122. mistralai/utils/annotations.py +13 -2
  123. mistralai/utils/logger.py +4 -1
  124. mistralai/utils/retries.py +2 -1
  125. mistralai/utils/security.py +13 -6
  126. mistralai/utils/serializers.py +25 -0
  127. {mistralai-1.0.3.dist-info → mistralai-1.2.0.dist-info}/METADATA +171 -66
  128. mistralai-1.2.0.dist-info/RECORD +276 -0
  129. {mistralai-1.0.3.dist-info → mistralai-1.2.0.dist-info}/WHEEL +1 -1
  130. mistralai_azure/__init__.py +4 -0
  131. mistralai_azure/_hooks/sdkhooks.py +23 -4
  132. mistralai_azure/_hooks/types.py +27 -9
  133. mistralai_azure/_version.py +12 -0
  134. mistralai_azure/basesdk.py +91 -6
  135. mistralai_azure/chat.py +308 -166
  136. mistralai_azure/models/__init__.py +164 -16
  137. mistralai_azure/models/assistantmessage.py +29 -11
  138. mistralai_azure/models/chatcompletionchoice.py +15 -6
  139. mistralai_azure/models/chatcompletionrequest.py +94 -22
  140. mistralai_azure/models/chatcompletionresponse.py +8 -4
  141. mistralai_azure/models/chatcompletionstreamrequest.py +96 -22
  142. mistralai_azure/models/completionchunk.py +12 -5
  143. mistralai_azure/models/completionevent.py +2 -3
  144. mistralai_azure/models/completionresponsestreamchoice.py +19 -8
  145. mistralai_azure/models/contentchunk.py +4 -11
  146. mistralai_azure/models/deltamessage.py +30 -12
  147. mistralai_azure/models/function.py +5 -4
  148. mistralai_azure/models/functioncall.py +4 -3
  149. mistralai_azure/models/functionname.py +17 -0
  150. mistralai_azure/models/httpvalidationerror.py +1 -3
  151. mistralai_azure/models/responseformat.py +7 -8
  152. mistralai_azure/models/responseformats.py +8 -0
  153. mistralai_azure/models/security.py +13 -5
  154. mistralai_azure/models/systemmessage.py +10 -9
  155. mistralai_azure/models/textchunk.py +14 -5
  156. mistralai_azure/models/tool.py +10 -9
  157. mistralai_azure/models/toolcall.py +10 -8
  158. mistralai_azure/models/toolchoice.py +29 -0
  159. mistralai_azure/models/toolchoiceenum.py +7 -0
  160. mistralai_azure/models/toolmessage.py +20 -7
  161. mistralai_azure/models/tooltypes.py +8 -0
  162. mistralai_azure/models/usageinfo.py +4 -3
  163. mistralai_azure/models/usermessage.py +42 -10
  164. mistralai_azure/models/validationerror.py +5 -3
  165. mistralai_azure/sdkconfiguration.py +9 -11
  166. mistralai_azure/utils/__init__.py +16 -3
  167. mistralai_azure/utils/annotations.py +13 -2
  168. mistralai_azure/utils/forms.py +10 -9
  169. mistralai_azure/utils/headers.py +8 -8
  170. mistralai_azure/utils/logger.py +6 -0
  171. mistralai_azure/utils/queryparams.py +16 -14
  172. mistralai_azure/utils/retries.py +2 -1
  173. mistralai_azure/utils/security.py +12 -6
  174. mistralai_azure/utils/serializers.py +42 -8
  175. mistralai_azure/utils/url.py +13 -8
  176. mistralai_azure/utils/values.py +6 -0
  177. mistralai_gcp/__init__.py +4 -0
  178. mistralai_gcp/_hooks/sdkhooks.py +23 -4
  179. mistralai_gcp/_hooks/types.py +27 -9
  180. mistralai_gcp/_version.py +12 -0
  181. mistralai_gcp/basesdk.py +91 -6
  182. mistralai_gcp/chat.py +308 -166
  183. mistralai_gcp/fim.py +198 -132
  184. mistralai_gcp/models/__init__.py +186 -18
  185. mistralai_gcp/models/assistantmessage.py +29 -11
  186. mistralai_gcp/models/chatcompletionchoice.py +15 -6
  187. mistralai_gcp/models/chatcompletionrequest.py +91 -22
  188. mistralai_gcp/models/chatcompletionresponse.py +8 -4
  189. mistralai_gcp/models/chatcompletionstreamrequest.py +93 -22
  190. mistralai_gcp/models/completionchunk.py +12 -5
  191. mistralai_gcp/models/completionevent.py +2 -3
  192. mistralai_gcp/models/completionresponsestreamchoice.py +19 -8
  193. mistralai_gcp/models/contentchunk.py +4 -11
  194. mistralai_gcp/models/deltamessage.py +30 -12
  195. mistralai_gcp/models/fimcompletionrequest.py +51 -17
  196. mistralai_gcp/models/fimcompletionresponse.py +8 -4
  197. mistralai_gcp/models/fimcompletionstreamrequest.py +51 -17
  198. mistralai_gcp/models/function.py +5 -4
  199. mistralai_gcp/models/functioncall.py +4 -3
  200. mistralai_gcp/models/functionname.py +17 -0
  201. mistralai_gcp/models/httpvalidationerror.py +1 -3
  202. mistralai_gcp/models/responseformat.py +7 -8
  203. mistralai_gcp/models/responseformats.py +8 -0
  204. mistralai_gcp/models/security.py +13 -5
  205. mistralai_gcp/models/systemmessage.py +10 -9
  206. mistralai_gcp/models/textchunk.py +14 -5
  207. mistralai_gcp/models/tool.py +10 -9
  208. mistralai_gcp/models/toolcall.py +10 -8
  209. mistralai_gcp/models/toolchoice.py +29 -0
  210. mistralai_gcp/models/toolchoiceenum.py +7 -0
  211. mistralai_gcp/models/toolmessage.py +20 -7
  212. mistralai_gcp/models/tooltypes.py +8 -0
  213. mistralai_gcp/models/usageinfo.py +4 -3
  214. mistralai_gcp/models/usermessage.py +42 -10
  215. mistralai_gcp/models/validationerror.py +5 -3
  216. mistralai_gcp/sdk.py +6 -7
  217. mistralai_gcp/sdkconfiguration.py +9 -11
  218. mistralai_gcp/utils/__init__.py +16 -3
  219. mistralai_gcp/utils/annotations.py +13 -2
  220. mistralai_gcp/utils/forms.py +10 -9
  221. mistralai_gcp/utils/headers.py +8 -8
  222. mistralai_gcp/utils/logger.py +6 -0
  223. mistralai_gcp/utils/queryparams.py +16 -14
  224. mistralai_gcp/utils/retries.py +2 -1
  225. mistralai_gcp/utils/security.py +12 -6
  226. mistralai_gcp/utils/serializers.py +42 -8
  227. mistralai_gcp/utils/url.py +13 -8
  228. mistralai_gcp/utils/values.py +6 -0
  229. mistralai-1.0.3.dist-info/RECORD +0 -236
  230. {mistralai-1.0.3.dist-info → mistralai-1.2.0.dist-info}/LICENSE +0 -0
@@ -3,16 +3,16 @@
3
3
  from __future__ import annotations
4
4
  from mistralai.types import BaseModel
5
5
  from mistralai.utils import FieldMetadata, PathParamMetadata
6
- from typing import TypedDict
7
- from typing_extensions import Annotated
6
+ from typing_extensions import Annotated, TypedDict
8
7
 
9
8
 
10
9
  class JobsAPIRoutesFineTuningGetFineTuningJobRequestTypedDict(TypedDict):
11
10
  job_id: str
12
11
  r"""The ID of the job to analyse."""
13
-
12
+
14
13
 
15
14
  class JobsAPIRoutesFineTuningGetFineTuningJobRequest(BaseModel):
16
- job_id: Annotated[str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))]
15
+ job_id: Annotated[
16
+ str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
17
+ ]
17
18
  r"""The ID of the job to analyse."""
18
-
@@ -5,13 +5,25 @@ from datetime import datetime
5
5
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
6
6
  from mistralai.utils import FieldMetadata, QueryParamMetadata
7
7
  from pydantic import model_serializer
8
- from typing import Literal, Optional, TypedDict
9
- from typing_extensions import Annotated, NotRequired
8
+ from typing import Literal, Optional
9
+ from typing_extensions import Annotated, NotRequired, TypedDict
10
10
 
11
11
 
12
- QueryParamStatus = Literal["QUEUED", "STARTED", "VALIDATING", "VALIDATED", "RUNNING", "FAILED_VALIDATION", "FAILED", "SUCCESS", "CANCELLED", "CANCELLATION_REQUESTED"]
12
+ QueryParamStatus = Literal[
13
+ "QUEUED",
14
+ "STARTED",
15
+ "VALIDATING",
16
+ "VALIDATED",
17
+ "RUNNING",
18
+ "FAILED_VALIDATION",
19
+ "FAILED",
20
+ "SUCCESS",
21
+ "CANCELLED",
22
+ "CANCELLATION_REQUESTED",
23
+ ]
13
24
  r"""The current job state to filter on. When set, the other results are not displayed."""
14
25
 
26
+
15
27
  class JobsAPIRoutesFineTuningGetFineTuningJobsRequestTypedDict(TypedDict):
16
28
  page: NotRequired[int]
17
29
  r"""The page number of the results to be returned."""
@@ -31,32 +43,84 @@ class JobsAPIRoutesFineTuningGetFineTuningJobsRequestTypedDict(TypedDict):
31
43
  r"""The Weight and Biases run name to filter on. When set, the other results are not displayed."""
32
44
  suffix: NotRequired[Nullable[str]]
33
45
  r"""The model suffix to filter on. When set, the other results are not displayed."""
34
-
46
+
35
47
 
36
48
  class JobsAPIRoutesFineTuningGetFineTuningJobsRequest(BaseModel):
37
- page: Annotated[Optional[int], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = 0
49
+ page: Annotated[
50
+ Optional[int],
51
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
52
+ ] = 0
38
53
  r"""The page number of the results to be returned."""
39
- page_size: Annotated[Optional[int], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = 100
54
+
55
+ page_size: Annotated[
56
+ Optional[int],
57
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
58
+ ] = 100
40
59
  r"""The number of items to return per page."""
41
- model: Annotated[OptionalNullable[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = UNSET
60
+
61
+ model: Annotated[
62
+ OptionalNullable[str],
63
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
64
+ ] = UNSET
42
65
  r"""The model name used for fine-tuning to filter on. When set, the other results are not displayed."""
43
- created_after: Annotated[OptionalNullable[datetime], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = UNSET
66
+
67
+ created_after: Annotated[
68
+ OptionalNullable[datetime],
69
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
70
+ ] = UNSET
44
71
  r"""The date/time to filter on. When set, the results for previous creation times are not displayed."""
45
- created_by_me: Annotated[Optional[bool], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = False
72
+
73
+ created_by_me: Annotated[
74
+ Optional[bool],
75
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
76
+ ] = False
46
77
  r"""When set, only return results for jobs created by the API caller. Other results are not displayed."""
47
- status: Annotated[OptionalNullable[QueryParamStatus], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = UNSET
78
+
79
+ status: Annotated[
80
+ OptionalNullable[QueryParamStatus],
81
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
82
+ ] = UNSET
48
83
  r"""The current job state to filter on. When set, the other results are not displayed."""
49
- wandb_project: Annotated[OptionalNullable[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = UNSET
84
+
85
+ wandb_project: Annotated[
86
+ OptionalNullable[str],
87
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
88
+ ] = UNSET
50
89
  r"""The Weights and Biases project to filter on. When set, the other results are not displayed."""
51
- wandb_name: Annotated[OptionalNullable[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = UNSET
90
+
91
+ wandb_name: Annotated[
92
+ OptionalNullable[str],
93
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
94
+ ] = UNSET
52
95
  r"""The Weight and Biases run name to filter on. When set, the other results are not displayed."""
53
- suffix: Annotated[OptionalNullable[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = UNSET
96
+
97
+ suffix: Annotated[
98
+ OptionalNullable[str],
99
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
100
+ ] = UNSET
54
101
  r"""The model suffix to filter on. When set, the other results are not displayed."""
55
-
102
+
56
103
  @model_serializer(mode="wrap")
57
104
  def serialize_model(self, handler):
58
- optional_fields = ["page", "page_size", "model", "created_after", "created_by_me", "status", "wandb_project", "wandb_name", "suffix"]
59
- nullable_fields = ["model", "created_after", "status", "wandb_project", "wandb_name", "suffix"]
105
+ optional_fields = [
106
+ "page",
107
+ "page_size",
108
+ "model",
109
+ "created_after",
110
+ "created_by_me",
111
+ "status",
112
+ "wandb_project",
113
+ "wandb_name",
114
+ "suffix",
115
+ ]
116
+ nullable_fields = [
117
+ "model",
118
+ "created_after",
119
+ "status",
120
+ "wandb_project",
121
+ "wandb_name",
122
+ "suffix",
123
+ ]
60
124
  null_default_fields = []
61
125
 
62
126
  serialized = handler(self)
@@ -66,9 +130,13 @@ class JobsAPIRoutesFineTuningGetFineTuningJobsRequest(BaseModel):
66
130
  for n, f in self.model_fields.items():
67
131
  k = f.alias or n
68
132
  val = serialized.get(k)
133
+ serialized.pop(k, None)
69
134
 
70
135
  optional_nullable = k in optional_fields and k in nullable_fields
71
- is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
136
+ is_set = (
137
+ self.__pydantic_fields_set__.intersection({n})
138
+ or k in null_default_fields
139
+ ) # pylint: disable=no-member
72
140
 
73
141
  if val is not None and val != UNSET_SENTINEL:
74
142
  m[k] = val
@@ -78,4 +146,3 @@ class JobsAPIRoutesFineTuningGetFineTuningJobsRequest(BaseModel):
78
146
  m[k] = val
79
147
 
80
148
  return m
81
-
@@ -3,14 +3,14 @@
3
3
  from __future__ import annotations
4
4
  from mistralai.types import BaseModel
5
5
  from mistralai.utils import FieldMetadata, PathParamMetadata
6
- from typing import TypedDict
7
- from typing_extensions import Annotated
6
+ from typing_extensions import Annotated, TypedDict
8
7
 
9
8
 
10
9
  class JobsAPIRoutesFineTuningStartFineTuningJobRequestTypedDict(TypedDict):
11
10
  job_id: str
12
-
11
+
13
12
 
14
13
  class JobsAPIRoutesFineTuningStartFineTuningJobRequest(BaseModel):
15
- job_id: Annotated[str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))]
16
-
14
+ job_id: Annotated[
15
+ str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
16
+ ]
@@ -3,16 +3,16 @@
3
3
  from __future__ import annotations
4
4
  from mistralai.types import BaseModel
5
5
  from mistralai.utils import FieldMetadata, PathParamMetadata
6
- from typing import TypedDict
7
- from typing_extensions import Annotated
6
+ from typing_extensions import Annotated, TypedDict
8
7
 
9
8
 
10
9
  class JobsAPIRoutesFineTuningUnarchiveFineTunedModelRequestTypedDict(TypedDict):
11
10
  model_id: str
12
11
  r"""The ID of the model to unarchive."""
13
-
12
+
14
13
 
15
14
  class JobsAPIRoutesFineTuningUnarchiveFineTunedModelRequest(BaseModel):
16
- model_id: Annotated[str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))]
15
+ model_id: Annotated[
16
+ str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
17
+ ]
17
18
  r"""The ID of the model to unarchive."""
18
-
@@ -4,18 +4,22 @@ from __future__ import annotations
4
4
  from .updateftmodelin import UpdateFTModelIn, UpdateFTModelInTypedDict
5
5
  from mistralai.types import BaseModel
6
6
  from mistralai.utils import FieldMetadata, PathParamMetadata, RequestMetadata
7
- from typing import TypedDict
8
- from typing_extensions import Annotated
7
+ from typing_extensions import Annotated, TypedDict
9
8
 
10
9
 
11
10
  class JobsAPIRoutesFineTuningUpdateFineTunedModelRequestTypedDict(TypedDict):
12
11
  model_id: str
13
12
  r"""The ID of the model to update."""
14
13
  update_ft_model_in: UpdateFTModelInTypedDict
15
-
14
+
16
15
 
17
16
  class JobsAPIRoutesFineTuningUpdateFineTunedModelRequest(BaseModel):
18
- model_id: Annotated[str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))]
17
+ model_id: Annotated[
18
+ str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
19
+ ]
19
20
  r"""The ID of the model to update."""
20
- update_ft_model_in: Annotated[UpdateFTModelIn, FieldMetadata(request=RequestMetadata(media_type="application/json"))]
21
-
21
+
22
+ update_ft_model_in: Annotated[
23
+ UpdateFTModelIn,
24
+ FieldMetadata(request=RequestMetadata(media_type="application/json")),
25
+ ]
@@ -3,20 +3,28 @@
3
3
  from __future__ import annotations
4
4
  from .jobout import JobOut, JobOutTypedDict
5
5
  from mistralai.types import BaseModel
6
+ from mistralai.utils import validate_const
6
7
  import pydantic
7
- from typing import Final, List, Literal, Optional, TypedDict
8
- from typing_extensions import Annotated, NotRequired
8
+ from pydantic.functional_validators import AfterValidator
9
+ from typing import List, Literal, Optional
10
+ from typing_extensions import Annotated, NotRequired, TypedDict
9
11
 
10
12
 
11
13
  JobsOutObject = Literal["list"]
12
14
 
15
+
13
16
  class JobsOutTypedDict(TypedDict):
14
17
  total: int
15
18
  data: NotRequired[List[JobOutTypedDict]]
16
-
19
+ object: JobsOutObject
20
+
17
21
 
18
22
  class JobsOut(BaseModel):
19
23
  total: int
24
+
20
25
  data: Optional[List[JobOut]] = None
21
- OBJECT: Annotated[Final[Optional[JobsOutObject]], pydantic.Field(alias="object")] = "list" # type: ignore
22
-
26
+
27
+ OBJECT: Annotated[
28
+ Annotated[Optional[JobsOutObject], AfterValidator(validate_const("list"))],
29
+ pydantic.Field(alias="object"),
30
+ ] = "list"
@@ -2,14 +2,17 @@
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
  LegacyJobMetadataOutObject = Literal["job.metadata"]
12
14
 
15
+
13
16
  class LegacyJobMetadataOutTypedDict(TypedDict):
14
17
  details: str
15
18
  expected_duration_seconds: NotRequired[Nullable[int]]
@@ -30,34 +33,74 @@ class LegacyJobMetadataOutTypedDict(TypedDict):
30
33
  r"""The number of complete passes through the entire training dataset."""
31
34
  training_steps: NotRequired[Nullable[int]]
32
35
  r"""The number of training steps to perform. A training step refers to a single update of the model weights during the fine-tuning process. This update is typically calculated using a batch of samples from the training dataset."""
33
-
36
+ object: LegacyJobMetadataOutObject
37
+
34
38
 
35
39
  class LegacyJobMetadataOut(BaseModel):
36
40
  details: str
41
+
37
42
  expected_duration_seconds: OptionalNullable[int] = UNSET
38
43
  r"""The approximated time (in seconds) for the fine-tuning process to complete."""
44
+
39
45
  cost: OptionalNullable[float] = UNSET
40
46
  r"""The cost of the fine-tuning job."""
47
+
41
48
  cost_currency: OptionalNullable[str] = UNSET
42
49
  r"""The currency used for the fine-tuning job cost."""
50
+
43
51
  train_tokens_per_step: OptionalNullable[int] = UNSET
44
52
  r"""The number of tokens consumed by one training step."""
53
+
45
54
  train_tokens: OptionalNullable[int] = UNSET
46
55
  r"""The total number of tokens used during the fine-tuning process."""
56
+
47
57
  data_tokens: OptionalNullable[int] = UNSET
48
58
  r"""The total number of tokens in the training dataset."""
59
+
49
60
  estimated_start_time: OptionalNullable[int] = UNSET
61
+
50
62
  deprecated: Optional[bool] = True
63
+
51
64
  epochs: OptionalNullable[float] = UNSET
52
65
  r"""The number of complete passes through the entire training dataset."""
66
+
53
67
  training_steps: OptionalNullable[int] = UNSET
54
68
  r"""The number of training steps to perform. A training step refers to a single update of the model weights during the fine-tuning process. This update is typically calculated using a batch of samples from the training dataset."""
55
- OBJECT: Annotated[Final[Optional[LegacyJobMetadataOutObject]], pydantic.Field(alias="object")] = "job.metadata" # type: ignore
56
-
69
+
70
+ OBJECT: Annotated[
71
+ Annotated[
72
+ Optional[LegacyJobMetadataOutObject],
73
+ AfterValidator(validate_const("job.metadata")),
74
+ ],
75
+ pydantic.Field(alias="object"),
76
+ ] = "job.metadata"
77
+
57
78
  @model_serializer(mode="wrap")
58
79
  def serialize_model(self, handler):
59
- optional_fields = ["expected_duration_seconds", "cost", "cost_currency", "train_tokens_per_step", "train_tokens", "data_tokens", "estimated_start_time", "deprecated", "epochs", "training_steps", "object"]
60
- nullable_fields = ["expected_duration_seconds", "cost", "cost_currency", "train_tokens_per_step", "train_tokens", "data_tokens", "estimated_start_time", "epochs", "training_steps"]
80
+ optional_fields = [
81
+ "expected_duration_seconds",
82
+ "cost",
83
+ "cost_currency",
84
+ "train_tokens_per_step",
85
+ "train_tokens",
86
+ "data_tokens",
87
+ "estimated_start_time",
88
+ "deprecated",
89
+ "epochs",
90
+ "training_steps",
91
+ "object",
92
+ ]
93
+ nullable_fields = [
94
+ "expected_duration_seconds",
95
+ "cost",
96
+ "cost_currency",
97
+ "train_tokens_per_step",
98
+ "train_tokens",
99
+ "data_tokens",
100
+ "estimated_start_time",
101
+ "epochs",
102
+ "training_steps",
103
+ ]
61
104
  null_default_fields = []
62
105
 
63
106
  serialized = handler(self)
@@ -67,9 +110,13 @@ class LegacyJobMetadataOut(BaseModel):
67
110
  for n, f in self.model_fields.items():
68
111
  k = f.alias or n
69
112
  val = serialized.get(k)
113
+ serialized.pop(k, None)
70
114
 
71
115
  optional_nullable = k in optional_fields and k in nullable_fields
72
- is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
116
+ is_set = (
117
+ self.__pydantic_fields_set__.intersection({n})
118
+ or k in null_default_fields
119
+ ) # pylint: disable=no-member
73
120
 
74
121
  if val is not None and val != UNSET_SENTINEL:
75
122
  m[k] = val
@@ -79,4 +126,3 @@ class LegacyJobMetadataOut(BaseModel):
79
126
  m[k] = val
80
127
 
81
128
  return m
82
-
@@ -3,15 +3,19 @@
3
3
  from __future__ import annotations
4
4
  from .fileschema import FileSchema, FileSchemaTypedDict
5
5
  from mistralai.types import BaseModel
6
- from typing import List, TypedDict
6
+ from typing import List
7
+ from typing_extensions import TypedDict
7
8
 
8
9
 
9
10
  class ListFilesOutTypedDict(TypedDict):
10
11
  data: List[FileSchemaTypedDict]
11
12
  object: str
12
-
13
+ total: int
14
+
13
15
 
14
16
  class ListFilesOut(BaseModel):
15
17
  data: List[FileSchema]
18
+
16
19
  object: str
17
-
20
+
21
+ total: int
@@ -3,25 +3,26 @@
3
3
  from __future__ import annotations
4
4
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
5
5
  from pydantic import model_serializer
6
- from typing import TypedDict
7
- from typing_extensions import NotRequired
6
+ from typing_extensions import NotRequired, TypedDict
8
7
 
9
8
 
10
9
  class MetricOutTypedDict(TypedDict):
11
10
  r"""Metrics at the step number during the fine-tuning job. Use these metrics to assess if the training is going smoothly (loss should decrease, token accuracy should increase)."""
12
-
11
+
13
12
  train_loss: NotRequired[Nullable[float]]
14
13
  valid_loss: NotRequired[Nullable[float]]
15
14
  valid_mean_token_accuracy: NotRequired[Nullable[float]]
16
-
15
+
17
16
 
18
17
  class MetricOut(BaseModel):
19
18
  r"""Metrics at the step number during the fine-tuning job. Use these metrics to assess if the training is going smoothly (loss should decrease, token accuracy should increase)."""
20
-
19
+
21
20
  train_loss: OptionalNullable[float] = UNSET
21
+
22
22
  valid_loss: OptionalNullable[float] = UNSET
23
+
23
24
  valid_mean_token_accuracy: OptionalNullable[float] = UNSET
24
-
25
+
25
26
  @model_serializer(mode="wrap")
26
27
  def serialize_model(self, handler):
27
28
  optional_fields = ["train_loss", "valid_loss", "valid_mean_token_accuracy"]
@@ -35,9 +36,13 @@ class MetricOut(BaseModel):
35
36
  for n, f in self.model_fields.items():
36
37
  k = f.alias or n
37
38
  val = serialized.get(k)
39
+ serialized.pop(k, None)
38
40
 
39
41
  optional_nullable = k in optional_fields and k in nullable_fields
40
- is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
42
+ is_set = (
43
+ self.__pydantic_fields_set__.intersection({n})
44
+ or k in null_default_fields
45
+ ) # pylint: disable=no-member
41
46
 
42
47
  if val is not None and val != UNSET_SENTINEL:
43
48
  m[k] = val
@@ -47,4 +52,3 @@ class MetricOut(BaseModel):
47
52
  m[k] = val
48
53
 
49
54
  return m
50
-
@@ -2,8 +2,8 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from mistralai.types import BaseModel
5
- from typing import Optional, TypedDict
6
- from typing_extensions import NotRequired
5
+ from typing import Optional
6
+ from typing_extensions import NotRequired, TypedDict
7
7
 
8
8
 
9
9
  class ModelCapabilitiesTypedDict(TypedDict):
@@ -11,11 +11,16 @@ class ModelCapabilitiesTypedDict(TypedDict):
11
11
  completion_fim: NotRequired[bool]
12
12
  function_calling: NotRequired[bool]
13
13
  fine_tuning: NotRequired[bool]
14
-
14
+ vision: NotRequired[bool]
15
+
15
16
 
16
17
  class ModelCapabilities(BaseModel):
17
18
  completion_chat: Optional[bool] = True
19
+
18
20
  completion_fim: Optional[bool] = False
21
+
19
22
  function_calling: Optional[bool] = True
23
+
20
24
  fine_tuning: Optional[bool] = False
21
-
25
+
26
+ vision: Optional[bool] = False
@@ -1,18 +1,32 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from .modelcard import ModelCard, ModelCardTypedDict
4
+ from .basemodelcard import BaseModelCard, BaseModelCardTypedDict
5
+ from .ftmodelcard import FTModelCard, FTModelCardTypedDict
5
6
  from mistralai.types import BaseModel
6
- from typing import List, Optional, TypedDict
7
- from typing_extensions import NotRequired
7
+ from mistralai.utils import get_discriminator
8
+ from pydantic import Discriminator, Tag
9
+ from typing import List, Optional, Union
10
+ from typing_extensions import Annotated, NotRequired, TypedDict
11
+
12
+
13
+ DataTypedDict = Union[BaseModelCardTypedDict, FTModelCardTypedDict]
14
+
15
+
16
+ Data = Annotated[
17
+ Union[
18
+ Annotated[BaseModelCard, Tag("base")], Annotated[FTModelCard, Tag("fine-tuned")]
19
+ ],
20
+ Discriminator(lambda m: get_discriminator(m, "type", "type")),
21
+ ]
8
22
 
9
23
 
10
24
  class ModelListTypedDict(TypedDict):
11
25
  object: NotRequired[str]
12
- data: NotRequired[List[ModelCardTypedDict]]
13
-
26
+ data: NotRequired[List[DataTypedDict]]
27
+
14
28
 
15
29
  class ModelList(BaseModel):
16
30
  object: Optional[str] = "list"
17
- data: Optional[List[ModelCard]] = None
18
-
31
+
32
+ data: Optional[List[Data]] = None
@@ -1,18 +1,17 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
+ from .responseformats import ResponseFormats
4
5
  from mistralai.types import BaseModel
5
- from typing import Literal, Optional, TypedDict
6
- from typing_extensions import NotRequired
6
+ from typing import Optional
7
+ from typing_extensions import NotRequired, TypedDict
7
8
 
8
9
 
9
- ResponseFormats = Literal["text", "json_object"]
10
- r"""An object specifying the format that the model must output. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message."""
11
-
12
10
  class ResponseFormatTypedDict(TypedDict):
13
11
  type: NotRequired[ResponseFormats]
14
-
12
+ r"""An object specifying the format that the model must output. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message."""
13
+
15
14
 
16
15
  class ResponseFormat(BaseModel):
17
- type: Optional[ResponseFormats] = "text"
18
-
16
+ type: Optional[ResponseFormats] = None
17
+ r"""An object specifying the format that the model must output. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message."""
@@ -0,0 +1,8 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from typing import Literal
5
+
6
+
7
+ ResponseFormats = Literal["text", "json_object"]
8
+ r"""An object specifying the format that the model must output. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message."""
@@ -1,18 +1,37 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
+ from .basemodelcard import BaseModelCard, BaseModelCardTypedDict
5
+ from .ftmodelcard import FTModelCard, FTModelCardTypedDict
4
6
  from mistralai.types import BaseModel
5
- from mistralai.utils import FieldMetadata, PathParamMetadata
6
- from typing import TypedDict
7
- from typing_extensions import Annotated
7
+ from mistralai.utils import FieldMetadata, PathParamMetadata, get_discriminator
8
+ from pydantic import Discriminator, Tag
9
+ from typing import Union
10
+ from typing_extensions import Annotated, TypedDict
8
11
 
9
12
 
10
13
  class RetrieveModelV1ModelsModelIDGetRequestTypedDict(TypedDict):
11
14
  model_id: str
12
15
  r"""The ID of the model to retrieve."""
13
-
16
+
14
17
 
15
18
  class RetrieveModelV1ModelsModelIDGetRequest(BaseModel):
16
- model_id: Annotated[str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))]
19
+ model_id: Annotated[
20
+ str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
21
+ ]
17
22
  r"""The ID of the model to retrieve."""
18
-
23
+
24
+
25
+ RetrieveModelV1ModelsModelIDGetResponseRetrieveModelV1ModelsModelIDGetTypedDict = Union[
26
+ BaseModelCardTypedDict, FTModelCardTypedDict
27
+ ]
28
+ r"""Successful Response"""
29
+
30
+
31
+ RetrieveModelV1ModelsModelIDGetResponseRetrieveModelV1ModelsModelIDGet = Annotated[
32
+ Union[
33
+ Annotated[BaseModelCard, Tag("base")], Annotated[FTModelCard, Tag("fine-tuned")]
34
+ ],
35
+ Discriminator(lambda m: get_discriminator(m, "type", "type")),
36
+ ]
37
+ r"""Successful Response"""