mistralai 1.0.0rc1__py3-none-any.whl → 1.0.1__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 (114) hide show
  1. mistralai/agents.py +434 -0
  2. mistralai/basesdk.py +43 -6
  3. mistralai/chat.py +29 -34
  4. mistralai/client.py +1 -1
  5. mistralai/embeddings.py +4 -4
  6. mistralai/files.py +10 -10
  7. mistralai/fim.py +17 -18
  8. mistralai/fine_tuning.py +10 -849
  9. mistralai/jobs.py +844 -0
  10. mistralai/models/__init__.py +6 -4
  11. mistralai/models/agentscompletionrequest.py +96 -0
  12. mistralai/models/agentscompletionstreamrequest.py +92 -0
  13. mistralai/models/assistantmessage.py +4 -9
  14. mistralai/models/chatcompletionchoice.py +4 -15
  15. mistralai/models/chatcompletionrequest.py +25 -30
  16. mistralai/models/chatcompletionstreamrequest.py +25 -30
  17. mistralai/models/completionresponsestreamchoice.py +4 -9
  18. mistralai/models/delete_model_v1_models_model_id_deleteop.py +2 -0
  19. mistralai/models/deltamessage.py +7 -12
  20. mistralai/models/detailedjobout.py +4 -9
  21. mistralai/models/embeddingrequest.py +12 -17
  22. mistralai/models/eventout.py +4 -9
  23. mistralai/models/fileschema.py +4 -9
  24. mistralai/models/fimcompletionrequest.py +19 -24
  25. mistralai/models/fimcompletionstreamrequest.py +19 -24
  26. mistralai/models/ftmodelout.py +4 -9
  27. mistralai/models/functioncall.py +9 -3
  28. mistralai/models/githubrepositoryin.py +4 -9
  29. mistralai/models/githubrepositoryout.py +4 -9
  30. mistralai/models/httpvalidationerror.py +1 -1
  31. mistralai/models/jobin.py +4 -9
  32. mistralai/models/jobmetadataout.py +4 -9
  33. mistralai/models/jobout.py +4 -9
  34. mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +2 -0
  35. mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +1 -59
  36. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +4 -9
  37. mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +2 -0
  38. mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +2 -0
  39. mistralai/models/legacyjobmetadataout.py +4 -9
  40. mistralai/models/metricout.py +4 -9
  41. mistralai/models/modelcard.py +4 -9
  42. mistralai/models/retrieve_model_v1_models_model_id_getop.py +2 -0
  43. mistralai/models/retrievefileout.py +4 -9
  44. mistralai/models/security.py +4 -4
  45. mistralai/models/systemmessage.py +6 -6
  46. mistralai/models/toolmessage.py +4 -9
  47. mistralai/models/trainingparameters.py +4 -9
  48. mistralai/models/trainingparametersin.py +4 -9
  49. mistralai/models/updateftmodelin.py +4 -9
  50. mistralai/models/uploadfileout.py +4 -9
  51. mistralai/models/usermessage.py +6 -6
  52. mistralai/models/validationerror.py +6 -6
  53. mistralai/models/wandbintegration.py +4 -9
  54. mistralai/models/wandbintegrationout.py +4 -9
  55. mistralai/models_.py +24 -24
  56. mistralai/sdk.py +14 -6
  57. mistralai/sdkconfiguration.py +5 -4
  58. mistralai/types/basemodel.py +10 -6
  59. mistralai/utils/__init__.py +4 -0
  60. mistralai/utils/eventstreaming.py +8 -9
  61. mistralai/utils/logger.py +16 -0
  62. mistralai/utils/retries.py +2 -2
  63. mistralai/utils/security.py +5 -2
  64. {mistralai-1.0.0rc1.dist-info → mistralai-1.0.1.dist-info}/METADATA +153 -69
  65. {mistralai-1.0.0rc1.dist-info → mistralai-1.0.1.dist-info}/RECORD +114 -107
  66. mistralai_azure/basesdk.py +42 -4
  67. mistralai_azure/chat.py +15 -20
  68. mistralai_azure/models/__init__.py +3 -3
  69. mistralai_azure/models/assistantmessage.py +4 -9
  70. mistralai_azure/models/chatcompletionchoice.py +4 -15
  71. mistralai_azure/models/chatcompletionrequest.py +21 -26
  72. mistralai_azure/models/chatcompletionstreamrequest.py +21 -26
  73. mistralai_azure/models/completionresponsestreamchoice.py +4 -9
  74. mistralai_azure/models/deltamessage.py +7 -12
  75. mistralai_azure/models/functioncall.py +9 -3
  76. mistralai_azure/models/httpvalidationerror.py +1 -1
  77. mistralai_azure/models/systemmessage.py +6 -6
  78. mistralai_azure/models/toolmessage.py +4 -9
  79. mistralai_azure/models/usermessage.py +6 -6
  80. mistralai_azure/models/validationerror.py +6 -6
  81. mistralai_azure/sdk.py +7 -2
  82. mistralai_azure/sdkconfiguration.py +5 -4
  83. mistralai_azure/types/basemodel.py +10 -6
  84. mistralai_azure/utils/__init__.py +4 -0
  85. mistralai_azure/utils/eventstreaming.py +8 -9
  86. mistralai_azure/utils/logger.py +16 -0
  87. mistralai_azure/utils/retries.py +2 -2
  88. mistralai_gcp/basesdk.py +42 -4
  89. mistralai_gcp/chat.py +12 -17
  90. mistralai_gcp/fim.py +12 -13
  91. mistralai_gcp/models/__init__.py +3 -3
  92. mistralai_gcp/models/assistantmessage.py +4 -9
  93. mistralai_gcp/models/chatcompletionchoice.py +4 -15
  94. mistralai_gcp/models/chatcompletionrequest.py +23 -28
  95. mistralai_gcp/models/chatcompletionstreamrequest.py +23 -28
  96. mistralai_gcp/models/completionresponsestreamchoice.py +4 -9
  97. mistralai_gcp/models/deltamessage.py +7 -12
  98. mistralai_gcp/models/fimcompletionrequest.py +19 -24
  99. mistralai_gcp/models/fimcompletionstreamrequest.py +19 -24
  100. mistralai_gcp/models/functioncall.py +9 -3
  101. mistralai_gcp/models/httpvalidationerror.py +1 -1
  102. mistralai_gcp/models/systemmessage.py +6 -6
  103. mistralai_gcp/models/toolmessage.py +4 -9
  104. mistralai_gcp/models/usermessage.py +6 -6
  105. mistralai_gcp/models/validationerror.py +6 -6
  106. mistralai_gcp/sdk.py +9 -0
  107. mistralai_gcp/sdkconfiguration.py +5 -4
  108. mistralai_gcp/types/basemodel.py +10 -6
  109. mistralai_gcp/utils/__init__.py +4 -0
  110. mistralai_gcp/utils/eventstreaming.py +8 -9
  111. mistralai_gcp/utils/logger.py +16 -0
  112. mistralai_gcp/utils/retries.py +2 -2
  113. {mistralai-1.0.0rc1.dist-info → mistralai-1.0.1.dist-info}/LICENSE +0 -0
  114. {mistralai-1.0.0rc1.dist-info → mistralai-1.0.1.dist-info}/WHEEL +0 -0
mistralai/chat.py CHANGED
@@ -1,21 +1,20 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from .basesdk import BaseSDK
4
- from mistralai import models
4
+ from mistralai import models, utils
5
5
  from mistralai._hooks import HookContext
6
- from mistralai.types import OptionalNullable, UNSET
7
- import mistralai.utils as utils
8
- from mistralai.utils import eventstreaming
6
+ from mistralai.types import Nullable, OptionalNullable, UNSET
7
+ from mistralai.utils import eventstreaming, get_security_from_env
9
8
  from typing import Any, AsyncGenerator, Generator, List, Optional, Union
10
9
 
11
10
  class Chat(BaseSDK):
12
11
  r"""Chat Completion API."""
13
12
 
14
13
 
15
- def create(
14
+ def complete(
16
15
  self, *,
16
+ model: Nullable[str],
17
17
  messages: Union[List[models.Messages], List[models.MessagesTypedDict]],
18
- model: OptionalNullable[str] = UNSET,
19
18
  temperature: Optional[float] = 0.7,
20
19
  top_p: Optional[float] = 1,
21
20
  max_tokens: OptionalNullable[int] = UNSET,
@@ -25,18 +24,16 @@ class Chat(BaseSDK):
25
24
  random_seed: OptionalNullable[int] = UNSET,
26
25
  response_format: Optional[Union[models.ResponseFormat, models.ResponseFormatTypedDict]] = None,
27
26
  tools: OptionalNullable[Union[List[models.Tool], List[models.ToolTypedDict]]] = UNSET,
28
- safe_prompt: Optional[bool] = False,
29
27
  tool_choice: Optional[models.ToolChoice] = "auto",
28
+ safe_prompt: Optional[bool] = False,
30
29
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
31
30
  server_url: Optional[str] = None,
32
31
  timeout_ms: Optional[int] = None,
33
32
  ) -> Optional[models.ChatCompletionResponse]:
34
33
  r"""Chat Completion
35
34
 
36
- Chat Completion
37
-
38
- :param messages: The prompt(s) to generate completions for, encoded as a list of dict with role and content.
39
35
  :param model: ID of the model to use. You can use the [List Available Models](/api#operation/listModels) API to see all of your available models, or see our [Model overview](/models) for model descriptions.
36
+ :param messages: The prompt(s) to generate completions for, encoded as a list of dict with role and content.
40
37
  :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.
41
38
  :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.
42
39
  :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.
@@ -46,8 +43,8 @@ class Chat(BaseSDK):
46
43
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
47
44
  :param response_format:
48
45
  :param tools:
49
- :param safe_prompt: Whether to inject a safety prompt before all conversations.
50
46
  :param tool_choice:
47
+ :param safe_prompt: Whether to inject a safety prompt before all conversations.
51
48
  :param retries: Override the default retry configuration for this method
52
49
  :param server_url: Override the default server URL for this method
53
50
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -72,8 +69,8 @@ class Chat(BaseSDK):
72
69
  messages=utils.get_pydantic_model(messages, List[models.Messages]),
73
70
  response_format=utils.get_pydantic_model(response_format, Optional[models.ResponseFormat]),
74
71
  tools=utils.get_pydantic_model(tools, OptionalNullable[List[models.Tool]]),
75
- safe_prompt=safe_prompt,
76
72
  tool_choice=tool_choice,
73
+ safe_prompt=safe_prompt,
77
74
  )
78
75
 
79
76
  req = self.build_request(
@@ -107,7 +104,7 @@ class Chat(BaseSDK):
107
104
  ])
108
105
 
109
106
  http_res = self.do_request(
110
- hook_ctx=HookContext(operation_id="chat_completion_v1_chat_completions_post", oauth2_scopes=[], security_source=self.sdk_configuration.security),
107
+ hook_ctx=HookContext(operation_id="chat_completion_v1_chat_completions_post", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
111
108
  request=req,
112
109
  error_status_codes=["422","4XX","5XX"],
113
110
  retry_config=retry_config
@@ -127,10 +124,10 @@ class Chat(BaseSDK):
127
124
 
128
125
 
129
126
 
130
- async def create_async(
127
+ async def complete_async(
131
128
  self, *,
129
+ model: Nullable[str],
132
130
  messages: Union[List[models.Messages], List[models.MessagesTypedDict]],
133
- model: OptionalNullable[str] = UNSET,
134
131
  temperature: Optional[float] = 0.7,
135
132
  top_p: Optional[float] = 1,
136
133
  max_tokens: OptionalNullable[int] = UNSET,
@@ -140,18 +137,16 @@ class Chat(BaseSDK):
140
137
  random_seed: OptionalNullable[int] = UNSET,
141
138
  response_format: Optional[Union[models.ResponseFormat, models.ResponseFormatTypedDict]] = None,
142
139
  tools: OptionalNullable[Union[List[models.Tool], List[models.ToolTypedDict]]] = UNSET,
143
- safe_prompt: Optional[bool] = False,
144
140
  tool_choice: Optional[models.ToolChoice] = "auto",
141
+ safe_prompt: Optional[bool] = False,
145
142
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
146
143
  server_url: Optional[str] = None,
147
144
  timeout_ms: Optional[int] = None,
148
145
  ) -> Optional[models.ChatCompletionResponse]:
149
146
  r"""Chat Completion
150
147
 
151
- Chat Completion
152
-
153
- :param messages: The prompt(s) to generate completions for, encoded as a list of dict with role and content.
154
148
  :param model: ID of the model to use. You can use the [List Available Models](/api#operation/listModels) API to see all of your available models, or see our [Model overview](/models) for model descriptions.
149
+ :param messages: The prompt(s) to generate completions for, encoded as a list of dict with role and content.
155
150
  :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.
156
151
  :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.
157
152
  :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.
@@ -161,8 +156,8 @@ class Chat(BaseSDK):
161
156
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
162
157
  :param response_format:
163
158
  :param tools:
164
- :param safe_prompt: Whether to inject a safety prompt before all conversations.
165
159
  :param tool_choice:
160
+ :param safe_prompt: Whether to inject a safety prompt before all conversations.
166
161
  :param retries: Override the default retry configuration for this method
167
162
  :param server_url: Override the default server URL for this method
168
163
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -187,8 +182,8 @@ class Chat(BaseSDK):
187
182
  messages=utils.get_pydantic_model(messages, List[models.Messages]),
188
183
  response_format=utils.get_pydantic_model(response_format, Optional[models.ResponseFormat]),
189
184
  tools=utils.get_pydantic_model(tools, OptionalNullable[List[models.Tool]]),
190
- safe_prompt=safe_prompt,
191
185
  tool_choice=tool_choice,
186
+ safe_prompt=safe_prompt,
192
187
  )
193
188
 
194
189
  req = self.build_request(
@@ -222,7 +217,7 @@ class Chat(BaseSDK):
222
217
  ])
223
218
 
224
219
  http_res = await self.do_request_async(
225
- hook_ctx=HookContext(operation_id="chat_completion_v1_chat_completions_post", oauth2_scopes=[], security_source=self.sdk_configuration.security),
220
+ hook_ctx=HookContext(operation_id="chat_completion_v1_chat_completions_post", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
226
221
  request=req,
227
222
  error_status_codes=["422","4XX","5XX"],
228
223
  retry_config=retry_config
@@ -244,8 +239,8 @@ class Chat(BaseSDK):
244
239
 
245
240
  def stream(
246
241
  self, *,
242
+ model: Nullable[str],
247
243
  messages: Union[List[models.ChatCompletionStreamRequestMessages], List[models.ChatCompletionStreamRequestMessagesTypedDict]],
248
- model: OptionalNullable[str] = UNSET,
249
244
  temperature: Optional[float] = 0.7,
250
245
  top_p: Optional[float] = 1,
251
246
  max_tokens: OptionalNullable[int] = UNSET,
@@ -255,8 +250,8 @@ class Chat(BaseSDK):
255
250
  random_seed: OptionalNullable[int] = UNSET,
256
251
  response_format: Optional[Union[models.ResponseFormat, models.ResponseFormatTypedDict]] = None,
257
252
  tools: OptionalNullable[Union[List[models.Tool], List[models.ToolTypedDict]]] = UNSET,
258
- safe_prompt: Optional[bool] = False,
259
253
  tool_choice: Optional[models.ChatCompletionStreamRequestToolChoice] = "auto",
254
+ safe_prompt: Optional[bool] = False,
260
255
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
261
256
  server_url: Optional[str] = None,
262
257
  timeout_ms: Optional[int] = None,
@@ -265,8 +260,8 @@ class Chat(BaseSDK):
265
260
 
266
261
  Mistral AI provides the ability to stream responses back to a client in order to allow partial results for certain requests. Tokens will be sent as data-only server-sent 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.
267
262
 
268
- :param messages: The prompt(s) to generate completions for, encoded as a list of dict with role and content.
269
263
  :param model: ID of the model to use. You can use the [List Available Models](/api#operation/listModels) API to see all of your available models, or see our [Model overview](/models) for model descriptions.
264
+ :param messages: The prompt(s) to generate completions for, encoded as a list of dict with role and content.
270
265
  :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.
271
266
  :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.
272
267
  :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.
@@ -276,8 +271,8 @@ class Chat(BaseSDK):
276
271
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
277
272
  :param response_format:
278
273
  :param tools:
279
- :param safe_prompt: Whether to inject a safety prompt before all conversations.
280
274
  :param tool_choice:
275
+ :param safe_prompt: Whether to inject a safety prompt before all conversations.
281
276
  :param retries: Override the default retry configuration for this method
282
277
  :param server_url: Override the default server URL for this method
283
278
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -302,8 +297,8 @@ class Chat(BaseSDK):
302
297
  messages=utils.get_pydantic_model(messages, List[models.ChatCompletionStreamRequestMessages]),
303
298
  response_format=utils.get_pydantic_model(response_format, Optional[models.ResponseFormat]),
304
299
  tools=utils.get_pydantic_model(tools, OptionalNullable[List[models.Tool]]),
305
- safe_prompt=safe_prompt,
306
300
  tool_choice=tool_choice,
301
+ safe_prompt=safe_prompt,
307
302
  )
308
303
 
309
304
  req = self.build_request(
@@ -337,7 +332,7 @@ class Chat(BaseSDK):
337
332
  ])
338
333
 
339
334
  http_res = self.do_request(
340
- hook_ctx=HookContext(operation_id="stream_chat", oauth2_scopes=[], security_source=self.sdk_configuration.security),
335
+ hook_ctx=HookContext(operation_id="stream_chat", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
341
336
  request=req,
342
337
  error_status_codes=["422","4XX","5XX"],
343
338
  stream=True,
@@ -360,8 +355,8 @@ class Chat(BaseSDK):
360
355
 
361
356
  async def stream_async(
362
357
  self, *,
358
+ model: Nullable[str],
363
359
  messages: Union[List[models.ChatCompletionStreamRequestMessages], List[models.ChatCompletionStreamRequestMessagesTypedDict]],
364
- model: OptionalNullable[str] = UNSET,
365
360
  temperature: Optional[float] = 0.7,
366
361
  top_p: Optional[float] = 1,
367
362
  max_tokens: OptionalNullable[int] = UNSET,
@@ -371,8 +366,8 @@ class Chat(BaseSDK):
371
366
  random_seed: OptionalNullable[int] = UNSET,
372
367
  response_format: Optional[Union[models.ResponseFormat, models.ResponseFormatTypedDict]] = None,
373
368
  tools: OptionalNullable[Union[List[models.Tool], List[models.ToolTypedDict]]] = UNSET,
374
- safe_prompt: Optional[bool] = False,
375
369
  tool_choice: Optional[models.ChatCompletionStreamRequestToolChoice] = "auto",
370
+ safe_prompt: Optional[bool] = False,
376
371
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
377
372
  server_url: Optional[str] = None,
378
373
  timeout_ms: Optional[int] = None,
@@ -381,8 +376,8 @@ class Chat(BaseSDK):
381
376
 
382
377
  Mistral AI provides the ability to stream responses back to a client in order to allow partial results for certain requests. Tokens will be sent as data-only server-sent 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.
383
378
 
384
- :param messages: The prompt(s) to generate completions for, encoded as a list of dict with role and content.
385
379
  :param model: ID of the model to use. You can use the [List Available Models](/api#operation/listModels) API to see all of your available models, or see our [Model overview](/models) for model descriptions.
380
+ :param messages: The prompt(s) to generate completions for, encoded as a list of dict with role and content.
386
381
  :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.
387
382
  :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.
388
383
  :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.
@@ -392,8 +387,8 @@ class Chat(BaseSDK):
392
387
  :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
393
388
  :param response_format:
394
389
  :param tools:
395
- :param safe_prompt: Whether to inject a safety prompt before all conversations.
396
390
  :param tool_choice:
391
+ :param safe_prompt: Whether to inject a safety prompt before all conversations.
397
392
  :param retries: Override the default retry configuration for this method
398
393
  :param server_url: Override the default server URL for this method
399
394
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -418,8 +413,8 @@ class Chat(BaseSDK):
418
413
  messages=utils.get_pydantic_model(messages, List[models.ChatCompletionStreamRequestMessages]),
419
414
  response_format=utils.get_pydantic_model(response_format, Optional[models.ResponseFormat]),
420
415
  tools=utils.get_pydantic_model(tools, OptionalNullable[List[models.Tool]]),
421
- safe_prompt=safe_prompt,
422
416
  tool_choice=tool_choice,
417
+ safe_prompt=safe_prompt,
423
418
  )
424
419
 
425
420
  req = self.build_request(
@@ -453,7 +448,7 @@ class Chat(BaseSDK):
453
448
  ])
454
449
 
455
450
  http_res = await self.do_request_async(
456
- hook_ctx=HookContext(operation_id="stream_chat", oauth2_scopes=[], security_source=self.sdk_configuration.security),
451
+ hook_ctx=HookContext(operation_id="stream_chat", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
457
452
  request=req,
458
453
  error_status_codes=["422","4XX","5XX"],
459
454
  stream=True,
mistralai/client.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from typing import Optional
2
2
 
3
- MIGRATION_MESSAGE = "This client is deprecated starting v1.0.0, pin your version to 0.4.2. Or migrate by following this documentation: TODO add link"
3
+ MIGRATION_MESSAGE = "This client is deprecated. To migrate to the new client, please refer to this guide: https://github.com/mistralai/client-python/blob/main/MIGRATION.md. If you need to use this client anyway, pin your version to 0.4.2."
4
4
 
5
5
 
6
6
  class MistralClient:
mistralai/embeddings.py CHANGED
@@ -1,10 +1,10 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from .basesdk import BaseSDK
4
- from mistralai import models
4
+ from mistralai import models, utils
5
5
  from mistralai._hooks import HookContext
6
6
  from mistralai.types import OptionalNullable, UNSET
7
- import mistralai.utils as utils
7
+ from mistralai.utils import get_security_from_env
8
8
  from typing import Any, Optional, Union
9
9
 
10
10
  class Embeddings(BaseSDK):
@@ -76,7 +76,7 @@ class Embeddings(BaseSDK):
76
76
  ])
77
77
 
78
78
  http_res = self.do_request(
79
- hook_ctx=HookContext(operation_id="embeddings_v1_embeddings_post", oauth2_scopes=[], security_source=self.sdk_configuration.security),
79
+ hook_ctx=HookContext(operation_id="embeddings_v1_embeddings_post", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
80
80
  request=req,
81
81
  error_status_codes=["422","4XX","5XX"],
82
82
  retry_config=retry_config
@@ -161,7 +161,7 @@ class Embeddings(BaseSDK):
161
161
  ])
162
162
 
163
163
  http_res = await self.do_request_async(
164
- hook_ctx=HookContext(operation_id="embeddings_v1_embeddings_post", oauth2_scopes=[], security_source=self.sdk_configuration.security),
164
+ hook_ctx=HookContext(operation_id="embeddings_v1_embeddings_post", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
165
165
  request=req,
166
166
  error_status_codes=["422","4XX","5XX"],
167
167
  retry_config=retry_config
mistralai/files.py CHANGED
@@ -1,10 +1,10 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from .basesdk import BaseSDK
4
- from mistralai import models
4
+ from mistralai import models, utils
5
5
  from mistralai._hooks import HookContext
6
6
  from mistralai.types import OptionalNullable, UNSET
7
- import mistralai.utils as utils
7
+ from mistralai.utils import get_security_from_env
8
8
  from typing import Optional, Union
9
9
 
10
10
  class Files(BaseSDK):
@@ -74,7 +74,7 @@ class Files(BaseSDK):
74
74
  ])
75
75
 
76
76
  http_res = self.do_request(
77
- hook_ctx=HookContext(operation_id="files_api_routes_upload_file", oauth2_scopes=[], security_source=self.sdk_configuration.security),
77
+ hook_ctx=HookContext(operation_id="files_api_routes_upload_file", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
78
78
  request=req,
79
79
  error_status_codes=["4XX","5XX"],
80
80
  retry_config=retry_config
@@ -153,7 +153,7 @@ class Files(BaseSDK):
153
153
  ])
154
154
 
155
155
  http_res = await self.do_request_async(
156
- hook_ctx=HookContext(operation_id="files_api_routes_upload_file", oauth2_scopes=[], security_source=self.sdk_configuration.security),
156
+ hook_ctx=HookContext(operation_id="files_api_routes_upload_file", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
157
157
  request=req,
158
158
  error_status_codes=["4XX","5XX"],
159
159
  retry_config=retry_config
@@ -220,7 +220,7 @@ class Files(BaseSDK):
220
220
  ])
221
221
 
222
222
  http_res = self.do_request(
223
- hook_ctx=HookContext(operation_id="files_api_routes_list_files", oauth2_scopes=[], security_source=self.sdk_configuration.security),
223
+ hook_ctx=HookContext(operation_id="files_api_routes_list_files", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
224
224
  request=req,
225
225
  error_status_codes=["4XX","5XX"],
226
226
  retry_config=retry_config
@@ -287,7 +287,7 @@ class Files(BaseSDK):
287
287
  ])
288
288
 
289
289
  http_res = await self.do_request_async(
290
- hook_ctx=HookContext(operation_id="files_api_routes_list_files", oauth2_scopes=[], security_source=self.sdk_configuration.security),
290
+ hook_ctx=HookContext(operation_id="files_api_routes_list_files", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
291
291
  request=req,
292
292
  error_status_codes=["4XX","5XX"],
293
293
  retry_config=retry_config
@@ -361,7 +361,7 @@ class Files(BaseSDK):
361
361
  ])
362
362
 
363
363
  http_res = self.do_request(
364
- hook_ctx=HookContext(operation_id="files_api_routes_retrieve_file", oauth2_scopes=[], security_source=self.sdk_configuration.security),
364
+ hook_ctx=HookContext(operation_id="files_api_routes_retrieve_file", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
365
365
  request=req,
366
366
  error_status_codes=["4XX","5XX"],
367
367
  retry_config=retry_config
@@ -435,7 +435,7 @@ class Files(BaseSDK):
435
435
  ])
436
436
 
437
437
  http_res = await self.do_request_async(
438
- hook_ctx=HookContext(operation_id="files_api_routes_retrieve_file", oauth2_scopes=[], security_source=self.sdk_configuration.security),
438
+ hook_ctx=HookContext(operation_id="files_api_routes_retrieve_file", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
439
439
  request=req,
440
440
  error_status_codes=["4XX","5XX"],
441
441
  retry_config=retry_config
@@ -509,7 +509,7 @@ class Files(BaseSDK):
509
509
  ])
510
510
 
511
511
  http_res = self.do_request(
512
- hook_ctx=HookContext(operation_id="files_api_routes_delete_file", oauth2_scopes=[], security_source=self.sdk_configuration.security),
512
+ hook_ctx=HookContext(operation_id="files_api_routes_delete_file", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
513
513
  request=req,
514
514
  error_status_codes=["4XX","5XX"],
515
515
  retry_config=retry_config
@@ -583,7 +583,7 @@ class Files(BaseSDK):
583
583
  ])
584
584
 
585
585
  http_res = await self.do_request_async(
586
- hook_ctx=HookContext(operation_id="files_api_routes_delete_file", oauth2_scopes=[], security_source=self.sdk_configuration.security),
586
+ hook_ctx=HookContext(operation_id="files_api_routes_delete_file", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
587
587
  request=req,
588
588
  error_status_codes=["4XX","5XX"],
589
589
  retry_config=retry_config
mistralai/fim.py CHANGED
@@ -1,21 +1,20 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from .basesdk import BaseSDK
4
- from mistralai import models
4
+ from mistralai import models, utils
5
5
  from mistralai._hooks import HookContext
6
- from mistralai.types import OptionalNullable, UNSET
7
- import mistralai.utils as utils
8
- from mistralai.utils import eventstreaming
6
+ from mistralai.types import Nullable, OptionalNullable, UNSET
7
+ from mistralai.utils import eventstreaming, get_security_from_env
9
8
  from typing import Any, AsyncGenerator, Generator, Optional, Union
10
9
 
11
10
  class Fim(BaseSDK):
12
11
  r"""Fill-in-the-middle API."""
13
12
 
14
13
 
15
- def create(
14
+ def complete(
16
15
  self, *,
16
+ model: Nullable[str],
17
17
  prompt: str,
18
- model: OptionalNullable[str] = UNSET,
19
18
  temperature: Optional[float] = 0.7,
20
19
  top_p: Optional[float] = 1,
21
20
  max_tokens: OptionalNullable[int] = UNSET,
@@ -32,8 +31,8 @@ class Fim(BaseSDK):
32
31
 
33
32
  FIM completion.
34
33
 
35
- :param prompt: The text/code to complete.
36
34
  :param model: ID of the model to use. Only compatible for now with: - `codestral-2405` - `codestral-latest`
35
+ :param prompt: The text/code to complete.
37
36
  :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.
38
37
  :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.
39
38
  :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.
@@ -98,7 +97,7 @@ class Fim(BaseSDK):
98
97
  ])
99
98
 
100
99
  http_res = self.do_request(
101
- hook_ctx=HookContext(operation_id="fim_completion_v1_fim_completions_post", oauth2_scopes=[], security_source=self.sdk_configuration.security),
100
+ hook_ctx=HookContext(operation_id="fim_completion_v1_fim_completions_post", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
102
101
  request=req,
103
102
  error_status_codes=["422","4XX","5XX"],
104
103
  retry_config=retry_config
@@ -118,10 +117,10 @@ class Fim(BaseSDK):
118
117
 
119
118
 
120
119
 
121
- async def create_async(
120
+ async def complete_async(
122
121
  self, *,
122
+ model: Nullable[str],
123
123
  prompt: str,
124
- model: OptionalNullable[str] = UNSET,
125
124
  temperature: Optional[float] = 0.7,
126
125
  top_p: Optional[float] = 1,
127
126
  max_tokens: OptionalNullable[int] = UNSET,
@@ -138,8 +137,8 @@ class Fim(BaseSDK):
138
137
 
139
138
  FIM completion.
140
139
 
141
- :param prompt: The text/code to complete.
142
140
  :param model: ID of the model to use. Only compatible for now with: - `codestral-2405` - `codestral-latest`
141
+ :param prompt: The text/code to complete.
143
142
  :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.
144
143
  :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.
145
144
  :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.
@@ -204,7 +203,7 @@ class Fim(BaseSDK):
204
203
  ])
205
204
 
206
205
  http_res = await self.do_request_async(
207
- hook_ctx=HookContext(operation_id="fim_completion_v1_fim_completions_post", oauth2_scopes=[], security_source=self.sdk_configuration.security),
206
+ hook_ctx=HookContext(operation_id="fim_completion_v1_fim_completions_post", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
208
207
  request=req,
209
208
  error_status_codes=["422","4XX","5XX"],
210
209
  retry_config=retry_config
@@ -226,8 +225,8 @@ class Fim(BaseSDK):
226
225
 
227
226
  def stream(
228
227
  self, *,
228
+ model: Nullable[str],
229
229
  prompt: str,
230
- model: OptionalNullable[str] = UNSET,
231
230
  temperature: Optional[float] = 0.7,
232
231
  top_p: Optional[float] = 1,
233
232
  max_tokens: OptionalNullable[int] = UNSET,
@@ -244,8 +243,8 @@ class Fim(BaseSDK):
244
243
 
245
244
  Mistral AI provides the ability to stream responses back to a client in order to allow partial results for certain requests. Tokens will be sent as data-only server-sent 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.
246
245
 
247
- :param prompt: The text/code to complete.
248
246
  :param model: ID of the model to use. Only compatible for now with: - `codestral-2405` - `codestral-latest`
247
+ :param prompt: The text/code to complete.
249
248
  :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.
250
249
  :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.
251
250
  :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.
@@ -310,7 +309,7 @@ class Fim(BaseSDK):
310
309
  ])
311
310
 
312
311
  http_res = self.do_request(
313
- hook_ctx=HookContext(operation_id="stream_fim", oauth2_scopes=[], security_source=self.sdk_configuration.security),
312
+ hook_ctx=HookContext(operation_id="stream_fim", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
314
313
  request=req,
315
314
  error_status_codes=["422","4XX","5XX"],
316
315
  stream=True,
@@ -333,8 +332,8 @@ class Fim(BaseSDK):
333
332
 
334
333
  async def stream_async(
335
334
  self, *,
335
+ model: Nullable[str],
336
336
  prompt: str,
337
- model: OptionalNullable[str] = UNSET,
338
337
  temperature: Optional[float] = 0.7,
339
338
  top_p: Optional[float] = 1,
340
339
  max_tokens: OptionalNullable[int] = UNSET,
@@ -351,8 +350,8 @@ class Fim(BaseSDK):
351
350
 
352
351
  Mistral AI provides the ability to stream responses back to a client in order to allow partial results for certain requests. Tokens will be sent as data-only server-sent 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.
353
352
 
354
- :param prompt: The text/code to complete.
355
353
  :param model: ID of the model to use. Only compatible for now with: - `codestral-2405` - `codestral-latest`
354
+ :param prompt: The text/code to complete.
356
355
  :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.
357
356
  :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.
358
357
  :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.
@@ -417,7 +416,7 @@ class Fim(BaseSDK):
417
416
  ])
418
417
 
419
418
  http_res = await self.do_request_async(
420
- hook_ctx=HookContext(operation_id="stream_fim", oauth2_scopes=[], security_source=self.sdk_configuration.security),
419
+ hook_ctx=HookContext(operation_id="stream_fim", oauth2_scopes=[], security_source=get_security_from_env(self.sdk_configuration.security, models.Security)),
421
420
  request=req,
422
421
  error_status_codes=["422","4XX","5XX"],
423
422
  stream=True,