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
@@ -10,13 +10,17 @@ from typing_extensions import Annotated, NotRequired
10
10
 
11
11
  JobsOutObject = Literal["list"]
12
12
 
13
+
13
14
  class JobsOutTypedDict(TypedDict):
14
15
  total: int
15
16
  data: NotRequired[List[JobOutTypedDict]]
16
-
17
+
17
18
 
18
19
  class JobsOut(BaseModel):
19
20
  total: int
21
+
20
22
  data: Optional[List[JobOut]] = None
23
+
24
+ # fmt: off
21
25
  OBJECT: Annotated[Final[Optional[JobsOutObject]], pydantic.Field(alias="object")] = "list" # type: ignore
22
-
26
+ # fmt: on
@@ -10,6 +10,7 @@ from typing_extensions import Annotated, NotRequired
10
10
 
11
11
  LegacyJobMetadataOutObject = Literal["job.metadata"]
12
12
 
13
+
13
14
  class LegacyJobMetadataOutTypedDict(TypedDict):
14
15
  details: str
15
16
  expected_duration_seconds: NotRequired[Nullable[int]]
@@ -30,34 +31,69 @@ class LegacyJobMetadataOutTypedDict(TypedDict):
30
31
  r"""The number of complete passes through the entire training dataset."""
31
32
  training_steps: NotRequired[Nullable[int]]
32
33
  r"""The number of training steps to perform. A training step refers to a single update of the model weights during the fine-tuning process. This update is typically calculated using a batch of samples from the training dataset."""
33
-
34
+
34
35
 
35
36
  class LegacyJobMetadataOut(BaseModel):
36
37
  details: str
38
+
37
39
  expected_duration_seconds: OptionalNullable[int] = UNSET
38
40
  r"""The approximated time (in seconds) for the fine-tuning process to complete."""
41
+
39
42
  cost: OptionalNullable[float] = UNSET
40
43
  r"""The cost of the fine-tuning job."""
44
+
41
45
  cost_currency: OptionalNullable[str] = UNSET
42
46
  r"""The currency used for the fine-tuning job cost."""
47
+
43
48
  train_tokens_per_step: OptionalNullable[int] = UNSET
44
49
  r"""The number of tokens consumed by one training step."""
50
+
45
51
  train_tokens: OptionalNullable[int] = UNSET
46
52
  r"""The total number of tokens used during the fine-tuning process."""
53
+
47
54
  data_tokens: OptionalNullable[int] = UNSET
48
55
  r"""The total number of tokens in the training dataset."""
56
+
49
57
  estimated_start_time: OptionalNullable[int] = UNSET
58
+
50
59
  deprecated: Optional[bool] = True
60
+
51
61
  epochs: OptionalNullable[float] = UNSET
52
62
  r"""The number of complete passes through the entire training dataset."""
63
+
53
64
  training_steps: OptionalNullable[int] = UNSET
54
65
  r"""The number of training steps to perform. A training step refers to a single update of the model weights during the fine-tuning process. This update is typically calculated using a batch of samples from the training dataset."""
66
+
67
+ # fmt: off
55
68
  OBJECT: Annotated[Final[Optional[LegacyJobMetadataOutObject]], pydantic.Field(alias="object")] = "job.metadata" # type: ignore
56
-
69
+ # fmt: on
70
+
57
71
  @model_serializer(mode="wrap")
58
72
  def serialize_model(self, handler):
59
- optional_fields = ["expected_duration_seconds", "cost", "cost_currency", "train_tokens_per_step", "train_tokens", "data_tokens", "estimated_start_time", "deprecated", "epochs", "training_steps", "object"]
60
- nullable_fields = ["expected_duration_seconds", "cost", "cost_currency", "train_tokens_per_step", "train_tokens", "data_tokens", "estimated_start_time", "epochs", "training_steps"]
73
+ optional_fields = [
74
+ "expected_duration_seconds",
75
+ "cost",
76
+ "cost_currency",
77
+ "train_tokens_per_step",
78
+ "train_tokens",
79
+ "data_tokens",
80
+ "estimated_start_time",
81
+ "deprecated",
82
+ "epochs",
83
+ "training_steps",
84
+ "object",
85
+ ]
86
+ nullable_fields = [
87
+ "expected_duration_seconds",
88
+ "cost",
89
+ "cost_currency",
90
+ "train_tokens_per_step",
91
+ "train_tokens",
92
+ "data_tokens",
93
+ "estimated_start_time",
94
+ "epochs",
95
+ "training_steps",
96
+ ]
61
97
  null_default_fields = []
62
98
 
63
99
  serialized = handler(self)
@@ -67,9 +103,13 @@ class LegacyJobMetadataOut(BaseModel):
67
103
  for n, f in self.model_fields.items():
68
104
  k = f.alias or n
69
105
  val = serialized.get(k)
106
+ serialized.pop(k, None)
70
107
 
71
108
  optional_nullable = k in optional_fields and k in nullable_fields
72
- is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
109
+ is_set = (
110
+ self.__pydantic_fields_set__.intersection({n})
111
+ or k in null_default_fields
112
+ ) # pylint: disable=no-member
73
113
 
74
114
  if val is not None and val != UNSET_SENTINEL:
75
115
  m[k] = val
@@ -79,4 +119,3 @@ class LegacyJobMetadataOut(BaseModel):
79
119
  m[k] = val
80
120
 
81
121
  return m
82
-
@@ -9,9 +9,9 @@ from typing import List, TypedDict
9
9
  class ListFilesOutTypedDict(TypedDict):
10
10
  data: List[FileSchemaTypedDict]
11
11
  object: str
12
-
12
+
13
13
 
14
14
  class ListFilesOut(BaseModel):
15
15
  data: List[FileSchema]
16
+
16
17
  object: str
17
-
@@ -9,19 +9,21 @@ from typing_extensions import NotRequired
9
9
 
10
10
  class MetricOutTypedDict(TypedDict):
11
11
  r"""Metrics at the step number during the fine-tuning job. Use these metrics to assess if the training is going smoothly (loss should decrease, token accuracy should increase)."""
12
-
12
+
13
13
  train_loss: NotRequired[Nullable[float]]
14
14
  valid_loss: NotRequired[Nullable[float]]
15
15
  valid_mean_token_accuracy: NotRequired[Nullable[float]]
16
-
16
+
17
17
 
18
18
  class MetricOut(BaseModel):
19
19
  r"""Metrics at the step number during the fine-tuning job. Use these metrics to assess if the training is going smoothly (loss should decrease, token accuracy should increase)."""
20
-
20
+
21
21
  train_loss: OptionalNullable[float] = UNSET
22
+
22
23
  valid_loss: OptionalNullable[float] = UNSET
24
+
23
25
  valid_mean_token_accuracy: OptionalNullable[float] = UNSET
24
-
26
+
25
27
  @model_serializer(mode="wrap")
26
28
  def serialize_model(self, handler):
27
29
  optional_fields = ["train_loss", "valid_loss", "valid_mean_token_accuracy"]
@@ -35,9 +37,13 @@ class MetricOut(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 MetricOut(BaseModel):
47
53
  m[k] = val
48
54
 
49
55
  return m
50
-
@@ -11,11 +11,16 @@ class ModelCapabilitiesTypedDict(TypedDict):
11
11
  completion_fim: NotRequired[bool]
12
12
  function_calling: NotRequired[bool]
13
13
  fine_tuning: NotRequired[bool]
14
-
14
+ vision: NotRequired[bool]
15
+
15
16
 
16
17
  class ModelCapabilities(BaseModel):
17
18
  completion_chat: Optional[bool] = True
19
+
18
20
  completion_fim: Optional[bool] = False
21
+
19
22
  function_calling: Optional[bool] = True
23
+
20
24
  fine_tuning: Optional[bool] = False
21
-
25
+
26
+ vision: Optional[bool] = False
@@ -1,18 +1,32 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from .modelcard import ModelCard, ModelCardTypedDict
4
+ from .basemodelcard import BaseModelCard, BaseModelCardTypedDict
5
+ from .ftmodelcard import FTModelCard, FTModelCardTypedDict
5
6
  from mistralai.types import BaseModel
6
- from typing import List, Optional, TypedDict
7
- from typing_extensions import NotRequired
7
+ from mistralai.utils import get_discriminator
8
+ from pydantic import Discriminator, Tag
9
+ from typing import List, Optional, TypedDict, Union
10
+ from typing_extensions import Annotated, NotRequired
11
+
12
+
13
+ DataTypedDict = Union[BaseModelCardTypedDict, FTModelCardTypedDict]
14
+
15
+
16
+ Data = Annotated[
17
+ Union[
18
+ Annotated[BaseModelCard, Tag("base")], Annotated[FTModelCard, Tag("fine-tuned")]
19
+ ],
20
+ Discriminator(lambda m: get_discriminator(m, "type", "type")),
21
+ ]
8
22
 
9
23
 
10
24
  class ModelListTypedDict(TypedDict):
11
25
  object: NotRequired[str]
12
- data: NotRequired[List[ModelCardTypedDict]]
13
-
26
+ data: NotRequired[List[DataTypedDict]]
27
+
14
28
 
15
29
  class ModelList(BaseModel):
16
30
  object: Optional[str] = "list"
17
- data: Optional[List[ModelCard]] = None
18
-
31
+
32
+ data: Optional[List[Data]] = None
@@ -1,18 +1,17 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
+ from .responseformats import ResponseFormats
4
5
  from mistralai.types import BaseModel
5
- from typing import Literal, Optional, TypedDict
6
+ from typing import Optional, TypedDict
6
7
  from typing_extensions import NotRequired
7
8
 
8
9
 
9
- ResponseFormats = Literal["text", "json_object"]
10
- r"""An object specifying the format that the model must output. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message."""
11
-
12
10
  class ResponseFormatTypedDict(TypedDict):
13
11
  type: NotRequired[ResponseFormats]
14
-
12
+ r"""An object specifying the format that the model must output. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message."""
13
+
15
14
 
16
15
  class ResponseFormat(BaseModel):
17
- type: Optional[ResponseFormats] = "text"
18
-
16
+ type: Optional[ResponseFormats] = None
17
+ r"""An object specifying the format that the model must output. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message."""
@@ -0,0 +1,8 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from typing import Literal
5
+
6
+
7
+ ResponseFormats = Literal["text", "json_object"]
8
+ r"""An object specifying the format that the model must output. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message."""
@@ -1,18 +1,37 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
+ from .basemodelcard import BaseModelCard, BaseModelCardTypedDict
5
+ from .ftmodelcard import FTModelCard, FTModelCardTypedDict
4
6
  from mistralai.types import BaseModel
5
- from mistralai.utils import FieldMetadata, PathParamMetadata
6
- from typing import TypedDict
7
+ from mistralai.utils import FieldMetadata, PathParamMetadata, get_discriminator
8
+ from pydantic import Discriminator, Tag
9
+ from typing import TypedDict, Union
7
10
  from typing_extensions import Annotated
8
11
 
9
12
 
10
13
  class RetrieveModelV1ModelsModelIDGetRequestTypedDict(TypedDict):
11
14
  model_id: str
12
15
  r"""The ID of the model to retrieve."""
13
-
16
+
14
17
 
15
18
  class RetrieveModelV1ModelsModelIDGetRequest(BaseModel):
16
- model_id: Annotated[str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))]
19
+ model_id: Annotated[
20
+ str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
21
+ ]
17
22
  r"""The ID of the model to retrieve."""
18
-
23
+
24
+
25
+ RetrieveModelV1ModelsModelIDGetResponseRetrieveModelV1ModelsModelIDGetTypedDict = Union[
26
+ BaseModelCardTypedDict, FTModelCardTypedDict
27
+ ]
28
+ r"""Successful Response"""
29
+
30
+
31
+ RetrieveModelV1ModelsModelIDGetResponseRetrieveModelV1ModelsModelIDGet = Annotated[
32
+ Union[
33
+ Annotated[BaseModelCard, Tag("base")], Annotated[FTModelCard, Tag("fine-tuned")]
34
+ ],
35
+ Discriminator(lambda m: get_discriminator(m, "type", "type")),
36
+ ]
37
+ r"""Successful Response"""
@@ -3,7 +3,14 @@
3
3
  from __future__ import annotations
4
4
  from .sampletype import SampleType
5
5
  from .source import Source
6
- from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL, UnrecognizedStr
6
+ from mistralai.types import (
7
+ BaseModel,
8
+ Nullable,
9
+ OptionalNullable,
10
+ UNSET,
11
+ UNSET_SENTINEL,
12
+ UnrecognizedStr,
13
+ )
7
14
  from mistralai.utils import validate_open_enum
8
15
  import pydantic
9
16
  from pydantic import model_serializer
@@ -15,6 +22,7 @@ from typing_extensions import Annotated, NotRequired
15
22
  RetrieveFileOutPurpose = Union[Literal["fine-tune"], UnrecognizedStr]
16
23
  r"""The intended purpose of the uploaded file. Only accepts fine-tuning (`fine-tune`) for now."""
17
24
 
25
+
18
26
  class RetrieveFileOutTypedDict(TypedDict):
19
27
  id: str
20
28
  r"""The unique identifier of the file."""
@@ -29,25 +37,35 @@ class RetrieveFileOutTypedDict(TypedDict):
29
37
  sample_type: SampleType
30
38
  source: Source
31
39
  num_lines: NotRequired[Nullable[int]]
32
-
40
+
33
41
 
34
42
  class RetrieveFileOut(BaseModel):
35
43
  id: str
36
44
  r"""The unique identifier of the file."""
45
+
37
46
  object: str
38
47
  r"""The object type, which is always \"file\"."""
48
+
39
49
  bytes: int
40
50
  r"""The size of the file, in bytes."""
51
+
41
52
  created_at: int
42
53
  r"""The UNIX timestamp (in seconds) of the event."""
54
+
43
55
  filename: str
44
56
  r"""The name of the uploaded file."""
57
+
45
58
  sample_type: SampleType
59
+
46
60
  source: Source
61
+
62
+ # fmt: off
47
63
  PURPOSE: Annotated[Final[Annotated[RetrieveFileOutPurpose, PlainValidator(validate_open_enum(False))]], pydantic.Field(alias="purpose")] = "fine-tune" # type: ignore
64
+ # fmt: on
48
65
  r"""The intended purpose of the uploaded file. Only accepts fine-tuning (`fine-tune`) for now."""
66
+
49
67
  num_lines: OptionalNullable[int] = UNSET
50
-
68
+
51
69
  @model_serializer(mode="wrap")
52
70
  def serialize_model(self, handler):
53
71
  optional_fields = ["num_lines"]
@@ -61,9 +79,13 @@ class RetrieveFileOut(BaseModel):
61
79
  for n, f in self.model_fields.items():
62
80
  k = f.alias or n
63
81
  val = serialized.get(k)
82
+ serialized.pop(k, None)
64
83
 
65
84
  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
85
+ is_set = (
86
+ self.__pydantic_fields_set__.intersection({n})
87
+ or k in null_default_fields
88
+ ) # pylint: disable=no-member
67
89
 
68
90
  if val is not None and val != UNSET_SENTINEL:
69
91
  m[k] = val
@@ -73,4 +95,3 @@ class RetrieveFileOut(BaseModel):
73
95
  m[k] = val
74
96
 
75
97
  return m
76
-
@@ -9,8 +9,17 @@ from typing_extensions import Annotated, NotRequired
9
9
 
10
10
  class SecurityTypedDict(TypedDict):
11
11
  api_key: NotRequired[str]
12
-
12
+
13
13
 
14
14
  class Security(BaseModel):
15
- api_key: Annotated[Optional[str], FieldMetadata(security=SecurityMetadata(scheme=True, scheme_type="http", sub_type="bearer", field_name="Authorization"))] = None
16
-
15
+ api_key: Annotated[
16
+ Optional[str],
17
+ FieldMetadata(
18
+ security=SecurityMetadata(
19
+ scheme=True,
20
+ scheme_type="http",
21
+ sub_type="bearer",
22
+ field_name="Authorization",
23
+ )
24
+ ),
25
+ ] = None
@@ -1,26 +1,27 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from .contentchunk import ContentChunk, ContentChunkTypedDict
4
+ from .textchunk import TextChunk, TextChunkTypedDict
5
5
  from mistralai.types import BaseModel
6
6
  from typing import List, Literal, Optional, TypedDict, Union
7
7
  from typing_extensions import NotRequired
8
8
 
9
9
 
10
- ContentTypedDict = Union[str, List[ContentChunkTypedDict]]
10
+ ContentTypedDict = Union[str, List[TextChunkTypedDict]]
11
11
 
12
12
 
13
- Content = Union[str, List[ContentChunk]]
13
+ Content = Union[str, List[TextChunk]]
14
14
 
15
15
 
16
16
  Role = Literal["system"]
17
17
 
18
+
18
19
  class SystemMessageTypedDict(TypedDict):
19
20
  content: ContentTypedDict
20
21
  role: NotRequired[Role]
21
-
22
+
22
23
 
23
24
  class SystemMessage(BaseModel):
24
25
  content: Content
26
+
25
27
  role: Optional[Role] = "system"
26
-
@@ -3,15 +3,20 @@
3
3
  from __future__ import annotations
4
4
  from mistralai.types import BaseModel
5
5
  import pydantic
6
- from typing import Final, Optional, TypedDict
6
+ from typing import Final, Literal, Optional, TypedDict
7
7
  from typing_extensions import Annotated
8
8
 
9
9
 
10
+ TextChunkType = Literal["text"]
11
+
12
+
10
13
  class TextChunkTypedDict(TypedDict):
11
14
  text: str
12
-
15
+
13
16
 
14
17
  class TextChunk(BaseModel):
15
18
  text: str
16
- TYPE: Annotated[Final[Optional[str]], pydantic.Field(alias="type")] = "text" # type: ignore
17
-
19
+
20
+ # fmt: off
21
+ TYPE: Annotated[Final[Optional[TextChunkType]], pydantic.Field(alias="type")] = "text" # type: ignore
22
+ # fmt: on
mistralai/models/tool.py CHANGED
@@ -2,21 +2,22 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from .function import Function, FunctionTypedDict
5
- from mistralai.types import BaseModel, UnrecognizedStr
5
+ from .tooltypes import ToolTypes
6
+ from mistralai.types import BaseModel
6
7
  from mistralai.utils import validate_open_enum
7
8
  from pydantic.functional_validators import PlainValidator
8
- from typing import Literal, Optional, TypedDict, Union
9
+ from typing import Optional, TypedDict
9
10
  from typing_extensions import Annotated, NotRequired
10
11
 
11
12
 
12
- ToolToolTypes = Union[Literal["function"], UnrecognizedStr]
13
-
14
13
  class ToolTypedDict(TypedDict):
15
14
  function: FunctionTypedDict
16
- type: NotRequired[ToolToolTypes]
17
-
15
+ type: NotRequired[ToolTypes]
16
+
18
17
 
19
18
  class Tool(BaseModel):
20
19
  function: Function
21
- type: Annotated[Optional[ToolToolTypes], PlainValidator(validate_open_enum(False))] = "function"
22
-
20
+
21
+ type: Annotated[Optional[ToolTypes], PlainValidator(validate_open_enum(False))] = (
22
+ None
23
+ )
@@ -2,23 +2,25 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from .functioncall import FunctionCall, FunctionCallTypedDict
5
- from mistralai.types import BaseModel, UnrecognizedStr
5
+ from .tooltypes import ToolTypes
6
+ from mistralai.types import BaseModel
6
7
  from mistralai.utils import validate_open_enum
7
8
  from pydantic.functional_validators import PlainValidator
8
- from typing import Literal, Optional, TypedDict, Union
9
+ from typing import Optional, TypedDict
9
10
  from typing_extensions import Annotated, NotRequired
10
11
 
11
12
 
12
- ToolTypes = Union[Literal["function"], UnrecognizedStr]
13
-
14
13
  class ToolCallTypedDict(TypedDict):
15
14
  function: FunctionCallTypedDict
16
15
  id: NotRequired[str]
17
16
  type: NotRequired[ToolTypes]
18
-
17
+
19
18
 
20
19
  class ToolCall(BaseModel):
21
20
  function: FunctionCall
21
+
22
22
  id: Optional[str] = "null"
23
- type: Annotated[Optional[ToolTypes], PlainValidator(validate_open_enum(False))] = "function"
24
-
23
+
24
+ type: Annotated[Optional[ToolTypes], PlainValidator(validate_open_enum(False))] = (
25
+ None
26
+ )
@@ -0,0 +1,29 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .functionname import FunctionName, FunctionNameTypedDict
5
+ from .tooltypes import ToolTypes
6
+ from mistralai.types import BaseModel
7
+ from mistralai.utils import validate_open_enum
8
+ from pydantic.functional_validators import PlainValidator
9
+ from typing import Optional, TypedDict
10
+ from typing_extensions import Annotated, NotRequired
11
+
12
+
13
+ class ToolChoiceTypedDict(TypedDict):
14
+ r"""ToolChoice is either a ToolChoiceEnum or a ToolChoice"""
15
+
16
+ function: FunctionNameTypedDict
17
+ r"""this restriction of `Function` is used to select a specific function to call"""
18
+ type: NotRequired[ToolTypes]
19
+
20
+
21
+ class ToolChoice(BaseModel):
22
+ r"""ToolChoice is either a ToolChoiceEnum or a ToolChoice"""
23
+
24
+ function: FunctionName
25
+ r"""this restriction of `Function` is used to select a specific function to call"""
26
+
27
+ type: Annotated[Optional[ToolTypes], PlainValidator(validate_open_enum(False))] = (
28
+ None
29
+ )
@@ -0,0 +1,7 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from typing import Literal
5
+
6
+
7
+ ToolChoiceEnum = Literal["auto", "none", "any", "required"]
@@ -9,19 +9,23 @@ from typing_extensions import NotRequired
9
9
 
10
10
  ToolMessageRole = Literal["tool"]
11
11
 
12
+
12
13
  class ToolMessageTypedDict(TypedDict):
13
14
  content: str
14
15
  tool_call_id: NotRequired[Nullable[str]]
15
16
  name: NotRequired[Nullable[str]]
16
17
  role: NotRequired[ToolMessageRole]
17
-
18
+
18
19
 
19
20
  class ToolMessage(BaseModel):
20
21
  content: str
22
+
21
23
  tool_call_id: OptionalNullable[str] = UNSET
24
+
22
25
  name: OptionalNullable[str] = UNSET
26
+
23
27
  role: Optional[ToolMessageRole] = "tool"
24
-
28
+
25
29
  @model_serializer(mode="wrap")
26
30
  def serialize_model(self, handler):
27
31
  optional_fields = ["tool_call_id", "name", "role"]
@@ -35,9 +39,13 @@ class ToolMessage(BaseModel):
35
39
  for n, f in self.model_fields.items():
36
40
  k = f.alias or n
37
41
  val = serialized.get(k)
42
+ serialized.pop(k, None)
38
43
 
39
44
  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
45
+ is_set = (
46
+ self.__pydantic_fields_set__.intersection({n})
47
+ or k in null_default_fields
48
+ ) # pylint: disable=no-member
41
49
 
42
50
  if val is not None and val != UNSET_SENTINEL:
43
51
  m[k] = val
@@ -47,4 +55,3 @@ class ToolMessage(BaseModel):
47
55
  m[k] = val
48
56
 
49
57
  return m
50
-
@@ -0,0 +1,8 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from mistralai.types import UnrecognizedStr
5
+ from typing import Literal, Union
6
+
7
+
8
+ ToolTypes = Union[Literal["function"], UnrecognizedStr]
@@ -9,9 +9,9 @@ from typing_extensions import NotRequired
9
9
  class TrainingFileTypedDict(TypedDict):
10
10
  file_id: str
11
11
  weight: NotRequired[float]
12
-
12
+
13
13
 
14
14
  class TrainingFile(BaseModel):
15
15
  file_id: str
16
+
16
17
  weight: Optional[float] = 1
17
-