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.
- mistralai/agents.py +434 -0
- mistralai/basesdk.py +43 -6
- mistralai/chat.py +29 -34
- mistralai/client.py +1 -1
- mistralai/embeddings.py +4 -4
- mistralai/files.py +10 -10
- mistralai/fim.py +17 -18
- mistralai/fine_tuning.py +10 -849
- mistralai/jobs.py +844 -0
- mistralai/models/__init__.py +6 -4
- 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 +25 -30
- mistralai/models/chatcompletionstreamrequest.py +25 -30
- mistralai/models/completionresponsestreamchoice.py +4 -9
- mistralai/models/delete_model_v1_models_model_id_deleteop.py +2 -0
- mistralai/models/deltamessage.py +7 -12
- mistralai/models/detailedjobout.py +4 -9
- mistralai/models/embeddingrequest.py +12 -17
- mistralai/models/eventout.py +4 -9
- mistralai/models/fileschema.py +4 -9
- mistralai/models/fimcompletionrequest.py +19 -24
- mistralai/models/fimcompletionstreamrequest.py +19 -24
- mistralai/models/ftmodelout.py +4 -9
- mistralai/models/functioncall.py +9 -3
- 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_archive_fine_tuned_modelop.py +2 -0
- mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +1 -59
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +4 -9
- mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +2 -0
- mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +2 -0
- mistralai/models/legacyjobmetadataout.py +4 -9
- mistralai/models/metricout.py +4 -9
- mistralai/models/modelcard.py +4 -9
- mistralai/models/retrieve_model_v1_models_model_id_getop.py +2 -0
- mistralai/models/retrievefileout.py +4 -9
- mistralai/models/security.py +4 -4
- mistralai/models/systemmessage.py +6 -6
- 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/usermessage.py +6 -6
- mistralai/models/validationerror.py +6 -6
- mistralai/models/wandbintegration.py +4 -9
- mistralai/models/wandbintegrationout.py +4 -9
- mistralai/models_.py +24 -24
- 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-1.0.0rc1.dist-info → mistralai-1.0.1.dist-info}/METADATA +153 -69
- {mistralai-1.0.0rc1.dist-info → mistralai-1.0.1.dist-info}/RECORD +114 -107
- mistralai_azure/basesdk.py +42 -4
- mistralai_azure/chat.py +15 -20
- mistralai_azure/models/__init__.py +3 -3
- mistralai_azure/models/assistantmessage.py +4 -9
- mistralai_azure/models/chatcompletionchoice.py +4 -15
- mistralai_azure/models/chatcompletionrequest.py +21 -26
- mistralai_azure/models/chatcompletionstreamrequest.py +21 -26
- mistralai_azure/models/completionresponsestreamchoice.py +4 -9
- mistralai_azure/models/deltamessage.py +7 -12
- mistralai_azure/models/functioncall.py +9 -3
- mistralai_azure/models/httpvalidationerror.py +1 -1
- mistralai_azure/models/systemmessage.py +6 -6
- mistralai_azure/models/toolmessage.py +4 -9
- mistralai_azure/models/usermessage.py +6 -6
- mistralai_azure/models/validationerror.py +6 -6
- 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 +3 -3
- mistralai_gcp/models/assistantmessage.py +4 -9
- mistralai_gcp/models/chatcompletionchoice.py +4 -15
- mistralai_gcp/models/chatcompletionrequest.py +23 -28
- mistralai_gcp/models/chatcompletionstreamrequest.py +23 -28
- mistralai_gcp/models/completionresponsestreamchoice.py +4 -9
- mistralai_gcp/models/deltamessage.py +7 -12
- mistralai_gcp/models/fimcompletionrequest.py +19 -24
- mistralai_gcp/models/fimcompletionstreamrequest.py +19 -24
- mistralai_gcp/models/functioncall.py +9 -3
- mistralai_gcp/models/httpvalidationerror.py +1 -1
- mistralai_gcp/models/systemmessage.py +6 -6
- mistralai_gcp/models/toolmessage.py +4 -9
- mistralai_gcp/models/usermessage.py +6 -6
- mistralai_gcp/models/validationerror.py +6 -6
- 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-1.0.0rc1.dist-info → mistralai-1.0.1.dist-info}/LICENSE +0 -0
- {mistralai-1.0.0rc1.dist-info → mistralai-1.0.1.dist-info}/WHEEL +0 -0
|
@@ -147,15 +147,14 @@ def _parse_event(
|
|
|
147
147
|
data = data[:-1]
|
|
148
148
|
event.data = data
|
|
149
149
|
|
|
150
|
-
|
|
151
|
-
data.isnumeric()
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
or data
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
):
|
|
150
|
+
data_is_primitive = (
|
|
151
|
+
data.isnumeric() or data == "true" or data == "false" or data == "null"
|
|
152
|
+
)
|
|
153
|
+
data_is_json = (
|
|
154
|
+
data.startswith("{") or data.startswith("[") or data.startswith('"')
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
if data_is_primitive or data_is_json:
|
|
159
158
|
try:
|
|
160
159
|
event.data = json.loads(data)
|
|
161
160
|
except Exception:
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
import httpx
|
|
4
|
+
from typing import Any, Protocol
|
|
5
|
+
|
|
6
|
+
class Logger(Protocol):
|
|
7
|
+
def debug(self, msg: str, *args: Any, **kwargs: Any) -> None:
|
|
8
|
+
pass
|
|
9
|
+
|
|
10
|
+
class NoOpLogger:
|
|
11
|
+
def debug(self, msg: str, *args: Any, **kwargs: Any) -> None:
|
|
12
|
+
pass
|
|
13
|
+
|
|
14
|
+
def get_body_content(req: httpx.Request) -> str:
|
|
15
|
+
return "<streaming body>" if not hasattr(req, "_content") else str(req.content)
|
|
16
|
+
|
mistralai/utils/retries.py
CHANGED
|
@@ -76,7 +76,7 @@ def retry(func, retries: Retries):
|
|
|
76
76
|
|
|
77
77
|
status_major = res.status_code / 100
|
|
78
78
|
|
|
79
|
-
if
|
|
79
|
+
if code_range <= status_major < code_range + 1:
|
|
80
80
|
raise TemporaryError(res)
|
|
81
81
|
else:
|
|
82
82
|
parsed_code = int(code)
|
|
@@ -125,7 +125,7 @@ async def retry_async(func, retries: Retries):
|
|
|
125
125
|
|
|
126
126
|
status_major = res.status_code / 100
|
|
127
127
|
|
|
128
|
-
if
|
|
128
|
+
if code_range <= status_major < code_range + 1:
|
|
129
129
|
raise TemporaryError(res)
|
|
130
130
|
else:
|
|
131
131
|
parsed_code = int(code)
|
mistralai/utils/security.py
CHANGED
|
@@ -53,11 +53,14 @@ def get_security(security: Any) -> Tuple[Dict[str, str], Dict[str, List[str]]]:
|
|
|
53
53
|
return headers, query_params
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
def get_security_from_env(security_class: Any) -> Optional[BaseModel]:
|
|
56
|
+
def get_security_from_env(security: Any, security_class: Any) -> Optional[BaseModel]:
|
|
57
|
+
if security is not None:
|
|
58
|
+
return security
|
|
59
|
+
|
|
57
60
|
if not issubclass(security_class, BaseModel):
|
|
58
61
|
raise TypeError("security_class must be a pydantic model class")
|
|
59
62
|
|
|
60
|
-
security_dict = {}
|
|
63
|
+
security_dict: Any = {}
|
|
61
64
|
|
|
62
65
|
if os.getenv("MISTRAL_API_KEY"):
|
|
63
66
|
security_dict["api_key"] = os.getenv("MISTRAL_API_KEY")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mistralai
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.1
|
|
4
4
|
Summary: Python Client SDK for the Mistral AI API.
|
|
5
5
|
Author: Mistral
|
|
6
6
|
Requires-Python: >=3.8,<4.0
|
|
@@ -20,15 +20,26 @@ Requires-Dist: requests (>=2.32.3,<3.0.0) ; extra == "gcp"
|
|
|
20
20
|
Requires-Dist: typing-inspect (>=0.9.0,<0.10.0)
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
|
|
23
|
-
#
|
|
24
|
-
|
|
25
|
-
<div align="left">
|
|
26
|
-
<a href="https://speakeasyapi.dev/"><img src="https://custom-icon-badges.demolab.com/badge/-Built%20By%20Speakeasy-212015?style=for-the-badge&logoColor=FBE331&logo=speakeasy&labelColor=545454" /></a>
|
|
27
|
-
</div>
|
|
23
|
+
# Mistral Python Client
|
|
28
24
|
|
|
29
25
|
## Migration warning
|
|
30
26
|
|
|
31
|
-
This documentation is for
|
|
27
|
+
This documentation is for Mistral AI SDK v1. You can find more details on how to migrate from v0 to v1 [here](MIGRATION.md)
|
|
28
|
+
|
|
29
|
+
## API Key Setup
|
|
30
|
+
|
|
31
|
+
Before you begin, you will need a Mistral AI API key.
|
|
32
|
+
|
|
33
|
+
1. Get your own Mistral API Key: <https://docs.mistral.ai/#api-access>
|
|
34
|
+
2. Set your Mistral API Key as an environment variable. You only need to do this once.
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# set Mistral API Key (using zsh for example)
|
|
38
|
+
$ echo 'export MISTRAL_API_KEY=[your_key_here]' >> ~/.zshenv
|
|
39
|
+
|
|
40
|
+
# reload the environment (or just quit and open a new terminal)
|
|
41
|
+
$ source ~/.zshenv
|
|
42
|
+
```
|
|
32
43
|
|
|
33
44
|
<!-- Start SDK Installation [installation] -->
|
|
34
45
|
## SDK Installation
|
|
@@ -61,12 +72,12 @@ s = Mistral(
|
|
|
61
72
|
)
|
|
62
73
|
|
|
63
74
|
|
|
64
|
-
res = s.chat.
|
|
75
|
+
res = s.chat.complete(model="mistral-small-latest", messages=[
|
|
65
76
|
{
|
|
66
77
|
"content": "Who is the best French painter? Answer in one short sentence.",
|
|
67
78
|
"role": "user",
|
|
68
79
|
},
|
|
69
|
-
]
|
|
80
|
+
])
|
|
70
81
|
|
|
71
82
|
if res is not None:
|
|
72
83
|
# handle response
|
|
@@ -86,12 +97,12 @@ async def main():
|
|
|
86
97
|
s = Mistral(
|
|
87
98
|
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
88
99
|
)
|
|
89
|
-
res = await s.chat.
|
|
100
|
+
res = await s.chat.complete_async(model="mistral-small-latest", messages=[
|
|
90
101
|
{
|
|
91
102
|
"content": "Who is the best French painter? Answer in one short sentence.",
|
|
92
103
|
"role": "user",
|
|
93
104
|
},
|
|
94
|
-
]
|
|
105
|
+
])
|
|
95
106
|
if res is not None:
|
|
96
107
|
# handle response
|
|
97
108
|
pass
|
|
@@ -144,17 +155,78 @@ async def main():
|
|
|
144
155
|
# handle response
|
|
145
156
|
pass
|
|
146
157
|
|
|
158
|
+
asyncio.run(main())
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Create Agents Completions
|
|
162
|
+
|
|
163
|
+
This example shows how to create agents completions.
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
# Synchronous Example
|
|
167
|
+
from mistralai import Mistral
|
|
168
|
+
import os
|
|
169
|
+
|
|
170
|
+
s = Mistral(
|
|
171
|
+
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
res = s.agents.complete(messages=[
|
|
176
|
+
{
|
|
177
|
+
"content": "Who is the best French painter? Answer in one short sentence.",
|
|
178
|
+
"role": "user",
|
|
179
|
+
},
|
|
180
|
+
], agent_id="<value>")
|
|
181
|
+
|
|
182
|
+
if res is not None:
|
|
183
|
+
# handle response
|
|
184
|
+
pass
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
</br>
|
|
188
|
+
|
|
189
|
+
The same SDK client can also be used to make asychronous requests by importing asyncio.
|
|
190
|
+
```python
|
|
191
|
+
# Asynchronous Example
|
|
192
|
+
import asyncio
|
|
193
|
+
from mistralai import Mistral
|
|
194
|
+
import os
|
|
195
|
+
|
|
196
|
+
async def main():
|
|
197
|
+
s = Mistral(
|
|
198
|
+
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
199
|
+
)
|
|
200
|
+
res = await s.agents.complete_async(messages=[
|
|
201
|
+
{
|
|
202
|
+
"content": "Who is the best French painter? Answer in one short sentence.",
|
|
203
|
+
"role": "user",
|
|
204
|
+
},
|
|
205
|
+
], agent_id="<value>")
|
|
206
|
+
if res is not None:
|
|
207
|
+
# handle response
|
|
208
|
+
pass
|
|
209
|
+
|
|
147
210
|
asyncio.run(main())
|
|
148
211
|
```
|
|
149
212
|
<!-- End SDK Example Usage [usage] -->
|
|
150
213
|
|
|
214
|
+
|
|
215
|
+
### More examples
|
|
216
|
+
|
|
217
|
+
You can run the examples in the `examples/` directory using `poetry run` or by entering the virtual environment using `poetry shell`.
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
## Providers' SDKs Example Usage
|
|
221
|
+
|
|
151
222
|
### Azure AI
|
|
152
223
|
|
|
153
224
|
**Prerequisites**
|
|
225
|
+
|
|
154
226
|
Before you begin, ensure you have `AZUREAI_ENDPOINT` and an `AZURE_API_KEY`. To obtain these, you will need to deploy Mistral on Azure AI.
|
|
155
227
|
See [instructions for deploying Mistral on Azure AI here](https://docs.mistral.ai/deployment/cloud/azure/).
|
|
156
228
|
|
|
157
|
-
Here's a basic example to get you started. You can also run [the example in the `examples` directory](/examples/azure
|
|
229
|
+
Here's a basic example to get you started. You can also run [the example in the `examples` directory](/examples/azure).
|
|
158
230
|
|
|
159
231
|
```python
|
|
160
232
|
import asyncio
|
|
@@ -164,33 +236,32 @@ from mistralai_azure import MistralAzure
|
|
|
164
236
|
|
|
165
237
|
client = MistralAzure(
|
|
166
238
|
azure_api_key=os.getenv("AZURE_API_KEY", ""),
|
|
167
|
-
azure_endpoint="
|
|
239
|
+
azure_endpoint=os.getenv("AZURE_ENDPOINT", "")
|
|
168
240
|
)
|
|
169
241
|
|
|
170
242
|
async def main() -> None:
|
|
171
|
-
res = await client.chat.
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
]
|
|
181
|
-
}
|
|
243
|
+
res = await client.chat.complete_async(
|
|
244
|
+
max_tokens= 100,
|
|
245
|
+
temperature= 0.5,
|
|
246
|
+
messages= [
|
|
247
|
+
{
|
|
248
|
+
"content": "Hello there!",
|
|
249
|
+
"role": "user"
|
|
250
|
+
}
|
|
251
|
+
]
|
|
182
252
|
)
|
|
183
253
|
print(res)
|
|
184
254
|
|
|
185
255
|
asyncio.run(main())
|
|
186
256
|
```
|
|
187
|
-
The documentation for the Azure SDK is available [here](
|
|
257
|
+
The documentation for the Azure SDK is available [here](packages/mistralai_azure/README.md).
|
|
188
258
|
|
|
189
259
|
### Google Cloud
|
|
190
260
|
|
|
261
|
+
|
|
191
262
|
**Prerequisites**
|
|
192
263
|
|
|
193
|
-
Before you begin, you will need to create a Google Cloud project and enable the Mistral API. To do this, follow the instructions [here](https://docs.mistral.ai/deployment/cloud/
|
|
264
|
+
Before you begin, you will need to create a Google Cloud project and enable the Mistral API. To do this, follow the instructions [here](https://docs.mistral.ai/deployment/cloud/vertex/).
|
|
194
265
|
|
|
195
266
|
To run this locally you will also need to ensure you are authenticated with Google Cloud. You can do this by running
|
|
196
267
|
|
|
@@ -218,23 +289,21 @@ client = MistralGoogleCloud()
|
|
|
218
289
|
|
|
219
290
|
|
|
220
291
|
async def main() -> None:
|
|
221
|
-
res = await client.chat.
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
]
|
|
230
|
-
}
|
|
292
|
+
res = await client.chat.complete_async(
|
|
293
|
+
model= "mistral-small-2402",
|
|
294
|
+
messages= [
|
|
295
|
+
{
|
|
296
|
+
"content": "Hello there!",
|
|
297
|
+
"role": "user"
|
|
298
|
+
}
|
|
299
|
+
]
|
|
231
300
|
)
|
|
232
301
|
print(res)
|
|
233
302
|
|
|
234
303
|
asyncio.run(main())
|
|
235
304
|
```
|
|
236
305
|
|
|
237
|
-
The documentation for the GCP SDK is available [here](
|
|
306
|
+
The documentation for the GCP SDK is available [here](packages/mistralai_gcp/README.md).
|
|
238
307
|
|
|
239
308
|
|
|
240
309
|
<!-- Start Available Resources and Operations [operations] -->
|
|
@@ -256,24 +325,30 @@ The documentation for the GCP SDK is available [here](/packages/mistralai_gcp/RE
|
|
|
256
325
|
* [retrieve](docs/sdks/files/README.md#retrieve) - Retrieve File
|
|
257
326
|
* [delete](docs/sdks/files/README.md#delete) - Delete File
|
|
258
327
|
|
|
259
|
-
### [fine_tuning](docs/sdks/finetuning/README.md)
|
|
260
328
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
* [
|
|
264
|
-
* [
|
|
265
|
-
* [
|
|
329
|
+
### [fine_tuning.jobs](docs/sdks/jobs/README.md)
|
|
330
|
+
|
|
331
|
+
* [list](docs/sdks/jobs/README.md#list) - Get Fine Tuning Jobs
|
|
332
|
+
* [create](docs/sdks/jobs/README.md#create) - Create Fine Tuning Job
|
|
333
|
+
* [get](docs/sdks/jobs/README.md#get) - Get Fine Tuning Job
|
|
334
|
+
* [cancel](docs/sdks/jobs/README.md#cancel) - Cancel Fine Tuning Job
|
|
335
|
+
* [start](docs/sdks/jobs/README.md#start) - Start Fine Tuning Job
|
|
266
336
|
|
|
267
337
|
### [chat](docs/sdks/chat/README.md)
|
|
268
338
|
|
|
269
|
-
* [
|
|
339
|
+
* [complete](docs/sdks/chat/README.md#complete) - Chat Completion
|
|
270
340
|
* [stream](docs/sdks/chat/README.md#stream) - Stream chat completion
|
|
271
341
|
|
|
272
342
|
### [fim](docs/sdks/fim/README.md)
|
|
273
343
|
|
|
274
|
-
* [
|
|
344
|
+
* [complete](docs/sdks/fim/README.md#complete) - Fim Completion
|
|
275
345
|
* [stream](docs/sdks/fim/README.md#stream) - Stream fim completion
|
|
276
346
|
|
|
347
|
+
### [agents](docs/sdks/agents/README.md)
|
|
348
|
+
|
|
349
|
+
* [complete](docs/sdks/agents/README.md#complete) - Agents Completion
|
|
350
|
+
* [stream](docs/sdks/agents/README.md#stream) - Stream Agents completion
|
|
351
|
+
|
|
277
352
|
### [embeddings](docs/sdks/embeddings/README.md)
|
|
278
353
|
|
|
279
354
|
* [create](docs/sdks/embeddings/README.md#create) - Embeddings
|
|
@@ -297,12 +372,12 @@ s = Mistral(
|
|
|
297
372
|
)
|
|
298
373
|
|
|
299
374
|
|
|
300
|
-
res = s.chat.stream(messages=[
|
|
375
|
+
res = s.chat.stream(model="mistral-small-latest", messages=[
|
|
301
376
|
{
|
|
302
377
|
"content": "Who is the best French painter? Answer in one short sentence.",
|
|
303
378
|
"role": "user",
|
|
304
379
|
},
|
|
305
|
-
]
|
|
380
|
+
])
|
|
306
381
|
|
|
307
382
|
if res is not None:
|
|
308
383
|
for event in res:
|
|
@@ -397,10 +472,10 @@ if res is not None:
|
|
|
397
472
|
|
|
398
473
|
Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an error. If Error objects are specified in your OpenAPI Spec, the SDK will raise the appropriate Error type.
|
|
399
474
|
|
|
400
|
-
| Error Object | Status Code
|
|
401
|
-
| -------------------------- |
|
|
402
|
-
| models.HTTPValidationError | 422
|
|
403
|
-
| models.SDKError | 4xx-5xx
|
|
475
|
+
| Error Object | Status Code | Content Type |
|
|
476
|
+
| -------------------------- | -------------------------- | -------------------------- |
|
|
477
|
+
| models.HTTPValidationError | 422 | application/json |
|
|
478
|
+
| models.SDKError | 4xx-5xx | */* |
|
|
404
479
|
|
|
405
480
|
### Example
|
|
406
481
|
|
|
@@ -437,9 +512,9 @@ if res is not None:
|
|
|
437
512
|
|
|
438
513
|
You can override the default server globally by passing a server name to the `server: str` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the names associated with the available servers:
|
|
439
514
|
|
|
440
|
-
| Name
|
|
441
|
-
|
|
|
442
|
-
| `prod` | `https://api.mistral.ai` | None
|
|
515
|
+
| Name | Server | Variables |
|
|
516
|
+
| ----- | ------ | --------- |
|
|
517
|
+
| `prod` | `https://api.mistral.ai` | None |
|
|
443
518
|
|
|
444
519
|
#### Example
|
|
445
520
|
|
|
@@ -572,9 +647,9 @@ s = Mistral(async_client=CustomClient(httpx.AsyncClient()))
|
|
|
572
647
|
|
|
573
648
|
This SDK supports the following security scheme globally:
|
|
574
649
|
|
|
575
|
-
| Name
|
|
576
|
-
|
|
|
577
|
-
| `api_key`
|
|
650
|
+
| Name | Type | Scheme | Environment Variable |
|
|
651
|
+
| -------------------- | -------------------- | -------------------- | -------------------- |
|
|
652
|
+
| `api_key` | http | HTTP Bearer | `MISTRAL_API_KEY` |
|
|
578
653
|
|
|
579
654
|
To authenticate with the API the `api_key` parameter must be set when initializing the SDK client instance. For example:
|
|
580
655
|
```python
|
|
@@ -594,28 +669,37 @@ if res is not None:
|
|
|
594
669
|
|
|
595
670
|
```
|
|
596
671
|
<!-- End Authentication [security] -->
|
|
597
|
-
## Providers Support
|
|
598
672
|
|
|
599
|
-
|
|
673
|
+
<!-- Start Debugging [debug] -->
|
|
674
|
+
## Debugging
|
|
675
|
+
|
|
676
|
+
To emit debug logs for SDK requests and responses you can pass a logger object directly into your SDK object.
|
|
677
|
+
|
|
678
|
+
```python
|
|
679
|
+
from mistralai import Mistral
|
|
680
|
+
import logging
|
|
600
681
|
|
|
601
|
-
|
|
602
|
-
|
|
682
|
+
logging.basicConfig(level=logging.DEBUG)
|
|
683
|
+
s = Mistral(debug_logger=logging.getLogger("mistralai"))
|
|
684
|
+
```
|
|
685
|
+
<!-- End Debugging [debug] -->
|
|
603
686
|
|
|
687
|
+
<!-- Start IDE Support [idesupport] -->
|
|
688
|
+
## IDE Support
|
|
604
689
|
|
|
605
|
-
|
|
690
|
+
### PyCharm
|
|
606
691
|
|
|
607
|
-
|
|
692
|
+
Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.
|
|
608
693
|
|
|
609
|
-
|
|
694
|
+
- [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/)
|
|
695
|
+
<!-- End IDE Support [idesupport] -->
|
|
610
696
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
697
|
+
<!-- Placeholder for Future Speakeasy SDK Sections -->
|
|
698
|
+
|
|
699
|
+
# Development
|
|
614
700
|
|
|
615
701
|
## Contributions
|
|
616
702
|
|
|
617
703
|
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation.
|
|
618
704
|
We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
|
|
619
705
|
|
|
620
|
-
### SDK Created by [Speakeasy](https://docs.speakeasyapi.dev/docs/using-speakeasy/client-sdks)
|
|
621
|
-
|