mistralai 1.1.0__py3-none-any.whl → 1.2.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 (186) hide show
  1. mistralai/__init__.py +4 -0
  2. mistralai/_version.py +12 -0
  3. mistralai/agents.py +56 -22
  4. mistralai/batch.py +17 -0
  5. mistralai/chat.py +64 -30
  6. mistralai/classifiers.py +396 -0
  7. mistralai/embeddings.py +10 -6
  8. mistralai/files.py +252 -19
  9. mistralai/fim.py +40 -30
  10. mistralai/jobs.py +40 -20
  11. mistralai/mistral_jobs.py +733 -0
  12. mistralai/models/__init__.py +108 -18
  13. mistralai/models/agentscompletionrequest.py +27 -10
  14. mistralai/models/agentscompletionstreamrequest.py +27 -10
  15. mistralai/models/apiendpoint.py +9 -0
  16. mistralai/models/archiveftmodelout.py +11 -5
  17. mistralai/models/assistantmessage.py +11 -6
  18. mistralai/models/basemodelcard.py +22 -6
  19. mistralai/models/batcherror.py +17 -0
  20. mistralai/models/batchjobin.py +58 -0
  21. mistralai/models/batchjobout.py +117 -0
  22. mistralai/models/batchjobsout.py +30 -0
  23. mistralai/models/batchjobstatus.py +15 -0
  24. mistralai/models/chatclassificationrequest.py +104 -0
  25. mistralai/models/chatcompletionchoice.py +9 -4
  26. mistralai/models/chatcompletionrequest.py +32 -13
  27. mistralai/models/chatcompletionresponse.py +2 -2
  28. mistralai/models/chatcompletionstreamrequest.py +32 -13
  29. mistralai/models/checkpointout.py +1 -1
  30. mistralai/models/classificationobject.py +21 -0
  31. mistralai/models/classificationrequest.py +59 -0
  32. mistralai/models/classificationresponse.py +21 -0
  33. mistralai/models/completionchunk.py +2 -2
  34. mistralai/models/completionevent.py +1 -1
  35. mistralai/models/completionresponsestreamchoice.py +11 -5
  36. mistralai/models/delete_model_v1_models_model_id_deleteop.py +1 -2
  37. mistralai/models/deletefileout.py +1 -1
  38. mistralai/models/deletemodelout.py +2 -2
  39. mistralai/models/deltamessage.py +14 -7
  40. mistralai/models/detailedjobout.py +11 -5
  41. mistralai/models/embeddingrequest.py +5 -5
  42. mistralai/models/embeddingresponse.py +2 -1
  43. mistralai/models/embeddingresponsedata.py +2 -2
  44. mistralai/models/eventout.py +2 -2
  45. mistralai/models/filepurpose.py +8 -0
  46. mistralai/models/files_api_routes_delete_fileop.py +1 -2
  47. mistralai/models/files_api_routes_download_fileop.py +16 -0
  48. mistralai/models/files_api_routes_list_filesop.py +96 -0
  49. mistralai/models/files_api_routes_retrieve_fileop.py +1 -2
  50. mistralai/models/files_api_routes_upload_fileop.py +9 -9
  51. mistralai/models/fileschema.py +7 -21
  52. mistralai/models/fimcompletionrequest.py +20 -13
  53. mistralai/models/fimcompletionresponse.py +2 -2
  54. mistralai/models/fimcompletionstreamrequest.py +20 -13
  55. mistralai/models/ftmodelcapabilitiesout.py +2 -2
  56. mistralai/models/ftmodelcard.py +24 -6
  57. mistralai/models/ftmodelout.py +9 -5
  58. mistralai/models/function.py +2 -2
  59. mistralai/models/functioncall.py +2 -1
  60. mistralai/models/functionname.py +1 -1
  61. mistralai/models/githubrepositoryin.py +11 -5
  62. mistralai/models/githubrepositoryout.py +11 -5
  63. mistralai/models/httpvalidationerror.py +0 -2
  64. mistralai/models/imageurl.py +1 -2
  65. mistralai/models/imageurlchunk.py +11 -5
  66. mistralai/models/jobin.py +2 -2
  67. mistralai/models/jobmetadataout.py +1 -2
  68. mistralai/models/jobout.py +10 -5
  69. mistralai/models/jobs_api_routes_batch_cancel_batch_jobop.py +16 -0
  70. mistralai/models/jobs_api_routes_batch_get_batch_jobop.py +16 -0
  71. mistralai/models/jobs_api_routes_batch_get_batch_jobsop.py +95 -0
  72. mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +1 -2
  73. mistralai/models/jobs_api_routes_fine_tuning_cancel_fine_tuning_jobop.py +1 -2
  74. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobop.py +1 -2
  75. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +2 -2
  76. mistralai/models/jobs_api_routes_fine_tuning_start_fine_tuning_jobop.py +1 -2
  77. mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +1 -2
  78. mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +1 -2
  79. mistralai/models/jobsout.py +9 -5
  80. mistralai/models/legacyjobmetadataout.py +12 -5
  81. mistralai/models/listfilesout.py +5 -1
  82. mistralai/models/metricout.py +1 -2
  83. mistralai/models/modelcapabilities.py +2 -2
  84. mistralai/models/modellist.py +2 -2
  85. mistralai/models/responseformat.py +2 -2
  86. mistralai/models/retrieve_model_v1_models_model_id_getop.py +2 -2
  87. mistralai/models/retrievefileout.py +10 -21
  88. mistralai/models/sampletype.py +6 -2
  89. mistralai/models/security.py +2 -2
  90. mistralai/models/source.py +3 -2
  91. mistralai/models/systemmessage.py +6 -6
  92. mistralai/models/textchunk.py +9 -5
  93. mistralai/models/tool.py +2 -2
  94. mistralai/models/toolcall.py +2 -2
  95. mistralai/models/toolchoice.py +2 -2
  96. mistralai/models/toolmessage.py +2 -2
  97. mistralai/models/trainingfile.py +2 -2
  98. mistralai/models/trainingparameters.py +7 -2
  99. mistralai/models/trainingparametersin.py +7 -2
  100. mistralai/models/unarchiveftmodelout.py +11 -5
  101. mistralai/models/updateftmodelin.py +1 -2
  102. mistralai/models/uploadfileout.py +7 -21
  103. mistralai/models/usageinfo.py +1 -1
  104. mistralai/models/usermessage.py +36 -5
  105. mistralai/models/validationerror.py +2 -1
  106. mistralai/models/wandbintegration.py +11 -5
  107. mistralai/models/wandbintegrationout.py +12 -6
  108. mistralai/models_.py +48 -24
  109. mistralai/sdk.py +7 -0
  110. mistralai/sdkconfiguration.py +7 -7
  111. mistralai/utils/__init__.py +8 -0
  112. mistralai/utils/annotations.py +13 -2
  113. mistralai/utils/serializers.py +25 -0
  114. {mistralai-1.1.0.dist-info → mistralai-1.2.0.dist-info}/METADATA +90 -14
  115. mistralai-1.2.0.dist-info/RECORD +276 -0
  116. {mistralai-1.1.0.dist-info → mistralai-1.2.0.dist-info}/WHEEL +1 -1
  117. mistralai_azure/__init__.py +4 -0
  118. mistralai_azure/_version.py +12 -0
  119. mistralai_azure/chat.py +64 -30
  120. mistralai_azure/models/__init__.py +9 -3
  121. mistralai_azure/models/assistantmessage.py +11 -6
  122. mistralai_azure/models/chatcompletionchoice.py +10 -5
  123. mistralai_azure/models/chatcompletionrequest.py +32 -13
  124. mistralai_azure/models/chatcompletionresponse.py +2 -2
  125. mistralai_azure/models/chatcompletionstreamrequest.py +32 -13
  126. mistralai_azure/models/completionchunk.py +2 -2
  127. mistralai_azure/models/completionevent.py +1 -1
  128. mistralai_azure/models/completionresponsestreamchoice.py +9 -4
  129. mistralai_azure/models/deltamessage.py +14 -7
  130. mistralai_azure/models/function.py +2 -2
  131. mistralai_azure/models/functioncall.py +2 -1
  132. mistralai_azure/models/functionname.py +1 -1
  133. mistralai_azure/models/httpvalidationerror.py +0 -2
  134. mistralai_azure/models/responseformat.py +2 -2
  135. mistralai_azure/models/security.py +1 -2
  136. mistralai_azure/models/systemmessage.py +6 -6
  137. mistralai_azure/models/textchunk.py +9 -5
  138. mistralai_azure/models/tool.py +2 -2
  139. mistralai_azure/models/toolcall.py +2 -2
  140. mistralai_azure/models/toolchoice.py +2 -2
  141. mistralai_azure/models/toolmessage.py +2 -2
  142. mistralai_azure/models/usageinfo.py +1 -1
  143. mistralai_azure/models/usermessage.py +36 -5
  144. mistralai_azure/models/validationerror.py +2 -1
  145. mistralai_azure/sdkconfiguration.py +7 -7
  146. mistralai_azure/utils/__init__.py +8 -0
  147. mistralai_azure/utils/annotations.py +13 -2
  148. mistralai_azure/utils/serializers.py +25 -0
  149. mistralai_gcp/__init__.py +4 -0
  150. mistralai_gcp/_version.py +12 -0
  151. mistralai_gcp/chat.py +64 -30
  152. mistralai_gcp/fim.py +40 -30
  153. mistralai_gcp/models/__init__.py +9 -3
  154. mistralai_gcp/models/assistantmessage.py +11 -6
  155. mistralai_gcp/models/chatcompletionchoice.py +10 -5
  156. mistralai_gcp/models/chatcompletionrequest.py +32 -13
  157. mistralai_gcp/models/chatcompletionresponse.py +2 -2
  158. mistralai_gcp/models/chatcompletionstreamrequest.py +32 -13
  159. mistralai_gcp/models/completionchunk.py +2 -2
  160. mistralai_gcp/models/completionevent.py +1 -1
  161. mistralai_gcp/models/completionresponsestreamchoice.py +9 -4
  162. mistralai_gcp/models/deltamessage.py +14 -7
  163. mistralai_gcp/models/fimcompletionrequest.py +20 -13
  164. mistralai_gcp/models/fimcompletionresponse.py +2 -2
  165. mistralai_gcp/models/fimcompletionstreamrequest.py +20 -13
  166. mistralai_gcp/models/function.py +2 -2
  167. mistralai_gcp/models/functioncall.py +2 -1
  168. mistralai_gcp/models/functionname.py +1 -1
  169. mistralai_gcp/models/httpvalidationerror.py +0 -2
  170. mistralai_gcp/models/responseformat.py +2 -2
  171. mistralai_gcp/models/security.py +1 -2
  172. mistralai_gcp/models/systemmessage.py +6 -6
  173. mistralai_gcp/models/textchunk.py +9 -5
  174. mistralai_gcp/models/tool.py +2 -2
  175. mistralai_gcp/models/toolcall.py +2 -2
  176. mistralai_gcp/models/toolchoice.py +2 -2
  177. mistralai_gcp/models/toolmessage.py +2 -2
  178. mistralai_gcp/models/usageinfo.py +1 -1
  179. mistralai_gcp/models/usermessage.py +36 -5
  180. mistralai_gcp/models/validationerror.py +2 -1
  181. mistralai_gcp/sdkconfiguration.py +7 -7
  182. mistralai_gcp/utils/__init__.py +8 -0
  183. mistralai_gcp/utils/annotations.py +13 -2
  184. mistralai_gcp/utils/serializers.py +25 -0
  185. mistralai-1.1.0.dist-info/RECORD +0 -254
  186. {mistralai-1.1.0.dist-info → mistralai-1.2.0.dist-info}/LICENSE +0 -0
mistralai/fim.py CHANGED
@@ -16,10 +16,9 @@ class Fim(BaseSDK):
16
16
  *,
17
17
  model: Nullable[str],
18
18
  prompt: str,
19
- temperature: Optional[float] = 0.7,
19
+ temperature: OptionalNullable[float] = UNSET,
20
20
  top_p: Optional[float] = 1,
21
21
  max_tokens: OptionalNullable[int] = UNSET,
22
- min_tokens: OptionalNullable[int] = UNSET,
23
22
  stream: Optional[bool] = False,
24
23
  stop: Optional[
25
24
  Union[
@@ -29,6 +28,7 @@ class Fim(BaseSDK):
29
28
  ] = None,
30
29
  random_seed: OptionalNullable[int] = UNSET,
31
30
  suffix: OptionalNullable[str] = UNSET,
31
+ min_tokens: OptionalNullable[int] = UNSET,
32
32
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
33
33
  server_url: Optional[str] = None,
34
34
  timeout_ms: Optional[int] = None,
@@ -39,14 +39,14 @@ class Fim(BaseSDK):
39
39
 
40
40
  :param model: ID of the model to use. Only compatible for now with: - `codestral-2405` - `codestral-latest`
41
41
  :param prompt: The text/code to complete.
42
- :param temperature: 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.
42
+ :param temperature: What sampling temperature to use, we recommend between 0.0 and 0.7. Higher values like 0.7 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both. The default value varies depending on the model you are targeting. Call the `/models` endpoint to retrieve the appropriate value.
43
43
  :param top_p: 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.
44
44
  :param max_tokens: 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.
45
- :param min_tokens: The minimum number of tokens to generate in the completion.
46
45
  :param stream: 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.
47
46
  :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
48
47
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
49
48
  :param suffix: 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`.
49
+ :param min_tokens: The minimum number of tokens to generate in the completion.
50
50
  :param retries: Override the default retry configuration for this method
51
51
  :param server_url: Override the default server URL for this method
52
52
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -64,12 +64,12 @@ class Fim(BaseSDK):
64
64
  temperature=temperature,
65
65
  top_p=top_p,
66
66
  max_tokens=max_tokens,
67
- min_tokens=min_tokens,
68
67
  stream=stream,
69
68
  stop=stop,
70
69
  random_seed=random_seed,
71
70
  prompt=prompt,
72
71
  suffix=suffix,
72
+ min_tokens=min_tokens,
73
73
  )
74
74
 
75
75
  req = self.build_request(
@@ -120,15 +120,17 @@ class Fim(BaseSDK):
120
120
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
121
121
  raise models.HTTPValidationError(data=data)
122
122
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
123
+ http_res_text = utils.stream_to_text(http_res)
123
124
  raise models.SDKError(
124
- "API error occurred", http_res.status_code, http_res.text, http_res
125
+ "API error occurred", http_res.status_code, http_res_text, http_res
125
126
  )
126
127
 
127
128
  content_type = http_res.headers.get("Content-Type")
129
+ http_res_text = utils.stream_to_text(http_res)
128
130
  raise models.SDKError(
129
131
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
130
132
  http_res.status_code,
131
- http_res.text,
133
+ http_res_text,
132
134
  http_res,
133
135
  )
134
136
 
@@ -137,10 +139,9 @@ class Fim(BaseSDK):
137
139
  *,
138
140
  model: Nullable[str],
139
141
  prompt: str,
140
- temperature: Optional[float] = 0.7,
142
+ temperature: OptionalNullable[float] = UNSET,
141
143
  top_p: Optional[float] = 1,
142
144
  max_tokens: OptionalNullable[int] = UNSET,
143
- min_tokens: OptionalNullable[int] = UNSET,
144
145
  stream: Optional[bool] = False,
145
146
  stop: Optional[
146
147
  Union[
@@ -150,6 +151,7 @@ class Fim(BaseSDK):
150
151
  ] = None,
151
152
  random_seed: OptionalNullable[int] = UNSET,
152
153
  suffix: OptionalNullable[str] = UNSET,
154
+ min_tokens: OptionalNullable[int] = UNSET,
153
155
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
154
156
  server_url: Optional[str] = None,
155
157
  timeout_ms: Optional[int] = None,
@@ -160,14 +162,14 @@ class Fim(BaseSDK):
160
162
 
161
163
  :param model: ID of the model to use. Only compatible for now with: - `codestral-2405` - `codestral-latest`
162
164
  :param prompt: The text/code to complete.
163
- :param temperature: 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.
165
+ :param temperature: What sampling temperature to use, we recommend between 0.0 and 0.7. Higher values like 0.7 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both. The default value varies depending on the model you are targeting. Call the `/models` endpoint to retrieve the appropriate value.
164
166
  :param top_p: 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.
165
167
  :param max_tokens: 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.
166
- :param min_tokens: The minimum number of tokens to generate in the completion.
167
168
  :param stream: 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.
168
169
  :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
169
170
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
170
171
  :param suffix: 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`.
172
+ :param min_tokens: The minimum number of tokens to generate in the completion.
171
173
  :param retries: Override the default retry configuration for this method
172
174
  :param server_url: Override the default server URL for this method
173
175
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -185,12 +187,12 @@ class Fim(BaseSDK):
185
187
  temperature=temperature,
186
188
  top_p=top_p,
187
189
  max_tokens=max_tokens,
188
- min_tokens=min_tokens,
189
190
  stream=stream,
190
191
  stop=stop,
191
192
  random_seed=random_seed,
192
193
  prompt=prompt,
193
194
  suffix=suffix,
195
+ min_tokens=min_tokens,
194
196
  )
195
197
 
196
198
  req = self.build_request_async(
@@ -241,15 +243,17 @@ class Fim(BaseSDK):
241
243
  data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
242
244
  raise models.HTTPValidationError(data=data)
243
245
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
246
+ http_res_text = await utils.stream_to_text_async(http_res)
244
247
  raise models.SDKError(
245
- "API error occurred", http_res.status_code, http_res.text, http_res
248
+ "API error occurred", http_res.status_code, http_res_text, http_res
246
249
  )
247
250
 
248
251
  content_type = http_res.headers.get("Content-Type")
252
+ http_res_text = await utils.stream_to_text_async(http_res)
249
253
  raise models.SDKError(
250
254
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
251
255
  http_res.status_code,
252
- http_res.text,
256
+ http_res_text,
253
257
  http_res,
254
258
  )
255
259
 
@@ -258,10 +262,9 @@ class Fim(BaseSDK):
258
262
  *,
259
263
  model: Nullable[str],
260
264
  prompt: str,
261
- temperature: Optional[float] = 0.7,
265
+ temperature: OptionalNullable[float] = UNSET,
262
266
  top_p: Optional[float] = 1,
263
267
  max_tokens: OptionalNullable[int] = UNSET,
264
- min_tokens: OptionalNullable[int] = UNSET,
265
268
  stream: Optional[bool] = True,
266
269
  stop: Optional[
267
270
  Union[
@@ -271,6 +274,7 @@ class Fim(BaseSDK):
271
274
  ] = None,
272
275
  random_seed: OptionalNullable[int] = UNSET,
273
276
  suffix: OptionalNullable[str] = UNSET,
277
+ min_tokens: OptionalNullable[int] = UNSET,
274
278
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
275
279
  server_url: Optional[str] = None,
276
280
  timeout_ms: Optional[int] = None,
@@ -281,14 +285,14 @@ class Fim(BaseSDK):
281
285
 
282
286
  :param model: ID of the model to use. Only compatible for now with: - `codestral-2405` - `codestral-latest`
283
287
  :param prompt: The text/code to complete.
284
- :param temperature: 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.
288
+ :param temperature: What sampling temperature to use, we recommend between 0.0 and 0.7. Higher values like 0.7 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both. The default value varies depending on the model you are targeting. Call the `/models` endpoint to retrieve the appropriate value.
285
289
  :param top_p: 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.
286
290
  :param max_tokens: 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.
287
- :param min_tokens: The minimum number of tokens to generate in the completion.
288
291
  :param stream:
289
292
  :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
290
293
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
291
294
  :param suffix: 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`.
295
+ :param min_tokens: The minimum number of tokens to generate in the completion.
292
296
  :param retries: Override the default retry configuration for this method
293
297
  :param server_url: Override the default server URL for this method
294
298
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -306,12 +310,12 @@ class Fim(BaseSDK):
306
310
  temperature=temperature,
307
311
  top_p=top_p,
308
312
  max_tokens=max_tokens,
309
- min_tokens=min_tokens,
310
313
  stream=stream,
311
314
  stop=stop,
312
315
  random_seed=random_seed,
313
316
  prompt=prompt,
314
317
  suffix=suffix,
318
+ min_tokens=min_tokens,
315
319
  )
316
320
 
317
321
  req = self.build_request(
@@ -362,18 +366,21 @@ class Fim(BaseSDK):
362
366
  sentinel="[DONE]",
363
367
  )
364
368
  if utils.match_response(http_res, "422", "application/json"):
365
- data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
369
+ http_res_text = utils.stream_to_text(http_res)
370
+ data = utils.unmarshal_json(http_res_text, models.HTTPValidationErrorData)
366
371
  raise models.HTTPValidationError(data=data)
367
372
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
373
+ http_res_text = utils.stream_to_text(http_res)
368
374
  raise models.SDKError(
369
- "API error occurred", http_res.status_code, http_res.text, http_res
375
+ "API error occurred", http_res.status_code, http_res_text, http_res
370
376
  )
371
377
 
372
378
  content_type = http_res.headers.get("Content-Type")
379
+ http_res_text = utils.stream_to_text(http_res)
373
380
  raise models.SDKError(
374
381
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
375
382
  http_res.status_code,
376
- http_res.text,
383
+ http_res_text,
377
384
  http_res,
378
385
  )
379
386
 
@@ -382,10 +389,9 @@ class Fim(BaseSDK):
382
389
  *,
383
390
  model: Nullable[str],
384
391
  prompt: str,
385
- temperature: Optional[float] = 0.7,
392
+ temperature: OptionalNullable[float] = UNSET,
386
393
  top_p: Optional[float] = 1,
387
394
  max_tokens: OptionalNullable[int] = UNSET,
388
- min_tokens: OptionalNullable[int] = UNSET,
389
395
  stream: Optional[bool] = True,
390
396
  stop: Optional[
391
397
  Union[
@@ -395,6 +401,7 @@ class Fim(BaseSDK):
395
401
  ] = None,
396
402
  random_seed: OptionalNullable[int] = UNSET,
397
403
  suffix: OptionalNullable[str] = UNSET,
404
+ min_tokens: OptionalNullable[int] = UNSET,
398
405
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
399
406
  server_url: Optional[str] = None,
400
407
  timeout_ms: Optional[int] = None,
@@ -405,14 +412,14 @@ class Fim(BaseSDK):
405
412
 
406
413
  :param model: ID of the model to use. Only compatible for now with: - `codestral-2405` - `codestral-latest`
407
414
  :param prompt: The text/code to complete.
408
- :param temperature: 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.
415
+ :param temperature: What sampling temperature to use, we recommend between 0.0 and 0.7. Higher values like 0.7 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both. The default value varies depending on the model you are targeting. Call the `/models` endpoint to retrieve the appropriate value.
409
416
  :param top_p: 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.
410
417
  :param max_tokens: 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.
411
- :param min_tokens: The minimum number of tokens to generate in the completion.
412
418
  :param stream:
413
419
  :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
414
420
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
415
421
  :param suffix: 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`.
422
+ :param min_tokens: The minimum number of tokens to generate in the completion.
416
423
  :param retries: Override the default retry configuration for this method
417
424
  :param server_url: Override the default server URL for this method
418
425
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -430,12 +437,12 @@ class Fim(BaseSDK):
430
437
  temperature=temperature,
431
438
  top_p=top_p,
432
439
  max_tokens=max_tokens,
433
- min_tokens=min_tokens,
434
440
  stream=stream,
435
441
  stop=stop,
436
442
  random_seed=random_seed,
437
443
  prompt=prompt,
438
444
  suffix=suffix,
445
+ min_tokens=min_tokens,
439
446
  )
440
447
 
441
448
  req = self.build_request_async(
@@ -486,17 +493,20 @@ class Fim(BaseSDK):
486
493
  sentinel="[DONE]",
487
494
  )
488
495
  if utils.match_response(http_res, "422", "application/json"):
489
- data = utils.unmarshal_json(http_res.text, models.HTTPValidationErrorData)
496
+ http_res_text = await utils.stream_to_text_async(http_res)
497
+ data = utils.unmarshal_json(http_res_text, models.HTTPValidationErrorData)
490
498
  raise models.HTTPValidationError(data=data)
491
499
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
500
+ http_res_text = await utils.stream_to_text_async(http_res)
492
501
  raise models.SDKError(
493
- "API error occurred", http_res.status_code, http_res.text, http_res
502
+ "API error occurred", http_res.status_code, http_res_text, http_res
494
503
  )
495
504
 
496
505
  content_type = http_res.headers.get("Content-Type")
506
+ http_res_text = await utils.stream_to_text_async(http_res)
497
507
  raise models.SDKError(
498
508
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
499
509
  http_res.status_code,
500
- http_res.text,
510
+ http_res_text,
501
511
  http_res,
502
512
  )
mistralai/jobs.py CHANGED
@@ -102,15 +102,17 @@ class Jobs(BaseSDK):
102
102
  if utils.match_response(http_res, "200", "application/json"):
103
103
  return utils.unmarshal_json(http_res.text, Optional[models.JobsOut])
104
104
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
105
+ http_res_text = utils.stream_to_text(http_res)
105
106
  raise models.SDKError(
106
- "API error occurred", http_res.status_code, http_res.text, http_res
107
+ "API error occurred", http_res.status_code, http_res_text, http_res
107
108
  )
108
109
 
109
110
  content_type = http_res.headers.get("Content-Type")
111
+ http_res_text = utils.stream_to_text(http_res)
110
112
  raise models.SDKError(
111
113
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
112
114
  http_res.status_code,
113
- http_res.text,
115
+ http_res_text,
114
116
  http_res,
115
117
  )
116
118
 
@@ -206,15 +208,17 @@ class Jobs(BaseSDK):
206
208
  if utils.match_response(http_res, "200", "application/json"):
207
209
  return utils.unmarshal_json(http_res.text, Optional[models.JobsOut])
208
210
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
211
+ http_res_text = await utils.stream_to_text_async(http_res)
209
212
  raise models.SDKError(
210
- "API error occurred", http_res.status_code, http_res.text, http_res
213
+ "API error occurred", http_res.status_code, http_res_text, http_res
211
214
  )
212
215
 
213
216
  content_type = http_res.headers.get("Content-Type")
217
+ http_res_text = await utils.stream_to_text_async(http_res)
214
218
  raise models.SDKError(
215
219
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
216
220
  http_res.status_code,
217
- http_res.text,
221
+ http_res_text,
218
222
  http_res,
219
223
  )
220
224
 
@@ -333,15 +337,17 @@ class Jobs(BaseSDK):
333
337
  Optional[models.JobsAPIRoutesFineTuningCreateFineTuningJobResponse],
334
338
  )
335
339
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
340
+ http_res_text = utils.stream_to_text(http_res)
336
341
  raise models.SDKError(
337
- "API error occurred", http_res.status_code, http_res.text, http_res
342
+ "API error occurred", http_res.status_code, http_res_text, http_res
338
343
  )
339
344
 
340
345
  content_type = http_res.headers.get("Content-Type")
346
+ http_res_text = utils.stream_to_text(http_res)
341
347
  raise models.SDKError(
342
348
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
343
349
  http_res.status_code,
344
- http_res.text,
350
+ http_res_text,
345
351
  http_res,
346
352
  )
347
353
 
@@ -460,15 +466,17 @@ class Jobs(BaseSDK):
460
466
  Optional[models.JobsAPIRoutesFineTuningCreateFineTuningJobResponse],
461
467
  )
462
468
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
469
+ http_res_text = await utils.stream_to_text_async(http_res)
463
470
  raise models.SDKError(
464
- "API error occurred", http_res.status_code, http_res.text, http_res
471
+ "API error occurred", http_res.status_code, http_res_text, http_res
465
472
  )
466
473
 
467
474
  content_type = http_res.headers.get("Content-Type")
475
+ http_res_text = await utils.stream_to_text_async(http_res)
468
476
  raise models.SDKError(
469
477
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
470
478
  http_res.status_code,
471
- http_res.text,
479
+ http_res_text,
472
480
  http_res,
473
481
  )
474
482
 
@@ -540,15 +548,17 @@ class Jobs(BaseSDK):
540
548
  if utils.match_response(http_res, "200", "application/json"):
541
549
  return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
542
550
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
551
+ http_res_text = utils.stream_to_text(http_res)
543
552
  raise models.SDKError(
544
- "API error occurred", http_res.status_code, http_res.text, http_res
553
+ "API error occurred", http_res.status_code, http_res_text, http_res
545
554
  )
546
555
 
547
556
  content_type = http_res.headers.get("Content-Type")
557
+ http_res_text = utils.stream_to_text(http_res)
548
558
  raise models.SDKError(
549
559
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
550
560
  http_res.status_code,
551
- http_res.text,
561
+ http_res_text,
552
562
  http_res,
553
563
  )
554
564
 
@@ -620,15 +630,17 @@ class Jobs(BaseSDK):
620
630
  if utils.match_response(http_res, "200", "application/json"):
621
631
  return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
622
632
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
633
+ http_res_text = await utils.stream_to_text_async(http_res)
623
634
  raise models.SDKError(
624
- "API error occurred", http_res.status_code, http_res.text, http_res
635
+ "API error occurred", http_res.status_code, http_res_text, http_res
625
636
  )
626
637
 
627
638
  content_type = http_res.headers.get("Content-Type")
639
+ http_res_text = await utils.stream_to_text_async(http_res)
628
640
  raise models.SDKError(
629
641
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
630
642
  http_res.status_code,
631
- http_res.text,
643
+ http_res_text,
632
644
  http_res,
633
645
  )
634
646
 
@@ -700,15 +712,17 @@ class Jobs(BaseSDK):
700
712
  if utils.match_response(http_res, "200", "application/json"):
701
713
  return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
702
714
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
715
+ http_res_text = utils.stream_to_text(http_res)
703
716
  raise models.SDKError(
704
- "API error occurred", http_res.status_code, http_res.text, http_res
717
+ "API error occurred", http_res.status_code, http_res_text, http_res
705
718
  )
706
719
 
707
720
  content_type = http_res.headers.get("Content-Type")
721
+ http_res_text = utils.stream_to_text(http_res)
708
722
  raise models.SDKError(
709
723
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
710
724
  http_res.status_code,
711
- http_res.text,
725
+ http_res_text,
712
726
  http_res,
713
727
  )
714
728
 
@@ -780,15 +794,17 @@ class Jobs(BaseSDK):
780
794
  if utils.match_response(http_res, "200", "application/json"):
781
795
  return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
782
796
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
797
+ http_res_text = await utils.stream_to_text_async(http_res)
783
798
  raise models.SDKError(
784
- "API error occurred", http_res.status_code, http_res.text, http_res
799
+ "API error occurred", http_res.status_code, http_res_text, http_res
785
800
  )
786
801
 
787
802
  content_type = http_res.headers.get("Content-Type")
803
+ http_res_text = await utils.stream_to_text_async(http_res)
788
804
  raise models.SDKError(
789
805
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
790
806
  http_res.status_code,
791
- http_res.text,
807
+ http_res_text,
792
808
  http_res,
793
809
  )
794
810
 
@@ -860,15 +876,17 @@ class Jobs(BaseSDK):
860
876
  if utils.match_response(http_res, "200", "application/json"):
861
877
  return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
862
878
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
879
+ http_res_text = utils.stream_to_text(http_res)
863
880
  raise models.SDKError(
864
- "API error occurred", http_res.status_code, http_res.text, http_res
881
+ "API error occurred", http_res.status_code, http_res_text, http_res
865
882
  )
866
883
 
867
884
  content_type = http_res.headers.get("Content-Type")
885
+ http_res_text = utils.stream_to_text(http_res)
868
886
  raise models.SDKError(
869
887
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
870
888
  http_res.status_code,
871
- http_res.text,
889
+ http_res_text,
872
890
  http_res,
873
891
  )
874
892
 
@@ -940,14 +958,16 @@ class Jobs(BaseSDK):
940
958
  if utils.match_response(http_res, "200", "application/json"):
941
959
  return utils.unmarshal_json(http_res.text, Optional[models.DetailedJobOut])
942
960
  if utils.match_response(http_res, ["4XX", "5XX"], "*"):
961
+ http_res_text = await utils.stream_to_text_async(http_res)
943
962
  raise models.SDKError(
944
- "API error occurred", http_res.status_code, http_res.text, http_res
963
+ "API error occurred", http_res.status_code, http_res_text, http_res
945
964
  )
946
965
 
947
966
  content_type = http_res.headers.get("Content-Type")
967
+ http_res_text = await utils.stream_to_text_async(http_res)
948
968
  raise models.SDKError(
949
969
  f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
950
970
  http_res.status_code,
951
- http_res.text,
971
+ http_res_text,
952
972
  http_res,
953
973
  )