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
@@ -2,30 +2,44 @@
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
  GithubRepositoryOutType = Literal["github"]
12
14
 
15
+
13
16
  class GithubRepositoryOutTypedDict(TypedDict):
14
17
  name: str
15
18
  owner: str
16
19
  commit_id: str
20
+ type: GithubRepositoryOutType
17
21
  ref: NotRequired[Nullable[str]]
18
22
  weight: NotRequired[float]
19
-
23
+
20
24
 
21
25
  class GithubRepositoryOut(BaseModel):
22
26
  name: str
27
+
23
28
  owner: str
29
+
24
30
  commit_id: str
25
- TYPE: Annotated[Final[Optional[GithubRepositoryOutType]], pydantic.Field(alias="type")] = "github" # type: ignore
31
+
32
+ TYPE: Annotated[
33
+ Annotated[
34
+ Optional[GithubRepositoryOutType], AfterValidator(validate_const("github"))
35
+ ],
36
+ pydantic.Field(alias="type"),
37
+ ] = "github"
38
+
26
39
  ref: OptionalNullable[str] = UNSET
40
+
27
41
  weight: Optional[float] = 1
28
-
42
+
29
43
  @model_serializer(mode="wrap")
30
44
  def serialize_model(self, handler):
31
45
  optional_fields = ["type", "ref", "weight"]
@@ -39,9 +53,13 @@ class GithubRepositoryOut(BaseModel):
39
53
  for n, f in self.model_fields.items():
40
54
  k = f.alias or n
41
55
  val = serialized.get(k)
56
+ serialized.pop(k, None)
42
57
 
43
58
  optional_nullable = k in optional_fields and k in nullable_fields
44
- is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
59
+ is_set = (
60
+ self.__pydantic_fields_set__.intersection({n})
61
+ or k in null_default_fields
62
+ ) # pylint: disable=no-member
45
63
 
46
64
  if val is not None and val != UNSET_SENTINEL:
47
65
  m[k] = val
@@ -51,4 +69,3 @@ class GithubRepositoryOut(BaseModel):
51
69
  m[k] = val
52
70
 
53
71
  return m
54
-
@@ -6,13 +6,12 @@ from mistralai import utils
6
6
  from mistralai.types import BaseModel
7
7
  from typing import List, Optional
8
8
 
9
+
9
10
  class HTTPValidationErrorData(BaseModel):
10
11
  detail: Optional[List[ValidationError]] = None
11
-
12
12
 
13
13
 
14
14
  class HTTPValidationError(Exception):
15
- r"""Validation Error"""
16
15
  data: HTTPValidationErrorData
17
16
 
18
17
  def __init__(self, data: HTTPValidationErrorData):
@@ -20,4 +19,3 @@ class HTTPValidationError(Exception):
20
19
 
21
20
  def __str__(self) -> str:
22
21
  return utils.marshal_json(self.data, HTTPValidationErrorData)
23
-
@@ -0,0 +1,47 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
5
+ from pydantic import model_serializer
6
+ from typing_extensions import NotRequired, TypedDict
7
+
8
+
9
+ class ImageURLTypedDict(TypedDict):
10
+ url: str
11
+ detail: NotRequired[Nullable[str]]
12
+
13
+
14
+ class ImageURL(BaseModel):
15
+ url: str
16
+
17
+ detail: OptionalNullable[str] = UNSET
18
+
19
+ @model_serializer(mode="wrap")
20
+ def serialize_model(self, handler):
21
+ optional_fields = ["detail"]
22
+ nullable_fields = ["detail"]
23
+ null_default_fields = []
24
+
25
+ serialized = handler(self)
26
+
27
+ m = {}
28
+
29
+ for n, f in self.model_fields.items():
30
+ k = f.alias or n
31
+ val = serialized.get(k)
32
+ serialized.pop(k, None)
33
+
34
+ optional_nullable = k in optional_fields and k in nullable_fields
35
+ is_set = (
36
+ self.__pydantic_fields_set__.intersection({n})
37
+ or k in null_default_fields
38
+ ) # pylint: disable=no-member
39
+
40
+ if val is not None and val != UNSET_SENTINEL:
41
+ m[k] = val
42
+ elif val != UNSET_SENTINEL and (
43
+ not k in optional_fields or (optional_nullable and is_set)
44
+ ):
45
+ m[k] = val
46
+
47
+ return m
@@ -0,0 +1,38 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .imageurl import ImageURL, ImageURLTypedDict
5
+ from mistralai.types import BaseModel
6
+ from mistralai.utils import validate_const
7
+ import pydantic
8
+ from pydantic.functional_validators import AfterValidator
9
+ from typing import Literal, Optional, Union
10
+ from typing_extensions import Annotated, TypedDict
11
+
12
+
13
+ ImageURLChunkType = Literal["image_url"]
14
+
15
+ ImageURLChunkImageURLTypedDict = Union[ImageURLTypedDict, str]
16
+
17
+
18
+ ImageURLChunkImageURL = Union[ImageURL, str]
19
+
20
+
21
+ class ImageURLChunkTypedDict(TypedDict):
22
+ r"""{\"type\":\"image_url\",\"image_url\":{\"url\":\"data:image/png;base64,iVBORw0"""
23
+
24
+ image_url: ImageURLChunkImageURLTypedDict
25
+ type: ImageURLChunkType
26
+
27
+
28
+ class ImageURLChunk(BaseModel):
29
+ r"""{\"type\":\"image_url\",\"image_url\":{\"url\":\"data:image/png;base64,iVBORw0"""
30
+
31
+ image_url: ImageURLChunkImageURL
32
+
33
+ TYPE: Annotated[
34
+ Annotated[
35
+ Optional[ImageURLChunkType], AfterValidator(validate_const("image_url"))
36
+ ],
37
+ pydantic.Field(alias="type"),
38
+ ] = "image_url"
mistralai/models/jobin.py CHANGED
@@ -8,8 +8,8 @@ from .trainingparametersin import TrainingParametersIn, TrainingParametersInType
8
8
  from .wandbintegration import WandbIntegration, WandbIntegrationTypedDict
9
9
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
10
10
  from pydantic import model_serializer
11
- from typing import List, Optional, TypedDict
12
- from typing_extensions import NotRequired
11
+ from typing import List, Optional
12
+ from typing_extensions import NotRequired, TypedDict
13
13
 
14
14
 
15
15
  JobInIntegrationsTypedDict = WandbIntegrationTypedDict
@@ -39,27 +39,41 @@ class JobInTypedDict(TypedDict):
39
39
  repositories: NotRequired[List[JobInRepositoriesTypedDict]]
40
40
  auto_start: NotRequired[bool]
41
41
  r"""This field will be required in a future release."""
42
-
42
+
43
43
 
44
44
  class JobIn(BaseModel):
45
45
  model: FineTuneableModel
46
46
  r"""The name of the model to fine-tune."""
47
+
47
48
  hyperparameters: TrainingParametersIn
48
49
  r"""The fine-tuning hyperparameter settings used in a fine-tune job."""
50
+
49
51
  training_files: Optional[List[TrainingFile]] = None
52
+
50
53
  validation_files: OptionalNullable[List[str]] = UNSET
51
54
  r"""A list containing the IDs of uploaded files that contain validation data. If you provide these files, the data is used to generate validation metrics periodically during fine-tuning. These metrics can be viewed in `checkpoints` when getting the status of a running fine-tuning job. The same data should not be present in both train and validation files."""
55
+
52
56
  suffix: OptionalNullable[str] = UNSET
53
57
  r"""A string that will be added to your fine-tuning model name. For example, a suffix of \"my-great-model\" would produce a model name like `ft:open-mistral-7b:my-great-model:xxx...`"""
58
+
54
59
  integrations: OptionalNullable[List[JobInIntegrations]] = UNSET
55
60
  r"""A list of integrations to enable for your fine-tuning job."""
61
+
56
62
  repositories: Optional[List[JobInRepositories]] = None
63
+
57
64
  auto_start: Optional[bool] = None
58
65
  r"""This field will be required in a future release."""
59
-
66
+
60
67
  @model_serializer(mode="wrap")
61
68
  def serialize_model(self, handler):
62
- optional_fields = ["training_files", "validation_files", "suffix", "integrations", "repositories", "auto_start"]
69
+ optional_fields = [
70
+ "training_files",
71
+ "validation_files",
72
+ "suffix",
73
+ "integrations",
74
+ "repositories",
75
+ "auto_start",
76
+ ]
63
77
  nullable_fields = ["validation_files", "suffix", "integrations"]
64
78
  null_default_fields = []
65
79
 
@@ -70,9 +84,13 @@ class JobIn(BaseModel):
70
84
  for n, f in self.model_fields.items():
71
85
  k = f.alias or n
72
86
  val = serialized.get(k)
87
+ serialized.pop(k, None)
73
88
 
74
89
  optional_nullable = k in optional_fields and k in nullable_fields
75
- is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
90
+ is_set = (
91
+ self.__pydantic_fields_set__.intersection({n})
92
+ or k in null_default_fields
93
+ ) # pylint: disable=no-member
76
94
 
77
95
  if val is not None and val != UNSET_SENTINEL:
78
96
  m[k] = val
@@ -82,4 +100,3 @@ class JobIn(BaseModel):
82
100
  m[k] = val
83
101
 
84
102
  return m
85
-
@@ -3,8 +3,7 @@
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 JobMetadataOutTypedDict(TypedDict):
@@ -15,21 +14,43 @@ class JobMetadataOutTypedDict(TypedDict):
15
14
  train_tokens: NotRequired[Nullable[int]]
16
15
  data_tokens: NotRequired[Nullable[int]]
17
16
  estimated_start_time: NotRequired[Nullable[int]]
18
-
17
+
19
18
 
20
19
  class JobMetadataOut(BaseModel):
21
20
  expected_duration_seconds: OptionalNullable[int] = UNSET
21
+
22
22
  cost: OptionalNullable[float] = UNSET
23
+
23
24
  cost_currency: OptionalNullable[str] = UNSET
25
+
24
26
  train_tokens_per_step: OptionalNullable[int] = UNSET
27
+
25
28
  train_tokens: OptionalNullable[int] = UNSET
29
+
26
30
  data_tokens: OptionalNullable[int] = UNSET
31
+
27
32
  estimated_start_time: OptionalNullable[int] = UNSET
28
-
33
+
29
34
  @model_serializer(mode="wrap")
30
35
  def serialize_model(self, handler):
31
- optional_fields = ["expected_duration_seconds", "cost", "cost_currency", "train_tokens_per_step", "train_tokens", "data_tokens", "estimated_start_time"]
32
- nullable_fields = ["expected_duration_seconds", "cost", "cost_currency", "train_tokens_per_step", "train_tokens", "data_tokens", "estimated_start_time"]
36
+ optional_fields = [
37
+ "expected_duration_seconds",
38
+ "cost",
39
+ "cost_currency",
40
+ "train_tokens_per_step",
41
+ "train_tokens",
42
+ "data_tokens",
43
+ "estimated_start_time",
44
+ ]
45
+ nullable_fields = [
46
+ "expected_duration_seconds",
47
+ "cost",
48
+ "cost_currency",
49
+ "train_tokens_per_step",
50
+ "train_tokens",
51
+ "data_tokens",
52
+ "estimated_start_time",
53
+ ]
33
54
  null_default_fields = []
34
55
 
35
56
  serialized = handler(self)
@@ -39,9 +60,13 @@ class JobMetadataOut(BaseModel):
39
60
  for n, f in self.model_fields.items():
40
61
  k = f.alias or n
41
62
  val = serialized.get(k)
63
+ serialized.pop(k, None)
42
64
 
43
65
  optional_nullable = k in optional_fields and k in nullable_fields
44
- is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
66
+ is_set = (
67
+ self.__pydantic_fields_set__.intersection({n})
68
+ or k in null_default_fields
69
+ ) # pylint: disable=no-member
45
70
 
46
71
  if val is not None and val != UNSET_SENTINEL:
47
72
  m[k] = val
@@ -51,4 +76,3 @@ class JobMetadataOut(BaseModel):
51
76
  m[k] = val
52
77
 
53
78
  return m
54
-
@@ -7,13 +7,26 @@ from .jobmetadataout import JobMetadataOut, JobMetadataOutTypedDict
7
7
  from .trainingparameters import TrainingParameters, TrainingParametersTypedDict
8
8
  from .wandbintegrationout import WandbIntegrationOut, WandbIntegrationOutTypedDict
9
9
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
10
+ from mistralai.utils import validate_const
10
11
  import pydantic
11
12
  from pydantic import model_serializer
12
- from typing import Final, List, Literal, Optional, TypedDict
13
- from typing_extensions import Annotated, NotRequired
14
-
15
-
16
- Status = Literal["QUEUED", "STARTED", "VALIDATING", "VALIDATED", "RUNNING", "FAILED_VALIDATION", "FAILED", "SUCCESS", "CANCELLED", "CANCELLATION_REQUESTED"]
13
+ from pydantic.functional_validators import AfterValidator
14
+ from typing import List, Literal, Optional
15
+ from typing_extensions import Annotated, NotRequired, TypedDict
16
+
17
+
18
+ Status = Literal[
19
+ "QUEUED",
20
+ "STARTED",
21
+ "VALIDATING",
22
+ "VALIDATED",
23
+ "RUNNING",
24
+ "FAILED_VALIDATION",
25
+ "FAILED",
26
+ "SUCCESS",
27
+ "CANCELLED",
28
+ "CANCELLATION_REQUESTED",
29
+ ]
17
30
  r"""The current status of the fine-tuning job."""
18
31
 
19
32
  Object = Literal["job"]
@@ -50,6 +63,8 @@ class JobOutTypedDict(TypedDict):
50
63
  r"""A list containing the IDs of uploaded files that contain training data."""
51
64
  validation_files: NotRequired[Nullable[List[str]]]
52
65
  r"""A list containing the IDs of uploaded files that contain validation data."""
66
+ object: Object
67
+ r"""The object type of the fine-tuning job."""
53
68
  fine_tuned_model: NotRequired[Nullable[str]]
54
69
  r"""The name of the fine-tuned model that is being created. The value will be `null` if the fine-tuning job is still running."""
55
70
  suffix: NotRequired[Nullable[str]]
@@ -60,44 +75,79 @@ class JobOutTypedDict(TypedDict):
60
75
  r"""Total number of tokens trained."""
61
76
  repositories: NotRequired[List[RepositoriesTypedDict]]
62
77
  metadata: NotRequired[Nullable[JobMetadataOutTypedDict]]
63
-
78
+
64
79
 
65
80
  class JobOut(BaseModel):
66
81
  id: str
67
82
  r"""The ID of the job."""
83
+
68
84
  auto_start: bool
85
+
69
86
  hyperparameters: TrainingParameters
87
+
70
88
  model: FineTuneableModel
71
89
  r"""The name of the model to fine-tune."""
90
+
72
91
  status: Status
73
92
  r"""The current status of the fine-tuning job."""
93
+
74
94
  job_type: str
75
95
  r"""The type of job (`FT` for fine-tuning)."""
96
+
76
97
  created_at: int
77
98
  r"""The UNIX timestamp (in seconds) for when the fine-tuning job was created."""
99
+
78
100
  modified_at: int
79
101
  r"""The UNIX timestamp (in seconds) for when the fine-tuning job was last modified."""
102
+
80
103
  training_files: List[str]
81
104
  r"""A list containing the IDs of uploaded files that contain training data."""
105
+
82
106
  validation_files: OptionalNullable[List[str]] = UNSET
83
107
  r"""A list containing the IDs of uploaded files that contain validation data."""
84
- OBJECT: Annotated[Final[Optional[Object]], pydantic.Field(alias="object")] = "job" # type: ignore
108
+
109
+ OBJECT: Annotated[
110
+ Annotated[Optional[Object], AfterValidator(validate_const("job"))],
111
+ pydantic.Field(alias="object"),
112
+ ] = "job"
85
113
  r"""The object type of the fine-tuning job."""
114
+
86
115
  fine_tuned_model: OptionalNullable[str] = UNSET
87
116
  r"""The name of the fine-tuned model that is being created. The value will be `null` if the fine-tuning job is still running."""
117
+
88
118
  suffix: OptionalNullable[str] = UNSET
89
119
  r"""Optional text/code that adds more context for the model. When given a `prompt` and a `suffix` the model will fill what is between them. When `suffix` is not provided, the model will simply execute completion starting with `prompt`."""
120
+
90
121
  integrations: OptionalNullable[List[Integrations]] = UNSET
91
122
  r"""A list of integrations enabled for your fine-tuning job."""
123
+
92
124
  trained_tokens: OptionalNullable[int] = UNSET
93
125
  r"""Total number of tokens trained."""
126
+
94
127
  repositories: Optional[List[Repositories]] = None
128
+
95
129
  metadata: OptionalNullable[JobMetadataOut] = UNSET
96
-
130
+
97
131
  @model_serializer(mode="wrap")
98
132
  def serialize_model(self, handler):
99
- optional_fields = ["validation_files", "object", "fine_tuned_model", "suffix", "integrations", "trained_tokens", "repositories", "metadata"]
100
- nullable_fields = ["validation_files", "fine_tuned_model", "suffix", "integrations", "trained_tokens", "metadata"]
133
+ optional_fields = [
134
+ "validation_files",
135
+ "object",
136
+ "fine_tuned_model",
137
+ "suffix",
138
+ "integrations",
139
+ "trained_tokens",
140
+ "repositories",
141
+ "metadata",
142
+ ]
143
+ nullable_fields = [
144
+ "validation_files",
145
+ "fine_tuned_model",
146
+ "suffix",
147
+ "integrations",
148
+ "trained_tokens",
149
+ "metadata",
150
+ ]
101
151
  null_default_fields = []
102
152
 
103
153
  serialized = handler(self)
@@ -107,9 +157,13 @@ class JobOut(BaseModel):
107
157
  for n, f in self.model_fields.items():
108
158
  k = f.alias or n
109
159
  val = serialized.get(k)
160
+ serialized.pop(k, None)
110
161
 
111
162
  optional_nullable = k in optional_fields and k in nullable_fields
112
- is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
163
+ is_set = (
164
+ self.__pydantic_fields_set__.intersection({n})
165
+ or k in null_default_fields
166
+ ) # pylint: disable=no-member
113
167
 
114
168
  if val is not None and val != UNSET_SENTINEL:
115
169
  m[k] = val
@@ -119,4 +173,3 @@ class JobOut(BaseModel):
119
173
  m[k] = val
120
174
 
121
175
  return m
122
-
@@ -0,0 +1,16 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from mistralai.types import BaseModel
5
+ from mistralai.utils import FieldMetadata, PathParamMetadata
6
+ from typing_extensions import Annotated, TypedDict
7
+
8
+
9
+ class JobsAPIRoutesBatchCancelBatchJobRequestTypedDict(TypedDict):
10
+ job_id: str
11
+
12
+
13
+ class JobsAPIRoutesBatchCancelBatchJobRequest(BaseModel):
14
+ job_id: Annotated[
15
+ str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
16
+ ]
@@ -0,0 +1,16 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from mistralai.types import BaseModel
5
+ from mistralai.utils import FieldMetadata, PathParamMetadata
6
+ from typing_extensions import Annotated, TypedDict
7
+
8
+
9
+ class JobsAPIRoutesBatchGetBatchJobRequestTypedDict(TypedDict):
10
+ job_id: str
11
+
12
+
13
+ class JobsAPIRoutesBatchGetBatchJobRequest(BaseModel):
14
+ job_id: Annotated[
15
+ str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
16
+ ]
@@ -0,0 +1,95 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .batchjobstatus import BatchJobStatus
5
+ from datetime import datetime
6
+ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
7
+ from mistralai.utils import FieldMetadata, QueryParamMetadata
8
+ from pydantic import model_serializer
9
+ from typing import Any, Dict, Optional
10
+ from typing_extensions import Annotated, NotRequired, TypedDict
11
+
12
+
13
+ class JobsAPIRoutesBatchGetBatchJobsRequestTypedDict(TypedDict):
14
+ page: NotRequired[int]
15
+ page_size: NotRequired[int]
16
+ model: NotRequired[Nullable[str]]
17
+ metadata: NotRequired[Nullable[Dict[str, Any]]]
18
+ created_after: NotRequired[Nullable[datetime]]
19
+ created_by_me: NotRequired[bool]
20
+ status: NotRequired[Nullable[BatchJobStatus]]
21
+
22
+
23
+ class JobsAPIRoutesBatchGetBatchJobsRequest(BaseModel):
24
+ page: Annotated[
25
+ Optional[int],
26
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
27
+ ] = 0
28
+
29
+ page_size: Annotated[
30
+ Optional[int],
31
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
32
+ ] = 100
33
+
34
+ model: Annotated[
35
+ OptionalNullable[str],
36
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
37
+ ] = UNSET
38
+
39
+ metadata: Annotated[
40
+ OptionalNullable[Dict[str, Any]],
41
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
42
+ ] = UNSET
43
+
44
+ created_after: Annotated[
45
+ OptionalNullable[datetime],
46
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
47
+ ] = UNSET
48
+
49
+ created_by_me: Annotated[
50
+ Optional[bool],
51
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
52
+ ] = False
53
+
54
+ status: Annotated[
55
+ OptionalNullable[BatchJobStatus],
56
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
57
+ ] = UNSET
58
+
59
+ @model_serializer(mode="wrap")
60
+ def serialize_model(self, handler):
61
+ optional_fields = [
62
+ "page",
63
+ "page_size",
64
+ "model",
65
+ "metadata",
66
+ "created_after",
67
+ "created_by_me",
68
+ "status",
69
+ ]
70
+ nullable_fields = ["model", "metadata", "created_after", "status"]
71
+ null_default_fields = []
72
+
73
+ serialized = handler(self)
74
+
75
+ m = {}
76
+
77
+ for n, f in self.model_fields.items():
78
+ k = f.alias or n
79
+ val = serialized.get(k)
80
+ serialized.pop(k, None)
81
+
82
+ optional_nullable = k in optional_fields and k in nullable_fields
83
+ is_set = (
84
+ self.__pydantic_fields_set__.intersection({n})
85
+ or k in null_default_fields
86
+ ) # pylint: disable=no-member
87
+
88
+ if val is not None and val != UNSET_SENTINEL:
89
+ m[k] = val
90
+ elif val != UNSET_SENTINEL and (
91
+ not k in optional_fields or (optional_nullable and is_set)
92
+ ):
93
+ m[k] = val
94
+
95
+ return m
@@ -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 JobsAPIRoutesFineTuningArchiveFineTunedModelRequestTypedDict(TypedDict):
11
10
  model_id: str
12
11
  r"""The ID of the model to archive."""
13
-
12
+
14
13
 
15
14
  class JobsAPIRoutesFineTuningArchiveFineTunedModelRequest(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 archive."""
18
-
@@ -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 JobsAPIRoutesFineTuningCancelFineTuningJobRequestTypedDict(TypedDict):
11
10
  job_id: str
12
11
  r"""The ID of the job to cancel."""
13
-
12
+
14
13
 
15
14
  class JobsAPIRoutesFineTuningCancelFineTuningJobRequest(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 cancel."""
18
-
@@ -6,10 +6,11 @@ from .legacyjobmetadataout import LegacyJobMetadataOut, LegacyJobMetadataOutType
6
6
  from typing import Union
7
7
 
8
8
 
9
- JobsAPIRoutesFineTuningCreateFineTuningJobResponseTypedDict = Union[LegacyJobMetadataOutTypedDict, JobOutTypedDict]
9
+ JobsAPIRoutesFineTuningCreateFineTuningJobResponseTypedDict = Union[
10
+ LegacyJobMetadataOutTypedDict, JobOutTypedDict
11
+ ]
10
12
  r"""OK"""
11
13
 
12
14
 
13
15
  JobsAPIRoutesFineTuningCreateFineTuningJobResponse = Union[LegacyJobMetadataOut, JobOut]
14
16
  r"""OK"""
15
-