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
@@ -9,17 +9,20 @@ from typing import Literal, TypedDict
9
9
 
10
10
  FinishReason = Literal["stop", "length", "error", "tool_calls"]
11
11
 
12
+
12
13
  class CompletionResponseStreamChoiceTypedDict(TypedDict):
13
14
  index: int
14
15
  delta: DeltaMessageTypedDict
15
16
  finish_reason: Nullable[FinishReason]
16
-
17
+
17
18
 
18
19
  class CompletionResponseStreamChoice(BaseModel):
19
20
  index: int
21
+
20
22
  delta: DeltaMessage
23
+
21
24
  finish_reason: Nullable[FinishReason]
22
-
25
+
23
26
  @model_serializer(mode="wrap")
24
27
  def serialize_model(self, handler):
25
28
  optional_fields = []
@@ -33,9 +36,13 @@ class CompletionResponseStreamChoice(BaseModel):
33
36
  for n, f in self.model_fields.items():
34
37
  k = f.alias or n
35
38
  val = serialized.get(k)
39
+ serialized.pop(k, None)
36
40
 
37
41
  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
42
+ is_set = (
43
+ self.__pydantic_fields_set__.intersection({n})
44
+ or k in null_default_fields
45
+ ) # pylint: disable=no-member
39
46
 
40
47
  if val is not None and val != UNSET_SENTINEL:
41
48
  m[k] = val
@@ -45,4 +52,3 @@ class CompletionResponseStreamChoice(BaseModel):
45
52
  m[k] = val
46
53
 
47
54
  return m
48
-
@@ -1,17 +1,10 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from mistralai_gcp.types import BaseModel
5
- import pydantic
6
- from typing import Final, Optional, TypedDict
7
- from typing_extensions import Annotated
4
+ from .textchunk import TextChunk, TextChunkTypedDict
8
5
 
9
6
 
10
- class ContentChunkTypedDict(TypedDict):
11
- text: str
12
-
7
+ ContentChunkTypedDict = TextChunkTypedDict
13
8
 
14
- class ContentChunk(BaseModel):
15
- text: str
16
- TYPE: Annotated[Final[Optional[str]], pydantic.Field(alias="type")] = "text" # type: ignore
17
-
9
+
10
+ ContentChunk = TextChunk
@@ -2,7 +2,13 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from .toolcall import ToolCall, ToolCallTypedDict
5
- from mistralai_gcp.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
5
+ from mistralai_gcp.types import (
6
+ BaseModel,
7
+ Nullable,
8
+ OptionalNullable,
9
+ UNSET,
10
+ UNSET_SENTINEL,
11
+ )
6
12
  from pydantic import model_serializer
7
13
  from typing import List, Optional, TypedDict
8
14
  from typing_extensions import NotRequired
@@ -12,13 +18,15 @@ class DeltaMessageTypedDict(TypedDict):
12
18
  role: NotRequired[str]
13
19
  content: NotRequired[Nullable[str]]
14
20
  tool_calls: NotRequired[Nullable[List[ToolCallTypedDict]]]
15
-
21
+
16
22
 
17
23
  class DeltaMessage(BaseModel):
18
24
  role: Optional[str] = None
25
+
19
26
  content: OptionalNullable[str] = UNSET
27
+
20
28
  tool_calls: OptionalNullable[List[ToolCall]] = UNSET
21
-
29
+
22
30
  @model_serializer(mode="wrap")
23
31
  def serialize_model(self, handler):
24
32
  optional_fields = ["role", "content", "tool_calls"]
@@ -32,9 +40,13 @@ class DeltaMessage(BaseModel):
32
40
  for n, f in self.model_fields.items():
33
41
  k = f.alias or n
34
42
  val = serialized.get(k)
43
+ serialized.pop(k, None)
35
44
 
36
45
  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
46
+ is_set = (
47
+ self.__pydantic_fields_set__.intersection({n})
48
+ or k in null_default_fields
49
+ ) # pylint: disable=no-member
38
50
 
39
51
  if val is not None and val != UNSET_SENTINEL:
40
52
  m[k] = val
@@ -44,4 +56,3 @@ class DeltaMessage(BaseModel):
44
56
  m[k] = val
45
57
 
46
58
  return m
47
-
@@ -1,7 +1,13 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from mistralai_gcp.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
4
+ from mistralai_gcp.types import (
5
+ BaseModel,
6
+ Nullable,
7
+ OptionalNullable,
8
+ UNSET,
9
+ UNSET_SENTINEL,
10
+ )
5
11
  from pydantic import model_serializer
6
12
  from typing import List, Optional, TypedDict, Union
7
13
  from typing_extensions import NotRequired
@@ -39,7 +45,7 @@ class FIMCompletionRequestTypedDict(TypedDict):
39
45
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
40
46
  suffix: NotRequired[Nullable[str]]
41
47
  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`."""
42
-
48
+
43
49
 
44
50
  class FIMCompletionRequest(BaseModel):
45
51
  model: Nullable[str]
@@ -47,28 +53,46 @@ class FIMCompletionRequest(BaseModel):
47
53
  - `codestral-2405`
48
54
  - `codestral-latest`
49
55
  """
56
+
50
57
  prompt: str
51
58
  r"""The text/code to complete."""
59
+
52
60
  temperature: Optional[float] = 0.7
53
61
  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."""
62
+
54
63
  top_p: Optional[float] = 1
55
64
  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."""
65
+
56
66
  max_tokens: OptionalNullable[int] = UNSET
57
67
  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."""
68
+
58
69
  min_tokens: OptionalNullable[int] = UNSET
59
70
  r"""The minimum number of tokens to generate in the completion."""
71
+
60
72
  stream: Optional[bool] = False
61
73
  r"""Whether to stream back partial progress. If set, tokens will be sent as data-only server-side events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON."""
74
+
62
75
  stop: Optional[FIMCompletionRequestStop] = None
63
76
  r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
77
+
64
78
  random_seed: OptionalNullable[int] = UNSET
65
79
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
80
+
66
81
  suffix: OptionalNullable[str] = UNSET
67
82
  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`."""
68
-
83
+
69
84
  @model_serializer(mode="wrap")
70
85
  def serialize_model(self, handler):
71
- optional_fields = ["temperature", "top_p", "max_tokens", "min_tokens", "stream", "stop", "random_seed", "suffix"]
86
+ optional_fields = [
87
+ "temperature",
88
+ "top_p",
89
+ "max_tokens",
90
+ "min_tokens",
91
+ "stream",
92
+ "stop",
93
+ "random_seed",
94
+ "suffix",
95
+ ]
72
96
  nullable_fields = ["model", "max_tokens", "min_tokens", "random_seed", "suffix"]
73
97
  null_default_fields = []
74
98
 
@@ -79,9 +103,13 @@ class FIMCompletionRequest(BaseModel):
79
103
  for n, f in self.model_fields.items():
80
104
  k = f.alias or n
81
105
  val = serialized.get(k)
106
+ serialized.pop(k, None)
82
107
 
83
108
  optional_nullable = k in optional_fields and k in nullable_fields
84
- 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
85
113
 
86
114
  if val is not None and val != UNSET_SENTINEL:
87
115
  m[k] = val
@@ -91,4 +119,3 @@ class FIMCompletionRequest(BaseModel):
91
119
  m[k] = val
92
120
 
93
121
  return m
94
-
@@ -15,13 +15,17 @@ class FIMCompletionResponseTypedDict(TypedDict):
15
15
  usage: UsageInfoTypedDict
16
16
  created: NotRequired[int]
17
17
  choices: NotRequired[List[ChatCompletionChoiceTypedDict]]
18
-
18
+
19
19
 
20
20
  class FIMCompletionResponse(BaseModel):
21
21
  id: str
22
+
22
23
  object: str
24
+
23
25
  model: str
26
+
24
27
  usage: UsageInfo
28
+
25
29
  created: Optional[int] = None
30
+
26
31
  choices: Optional[List[ChatCompletionChoice]] = None
27
-
@@ -1,7 +1,13 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from mistralai_gcp.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
4
+ from mistralai_gcp.types import (
5
+ BaseModel,
6
+ Nullable,
7
+ OptionalNullable,
8
+ UNSET,
9
+ UNSET_SENTINEL,
10
+ )
5
11
  from pydantic import model_serializer
6
12
  from typing import List, Optional, TypedDict, Union
7
13
  from typing_extensions import NotRequired
@@ -38,7 +44,7 @@ class FIMCompletionStreamRequestTypedDict(TypedDict):
38
44
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
39
45
  suffix: NotRequired[Nullable[str]]
40
46
  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`."""
41
-
47
+
42
48
 
43
49
  class FIMCompletionStreamRequest(BaseModel):
44
50
  model: Nullable[str]
@@ -46,27 +52,45 @@ class FIMCompletionStreamRequest(BaseModel):
46
52
  - `codestral-2405`
47
53
  - `codestral-latest`
48
54
  """
55
+
49
56
  prompt: str
50
57
  r"""The text/code to complete."""
58
+
51
59
  temperature: Optional[float] = 0.7
52
60
  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."""
61
+
53
62
  top_p: Optional[float] = 1
54
63
  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."""
64
+
55
65
  max_tokens: OptionalNullable[int] = UNSET
56
66
  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."""
67
+
57
68
  min_tokens: OptionalNullable[int] = UNSET
58
69
  r"""The minimum number of tokens to generate in the completion."""
70
+
59
71
  stream: Optional[bool] = True
72
+
60
73
  stop: Optional[FIMCompletionStreamRequestStop] = None
61
74
  r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
75
+
62
76
  random_seed: OptionalNullable[int] = UNSET
63
77
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
78
+
64
79
  suffix: OptionalNullable[str] = UNSET
65
80
  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`."""
66
-
81
+
67
82
  @model_serializer(mode="wrap")
68
83
  def serialize_model(self, handler):
69
- optional_fields = ["temperature", "top_p", "max_tokens", "min_tokens", "stream", "stop", "random_seed", "suffix"]
84
+ optional_fields = [
85
+ "temperature",
86
+ "top_p",
87
+ "max_tokens",
88
+ "min_tokens",
89
+ "stream",
90
+ "stop",
91
+ "random_seed",
92
+ "suffix",
93
+ ]
70
94
  nullable_fields = ["model", "max_tokens", "min_tokens", "random_seed", "suffix"]
71
95
  null_default_fields = []
72
96
 
@@ -77,9 +101,13 @@ class FIMCompletionStreamRequest(BaseModel):
77
101
  for n, f in self.model_fields.items():
78
102
  k = f.alias or n
79
103
  val = serialized.get(k)
104
+ serialized.pop(k, None)
80
105
 
81
106
  optional_nullable = k in optional_fields and k in nullable_fields
82
- is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
107
+ is_set = (
108
+ self.__pydantic_fields_set__.intersection({n})
109
+ or k in null_default_fields
110
+ ) # pylint: disable=no-member
83
111
 
84
112
  if val is not None and val != UNSET_SENTINEL:
85
113
  m[k] = val
@@ -89,4 +117,3 @@ class FIMCompletionStreamRequest(BaseModel):
89
117
  m[k] = val
90
118
 
91
119
  return m
92
-
@@ -10,10 +10,11 @@ class FunctionTypedDict(TypedDict):
10
10
  name: str
11
11
  parameters: Dict[str, Any]
12
12
  description: NotRequired[str]
13
-
13
+
14
14
 
15
15
  class Function(BaseModel):
16
16
  name: str
17
+
17
18
  parameters: Dict[str, Any]
19
+
18
20
  description: Optional[str] = ""
19
-
@@ -14,9 +14,9 @@ Arguments = Union[Dict[str, Any], str]
14
14
  class FunctionCallTypedDict(TypedDict):
15
15
  name: str
16
16
  arguments: ArgumentsTypedDict
17
-
17
+
18
18
 
19
19
  class FunctionCall(BaseModel):
20
20
  name: str
21
+
21
22
  arguments: Arguments
22
-
@@ -0,0 +1,17 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from mistralai_gcp.types import BaseModel
5
+ from typing import TypedDict
6
+
7
+
8
+ class FunctionNameTypedDict(TypedDict):
9
+ r"""this restriction of `Function` is used to select a specific function to call"""
10
+
11
+ name: str
12
+
13
+
14
+ class FunctionName(BaseModel):
15
+ r"""this restriction of `Function` is used to select a specific function to call"""
16
+
17
+ name: str
@@ -6,13 +6,14 @@ from mistralai_gcp import utils
6
6
  from mistralai_gcp.types import BaseModel
7
7
  from typing import List, Optional
8
8
 
9
+
9
10
  class HTTPValidationErrorData(BaseModel):
10
11
  detail: Optional[List[ValidationError]] = None
11
-
12
12
 
13
13
 
14
14
  class HTTPValidationError(Exception):
15
15
  r"""Validation Error"""
16
+
16
17
  data: HTTPValidationErrorData
17
18
 
18
19
  def __init__(self, data: HTTPValidationErrorData):
@@ -20,4 +21,3 @@ class HTTPValidationError(Exception):
20
21
 
21
22
  def __str__(self) -> str:
22
23
  return utils.marshal_json(self.data, HTTPValidationErrorData)
23
-
@@ -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_gcp.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."""
@@ -9,8 +9,17 @@ from typing_extensions import Annotated
9
9
 
10
10
  class SecurityTypedDict(TypedDict):
11
11
  api_key: str
12
-
12
+
13
13
 
14
14
  class Security(BaseModel):
15
- api_key: Annotated[str, FieldMetadata(security=SecurityMetadata(scheme=True, scheme_type="http", sub_type="bearer", field_name="Authorization"))]
16
-
15
+ api_key: Annotated[
16
+ str,
17
+ FieldMetadata(
18
+ security=SecurityMetadata(
19
+ scheme=True,
20
+ scheme_type="http",
21
+ sub_type="bearer",
22
+ field_name="Authorization",
23
+ )
24
+ ),
25
+ ]
@@ -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_gcp.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_gcp.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
+ Type = 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[Type]], pydantic.Field(alias="type")] = "text" # type: ignore
22
+ # fmt: on
@@ -2,21 +2,22 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from .function import Function, FunctionTypedDict
5
- from mistralai_gcp.types import BaseModel, UnrecognizedStr
5
+ from .tooltypes import ToolTypes
6
+ from mistralai_gcp.types import BaseModel
6
7
  from mistralai_gcp.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_gcp.types import BaseModel, UnrecognizedStr
5
+ from .tooltypes import ToolTypes
6
+ from mistralai_gcp.types import BaseModel
6
7
  from mistralai_gcp.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_gcp.types import BaseModel
7
+ from mistralai_gcp.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"]
@@ -1,7 +1,13 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from mistralai_gcp.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
4
+ from mistralai_gcp.types import (
5
+ BaseModel,
6
+ Nullable,
7
+ OptionalNullable,
8
+ UNSET,
9
+ UNSET_SENTINEL,
10
+ )
5
11
  from pydantic import model_serializer
6
12
  from typing import Literal, Optional, TypedDict
7
13
  from typing_extensions import NotRequired
@@ -9,19 +15,23 @@ from typing_extensions import NotRequired
9
15
 
10
16
  ToolMessageRole = Literal["tool"]
11
17
 
18
+
12
19
  class ToolMessageTypedDict(TypedDict):
13
20
  content: str
14
21
  tool_call_id: NotRequired[Nullable[str]]
15
22
  name: NotRequired[Nullable[str]]
16
23
  role: NotRequired[ToolMessageRole]
17
-
24
+
18
25
 
19
26
  class ToolMessage(BaseModel):
20
27
  content: str
28
+
21
29
  tool_call_id: OptionalNullable[str] = UNSET
30
+
22
31
  name: OptionalNullable[str] = UNSET
32
+
23
33
  role: Optional[ToolMessageRole] = "tool"
24
-
34
+
25
35
  @model_serializer(mode="wrap")
26
36
  def serialize_model(self, handler):
27
37
  optional_fields = ["tool_call_id", "name", "role"]
@@ -35,9 +45,13 @@ class ToolMessage(BaseModel):
35
45
  for n, f in self.model_fields.items():
36
46
  k = f.alias or n
37
47
  val = serialized.get(k)
48
+ serialized.pop(k, None)
38
49
 
39
50
  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
51
+ is_set = (
52
+ self.__pydantic_fields_set__.intersection({n})
53
+ or k in null_default_fields
54
+ ) # pylint: disable=no-member
41
55
 
42
56
  if val is not None and val != UNSET_SENTINEL:
43
57
  m[k] = val
@@ -47,4 +61,3 @@ class ToolMessage(BaseModel):
47
61
  m[k] = val
48
62
 
49
63
  return m
50
-