mistralai 1.1.0__py3-none-any.whl → 1.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. mistralai/__init__.py +4 -0
  2. mistralai/_version.py +12 -0
  3. mistralai/agents.py +56 -22
  4. mistralai/batch.py +17 -0
  5. mistralai/chat.py +64 -30
  6. mistralai/classifiers.py +396 -0
  7. mistralai/embeddings.py +10 -6
  8. mistralai/files.py +252 -19
  9. mistralai/fim.py +40 -30
  10. mistralai/jobs.py +40 -20
  11. mistralai/mistral_jobs.py +733 -0
  12. mistralai/models/__init__.py +108 -18
  13. mistralai/models/agentscompletionrequest.py +27 -10
  14. mistralai/models/agentscompletionstreamrequest.py +27 -10
  15. mistralai/models/apiendpoint.py +9 -0
  16. mistralai/models/archiveftmodelout.py +11 -5
  17. mistralai/models/assistantmessage.py +11 -6
  18. mistralai/models/basemodelcard.py +22 -6
  19. mistralai/models/batcherror.py +17 -0
  20. mistralai/models/batchjobin.py +58 -0
  21. mistralai/models/batchjobout.py +117 -0
  22. mistralai/models/batchjobsout.py +30 -0
  23. mistralai/models/batchjobstatus.py +15 -0
  24. mistralai/models/chatclassificationrequest.py +104 -0
  25. mistralai/models/chatcompletionchoice.py +9 -4
  26. mistralai/models/chatcompletionrequest.py +32 -13
  27. mistralai/models/chatcompletionresponse.py +2 -2
  28. mistralai/models/chatcompletionstreamrequest.py +32 -13
  29. mistralai/models/checkpointout.py +1 -1
  30. mistralai/models/classificationobject.py +21 -0
  31. mistralai/models/classificationrequest.py +59 -0
  32. mistralai/models/classificationresponse.py +21 -0
  33. mistralai/models/completionchunk.py +2 -2
  34. mistralai/models/completionevent.py +1 -1
  35. mistralai/models/completionresponsestreamchoice.py +11 -5
  36. mistralai/models/delete_model_v1_models_model_id_deleteop.py +1 -2
  37. mistralai/models/deletefileout.py +1 -1
  38. mistralai/models/deletemodelout.py +2 -2
  39. mistralai/models/deltamessage.py +14 -7
  40. mistralai/models/detailedjobout.py +11 -5
  41. mistralai/models/embeddingrequest.py +5 -5
  42. mistralai/models/embeddingresponse.py +2 -1
  43. mistralai/models/embeddingresponsedata.py +2 -2
  44. mistralai/models/eventout.py +2 -2
  45. mistralai/models/filepurpose.py +8 -0
  46. mistralai/models/files_api_routes_delete_fileop.py +1 -2
  47. mistralai/models/files_api_routes_download_fileop.py +16 -0
  48. mistralai/models/files_api_routes_list_filesop.py +96 -0
  49. mistralai/models/files_api_routes_retrieve_fileop.py +1 -2
  50. mistralai/models/files_api_routes_upload_fileop.py +9 -9
  51. mistralai/models/fileschema.py +7 -21
  52. mistralai/models/fimcompletionrequest.py +20 -13
  53. mistralai/models/fimcompletionresponse.py +2 -2
  54. mistralai/models/fimcompletionstreamrequest.py +20 -13
  55. mistralai/models/ftmodelcapabilitiesout.py +2 -2
  56. mistralai/models/ftmodelcard.py +24 -6
  57. mistralai/models/ftmodelout.py +9 -5
  58. mistralai/models/function.py +2 -2
  59. mistralai/models/functioncall.py +2 -1
  60. mistralai/models/functionname.py +1 -1
  61. mistralai/models/githubrepositoryin.py +11 -5
  62. mistralai/models/githubrepositoryout.py +11 -5
  63. mistralai/models/httpvalidationerror.py +0 -2
  64. mistralai/models/imageurl.py +1 -2
  65. mistralai/models/imageurlchunk.py +11 -5
  66. mistralai/models/jobin.py +2 -2
  67. mistralai/models/jobmetadataout.py +1 -2
  68. mistralai/models/jobout.py +10 -5
  69. mistralai/models/jobs_api_routes_batch_cancel_batch_jobop.py +16 -0
  70. mistralai/models/jobs_api_routes_batch_get_batch_jobop.py +16 -0
  71. mistralai/models/jobs_api_routes_batch_get_batch_jobsop.py +95 -0
  72. mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +1 -2
  73. mistralai/models/jobs_api_routes_fine_tuning_cancel_fine_tuning_jobop.py +1 -2
  74. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobop.py +1 -2
  75. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +2 -2
  76. mistralai/models/jobs_api_routes_fine_tuning_start_fine_tuning_jobop.py +1 -2
  77. mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +1 -2
  78. mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +1 -2
  79. mistralai/models/jobsout.py +9 -5
  80. mistralai/models/legacyjobmetadataout.py +12 -5
  81. mistralai/models/listfilesout.py +5 -1
  82. mistralai/models/metricout.py +1 -2
  83. mistralai/models/modelcapabilities.py +2 -2
  84. mistralai/models/modellist.py +2 -2
  85. mistralai/models/responseformat.py +2 -2
  86. mistralai/models/retrieve_model_v1_models_model_id_getop.py +2 -2
  87. mistralai/models/retrievefileout.py +10 -21
  88. mistralai/models/sampletype.py +6 -2
  89. mistralai/models/security.py +2 -2
  90. mistralai/models/source.py +3 -2
  91. mistralai/models/systemmessage.py +6 -6
  92. mistralai/models/textchunk.py +9 -5
  93. mistralai/models/tool.py +2 -2
  94. mistralai/models/toolcall.py +2 -2
  95. mistralai/models/toolchoice.py +2 -2
  96. mistralai/models/toolmessage.py +2 -2
  97. mistralai/models/trainingfile.py +2 -2
  98. mistralai/models/trainingparameters.py +7 -2
  99. mistralai/models/trainingparametersin.py +7 -2
  100. mistralai/models/unarchiveftmodelout.py +11 -5
  101. mistralai/models/updateftmodelin.py +1 -2
  102. mistralai/models/uploadfileout.py +7 -21
  103. mistralai/models/usageinfo.py +1 -1
  104. mistralai/models/usermessage.py +36 -5
  105. mistralai/models/validationerror.py +2 -1
  106. mistralai/models/wandbintegration.py +11 -5
  107. mistralai/models/wandbintegrationout.py +12 -6
  108. mistralai/models_.py +48 -24
  109. mistralai/sdk.py +7 -0
  110. mistralai/sdkconfiguration.py +7 -7
  111. mistralai/utils/__init__.py +8 -0
  112. mistralai/utils/annotations.py +13 -2
  113. mistralai/utils/serializers.py +25 -0
  114. {mistralai-1.1.0.dist-info → mistralai-1.2.1.dist-info}/METADATA +90 -14
  115. mistralai-1.2.1.dist-info/RECORD +276 -0
  116. {mistralai-1.1.0.dist-info → mistralai-1.2.1.dist-info}/WHEEL +1 -1
  117. mistralai_azure/__init__.py +4 -0
  118. mistralai_azure/_version.py +12 -0
  119. mistralai_azure/chat.py +64 -30
  120. mistralai_azure/models/__init__.py +9 -3
  121. mistralai_azure/models/assistantmessage.py +11 -6
  122. mistralai_azure/models/chatcompletionchoice.py +10 -5
  123. mistralai_azure/models/chatcompletionrequest.py +32 -13
  124. mistralai_azure/models/chatcompletionresponse.py +2 -2
  125. mistralai_azure/models/chatcompletionstreamrequest.py +32 -13
  126. mistralai_azure/models/completionchunk.py +2 -2
  127. mistralai_azure/models/completionevent.py +1 -1
  128. mistralai_azure/models/completionresponsestreamchoice.py +9 -4
  129. mistralai_azure/models/deltamessage.py +14 -7
  130. mistralai_azure/models/function.py +2 -2
  131. mistralai_azure/models/functioncall.py +2 -1
  132. mistralai_azure/models/functionname.py +1 -1
  133. mistralai_azure/models/httpvalidationerror.py +0 -2
  134. mistralai_azure/models/responseformat.py +2 -2
  135. mistralai_azure/models/security.py +1 -2
  136. mistralai_azure/models/systemmessage.py +6 -6
  137. mistralai_azure/models/textchunk.py +9 -5
  138. mistralai_azure/models/tool.py +2 -2
  139. mistralai_azure/models/toolcall.py +2 -2
  140. mistralai_azure/models/toolchoice.py +2 -2
  141. mistralai_azure/models/toolmessage.py +2 -2
  142. mistralai_azure/models/usageinfo.py +1 -1
  143. mistralai_azure/models/usermessage.py +36 -5
  144. mistralai_azure/models/validationerror.py +2 -1
  145. mistralai_azure/sdkconfiguration.py +7 -7
  146. mistralai_azure/utils/__init__.py +8 -0
  147. mistralai_azure/utils/annotations.py +13 -2
  148. mistralai_azure/utils/serializers.py +25 -0
  149. mistralai_gcp/__init__.py +4 -0
  150. mistralai_gcp/_version.py +12 -0
  151. mistralai_gcp/chat.py +64 -30
  152. mistralai_gcp/fim.py +40 -30
  153. mistralai_gcp/models/__init__.py +9 -3
  154. mistralai_gcp/models/assistantmessage.py +11 -6
  155. mistralai_gcp/models/chatcompletionchoice.py +10 -5
  156. mistralai_gcp/models/chatcompletionrequest.py +32 -13
  157. mistralai_gcp/models/chatcompletionresponse.py +2 -2
  158. mistralai_gcp/models/chatcompletionstreamrequest.py +32 -13
  159. mistralai_gcp/models/completionchunk.py +2 -2
  160. mistralai_gcp/models/completionevent.py +1 -1
  161. mistralai_gcp/models/completionresponsestreamchoice.py +9 -4
  162. mistralai_gcp/models/deltamessage.py +14 -7
  163. mistralai_gcp/models/fimcompletionrequest.py +20 -13
  164. mistralai_gcp/models/fimcompletionresponse.py +2 -2
  165. mistralai_gcp/models/fimcompletionstreamrequest.py +20 -13
  166. mistralai_gcp/models/function.py +2 -2
  167. mistralai_gcp/models/functioncall.py +2 -1
  168. mistralai_gcp/models/functionname.py +1 -1
  169. mistralai_gcp/models/httpvalidationerror.py +0 -2
  170. mistralai_gcp/models/responseformat.py +2 -2
  171. mistralai_gcp/models/security.py +1 -2
  172. mistralai_gcp/models/systemmessage.py +6 -6
  173. mistralai_gcp/models/textchunk.py +9 -5
  174. mistralai_gcp/models/tool.py +2 -2
  175. mistralai_gcp/models/toolcall.py +2 -2
  176. mistralai_gcp/models/toolchoice.py +2 -2
  177. mistralai_gcp/models/toolmessage.py +2 -2
  178. mistralai_gcp/models/usageinfo.py +1 -1
  179. mistralai_gcp/models/usermessage.py +36 -5
  180. mistralai_gcp/models/validationerror.py +2 -1
  181. mistralai_gcp/sdk.py +20 -11
  182. mistralai_gcp/sdkconfiguration.py +7 -7
  183. mistralai_gcp/utils/__init__.py +8 -0
  184. mistralai_gcp/utils/annotations.py +13 -2
  185. mistralai_gcp/utils/serializers.py +25 -0
  186. mistralai-1.1.0.dist-info/RECORD +0 -254
  187. {mistralai-1.1.0.dist-info → mistralai-1.2.1.dist-info}/LICENSE +0 -0
@@ -3,8 +3,8 @@
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 List, Optional, TypedDict, Union
7
- from typing_extensions import NotRequired
6
+ from typing import List, Optional, Union
7
+ from typing_extensions import NotRequired, TypedDict
8
8
 
9
9
 
10
10
  FIMCompletionStreamRequestStopTypedDict = Union[str, List[str]]
@@ -23,14 +23,12 @@ class FIMCompletionStreamRequestTypedDict(TypedDict):
23
23
  """
24
24
  prompt: str
25
25
  r"""The text/code to complete."""
26
- temperature: NotRequired[float]
27
- r"""What sampling temperature to use, between 0.0 and 1.0. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both."""
26
+ temperature: NotRequired[Nullable[float]]
27
+ r"""What sampling temperature to use, we recommend between 0.0 and 0.7. Higher values like 0.7 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both. The default value varies depending on the model you are targeting. Call the `/models` endpoint to retrieve the appropriate value."""
28
28
  top_p: NotRequired[float]
29
29
  r"""Nucleus sampling, where the model considers the results of the tokens with `top_p` probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or `temperature` but not both."""
30
30
  max_tokens: NotRequired[Nullable[int]]
31
31
  r"""The maximum number of tokens to generate in the completion. The token count of your prompt plus `max_tokens` cannot exceed the model's context length."""
32
- min_tokens: NotRequired[Nullable[int]]
33
- r"""The minimum number of tokens to generate in the completion."""
34
32
  stream: NotRequired[bool]
35
33
  stop: NotRequired[FIMCompletionStreamRequestStopTypedDict]
36
34
  r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
@@ -38,6 +36,8 @@ class FIMCompletionStreamRequestTypedDict(TypedDict):
38
36
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
39
37
  suffix: NotRequired[Nullable[str]]
40
38
  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`."""
39
+ min_tokens: NotRequired[Nullable[int]]
40
+ r"""The minimum number of tokens to generate in the completion."""
41
41
 
42
42
 
43
43
  class FIMCompletionStreamRequest(BaseModel):
@@ -50,8 +50,8 @@ class FIMCompletionStreamRequest(BaseModel):
50
50
  prompt: str
51
51
  r"""The text/code to complete."""
52
52
 
53
- temperature: Optional[float] = 0.7
54
- r"""What sampling temperature to use, between 0.0 and 1.0. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both."""
53
+ temperature: OptionalNullable[float] = UNSET
54
+ r"""What sampling temperature to use, we recommend between 0.0 and 0.7. Higher values like 0.7 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both. The default value varies depending on the model you are targeting. Call the `/models` endpoint to retrieve the appropriate value."""
55
55
 
56
56
  top_p: Optional[float] = 1
57
57
  r"""Nucleus sampling, where the model considers the results of the tokens with `top_p` probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or `temperature` but not both."""
@@ -59,9 +59,6 @@ class FIMCompletionStreamRequest(BaseModel):
59
59
  max_tokens: OptionalNullable[int] = UNSET
60
60
  r"""The maximum number of tokens to generate in the completion. The token count of your prompt plus `max_tokens` cannot exceed the model's context length."""
61
61
 
62
- min_tokens: OptionalNullable[int] = UNSET
63
- r"""The minimum number of tokens to generate in the completion."""
64
-
65
62
  stream: Optional[bool] = True
66
63
 
67
64
  stop: Optional[FIMCompletionStreamRequestStop] = None
@@ -73,19 +70,29 @@ class FIMCompletionStreamRequest(BaseModel):
73
70
  suffix: OptionalNullable[str] = UNSET
74
71
  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`."""
75
72
 
73
+ min_tokens: OptionalNullable[int] = UNSET
74
+ r"""The minimum number of tokens to generate in the completion."""
75
+
76
76
  @model_serializer(mode="wrap")
77
77
  def serialize_model(self, handler):
78
78
  optional_fields = [
79
79
  "temperature",
80
80
  "top_p",
81
81
  "max_tokens",
82
- "min_tokens",
83
82
  "stream",
84
83
  "stop",
85
84
  "random_seed",
86
85
  "suffix",
86
+ "min_tokens",
87
+ ]
88
+ nullable_fields = [
89
+ "model",
90
+ "temperature",
91
+ "max_tokens",
92
+ "random_seed",
93
+ "suffix",
94
+ "min_tokens",
87
95
  ]
88
- nullable_fields = ["model", "max_tokens", "min_tokens", "random_seed", "suffix"]
89
96
  null_default_fields = []
90
97
 
91
98
  serialized = handler(self)
@@ -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 FTModelCapabilitiesOutTypedDict(TypedDict):
@@ -4,10 +4,15 @@ from __future__ import annotations
4
4
  from .modelcapabilities import ModelCapabilities, ModelCapabilitiesTypedDict
5
5
  from datetime import datetime
6
6
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
7
+ from mistralai.utils import validate_const
7
8
  import pydantic
8
9
  from pydantic import model_serializer
9
- from typing import Final, List, Optional, TypedDict
10
- from typing_extensions import Annotated, NotRequired
10
+ from pydantic.functional_validators import AfterValidator
11
+ from typing import List, Literal, Optional
12
+ from typing_extensions import Annotated, NotRequired, TypedDict
13
+
14
+
15
+ FTModelCardType = Literal["fine-tuned"]
11
16
 
12
17
 
13
18
  class FTModelCardTypedDict(TypedDict):
@@ -25,6 +30,8 @@ class FTModelCardTypedDict(TypedDict):
25
30
  max_context_length: NotRequired[int]
26
31
  aliases: NotRequired[List[str]]
27
32
  deprecation: NotRequired[Nullable[datetime]]
33
+ default_model_temperature: NotRequired[Nullable[float]]
34
+ type: FTModelCardType
28
35
  archived: NotRequired[bool]
29
36
 
30
37
 
@@ -55,9 +62,14 @@ class FTModelCard(BaseModel):
55
62
 
56
63
  deprecation: OptionalNullable[datetime] = UNSET
57
64
 
58
- # fmt: off
59
- TYPE: Annotated[Final[Optional[str]], pydantic.Field(alias="type")] = "fine-tuned" # type: ignore
60
- # fmt: on
65
+ default_model_temperature: OptionalNullable[float] = UNSET
66
+
67
+ TYPE: Annotated[
68
+ Annotated[
69
+ Optional[FTModelCardType], AfterValidator(validate_const("fine-tuned"))
70
+ ],
71
+ pydantic.Field(alias="type"),
72
+ ] = "fine-tuned"
61
73
 
62
74
  archived: Optional[bool] = False
63
75
 
@@ -72,10 +84,16 @@ class FTModelCard(BaseModel):
72
84
  "max_context_length",
73
85
  "aliases",
74
86
  "deprecation",
87
+ "default_model_temperature",
75
88
  "type",
76
89
  "archived",
77
90
  ]
78
- nullable_fields = ["name", "description", "deprecation"]
91
+ nullable_fields = [
92
+ "name",
93
+ "description",
94
+ "deprecation",
95
+ "default_model_temperature",
96
+ ]
79
97
  null_default_fields = []
80
98
 
81
99
  serialized = handler(self)
@@ -6,10 +6,12 @@ from .ftmodelcapabilitiesout import (
6
6
  FTModelCapabilitiesOutTypedDict,
7
7
  )
8
8
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
9
+ from mistralai.utils import validate_const
9
10
  import pydantic
10
11
  from pydantic import model_serializer
11
- from typing import Final, List, Literal, Optional, TypedDict
12
- from typing_extensions import Annotated, NotRequired
12
+ from pydantic.functional_validators import AfterValidator
13
+ from typing import List, Literal, Optional
14
+ from typing_extensions import Annotated, NotRequired, TypedDict
13
15
 
14
16
 
15
17
  FTModelOutObject = Literal["model"]
@@ -23,6 +25,7 @@ class FTModelOutTypedDict(TypedDict):
23
25
  archived: bool
24
26
  capabilities: FTModelCapabilitiesOutTypedDict
25
27
  job: str
28
+ object: FTModelOutObject
26
29
  name: NotRequired[Nullable[str]]
27
30
  description: NotRequired[Nullable[str]]
28
31
  max_context_length: NotRequired[int]
@@ -44,9 +47,10 @@ class FTModelOut(BaseModel):
44
47
 
45
48
  job: str
46
49
 
47
- # fmt: off
48
- OBJECT: Annotated[Final[Optional[FTModelOutObject]], pydantic.Field(alias="object")] = "model" # type: ignore
49
- # fmt: on
50
+ OBJECT: Annotated[
51
+ Annotated[Optional[FTModelOutObject], AfterValidator(validate_const("model"))],
52
+ pydantic.Field(alias="object"),
53
+ ] = "model"
50
54
 
51
55
  name: OptionalNullable[str] = UNSET
52
56
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from mistralai.types import BaseModel
5
- from typing import Any, Dict, Optional, TypedDict
6
- from typing_extensions import NotRequired
5
+ from typing import Any, Dict, Optional
6
+ from typing_extensions import NotRequired, TypedDict
7
7
 
8
8
 
9
9
  class FunctionTypedDict(TypedDict):
@@ -2,7 +2,8 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from mistralai.types import BaseModel
5
- from typing import Any, Dict, TypedDict, Union
5
+ from typing import Any, Dict, Union
6
+ from typing_extensions import TypedDict
6
7
 
7
8
 
8
9
  ArgumentsTypedDict = Union[Dict[str, Any], str]
@@ -2,7 +2,7 @@
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 FunctionNameTypedDict(TypedDict):
@@ -2,10 +2,12 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
5
+ from mistralai.utils import validate_const
5
6
  import pydantic
6
7
  from pydantic import model_serializer
7
- from typing import Final, Literal, Optional, TypedDict
8
- from typing_extensions import Annotated, NotRequired
8
+ from pydantic.functional_validators import AfterValidator
9
+ from typing import Literal, Optional
10
+ from typing_extensions import Annotated, NotRequired, TypedDict
9
11
 
10
12
 
11
13
  GithubRepositoryInType = Literal["github"]
@@ -15,6 +17,7 @@ class GithubRepositoryInTypedDict(TypedDict):
15
17
  name: str
16
18
  owner: str
17
19
  token: str
20
+ type: GithubRepositoryInType
18
21
  ref: NotRequired[Nullable[str]]
19
22
  weight: NotRequired[float]
20
23
 
@@ -26,9 +29,12 @@ class GithubRepositoryIn(BaseModel):
26
29
 
27
30
  token: str
28
31
 
29
- # fmt: off
30
- TYPE: Annotated[Final[Optional[GithubRepositoryInType]], pydantic.Field(alias="type")] = "github" # type: ignore
31
- # fmt: on
32
+ TYPE: Annotated[
33
+ Annotated[
34
+ Optional[GithubRepositoryInType], AfterValidator(validate_const("github"))
35
+ ],
36
+ pydantic.Field(alias="type"),
37
+ ] = "github"
32
38
 
33
39
  ref: OptionalNullable[str] = UNSET
34
40
 
@@ -2,10 +2,12 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
5
+ from mistralai.utils import validate_const
5
6
  import pydantic
6
7
  from pydantic import model_serializer
7
- from typing import Final, Literal, Optional, TypedDict
8
- from typing_extensions import Annotated, NotRequired
8
+ from pydantic.functional_validators import AfterValidator
9
+ from typing import Literal, Optional
10
+ from typing_extensions import Annotated, NotRequired, TypedDict
9
11
 
10
12
 
11
13
  GithubRepositoryOutType = Literal["github"]
@@ -15,6 +17,7 @@ class GithubRepositoryOutTypedDict(TypedDict):
15
17
  name: str
16
18
  owner: str
17
19
  commit_id: str
20
+ type: GithubRepositoryOutType
18
21
  ref: NotRequired[Nullable[str]]
19
22
  weight: NotRequired[float]
20
23
 
@@ -26,9 +29,12 @@ class GithubRepositoryOut(BaseModel):
26
29
 
27
30
  commit_id: str
28
31
 
29
- # fmt: off
30
- TYPE: Annotated[Final[Optional[GithubRepositoryOutType]], pydantic.Field(alias="type")] = "github" # type: ignore
31
- # fmt: on
32
+ TYPE: Annotated[
33
+ Annotated[
34
+ Optional[GithubRepositoryOutType], AfterValidator(validate_const("github"))
35
+ ],
36
+ pydantic.Field(alias="type"),
37
+ ] = "github"
32
38
 
33
39
  ref: OptionalNullable[str] = UNSET
34
40
 
@@ -12,8 +12,6 @@ class HTTPValidationErrorData(BaseModel):
12
12
 
13
13
 
14
14
  class HTTPValidationError(Exception):
15
- r"""Validation Error"""
16
-
17
15
  data: HTTPValidationErrorData
18
16
 
19
17
  def __init__(self, data: HTTPValidationErrorData):
@@ -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 ImageURLTypedDict(TypedDict):
@@ -3,9 +3,11 @@
3
3
  from __future__ import annotations
4
4
  from .imageurl import ImageURL, ImageURLTypedDict
5
5
  from mistralai.types import BaseModel
6
+ from mistralai.utils import validate_const
6
7
  import pydantic
7
- from typing import Final, Literal, Optional, TypedDict, Union
8
- from typing_extensions import Annotated
8
+ from pydantic.functional_validators import AfterValidator
9
+ from typing import Literal, Optional, Union
10
+ from typing_extensions import Annotated, TypedDict
9
11
 
10
12
 
11
13
  ImageURLChunkType = Literal["image_url"]
@@ -20,6 +22,7 @@ class ImageURLChunkTypedDict(TypedDict):
20
22
  r"""{\"type\":\"image_url\",\"image_url\":{\"url\":\"data:image/png;base64,iVBORw0"""
21
23
 
22
24
  image_url: ImageURLChunkImageURLTypedDict
25
+ type: ImageURLChunkType
23
26
 
24
27
 
25
28
  class ImageURLChunk(BaseModel):
@@ -27,6 +30,9 @@ class ImageURLChunk(BaseModel):
27
30
 
28
31
  image_url: ImageURLChunkImageURL
29
32
 
30
- # fmt: off
31
- TYPE: Annotated[Final[Optional[ImageURLChunkType]], pydantic.Field(alias="type")] = "image_url" # type: ignore
32
- # fmt: on
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
@@ -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):
@@ -7,10 +7,12 @@ 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
13
+ from pydantic.functional_validators import AfterValidator
14
+ from typing import List, Literal, Optional
15
+ from typing_extensions import Annotated, NotRequired, TypedDict
14
16
 
15
17
 
16
18
  Status = Literal[
@@ -61,6 +63,8 @@ class JobOutTypedDict(TypedDict):
61
63
  r"""A list containing the IDs of uploaded files that contain training data."""
62
64
  validation_files: NotRequired[Nullable[List[str]]]
63
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."""
64
68
  fine_tuned_model: NotRequired[Nullable[str]]
65
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."""
66
70
  suffix: NotRequired[Nullable[str]]
@@ -102,9 +106,10 @@ class JobOut(BaseModel):
102
106
  validation_files: OptionalNullable[List[str]] = UNSET
103
107
  r"""A list containing the IDs of uploaded files that contain validation data."""
104
108
 
105
- # fmt: off
106
- OBJECT: Annotated[Final[Optional[Object]], pydantic.Field(alias="object")] = "job" # type: ignore
107
- # fmt: on
109
+ OBJECT: Annotated[
110
+ Annotated[Optional[Object], AfterValidator(validate_const("job"))],
111
+ pydantic.Field(alias="object"),
112
+ ] = "job"
108
113
  r"""The object type of the fine-tuning job."""
109
114
 
110
115
  fine_tuned_model: OptionalNullable[str] = UNSET
@@ -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,8 +3,7 @@
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):
@@ -3,8 +3,7 @@
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):
@@ -3,8 +3,7 @@
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):
@@ -5,8 +5,8 @@ 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
12
  QueryParamStatus = Literal[
@@ -3,8 +3,7 @@
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):
@@ -3,8 +3,7 @@
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):
@@ -4,8 +4,7 @@ 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):