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
@@ -1,20 +1,16 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
+ from .filepurpose import FilePurpose
4
5
  from .sampletype import SampleType
5
6
  from .source import Source
6
- from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL, UnrecognizedStr
7
+ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
7
8
  from mistralai.utils import validate_open_enum
8
- import pydantic
9
9
  from pydantic import model_serializer
10
10
  from pydantic.functional_validators import PlainValidator
11
- from typing import Final, Literal, TypedDict, Union
12
- from typing_extensions import Annotated, NotRequired
11
+ from typing_extensions import Annotated, NotRequired, TypedDict
13
12
 
14
13
 
15
- Purpose = Union[Literal["fine-tune"], UnrecognizedStr]
16
- r"""The intended purpose of the uploaded file. Only accepts fine-tuning (`fine-tune`) for now."""
17
-
18
14
  class UploadFileOutTypedDict(TypedDict):
19
15
  id: str
20
16
  r"""The unique identifier of the file."""
@@ -26,28 +22,36 @@ class UploadFileOutTypedDict(TypedDict):
26
22
  r"""The UNIX timestamp (in seconds) of the event."""
27
23
  filename: str
28
24
  r"""The name of the uploaded file."""
25
+ purpose: FilePurpose
29
26
  sample_type: SampleType
30
27
  source: Source
31
28
  num_lines: NotRequired[Nullable[int]]
32
-
29
+
33
30
 
34
31
  class UploadFileOut(BaseModel):
35
32
  id: str
36
33
  r"""The unique identifier of the file."""
34
+
37
35
  object: str
38
36
  r"""The object type, which is always \"file\"."""
37
+
39
38
  bytes: int
40
39
  r"""The size of the file, in bytes."""
40
+
41
41
  created_at: int
42
42
  r"""The UNIX timestamp (in seconds) of the event."""
43
+
43
44
  filename: str
44
45
  r"""The name of the uploaded file."""
45
- sample_type: SampleType
46
- source: Source
47
- PURPOSE: Annotated[Final[Annotated[Purpose, PlainValidator(validate_open_enum(False))]], pydantic.Field(alias="purpose")] = "fine-tune" # type: ignore
48
- r"""The intended purpose of the uploaded file. Only accepts fine-tuning (`fine-tune`) for now."""
46
+
47
+ purpose: Annotated[FilePurpose, PlainValidator(validate_open_enum(False))]
48
+
49
+ sample_type: Annotated[SampleType, PlainValidator(validate_open_enum(False))]
50
+
51
+ source: Annotated[Source, PlainValidator(validate_open_enum(False))]
52
+
49
53
  num_lines: OptionalNullable[int] = UNSET
50
-
54
+
51
55
  @model_serializer(mode="wrap")
52
56
  def serialize_model(self, handler):
53
57
  optional_fields = ["num_lines"]
@@ -61,9 +65,13 @@ class UploadFileOut(BaseModel):
61
65
  for n, f in self.model_fields.items():
62
66
  k = f.alias or n
63
67
  val = serialized.get(k)
68
+ serialized.pop(k, None)
64
69
 
65
70
  optional_nullable = k in optional_fields and k in nullable_fields
66
- is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
71
+ is_set = (
72
+ self.__pydantic_fields_set__.intersection({n})
73
+ or k in null_default_fields
74
+ ) # pylint: disable=no-member
67
75
 
68
76
  if val is not None and val != UNSET_SENTINEL:
69
77
  m[k] = val
@@ -73,4 +81,3 @@ class UploadFileOut(BaseModel):
73
81
  m[k] = val
74
82
 
75
83
  return m
76
-
@@ -2,17 +2,18 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from mistralai.types import BaseModel
5
- from typing import TypedDict
5
+ from typing_extensions import TypedDict
6
6
 
7
7
 
8
8
  class UsageInfoTypedDict(TypedDict):
9
9
  prompt_tokens: int
10
10
  completion_tokens: int
11
11
  total_tokens: int
12
-
12
+
13
13
 
14
14
  class UsageInfo(BaseModel):
15
15
  prompt_tokens: int
16
+
16
17
  completion_tokens: int
18
+
17
19
  total_tokens: int
18
-
@@ -1,26 +1,58 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from .textchunk import TextChunk, TextChunkTypedDict
5
- from mistralai.types import BaseModel
6
- from typing import List, Literal, Optional, TypedDict, Union
7
- from typing_extensions import NotRequired
4
+ from .contentchunk import ContentChunk, ContentChunkTypedDict
5
+ from mistralai.types import BaseModel, Nullable, UNSET_SENTINEL
6
+ from pydantic import model_serializer
7
+ from typing import List, Literal, Optional, Union
8
+ from typing_extensions import NotRequired, TypedDict
8
9
 
9
10
 
10
- UserMessageContentTypedDict = Union[str, List[TextChunkTypedDict]]
11
+ UserMessageContentTypedDict = Union[str, List[ContentChunkTypedDict]]
11
12
 
12
13
 
13
- UserMessageContent = Union[str, List[TextChunk]]
14
+ UserMessageContent = Union[str, List[ContentChunk]]
14
15
 
15
16
 
16
17
  UserMessageRole = Literal["user"]
17
18
 
19
+
18
20
  class UserMessageTypedDict(TypedDict):
19
- content: UserMessageContentTypedDict
21
+ content: Nullable[UserMessageContentTypedDict]
20
22
  role: NotRequired[UserMessageRole]
21
-
23
+
22
24
 
23
25
  class UserMessage(BaseModel):
24
- content: UserMessageContent
26
+ content: Nullable[UserMessageContent]
27
+
25
28
  role: Optional[UserMessageRole] = "user"
26
-
29
+
30
+ @model_serializer(mode="wrap")
31
+ def serialize_model(self, handler):
32
+ optional_fields = ["role"]
33
+ nullable_fields = ["content"]
34
+ null_default_fields = []
35
+
36
+ serialized = handler(self)
37
+
38
+ m = {}
39
+
40
+ for n, f in self.model_fields.items():
41
+ k = f.alias or n
42
+ val = serialized.get(k)
43
+ serialized.pop(k, None)
44
+
45
+ optional_nullable = k in optional_fields and k in nullable_fields
46
+ is_set = (
47
+ self.__pydantic_fields_set__.intersection({n})
48
+ or k in null_default_fields
49
+ ) # pylint: disable=no-member
50
+
51
+ if val is not None and val != UNSET_SENTINEL:
52
+ m[k] = val
53
+ elif val != UNSET_SENTINEL and (
54
+ not k in optional_fields or (optional_nullable and is_set)
55
+ ):
56
+ m[k] = val
57
+
58
+ return m
@@ -2,7 +2,8 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from mistralai.types import BaseModel
5
- from typing import List, TypedDict, Union
5
+ from typing import List, Union
6
+ from typing_extensions import TypedDict
6
7
 
7
8
 
8
9
  LocTypedDict = Union[str, int]
@@ -15,10 +16,11 @@ class ValidationErrorTypedDict(TypedDict):
15
16
  loc: List[LocTypedDict]
16
17
  msg: str
17
18
  type: str
18
-
19
+
19
20
 
20
21
  class ValidationError(BaseModel):
21
22
  loc: List[Loc]
23
+
22
24
  msg: str
25
+
23
26
  type: str
24
-
@@ -2,34 +2,47 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
5
+ from mistralai.utils import validate_const
5
6
  import pydantic
6
7
  from pydantic import model_serializer
7
- from typing import Final, Literal, Optional, TypedDict
8
- from typing_extensions import Annotated, NotRequired
8
+ from pydantic.functional_validators import AfterValidator
9
+ from typing import Literal, Optional
10
+ from typing_extensions import Annotated, NotRequired, TypedDict
9
11
 
10
12
 
11
13
  WandbIntegrationType = Literal["wandb"]
12
14
 
15
+
13
16
  class WandbIntegrationTypedDict(TypedDict):
14
17
  project: str
15
18
  r"""The name of the project that the new run will be created under."""
16
19
  api_key: str
17
20
  r"""The WandB API key to use for authentication."""
21
+ type: WandbIntegrationType
18
22
  name: NotRequired[Nullable[str]]
19
23
  r"""A display name to set for the run. If not set, will use the job ID as the name."""
20
24
  run_name: NotRequired[Nullable[str]]
21
-
25
+
22
26
 
23
27
  class WandbIntegration(BaseModel):
24
28
  project: str
25
29
  r"""The name of the project that the new run will be created under."""
30
+
26
31
  api_key: str
27
32
  r"""The WandB API key to use for authentication."""
28
- TYPE: Annotated[Final[Optional[WandbIntegrationType]], pydantic.Field(alias="type")] = "wandb" # type: ignore
33
+
34
+ TYPE: Annotated[
35
+ Annotated[
36
+ Optional[WandbIntegrationType], AfterValidator(validate_const("wandb"))
37
+ ],
38
+ pydantic.Field(alias="type"),
39
+ ] = "wandb"
40
+
29
41
  name: OptionalNullable[str] = UNSET
30
42
  r"""A display name to set for the run. If not set, will use the job ID as the name."""
43
+
31
44
  run_name: OptionalNullable[str] = UNSET
32
-
45
+
33
46
  @model_serializer(mode="wrap")
34
47
  def serialize_model(self, handler):
35
48
  optional_fields = ["type", "name", "run_name"]
@@ -43,9 +56,13 @@ class WandbIntegration(BaseModel):
43
56
  for n, f in self.model_fields.items():
44
57
  k = f.alias or n
45
58
  val = serialized.get(k)
59
+ serialized.pop(k, None)
46
60
 
47
61
  optional_nullable = k in optional_fields and k in nullable_fields
48
- is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
62
+ is_set = (
63
+ self.__pydantic_fields_set__.intersection({n})
64
+ or k in null_default_fields
65
+ ) # pylint: disable=no-member
49
66
 
50
67
  if val is not None and val != UNSET_SENTINEL:
51
68
  m[k] = val
@@ -55,4 +72,3 @@ class WandbIntegration(BaseModel):
55
72
  m[k] = val
56
73
 
57
74
  return m
58
-
@@ -2,30 +2,42 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
5
+ from mistralai.utils import validate_const
5
6
  import pydantic
6
7
  from pydantic import model_serializer
7
- from typing import Final, Literal, Optional, TypedDict
8
- from typing_extensions import Annotated, NotRequired
8
+ from pydantic.functional_validators import AfterValidator
9
+ from typing import Literal, Optional
10
+ from typing_extensions import Annotated, NotRequired, TypedDict
9
11
 
10
12
 
11
- Type = Literal["wandb"]
13
+ WandbIntegrationOutType = Literal["wandb"]
14
+
12
15
 
13
16
  class WandbIntegrationOutTypedDict(TypedDict):
14
17
  project: str
15
18
  r"""The name of the project that the new run will be created under."""
19
+ type: WandbIntegrationOutType
16
20
  name: NotRequired[Nullable[str]]
17
21
  r"""A display name to set for the run. If not set, will use the job ID as the name."""
18
22
  run_name: NotRequired[Nullable[str]]
19
-
23
+
20
24
 
21
25
  class WandbIntegrationOut(BaseModel):
22
26
  project: str
23
27
  r"""The name of the project that the new run will be created under."""
24
- TYPE: Annotated[Final[Optional[Type]], pydantic.Field(alias="type")] = "wandb" # type: ignore
28
+
29
+ TYPE: Annotated[
30
+ Annotated[
31
+ Optional[WandbIntegrationOutType], AfterValidator(validate_const("wandb"))
32
+ ],
33
+ pydantic.Field(alias="type"),
34
+ ] = "wandb"
35
+
25
36
  name: OptionalNullable[str] = UNSET
26
37
  r"""A display name to set for the run. If not set, will use the job ID as the name."""
38
+
27
39
  run_name: OptionalNullable[str] = UNSET
28
-
40
+
29
41
  @model_serializer(mode="wrap")
30
42
  def serialize_model(self, handler):
31
43
  optional_fields = ["type", "name", "run_name"]
@@ -39,9 +51,13 @@ class WandbIntegrationOut(BaseModel):
39
51
  for n, f in self.model_fields.items():
40
52
  k = f.alias or n
41
53
  val = serialized.get(k)
54
+ serialized.pop(k, None)
42
55
 
43
56
  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
57
+ is_set = (
58
+ self.__pydantic_fields_set__.intersection({n})
59
+ or k in null_default_fields
60
+ ) # pylint: disable=no-member
45
61
 
46
62
  if val is not None and val != UNSET_SENTINEL:
47
63
  m[k] = val
@@ -51,4 +67,3 @@ class WandbIntegrationOut(BaseModel):
51
67
  m[k] = val
52
68
 
53
69
  return m
54
-