mistralai 1.0.3__py3-none-any.whl → 1.1.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 (199) hide show
  1. mistralai/_hooks/sdkhooks.py +23 -4
  2. mistralai/_hooks/types.py +27 -9
  3. mistralai/agents.py +286 -150
  4. mistralai/basesdk.py +90 -5
  5. mistralai/chat.py +260 -144
  6. mistralai/embeddings.py +73 -53
  7. mistralai/files.py +252 -192
  8. mistralai/fim.py +174 -110
  9. mistralai/fine_tuning.py +3 -2
  10. mistralai/jobs.py +372 -263
  11. mistralai/models/__init__.py +499 -46
  12. mistralai/models/agentscompletionrequest.py +47 -11
  13. mistralai/models/agentscompletionstreamrequest.py +49 -11
  14. mistralai/models/archiveftmodelout.py +6 -2
  15. mistralai/models/assistantmessage.py +11 -4
  16. mistralai/models/{modelcard.py → basemodelcard.py} +37 -14
  17. mistralai/models/chatcompletionchoice.py +4 -2
  18. mistralai/models/chatcompletionrequest.py +57 -11
  19. mistralai/models/chatcompletionresponse.py +6 -2
  20. mistralai/models/chatcompletionstreamrequest.py +59 -11
  21. mistralai/models/checkpointout.py +3 -2
  22. mistralai/models/completionchunk.py +10 -3
  23. mistralai/models/completionevent.py +1 -2
  24. mistralai/models/completionresponsestreamchoice.py +13 -5
  25. mistralai/models/contentchunk.py +13 -10
  26. mistralai/models/delete_model_v1_models_model_id_deleteop.py +4 -3
  27. mistralai/models/deletefileout.py +3 -2
  28. mistralai/models/deletemodelout.py +3 -2
  29. mistralai/models/deltamessage.py +9 -4
  30. mistralai/models/detailedjobout.py +59 -7
  31. mistralai/models/embeddingrequest.py +9 -4
  32. mistralai/models/embeddingresponse.py +5 -2
  33. mistralai/models/embeddingresponsedata.py +3 -2
  34. mistralai/models/eventout.py +9 -4
  35. mistralai/models/files_api_routes_delete_fileop.py +4 -3
  36. mistralai/models/files_api_routes_retrieve_fileop.py +4 -3
  37. mistralai/models/files_api_routes_upload_fileop.py +27 -8
  38. mistralai/models/fileschema.py +26 -5
  39. mistralai/models/fimcompletionrequest.py +26 -5
  40. mistralai/models/fimcompletionresponse.py +6 -2
  41. mistralai/models/fimcompletionstreamrequest.py +26 -5
  42. mistralai/models/finetuneablemodel.py +7 -1
  43. mistralai/models/ftmodelcapabilitiesout.py +4 -2
  44. mistralai/models/ftmodelcard.py +103 -0
  45. mistralai/models/ftmodelout.py +32 -6
  46. mistralai/models/function.py +3 -2
  47. mistralai/models/functioncall.py +2 -2
  48. mistralai/models/functionname.py +17 -0
  49. mistralai/models/githubrepositoryin.py +15 -4
  50. mistralai/models/githubrepositoryout.py +15 -4
  51. mistralai/models/httpvalidationerror.py +2 -2
  52. mistralai/models/imageurl.py +48 -0
  53. mistralai/models/imageurlchunk.py +32 -0
  54. mistralai/models/jobin.py +22 -5
  55. mistralai/models/jobmetadataout.py +31 -6
  56. mistralai/models/jobout.py +55 -7
  57. mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +4 -3
  58. mistralai/models/jobs_api_routes_fine_tuning_cancel_fine_tuning_jobop.py +4 -3
  59. mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +3 -2
  60. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobop.py +4 -3
  61. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +83 -16
  62. mistralai/models/jobs_api_routes_fine_tuning_start_fine_tuning_jobop.py +4 -3
  63. mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +4 -3
  64. mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +9 -4
  65. mistralai/models/jobsout.py +6 -2
  66. mistralai/models/legacyjobmetadataout.py +45 -6
  67. mistralai/models/listfilesout.py +2 -2
  68. mistralai/models/metricout.py +11 -6
  69. mistralai/models/modelcapabilities.py +7 -2
  70. mistralai/models/modellist.py +21 -7
  71. mistralai/models/responseformat.py +6 -7
  72. mistralai/models/responseformats.py +8 -0
  73. mistralai/models/retrieve_model_v1_models_model_id_getop.py +24 -5
  74. mistralai/models/retrievefileout.py +26 -5
  75. mistralai/models/security.py +12 -3
  76. mistralai/models/systemmessage.py +6 -5
  77. mistralai/models/textchunk.py +9 -4
  78. mistralai/models/tool.py +9 -8
  79. mistralai/models/toolcall.py +9 -7
  80. mistralai/models/toolchoice.py +29 -0
  81. mistralai/models/toolchoiceenum.py +7 -0
  82. mistralai/models/toolmessage.py +11 -4
  83. mistralai/models/tooltypes.py +8 -0
  84. mistralai/models/trainingfile.py +2 -2
  85. mistralai/models/trainingparameters.py +27 -6
  86. mistralai/models/trainingparametersin.py +29 -8
  87. mistralai/models/unarchiveftmodelout.py +6 -2
  88. mistralai/models/updateftmodelin.py +8 -4
  89. mistralai/models/uploadfileout.py +26 -5
  90. mistralai/models/usageinfo.py +3 -2
  91. mistralai/models/usermessage.py +6 -5
  92. mistralai/models/validationerror.py +3 -2
  93. mistralai/models/wandbintegration.py +14 -4
  94. mistralai/models/wandbintegrationout.py +13 -4
  95. mistralai/models_.py +392 -294
  96. mistralai/sdk.py +24 -19
  97. mistralai/sdkconfiguration.py +6 -8
  98. mistralai/utils/__init__.py +6 -1
  99. mistralai/utils/logger.py +4 -1
  100. mistralai/utils/retries.py +2 -1
  101. mistralai/utils/security.py +13 -6
  102. {mistralai-1.0.3.dist-info → mistralai-1.1.0.dist-info}/METADATA +102 -73
  103. mistralai-1.1.0.dist-info/RECORD +254 -0
  104. mistralai_azure/_hooks/sdkhooks.py +23 -4
  105. mistralai_azure/_hooks/types.py +27 -9
  106. mistralai_azure/basesdk.py +91 -6
  107. mistralai_azure/chat.py +252 -144
  108. mistralai_azure/models/__init__.py +157 -15
  109. mistralai_azure/models/assistantmessage.py +18 -5
  110. mistralai_azure/models/chatcompletionchoice.py +7 -3
  111. mistralai_azure/models/chatcompletionrequest.py +65 -12
  112. mistralai_azure/models/chatcompletionresponse.py +6 -2
  113. mistralai_azure/models/chatcompletionstreamrequest.py +67 -12
  114. mistralai_azure/models/completionchunk.py +10 -3
  115. mistralai_azure/models/completionevent.py +1 -2
  116. mistralai_azure/models/completionresponsestreamchoice.py +10 -4
  117. mistralai_azure/models/contentchunk.py +4 -11
  118. mistralai_azure/models/deltamessage.py +16 -5
  119. mistralai_azure/models/function.py +3 -2
  120. mistralai_azure/models/functioncall.py +2 -2
  121. mistralai_azure/models/functionname.py +17 -0
  122. mistralai_azure/models/httpvalidationerror.py +2 -2
  123. mistralai_azure/models/responseformat.py +6 -7
  124. mistralai_azure/models/responseformats.py +8 -0
  125. mistralai_azure/models/security.py +12 -3
  126. mistralai_azure/models/systemmessage.py +6 -5
  127. mistralai_azure/models/textchunk.py +9 -4
  128. mistralai_azure/models/tool.py +9 -8
  129. mistralai_azure/models/toolcall.py +9 -7
  130. mistralai_azure/models/toolchoice.py +29 -0
  131. mistralai_azure/models/toolchoiceenum.py +7 -0
  132. mistralai_azure/models/toolmessage.py +18 -5
  133. mistralai_azure/models/tooltypes.py +8 -0
  134. mistralai_azure/models/usageinfo.py +3 -2
  135. mistralai_azure/models/usermessage.py +6 -5
  136. mistralai_azure/models/validationerror.py +3 -2
  137. mistralai_azure/sdkconfiguration.py +6 -8
  138. mistralai_azure/utils/__init__.py +8 -3
  139. mistralai_azure/utils/forms.py +10 -9
  140. mistralai_azure/utils/headers.py +8 -8
  141. mistralai_azure/utils/logger.py +6 -0
  142. mistralai_azure/utils/queryparams.py +16 -14
  143. mistralai_azure/utils/retries.py +2 -1
  144. mistralai_azure/utils/security.py +12 -6
  145. mistralai_azure/utils/serializers.py +17 -8
  146. mistralai_azure/utils/url.py +13 -8
  147. mistralai_azure/utils/values.py +6 -0
  148. mistralai_gcp/_hooks/sdkhooks.py +23 -4
  149. mistralai_gcp/_hooks/types.py +27 -9
  150. mistralai_gcp/basesdk.py +91 -6
  151. mistralai_gcp/chat.py +252 -144
  152. mistralai_gcp/fim.py +166 -110
  153. mistralai_gcp/models/__init__.py +179 -17
  154. mistralai_gcp/models/assistantmessage.py +18 -5
  155. mistralai_gcp/models/chatcompletionchoice.py +7 -3
  156. mistralai_gcp/models/chatcompletionrequest.py +62 -12
  157. mistralai_gcp/models/chatcompletionresponse.py +6 -2
  158. mistralai_gcp/models/chatcompletionstreamrequest.py +64 -12
  159. mistralai_gcp/models/completionchunk.py +10 -3
  160. mistralai_gcp/models/completionevent.py +1 -2
  161. mistralai_gcp/models/completionresponsestreamchoice.py +10 -4
  162. mistralai_gcp/models/contentchunk.py +4 -11
  163. mistralai_gcp/models/deltamessage.py +16 -5
  164. mistralai_gcp/models/fimcompletionrequest.py +33 -6
  165. mistralai_gcp/models/fimcompletionresponse.py +6 -2
  166. mistralai_gcp/models/fimcompletionstreamrequest.py +33 -6
  167. mistralai_gcp/models/function.py +3 -2
  168. mistralai_gcp/models/functioncall.py +2 -2
  169. mistralai_gcp/models/functionname.py +17 -0
  170. mistralai_gcp/models/httpvalidationerror.py +2 -2
  171. mistralai_gcp/models/responseformat.py +6 -7
  172. mistralai_gcp/models/responseformats.py +8 -0
  173. mistralai_gcp/models/security.py +12 -3
  174. mistralai_gcp/models/systemmessage.py +6 -5
  175. mistralai_gcp/models/textchunk.py +9 -4
  176. mistralai_gcp/models/tool.py +9 -8
  177. mistralai_gcp/models/toolcall.py +9 -7
  178. mistralai_gcp/models/toolchoice.py +29 -0
  179. mistralai_gcp/models/toolchoiceenum.py +7 -0
  180. mistralai_gcp/models/toolmessage.py +18 -5
  181. mistralai_gcp/models/tooltypes.py +8 -0
  182. mistralai_gcp/models/usageinfo.py +3 -2
  183. mistralai_gcp/models/usermessage.py +6 -5
  184. mistralai_gcp/models/validationerror.py +3 -2
  185. mistralai_gcp/sdk.py +6 -7
  186. mistralai_gcp/sdkconfiguration.py +6 -8
  187. mistralai_gcp/utils/__init__.py +8 -3
  188. mistralai_gcp/utils/forms.py +10 -9
  189. mistralai_gcp/utils/headers.py +8 -8
  190. mistralai_gcp/utils/logger.py +6 -0
  191. mistralai_gcp/utils/queryparams.py +16 -14
  192. mistralai_gcp/utils/retries.py +2 -1
  193. mistralai_gcp/utils/security.py +12 -6
  194. mistralai_gcp/utils/serializers.py +17 -8
  195. mistralai_gcp/utils/url.py +13 -8
  196. mistralai_gcp/utils/values.py +6 -0
  197. mistralai-1.0.3.dist-info/RECORD +0 -236
  198. {mistralai-1.0.3.dist-info → mistralai-1.1.0.dist-info}/LICENSE +0 -0
  199. {mistralai-1.0.3.dist-info → mistralai-1.1.0.dist-info}/WHEEL +0 -0
@@ -5,12 +5,14 @@ from .assistantmessage import AssistantMessage, AssistantMessageTypedDict
5
5
  from .responseformat import ResponseFormat, ResponseFormatTypedDict
6
6
  from .systemmessage import SystemMessage, SystemMessageTypedDict
7
7
  from .tool import Tool, ToolTypedDict
8
+ from .toolchoice import ToolChoice, ToolChoiceTypedDict
9
+ from .toolchoiceenum import ToolChoiceEnum
8
10
  from .toolmessage import ToolMessage, ToolMessageTypedDict
9
11
  from .usermessage import UserMessage, UserMessageTypedDict
10
12
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
11
13
  from mistralai.utils import get_discriminator
12
14
  from pydantic import Discriminator, Tag, model_serializer
13
- from typing import List, Literal, Optional, TypedDict, Union
15
+ from typing import List, Optional, TypedDict, Union
14
16
  from typing_extensions import Annotated, NotRequired
15
17
 
16
18
 
@@ -22,13 +24,32 @@ ChatCompletionStreamRequestStop = Union[str, List[str]]
22
24
  r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
23
25
 
24
26
 
25
- ChatCompletionStreamRequestMessagesTypedDict = Union[SystemMessageTypedDict, UserMessageTypedDict, AssistantMessageTypedDict, ToolMessageTypedDict]
27
+ ChatCompletionStreamRequestMessagesTypedDict = Union[
28
+ SystemMessageTypedDict,
29
+ UserMessageTypedDict,
30
+ AssistantMessageTypedDict,
31
+ ToolMessageTypedDict,
32
+ ]
26
33
 
27
34
 
28
- ChatCompletionStreamRequestMessages = Annotated[Union[Annotated[AssistantMessage, Tag("assistant")], Annotated[SystemMessage, Tag("system")], Annotated[ToolMessage, Tag("tool")], Annotated[UserMessage, Tag("user")]], Discriminator(lambda m: get_discriminator(m, "role", "role"))]
35
+ ChatCompletionStreamRequestMessages = Annotated[
36
+ Union[
37
+ Annotated[AssistantMessage, Tag("assistant")],
38
+ Annotated[SystemMessage, Tag("system")],
39
+ Annotated[ToolMessage, Tag("tool")],
40
+ Annotated[UserMessage, Tag("user")],
41
+ ],
42
+ Discriminator(lambda m: get_discriminator(m, "role", "role")),
43
+ ]
29
44
 
30
45
 
31
- ChatCompletionStreamRequestToolChoice = Literal["auto", "none", "any"]
46
+ ChatCompletionStreamRequestToolChoiceTypedDict = Union[
47
+ ToolChoiceTypedDict, ToolChoiceEnum
48
+ ]
49
+
50
+
51
+ ChatCompletionStreamRequestToolChoice = Union[ToolChoice, ToolChoiceEnum]
52
+
32
53
 
33
54
  class ChatCompletionStreamRequestTypedDict(TypedDict):
34
55
  model: Nullable[str]
@@ -50,38 +71,62 @@ class ChatCompletionStreamRequestTypedDict(TypedDict):
50
71
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
51
72
  response_format: NotRequired[ResponseFormatTypedDict]
52
73
  tools: NotRequired[Nullable[List[ToolTypedDict]]]
53
- tool_choice: NotRequired[ChatCompletionStreamRequestToolChoice]
74
+ tool_choice: NotRequired[ChatCompletionStreamRequestToolChoiceTypedDict]
54
75
  safe_prompt: NotRequired[bool]
55
76
  r"""Whether to inject a safety prompt before all conversations."""
56
-
77
+
57
78
 
58
79
  class ChatCompletionStreamRequest(BaseModel):
59
80
  model: Nullable[str]
60
81
  r"""ID of the model to use. You can use the [List Available Models](/api/#tag/models/operation/list_models_v1_models_get) API to see all of your available models, or see our [Model overview](/models) for model descriptions."""
82
+
61
83
  messages: List[ChatCompletionStreamRequestMessages]
62
84
  r"""The prompt(s) to generate completions for, encoded as a list of dict with role and content."""
85
+
63
86
  temperature: Optional[float] = 0.7
64
87
  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."""
88
+
65
89
  top_p: Optional[float] = 1
66
90
  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."""
91
+
67
92
  max_tokens: OptionalNullable[int] = UNSET
68
93
  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."""
94
+
69
95
  min_tokens: OptionalNullable[int] = UNSET
70
96
  r"""The minimum number of tokens to generate in the completion."""
97
+
71
98
  stream: Optional[bool] = True
99
+
72
100
  stop: Optional[ChatCompletionStreamRequestStop] = None
73
101
  r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
102
+
74
103
  random_seed: OptionalNullable[int] = UNSET
75
104
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
105
+
76
106
  response_format: Optional[ResponseFormat] = None
107
+
77
108
  tools: OptionalNullable[List[Tool]] = UNSET
78
- tool_choice: Optional[ChatCompletionStreamRequestToolChoice] = "auto"
109
+
110
+ tool_choice: Optional[ChatCompletionStreamRequestToolChoice] = None
111
+
79
112
  safe_prompt: Optional[bool] = False
80
113
  r"""Whether to inject a safety prompt before all conversations."""
81
-
114
+
82
115
  @model_serializer(mode="wrap")
83
116
  def serialize_model(self, handler):
84
- optional_fields = ["temperature", "top_p", "max_tokens", "min_tokens", "stream", "stop", "random_seed", "response_format", "tools", "tool_choice", "safe_prompt"]
117
+ optional_fields = [
118
+ "temperature",
119
+ "top_p",
120
+ "max_tokens",
121
+ "min_tokens",
122
+ "stream",
123
+ "stop",
124
+ "random_seed",
125
+ "response_format",
126
+ "tools",
127
+ "tool_choice",
128
+ "safe_prompt",
129
+ ]
85
130
  nullable_fields = ["model", "max_tokens", "min_tokens", "random_seed", "tools"]
86
131
  null_default_fields = []
87
132
 
@@ -92,9 +137,13 @@ class ChatCompletionStreamRequest(BaseModel):
92
137
  for n, f in self.model_fields.items():
93
138
  k = f.alias or n
94
139
  val = serialized.get(k)
140
+ serialized.pop(k, None)
95
141
 
96
142
  optional_nullable = k in optional_fields and k in nullable_fields
97
- is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
143
+ is_set = (
144
+ self.__pydantic_fields_set__.intersection({n})
145
+ or k in null_default_fields
146
+ ) # pylint: disable=no-member
98
147
 
99
148
  if val is not None and val != UNSET_SENTINEL:
100
149
  m[k] = val
@@ -104,4 +153,3 @@ class ChatCompletionStreamRequest(BaseModel):
104
153
  m[k] = val
105
154
 
106
155
  return m
107
-
@@ -13,13 +13,14 @@ class CheckpointOutTypedDict(TypedDict):
13
13
  r"""The step number that the checkpoint was created at."""
14
14
  created_at: int
15
15
  r"""The UNIX timestamp (in seconds) for when the checkpoint was created."""
16
-
16
+
17
17
 
18
18
  class CheckpointOut(BaseModel):
19
19
  metrics: MetricOut
20
20
  r"""Metrics at the step number during the fine-tuning job. Use these metrics to assess if the training is going smoothly (loss should decrease, token accuracy should increase)."""
21
+
21
22
  step_number: int
22
23
  r"""The step number that the checkpoint was created at."""
24
+
23
25
  created_at: int
24
26
  r"""The UNIX timestamp (in seconds) for when the checkpoint was created."""
25
-
@@ -1,7 +1,10 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from .completionresponsestreamchoice import CompletionResponseStreamChoice, CompletionResponseStreamChoiceTypedDict
4
+ from .completionresponsestreamchoice import (
5
+ CompletionResponseStreamChoice,
6
+ CompletionResponseStreamChoiceTypedDict,
7
+ )
5
8
  from .usageinfo import UsageInfo, UsageInfoTypedDict
6
9
  from mistralai.types import BaseModel
7
10
  from typing import List, Optional, TypedDict
@@ -15,13 +18,17 @@ class CompletionChunkTypedDict(TypedDict):
15
18
  object: NotRequired[str]
16
19
  created: NotRequired[int]
17
20
  usage: NotRequired[UsageInfoTypedDict]
18
-
21
+
19
22
 
20
23
  class CompletionChunk(BaseModel):
21
24
  id: str
25
+
22
26
  model: str
27
+
23
28
  choices: List[CompletionResponseStreamChoice]
29
+
24
30
  object: Optional[str] = None
31
+
25
32
  created: Optional[int] = None
33
+
26
34
  usage: Optional[UsageInfo] = None
27
-
@@ -8,8 +8,7 @@ from typing import TypedDict
8
8
 
9
9
  class CompletionEventTypedDict(TypedDict):
10
10
  data: CompletionChunkTypedDict
11
-
11
+
12
12
 
13
13
  class CompletionEvent(BaseModel):
14
14
  data: CompletionChunk
15
-
@@ -7,19 +7,24 @@ from pydantic import model_serializer
7
7
  from typing import Literal, TypedDict
8
8
 
9
9
 
10
- CompletionResponseStreamChoiceFinishReason = Literal["stop", "length", "error", "tool_calls"]
10
+ CompletionResponseStreamChoiceFinishReason = Literal[
11
+ "stop", "length", "error", "tool_calls"
12
+ ]
13
+
11
14
 
12
15
  class CompletionResponseStreamChoiceTypedDict(TypedDict):
13
16
  index: int
14
17
  delta: DeltaMessageTypedDict
15
18
  finish_reason: Nullable[CompletionResponseStreamChoiceFinishReason]
16
-
19
+
17
20
 
18
21
  class CompletionResponseStreamChoice(BaseModel):
19
22
  index: int
23
+
20
24
  delta: DeltaMessage
25
+
21
26
  finish_reason: Nullable[CompletionResponseStreamChoiceFinishReason]
22
-
27
+
23
28
  @model_serializer(mode="wrap")
24
29
  def serialize_model(self, handler):
25
30
  optional_fields = []
@@ -33,9 +38,13 @@ class CompletionResponseStreamChoice(BaseModel):
33
38
  for n, f in self.model_fields.items():
34
39
  k = f.alias or n
35
40
  val = serialized.get(k)
41
+ serialized.pop(k, None)
36
42
 
37
43
  optional_nullable = k in optional_fields and k in nullable_fields
38
- is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
44
+ is_set = (
45
+ self.__pydantic_fields_set__.intersection({n})
46
+ or k in null_default_fields
47
+ ) # pylint: disable=no-member
39
48
 
40
49
  if val is not None and val != UNSET_SENTINEL:
41
50
  m[k] = val
@@ -45,4 +54,3 @@ class CompletionResponseStreamChoice(BaseModel):
45
54
  m[k] = val
46
55
 
47
56
  return m
48
-
@@ -1,17 +1,20 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from mistralai.types import BaseModel
5
- import pydantic
6
- from typing import Final, Optional, TypedDict
4
+ from .imageurlchunk import ImageURLChunk, ImageURLChunkTypedDict
5
+ from .textchunk import TextChunk, TextChunkTypedDict
6
+ from mistralai.utils import get_discriminator
7
+ from pydantic import Discriminator, Tag
8
+ from typing import Union
7
9
  from typing_extensions import Annotated
8
10
 
9
11
 
10
- class ContentChunkTypedDict(TypedDict):
11
- text: str
12
-
12
+ ContentChunkTypedDict = Union[TextChunkTypedDict, ImageURLChunkTypedDict]
13
13
 
14
- class ContentChunk(BaseModel):
15
- text: str
16
- TYPE: Annotated[Final[Optional[str]], pydantic.Field(alias="type")] = "text" # type: ignore
17
-
14
+
15
+ ContentChunk = Annotated[
16
+ Union[
17
+ Annotated[ImageURLChunk, Tag("image_url")], Annotated[TextChunk, Tag("text")]
18
+ ],
19
+ Discriminator(lambda m: get_discriminator(m, "type", "type")),
20
+ ]
@@ -10,9 +10,10 @@ from typing_extensions import Annotated
10
10
  class DeleteModelV1ModelsModelIDDeleteRequestTypedDict(TypedDict):
11
11
  model_id: str
12
12
  r"""The ID of the model to delete."""
13
-
13
+
14
14
 
15
15
  class DeleteModelV1ModelsModelIDDeleteRequest(BaseModel):
16
- model_id: Annotated[str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))]
16
+ model_id: Annotated[
17
+ str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
18
+ ]
17
19
  r"""The ID of the model to delete."""
18
-
@@ -12,13 +12,14 @@ class DeleteFileOutTypedDict(TypedDict):
12
12
  r"""The object type that was deleted"""
13
13
  deleted: bool
14
14
  r"""The deletion status."""
15
-
15
+
16
16
 
17
17
  class DeleteFileOut(BaseModel):
18
18
  id: str
19
19
  r"""The ID of the deleted file."""
20
+
20
21
  object: str
21
22
  r"""The object type that was deleted"""
23
+
22
24
  deleted: bool
23
25
  r"""The deletion status."""
24
-
@@ -13,13 +13,14 @@ class DeleteModelOutTypedDict(TypedDict):
13
13
  r"""The object type that was deleted"""
14
14
  deleted: NotRequired[bool]
15
15
  r"""The deletion status"""
16
-
16
+
17
17
 
18
18
  class DeleteModelOut(BaseModel):
19
19
  id: str
20
20
  r"""The ID of the deleted model."""
21
+
21
22
  object: Optional[str] = "model"
22
23
  r"""The object type that was deleted"""
24
+
23
25
  deleted: Optional[bool] = True
24
26
  r"""The deletion status"""
25
-
@@ -12,13 +12,15 @@ class DeltaMessageTypedDict(TypedDict):
12
12
  role: NotRequired[str]
13
13
  content: NotRequired[Nullable[str]]
14
14
  tool_calls: NotRequired[Nullable[List[ToolCallTypedDict]]]
15
-
15
+
16
16
 
17
17
  class DeltaMessage(BaseModel):
18
18
  role: Optional[str] = None
19
+
19
20
  content: OptionalNullable[str] = UNSET
21
+
20
22
  tool_calls: OptionalNullable[List[ToolCall]] = UNSET
21
-
23
+
22
24
  @model_serializer(mode="wrap")
23
25
  def serialize_model(self, handler):
24
26
  optional_fields = ["role", "content", "tool_calls"]
@@ -32,9 +34,13 @@ class DeltaMessage(BaseModel):
32
34
  for n, f in self.model_fields.items():
33
35
  k = f.alias or n
34
36
  val = serialized.get(k)
37
+ serialized.pop(k, None)
35
38
 
36
39
  optional_nullable = k in optional_fields and k in nullable_fields
37
- is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
40
+ is_set = (
41
+ self.__pydantic_fields_set__.intersection({n})
42
+ or k in null_default_fields
43
+ ) # pylint: disable=no-member
38
44
 
39
45
  if val is not None and val != UNSET_SENTINEL:
40
46
  m[k] = val
@@ -44,4 +50,3 @@ class DeltaMessage(BaseModel):
44
50
  m[k] = val
45
51
 
46
52
  return m
47
-
@@ -15,7 +15,18 @@ from typing import Final, List, Literal, Optional, TypedDict
15
15
  from typing_extensions import Annotated, NotRequired
16
16
 
17
17
 
18
- DetailedJobOutStatus = Literal["QUEUED", "STARTED", "VALIDATING", "VALIDATED", "RUNNING", "FAILED_VALIDATION", "FAILED", "SUCCESS", "CANCELLED", "CANCELLATION_REQUESTED"]
18
+ DetailedJobOutStatus = Literal[
19
+ "QUEUED",
20
+ "STARTED",
21
+ "VALIDATING",
22
+ "VALIDATED",
23
+ "RUNNING",
24
+ "FAILED_VALIDATION",
25
+ "FAILED",
26
+ "SUCCESS",
27
+ "CANCELLED",
28
+ "CANCELLATION_REQUESTED",
29
+ ]
19
30
 
20
31
  DetailedJobOutObject = Literal["job"]
21
32
 
@@ -52,35 +63,73 @@ class DetailedJobOutTypedDict(TypedDict):
52
63
  events: NotRequired[List[EventOutTypedDict]]
53
64
  r"""Event items are created every time the status of a fine-tuning job changes. The timestamped list of all events is accessible here."""
54
65
  checkpoints: NotRequired[List[CheckpointOutTypedDict]]
55
-
66
+
56
67
 
57
68
  class DetailedJobOut(BaseModel):
58
69
  id: str
70
+
59
71
  auto_start: bool
72
+
60
73
  hyperparameters: TrainingParameters
74
+
61
75
  model: FineTuneableModel
62
76
  r"""The name of the model to fine-tune."""
77
+
63
78
  status: DetailedJobOutStatus
79
+
64
80
  job_type: str
81
+
65
82
  created_at: int
83
+
66
84
  modified_at: int
85
+
67
86
  training_files: List[str]
87
+
68
88
  validation_files: OptionalNullable[List[str]] = UNSET
89
+
90
+ # fmt: off
69
91
  OBJECT: Annotated[Final[Optional[DetailedJobOutObject]], pydantic.Field(alias="object")] = "job" # type: ignore
92
+ # fmt: on
93
+
70
94
  fine_tuned_model: OptionalNullable[str] = UNSET
95
+
71
96
  suffix: OptionalNullable[str] = UNSET
97
+
72
98
  integrations: OptionalNullable[List[DetailedJobOutIntegrations]] = UNSET
99
+
73
100
  trained_tokens: OptionalNullable[int] = UNSET
101
+
74
102
  repositories: Optional[List[DetailedJobOutRepositories]] = None
103
+
75
104
  metadata: OptionalNullable[JobMetadataOut] = UNSET
105
+
76
106
  events: Optional[List[EventOut]] = None
77
107
  r"""Event items are created every time the status of a fine-tuning job changes. The timestamped list of all events is accessible here."""
108
+
78
109
  checkpoints: Optional[List[CheckpointOut]] = None
79
-
110
+
80
111
  @model_serializer(mode="wrap")
81
112
  def serialize_model(self, handler):
82
- optional_fields = ["validation_files", "object", "fine_tuned_model", "suffix", "integrations", "trained_tokens", "repositories", "metadata", "events", "checkpoints"]
83
- nullable_fields = ["validation_files", "fine_tuned_model", "suffix", "integrations", "trained_tokens", "metadata"]
113
+ optional_fields = [
114
+ "validation_files",
115
+ "object",
116
+ "fine_tuned_model",
117
+ "suffix",
118
+ "integrations",
119
+ "trained_tokens",
120
+ "repositories",
121
+ "metadata",
122
+ "events",
123
+ "checkpoints",
124
+ ]
125
+ nullable_fields = [
126
+ "validation_files",
127
+ "fine_tuned_model",
128
+ "suffix",
129
+ "integrations",
130
+ "trained_tokens",
131
+ "metadata",
132
+ ]
84
133
  null_default_fields = []
85
134
 
86
135
  serialized = handler(self)
@@ -90,9 +139,13 @@ class DetailedJobOut(BaseModel):
90
139
  for n, f in self.model_fields.items():
91
140
  k = f.alias or n
92
141
  val = serialized.get(k)
142
+ serialized.pop(k, None)
93
143
 
94
144
  optional_nullable = k in optional_fields and k in nullable_fields
95
- is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
145
+ is_set = (
146
+ self.__pydantic_fields_set__.intersection({n})
147
+ or k in null_default_fields
148
+ ) # pylint: disable=no-member
96
149
 
97
150
  if val is not None and val != UNSET_SENTINEL:
98
151
  m[k] = val
@@ -102,4 +155,3 @@ class DetailedJobOut(BaseModel):
102
155
  m[k] = val
103
156
 
104
157
  return m
105
-
@@ -23,16 +23,18 @@ class EmbeddingRequestTypedDict(TypedDict):
23
23
  r"""ID of the model to use."""
24
24
  encoding_format: NotRequired[Nullable[str]]
25
25
  r"""The format to return the embeddings in."""
26
-
26
+
27
27
 
28
28
  class EmbeddingRequest(BaseModel):
29
29
  inputs: Annotated[Inputs, pydantic.Field(alias="input")]
30
30
  r"""Text to embed."""
31
+
31
32
  model: str
32
33
  r"""ID of the model to use."""
34
+
33
35
  encoding_format: OptionalNullable[str] = UNSET
34
36
  r"""The format to return the embeddings in."""
35
-
37
+
36
38
  @model_serializer(mode="wrap")
37
39
  def serialize_model(self, handler):
38
40
  optional_fields = ["encoding_format"]
@@ -46,9 +48,13 @@ class EmbeddingRequest(BaseModel):
46
48
  for n, f in self.model_fields.items():
47
49
  k = f.alias or n
48
50
  val = serialized.get(k)
51
+ serialized.pop(k, None)
49
52
 
50
53
  optional_nullable = k in optional_fields and k in nullable_fields
51
- is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
54
+ is_set = (
55
+ self.__pydantic_fields_set__.intersection({n})
56
+ or k in null_default_fields
57
+ ) # pylint: disable=no-member
52
58
 
53
59
  if val is not None and val != UNSET_SENTINEL:
54
60
  m[k] = val
@@ -58,4 +64,3 @@ class EmbeddingRequest(BaseModel):
58
64
  m[k] = val
59
65
 
60
66
  return m
61
-
@@ -13,12 +13,15 @@ class EmbeddingResponseTypedDict(TypedDict):
13
13
  model: str
14
14
  usage: UsageInfoTypedDict
15
15
  data: List[EmbeddingResponseDataTypedDict]
16
-
16
+
17
17
 
18
18
  class EmbeddingResponse(BaseModel):
19
19
  id: str
20
+
20
21
  object: str
22
+
21
23
  model: str
24
+
22
25
  usage: UsageInfo
26
+
23
27
  data: List[EmbeddingResponseData]
24
-
@@ -10,10 +10,11 @@ class EmbeddingResponseDataTypedDict(TypedDict):
10
10
  object: NotRequired[str]
11
11
  embedding: NotRequired[List[float]]
12
12
  index: NotRequired[int]
13
-
13
+
14
14
 
15
15
  class EmbeddingResponseData(BaseModel):
16
16
  object: Optional[str] = None
17
+
17
18
  embedding: Optional[List[float]] = None
19
+
18
20
  index: Optional[int] = None
19
-
@@ -13,15 +13,17 @@ class EventOutTypedDict(TypedDict):
13
13
  created_at: int
14
14
  r"""The UNIX timestamp (in seconds) of the event."""
15
15
  data: NotRequired[Nullable[Dict[str, Any]]]
16
-
16
+
17
17
 
18
18
  class EventOut(BaseModel):
19
19
  name: str
20
20
  r"""The name of the event."""
21
+
21
22
  created_at: int
22
23
  r"""The UNIX timestamp (in seconds) of the event."""
24
+
23
25
  data: OptionalNullable[Dict[str, Any]] = UNSET
24
-
26
+
25
27
  @model_serializer(mode="wrap")
26
28
  def serialize_model(self, handler):
27
29
  optional_fields = ["data"]
@@ -35,9 +37,13 @@ class EventOut(BaseModel):
35
37
  for n, f in self.model_fields.items():
36
38
  k = f.alias or n
37
39
  val = serialized.get(k)
40
+ serialized.pop(k, None)
38
41
 
39
42
  optional_nullable = k in optional_fields and k in nullable_fields
40
- is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
43
+ is_set = (
44
+ self.__pydantic_fields_set__.intersection({n})
45
+ or k in null_default_fields
46
+ ) # pylint: disable=no-member
41
47
 
42
48
  if val is not None and val != UNSET_SENTINEL:
43
49
  m[k] = val
@@ -47,4 +53,3 @@ class EventOut(BaseModel):
47
53
  m[k] = val
48
54
 
49
55
  return m
50
-
@@ -9,8 +9,9 @@ from typing_extensions import Annotated
9
9
 
10
10
  class FilesAPIRoutesDeleteFileRequestTypedDict(TypedDict):
11
11
  file_id: str
12
-
12
+
13
13
 
14
14
  class FilesAPIRoutesDeleteFileRequest(BaseModel):
15
- file_id: Annotated[str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))]
16
-
15
+ file_id: Annotated[
16
+ str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
17
+ ]
@@ -9,8 +9,9 @@ from typing_extensions import Annotated
9
9
 
10
10
  class FilesAPIRoutesRetrieveFileRequestTypedDict(TypedDict):
11
11
  file_id: str
12
-
12
+
13
13
 
14
14
  class FilesAPIRoutesRetrieveFileRequest(BaseModel):
15
- file_id: Annotated[str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))]
16
-
15
+ file_id: Annotated[
16
+ str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
17
+ ]