mistralai 1.0.2__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.2.dist-info → mistralai-1.1.0.dist-info}/METADATA +103 -74
  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 +14 -10
  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.2.dist-info/RECORD +0 -236
  198. {mistralai-1.0.2.dist-info → mistralai-1.1.0.dist-info}/LICENSE +0 -0
  199. {mistralai-1.0.2.dist-info → mistralai-1.1.0.dist-info}/WHEEL +0 -0
@@ -12,17 +12,30 @@ from typing_extensions import Annotated, NotRequired
12
12
 
13
13
  FilesAPIRoutesUploadFilePurpose = Union[Literal["fine-tune"], UnrecognizedStr]
14
14
 
15
+
15
16
  class FileTypedDict(TypedDict):
16
17
  file_name: str
17
18
  content: Union[bytes, IO[bytes], io.BufferedReader]
18
19
  content_type: NotRequired[str]
19
-
20
+
20
21
 
21
22
  class File(BaseModel):
22
- file_name: Annotated[str, pydantic.Field(alias="file"), FieldMetadata(multipart=True)]
23
- content: Annotated[Union[bytes, IO[bytes], io.BufferedReader], pydantic.Field(alias=""), FieldMetadata(multipart=MultipartFormMetadata(content=True))]
24
- content_type: Annotated[Optional[str], pydantic.Field(alias="Content-Type"), FieldMetadata(multipart=True)] = None
25
-
23
+ file_name: Annotated[
24
+ str, pydantic.Field(alias="file"), FieldMetadata(multipart=True)
25
+ ]
26
+
27
+ content: Annotated[
28
+ Union[bytes, IO[bytes], io.BufferedReader],
29
+ pydantic.Field(alias=""),
30
+ FieldMetadata(multipart=MultipartFormMetadata(content=True)),
31
+ ]
32
+
33
+ content_type: Annotated[
34
+ Optional[str],
35
+ pydantic.Field(alias="Content-Type"),
36
+ FieldMetadata(multipart=True),
37
+ ] = None
38
+
26
39
 
27
40
  class FilesAPIRoutesUploadFileMultiPartBodyParamsTypedDict(TypedDict):
28
41
  file: FileTypedDict
@@ -36,10 +49,14 @@ class FilesAPIRoutesUploadFileMultiPartBodyParamsTypedDict(TypedDict):
36
49
  file=@path/to/your/file.jsonl
37
50
  ```
38
51
  """
39
-
52
+
40
53
 
41
54
  class FilesAPIRoutesUploadFileMultiPartBodyParams(BaseModel):
42
- file: Annotated[File, pydantic.Field(alias=""), FieldMetadata(multipart=MultipartFormMetadata(file=True))]
55
+ file: Annotated[
56
+ File,
57
+ pydantic.Field(alias=""),
58
+ FieldMetadata(multipart=MultipartFormMetadata(file=True)),
59
+ ]
43
60
  r"""The File object (not file name) to be uploaded.
44
61
  To upload a file and specify a custom file name you should format your request as such:
45
62
  ```bash
@@ -50,5 +67,7 @@ class FilesAPIRoutesUploadFileMultiPartBodyParams(BaseModel):
50
67
  file=@path/to/your/file.jsonl
51
68
  ```
52
69
  """
70
+
71
+ # fmt: off
53
72
  PURPOSE: Annotated[Final[Annotated[Optional[FilesAPIRoutesUploadFilePurpose], PlainValidator(validate_open_enum(False))]], pydantic.Field(alias="purpose"), FieldMetadata(multipart=True)] = "fine-tune" # type: ignore
54
-
73
+ # fmt: on
@@ -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
  FileSchemaPurpose = 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 FileSchemaTypedDict(TypedDict):
19
27
  id: str
20
28
  r"""The unique identifier of the file."""
@@ -29,25 +37,35 @@ class FileSchemaTypedDict(TypedDict):
29
37
  sample_type: SampleType
30
38
  source: Source
31
39
  num_lines: NotRequired[Nullable[int]]
32
-
40
+
33
41
 
34
42
  class FileSchema(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[FileSchemaPurpose, 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 FileSchema(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 FileSchema(BaseModel):
73
95
  m[k] = val
74
96
 
75
97
  return m
76
-
@@ -39,7 +39,7 @@ class FIMCompletionRequestTypedDict(TypedDict):
39
39
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
40
40
  suffix: NotRequired[Nullable[str]]
41
41
  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
-
42
+
43
43
 
44
44
  class FIMCompletionRequest(BaseModel):
45
45
  model: Nullable[str]
@@ -47,28 +47,46 @@ class FIMCompletionRequest(BaseModel):
47
47
  - `codestral-2405`
48
48
  - `codestral-latest`
49
49
  """
50
+
50
51
  prompt: str
51
52
  r"""The text/code to complete."""
53
+
52
54
  temperature: Optional[float] = 0.7
53
55
  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."""
56
+
54
57
  top_p: Optional[float] = 1
55
58
  r"""Nucleus sampling, where the model considers the results of the tokens with `top_p` probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or `temperature` but not both."""
59
+
56
60
  max_tokens: OptionalNullable[int] = UNSET
57
61
  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."""
62
+
58
63
  min_tokens: OptionalNullable[int] = UNSET
59
64
  r"""The minimum number of tokens to generate in the completion."""
65
+
60
66
  stream: Optional[bool] = False
61
67
  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."""
68
+
62
69
  stop: Optional[FIMCompletionRequestStop] = None
63
70
  r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
71
+
64
72
  random_seed: OptionalNullable[int] = UNSET
65
73
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
74
+
66
75
  suffix: OptionalNullable[str] = UNSET
67
76
  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
-
77
+
69
78
  @model_serializer(mode="wrap")
70
79
  def serialize_model(self, handler):
71
- optional_fields = ["temperature", "top_p", "max_tokens", "min_tokens", "stream", "stop", "random_seed", "suffix"]
80
+ optional_fields = [
81
+ "temperature",
82
+ "top_p",
83
+ "max_tokens",
84
+ "min_tokens",
85
+ "stream",
86
+ "stop",
87
+ "random_seed",
88
+ "suffix",
89
+ ]
72
90
  nullable_fields = ["model", "max_tokens", "min_tokens", "random_seed", "suffix"]
73
91
  null_default_fields = []
74
92
 
@@ -79,9 +97,13 @@ class FIMCompletionRequest(BaseModel):
79
97
  for n, f in self.model_fields.items():
80
98
  k = f.alias or n
81
99
  val = serialized.get(k)
100
+ serialized.pop(k, None)
82
101
 
83
102
  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
103
+ is_set = (
104
+ self.__pydantic_fields_set__.intersection({n})
105
+ or k in null_default_fields
106
+ ) # pylint: disable=no-member
85
107
 
86
108
  if val is not None and val != UNSET_SENTINEL:
87
109
  m[k] = val
@@ -91,4 +113,3 @@ class FIMCompletionRequest(BaseModel):
91
113
  m[k] = val
92
114
 
93
115
  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
-
@@ -38,7 +38,7 @@ class FIMCompletionStreamRequestTypedDict(TypedDict):
38
38
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
39
39
  suffix: NotRequired[Nullable[str]]
40
40
  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
-
41
+
42
42
 
43
43
  class FIMCompletionStreamRequest(BaseModel):
44
44
  model: Nullable[str]
@@ -46,27 +46,45 @@ class FIMCompletionStreamRequest(BaseModel):
46
46
  - `codestral-2405`
47
47
  - `codestral-latest`
48
48
  """
49
+
49
50
  prompt: str
50
51
  r"""The text/code to complete."""
52
+
51
53
  temperature: Optional[float] = 0.7
52
54
  r"""What sampling temperature to use, between 0.0 and 1.0. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both."""
55
+
53
56
  top_p: Optional[float] = 1
54
57
  r"""Nucleus sampling, where the model considers the results of the tokens with `top_p` probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or `temperature` but not both."""
58
+
55
59
  max_tokens: OptionalNullable[int] = UNSET
56
60
  r"""The maximum number of tokens to generate in the completion. The token count of your prompt plus `max_tokens` cannot exceed the model's context length."""
61
+
57
62
  min_tokens: OptionalNullable[int] = UNSET
58
63
  r"""The minimum number of tokens to generate in the completion."""
64
+
59
65
  stream: Optional[bool] = True
66
+
60
67
  stop: Optional[FIMCompletionStreamRequestStop] = None
61
68
  r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
69
+
62
70
  random_seed: OptionalNullable[int] = UNSET
63
71
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
72
+
64
73
  suffix: OptionalNullable[str] = UNSET
65
74
  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
-
75
+
67
76
  @model_serializer(mode="wrap")
68
77
  def serialize_model(self, handler):
69
- optional_fields = ["temperature", "top_p", "max_tokens", "min_tokens", "stream", "stop", "random_seed", "suffix"]
78
+ optional_fields = [
79
+ "temperature",
80
+ "top_p",
81
+ "max_tokens",
82
+ "min_tokens",
83
+ "stream",
84
+ "stop",
85
+ "random_seed",
86
+ "suffix",
87
+ ]
70
88
  nullable_fields = ["model", "max_tokens", "min_tokens", "random_seed", "suffix"]
71
89
  null_default_fields = []
72
90
 
@@ -77,9 +95,13 @@ class FIMCompletionStreamRequest(BaseModel):
77
95
  for n, f in self.model_fields.items():
78
96
  k = f.alias or n
79
97
  val = serialized.get(k)
98
+ serialized.pop(k, None)
80
99
 
81
100
  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
101
+ is_set = (
102
+ self.__pydantic_fields_set__.intersection({n})
103
+ or k in null_default_fields
104
+ ) # pylint: disable=no-member
83
105
 
84
106
  if val is not None and val != UNSET_SENTINEL:
85
107
  m[k] = val
@@ -89,4 +111,3 @@ class FIMCompletionStreamRequest(BaseModel):
89
111
  m[k] = val
90
112
 
91
113
  return m
92
-
@@ -4,5 +4,11 @@ from __future__ import annotations
4
4
  from typing import Literal
5
5
 
6
6
 
7
- FineTuneableModel = Literal["open-mistral-7b", "mistral-small-latest", "codestral-latest", "mistral-large-latest", "open-mistral-nemo"]
7
+ FineTuneableModel = Literal[
8
+ "open-mistral-7b",
9
+ "mistral-small-latest",
10
+ "codestral-latest",
11
+ "mistral-large-latest",
12
+ "open-mistral-nemo",
13
+ ]
8
14
  r"""The name of the model to fine-tune."""
@@ -11,11 +11,13 @@ class FTModelCapabilitiesOutTypedDict(TypedDict):
11
11
  completion_fim: NotRequired[bool]
12
12
  function_calling: NotRequired[bool]
13
13
  fine_tuning: NotRequired[bool]
14
-
14
+
15
15
 
16
16
  class FTModelCapabilitiesOut(BaseModel):
17
17
  completion_chat: Optional[bool] = True
18
+
18
19
  completion_fim: Optional[bool] = False
20
+
19
21
  function_calling: Optional[bool] = False
22
+
20
23
  fine_tuning: Optional[bool] = False
21
-
@@ -0,0 +1,103 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .modelcapabilities import ModelCapabilities, ModelCapabilitiesTypedDict
5
+ from datetime import datetime
6
+ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
7
+ import pydantic
8
+ from pydantic import model_serializer
9
+ from typing import Final, List, Optional, TypedDict
10
+ from typing_extensions import Annotated, NotRequired
11
+
12
+
13
+ class FTModelCardTypedDict(TypedDict):
14
+ r"""Extra fields for fine-tuned models."""
15
+
16
+ id: str
17
+ capabilities: ModelCapabilitiesTypedDict
18
+ job: str
19
+ root: str
20
+ object: NotRequired[str]
21
+ created: NotRequired[int]
22
+ owned_by: NotRequired[str]
23
+ name: NotRequired[Nullable[str]]
24
+ description: NotRequired[Nullable[str]]
25
+ max_context_length: NotRequired[int]
26
+ aliases: NotRequired[List[str]]
27
+ deprecation: NotRequired[Nullable[datetime]]
28
+ archived: NotRequired[bool]
29
+
30
+
31
+ class FTModelCard(BaseModel):
32
+ r"""Extra fields for fine-tuned models."""
33
+
34
+ id: str
35
+
36
+ capabilities: ModelCapabilities
37
+
38
+ job: str
39
+
40
+ root: str
41
+
42
+ object: Optional[str] = "model"
43
+
44
+ created: Optional[int] = None
45
+
46
+ owned_by: Optional[str] = "mistralai"
47
+
48
+ name: OptionalNullable[str] = UNSET
49
+
50
+ description: OptionalNullable[str] = UNSET
51
+
52
+ max_context_length: Optional[int] = 32768
53
+
54
+ aliases: Optional[List[str]] = None
55
+
56
+ deprecation: OptionalNullable[datetime] = UNSET
57
+
58
+ # fmt: off
59
+ TYPE: Annotated[Final[Optional[str]], pydantic.Field(alias="type")] = "fine-tuned" # type: ignore
60
+ # fmt: on
61
+
62
+ archived: Optional[bool] = False
63
+
64
+ @model_serializer(mode="wrap")
65
+ def serialize_model(self, handler):
66
+ optional_fields = [
67
+ "object",
68
+ "created",
69
+ "owned_by",
70
+ "name",
71
+ "description",
72
+ "max_context_length",
73
+ "aliases",
74
+ "deprecation",
75
+ "type",
76
+ "archived",
77
+ ]
78
+ nullable_fields = ["name", "description", "deprecation"]
79
+ null_default_fields = []
80
+
81
+ serialized = handler(self)
82
+
83
+ m = {}
84
+
85
+ for n, f in self.model_fields.items():
86
+ k = f.alias or n
87
+ val = serialized.get(k)
88
+ serialized.pop(k, None)
89
+
90
+ optional_nullable = k in optional_fields and k in nullable_fields
91
+ is_set = (
92
+ self.__pydantic_fields_set__.intersection({n})
93
+ or k in null_default_fields
94
+ ) # pylint: disable=no-member
95
+
96
+ if val is not None and val != UNSET_SENTINEL:
97
+ m[k] = val
98
+ elif val != UNSET_SENTINEL and (
99
+ not k in optional_fields or (optional_nullable and is_set)
100
+ ):
101
+ m[k] = val
102
+
103
+ return m
@@ -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 .ftmodelcapabilitiesout import FTModelCapabilitiesOut, FTModelCapabilitiesOutTypedDict
4
+ from .ftmodelcapabilitiesout import (
5
+ FTModelCapabilitiesOut,
6
+ FTModelCapabilitiesOutTypedDict,
7
+ )
5
8
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
6
9
  import pydantic
7
10
  from pydantic import model_serializer
@@ -11,6 +14,7 @@ from typing_extensions import Annotated, NotRequired
11
14
 
12
15
  FTModelOutObject = Literal["model"]
13
16
 
17
+
14
18
  class FTModelOutTypedDict(TypedDict):
15
19
  id: str
16
20
  created: int
@@ -23,25 +27,44 @@ class FTModelOutTypedDict(TypedDict):
23
27
  description: NotRequired[Nullable[str]]
24
28
  max_context_length: NotRequired[int]
25
29
  aliases: NotRequired[List[str]]
26
-
30
+
27
31
 
28
32
  class FTModelOut(BaseModel):
29
33
  id: str
34
+
30
35
  created: int
36
+
31
37
  owned_by: str
38
+
32
39
  root: str
40
+
33
41
  archived: bool
42
+
34
43
  capabilities: FTModelCapabilitiesOut
44
+
35
45
  job: str
46
+
47
+ # fmt: off
36
48
  OBJECT: Annotated[Final[Optional[FTModelOutObject]], pydantic.Field(alias="object")] = "model" # type: ignore
49
+ # fmt: on
50
+
37
51
  name: OptionalNullable[str] = UNSET
52
+
38
53
  description: OptionalNullable[str] = UNSET
54
+
39
55
  max_context_length: Optional[int] = 32768
56
+
40
57
  aliases: Optional[List[str]] = None
41
-
58
+
42
59
  @model_serializer(mode="wrap")
43
60
  def serialize_model(self, handler):
44
- optional_fields = ["object", "name", "description", "max_context_length", "aliases"]
61
+ optional_fields = [
62
+ "object",
63
+ "name",
64
+ "description",
65
+ "max_context_length",
66
+ "aliases",
67
+ ]
45
68
  nullable_fields = ["name", "description"]
46
69
  null_default_fields = []
47
70
 
@@ -52,9 +75,13 @@ class FTModelOut(BaseModel):
52
75
  for n, f in self.model_fields.items():
53
76
  k = f.alias or n
54
77
  val = serialized.get(k)
78
+ serialized.pop(k, None)
55
79
 
56
80
  optional_nullable = k in optional_fields and k in nullable_fields
57
- is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
81
+ is_set = (
82
+ self.__pydantic_fields_set__.intersection({n})
83
+ or k in null_default_fields
84
+ ) # pylint: disable=no-member
58
85
 
59
86
  if val is not None and val != UNSET_SENTINEL:
60
87
  m[k] = val
@@ -64,4 +91,3 @@ class FTModelOut(BaseModel):
64
91
  m[k] = val
65
92
 
66
93
  return m
67
-
@@ -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.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
@@ -10,22 +10,30 @@ from typing_extensions import Annotated, NotRequired
10
10
 
11
11
  GithubRepositoryInType = Literal["github"]
12
12
 
13
+
13
14
  class GithubRepositoryInTypedDict(TypedDict):
14
15
  name: str
15
16
  owner: str
16
17
  token: str
17
18
  ref: NotRequired[Nullable[str]]
18
19
  weight: NotRequired[float]
19
-
20
+
20
21
 
21
22
  class GithubRepositoryIn(BaseModel):
22
23
  name: str
24
+
23
25
  owner: str
26
+
24
27
  token: str
28
+
29
+ # fmt: off
25
30
  TYPE: Annotated[Final[Optional[GithubRepositoryInType]], pydantic.Field(alias="type")] = "github" # type: ignore
31
+ # fmt: on
32
+
26
33
  ref: OptionalNullable[str] = UNSET
34
+
27
35
  weight: Optional[float] = 1
28
-
36
+
29
37
  @model_serializer(mode="wrap")
30
38
  def serialize_model(self, handler):
31
39
  optional_fields = ["type", "ref", "weight"]
@@ -39,9 +47,13 @@ class GithubRepositoryIn(BaseModel):
39
47
  for n, f in self.model_fields.items():
40
48
  k = f.alias or n
41
49
  val = serialized.get(k)
50
+ serialized.pop(k, None)
42
51
 
43
52
  optional_nullable = k in optional_fields and k in nullable_fields
44
- is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
53
+ is_set = (
54
+ self.__pydantic_fields_set__.intersection({n})
55
+ or k in null_default_fields
56
+ ) # pylint: disable=no-member
45
57
 
46
58
  if val is not None and val != UNSET_SENTINEL:
47
59
  m[k] = val
@@ -51,4 +63,3 @@ class GithubRepositoryIn(BaseModel):
51
63
  m[k] = val
52
64
 
53
65
  return m
54
-