mistralai 0.5.5a50__py3-none-any.whl → 1.0.0rc2__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.
- mistralai/agents.py +434 -0
- mistralai/basesdk.py +43 -6
- mistralai/chat.py +29 -34
- mistralai/embeddings.py +4 -4
- mistralai/files.py +10 -10
- mistralai/fim.py +17 -18
- mistralai/fine_tuning.py +10 -849
- mistralai/jobs.py +854 -0
- mistralai/models/__init__.py +4 -2
- mistralai/models/agentscompletionrequest.py +96 -0
- mistralai/models/agentscompletionstreamrequest.py +92 -0
- mistralai/models/assistantmessage.py +4 -9
- mistralai/models/chatcompletionchoice.py +4 -15
- mistralai/models/chatcompletionrequest.py +11 -16
- mistralai/models/chatcompletionstreamrequest.py +11 -16
- mistralai/models/completionresponsestreamchoice.py +4 -9
- mistralai/models/deltamessage.py +4 -9
- mistralai/models/detailedjobout.py +4 -9
- mistralai/models/embeddingrequest.py +4 -9
- mistralai/models/eventout.py +4 -9
- mistralai/models/fileschema.py +4 -9
- mistralai/models/fimcompletionrequest.py +11 -16
- mistralai/models/fimcompletionstreamrequest.py +11 -16
- mistralai/models/ftmodelout.py +4 -9
- mistralai/models/githubrepositoryin.py +4 -9
- mistralai/models/githubrepositoryout.py +4 -9
- mistralai/models/httpvalidationerror.py +1 -1
- mistralai/models/jobin.py +4 -9
- mistralai/models/jobmetadataout.py +4 -9
- mistralai/models/jobout.py +4 -9
- mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +4 -9
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +4 -9
- mistralai/models/legacyjobmetadataout.py +4 -9
- mistralai/models/metricout.py +4 -9
- mistralai/models/modelcard.py +4 -9
- mistralai/models/retrievefileout.py +4 -9
- mistralai/models/security.py +4 -4
- mistralai/models/toolmessage.py +4 -9
- mistralai/models/trainingparameters.py +4 -9
- mistralai/models/trainingparametersin.py +4 -9
- mistralai/models/updateftmodelin.py +4 -9
- mistralai/models/uploadfileout.py +4 -9
- mistralai/models/wandbintegration.py +4 -9
- mistralai/models/wandbintegrationout.py +4 -9
- mistralai/models_.py +14 -14
- mistralai/sdk.py +14 -6
- mistralai/sdkconfiguration.py +5 -4
- mistralai/types/basemodel.py +10 -6
- mistralai/utils/__init__.py +4 -0
- mistralai/utils/eventstreaming.py +8 -9
- mistralai/utils/logger.py +16 -0
- mistralai/utils/retries.py +2 -2
- mistralai/utils/security.py +5 -2
- {mistralai-0.5.5a50.dist-info → mistralai-1.0.0rc2.dist-info}/METADATA +113 -53
- {mistralai-0.5.5a50.dist-info → mistralai-1.0.0rc2.dist-info}/RECORD +96 -89
- mistralai_azure/basesdk.py +42 -4
- mistralai_azure/chat.py +15 -20
- mistralai_azure/models/__init__.py +2 -2
- mistralai_azure/models/assistantmessage.py +4 -9
- mistralai_azure/models/chatcompletionchoice.py +4 -15
- mistralai_azure/models/chatcompletionrequest.py +7 -12
- mistralai_azure/models/chatcompletionstreamrequest.py +7 -12
- mistralai_azure/models/completionresponsestreamchoice.py +4 -9
- mistralai_azure/models/deltamessage.py +4 -9
- mistralai_azure/models/httpvalidationerror.py +1 -1
- mistralai_azure/models/toolmessage.py +4 -9
- mistralai_azure/sdk.py +7 -2
- mistralai_azure/sdkconfiguration.py +5 -4
- mistralai_azure/types/basemodel.py +10 -6
- mistralai_azure/utils/__init__.py +4 -0
- mistralai_azure/utils/eventstreaming.py +8 -9
- mistralai_azure/utils/logger.py +16 -0
- mistralai_azure/utils/retries.py +2 -2
- mistralai_gcp/basesdk.py +42 -4
- mistralai_gcp/chat.py +12 -17
- mistralai_gcp/fim.py +12 -13
- mistralai_gcp/models/__init__.py +2 -2
- mistralai_gcp/models/assistantmessage.py +4 -9
- mistralai_gcp/models/chatcompletionchoice.py +4 -15
- mistralai_gcp/models/chatcompletionrequest.py +9 -14
- mistralai_gcp/models/chatcompletionstreamrequest.py +9 -14
- mistralai_gcp/models/completionresponsestreamchoice.py +4 -9
- mistralai_gcp/models/deltamessage.py +4 -9
- mistralai_gcp/models/fimcompletionrequest.py +11 -16
- mistralai_gcp/models/fimcompletionstreamrequest.py +11 -16
- mistralai_gcp/models/httpvalidationerror.py +1 -1
- mistralai_gcp/models/toolmessage.py +4 -9
- mistralai_gcp/sdk.py +9 -0
- mistralai_gcp/sdkconfiguration.py +5 -4
- mistralai_gcp/types/basemodel.py +10 -6
- mistralai_gcp/utils/__init__.py +4 -0
- mistralai_gcp/utils/eventstreaming.py +8 -9
- mistralai_gcp/utils/logger.py +16 -0
- mistralai_gcp/utils/retries.py +2 -2
- {mistralai-0.5.5a50.dist-info → mistralai-1.0.0rc2.dist-info}/LICENSE +0 -0
- {mistralai-0.5.5a50.dist-info → mistralai-1.0.0rc2.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
|
-
|
|
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
|
|
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
|
|
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/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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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,
|