mistralai 1.0.3__py3-none-any.whl → 1.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mistralai/__init__.py +4 -0
- mistralai/_hooks/sdkhooks.py +23 -4
- mistralai/_hooks/types.py +27 -9
- mistralai/_version.py +12 -0
- mistralai/agents.py +334 -164
- mistralai/basesdk.py +90 -5
- mistralai/batch.py +17 -0
- mistralai/chat.py +316 -166
- mistralai/classifiers.py +396 -0
- mistralai/embeddings.py +79 -55
- mistralai/files.py +487 -194
- mistralai/fim.py +206 -132
- mistralai/fine_tuning.py +3 -2
- mistralai/jobs.py +392 -263
- mistralai/mistral_jobs.py +733 -0
- mistralai/models/__init__.py +593 -50
- mistralai/models/agentscompletionrequest.py +70 -17
- mistralai/models/agentscompletionstreamrequest.py +72 -17
- mistralai/models/apiendpoint.py +9 -0
- mistralai/models/archiveftmodelout.py +15 -5
- mistralai/models/assistantmessage.py +22 -10
- mistralai/models/{modelcard.py → basemodelcard.py} +53 -14
- mistralai/models/batcherror.py +17 -0
- mistralai/models/batchjobin.py +58 -0
- mistralai/models/batchjobout.py +117 -0
- mistralai/models/batchjobsout.py +30 -0
- mistralai/models/batchjobstatus.py +15 -0
- mistralai/models/chatclassificationrequest.py +104 -0
- mistralai/models/chatcompletionchoice.py +13 -6
- mistralai/models/chatcompletionrequest.py +86 -21
- mistralai/models/chatcompletionresponse.py +8 -4
- mistralai/models/chatcompletionstreamrequest.py +88 -21
- mistralai/models/checkpointout.py +4 -3
- mistralai/models/classificationobject.py +21 -0
- mistralai/models/classificationrequest.py +59 -0
- mistralai/models/classificationresponse.py +21 -0
- mistralai/models/completionchunk.py +12 -5
- mistralai/models/completionevent.py +2 -3
- mistralai/models/completionresponsestreamchoice.py +22 -8
- mistralai/models/contentchunk.py +13 -10
- mistralai/models/delete_model_v1_models_model_id_deleteop.py +5 -5
- mistralai/models/deletefileout.py +4 -3
- mistralai/models/deletemodelout.py +5 -4
- mistralai/models/deltamessage.py +23 -11
- mistralai/models/detailedjobout.py +70 -12
- mistralai/models/embeddingrequest.py +14 -9
- mistralai/models/embeddingresponse.py +7 -3
- mistralai/models/embeddingresponsedata.py +5 -4
- mistralai/models/eventout.py +11 -6
- mistralai/models/filepurpose.py +8 -0
- mistralai/models/files_api_routes_delete_fileop.py +5 -5
- mistralai/models/files_api_routes_download_fileop.py +16 -0
- mistralai/models/files_api_routes_list_filesop.py +96 -0
- mistralai/models/files_api_routes_retrieve_fileop.py +5 -5
- mistralai/models/files_api_routes_upload_fileop.py +33 -14
- mistralai/models/fileschema.py +22 -15
- mistralai/models/fimcompletionrequest.py +44 -16
- mistralai/models/fimcompletionresponse.py +8 -4
- mistralai/models/fimcompletionstreamrequest.py +44 -16
- mistralai/models/finetuneablemodel.py +7 -1
- mistralai/models/ftmodelcapabilitiesout.py +6 -4
- mistralai/models/ftmodelcard.py +121 -0
- mistralai/models/ftmodelout.py +39 -9
- mistralai/models/function.py +5 -4
- mistralai/models/functioncall.py +4 -3
- mistralai/models/functionname.py +17 -0
- mistralai/models/githubrepositoryin.py +24 -7
- mistralai/models/githubrepositoryout.py +24 -7
- mistralai/models/httpvalidationerror.py +1 -3
- mistralai/models/imageurl.py +47 -0
- mistralai/models/imageurlchunk.py +38 -0
- mistralai/models/jobin.py +24 -7
- mistralai/models/jobmetadataout.py +32 -8
- mistralai/models/jobout.py +65 -12
- mistralai/models/jobs_api_routes_batch_cancel_batch_jobop.py +16 -0
- mistralai/models/jobs_api_routes_batch_get_batch_jobop.py +16 -0
- mistralai/models/jobs_api_routes_batch_get_batch_jobsop.py +95 -0
- mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +5 -5
- mistralai/models/jobs_api_routes_fine_tuning_cancel_fine_tuning_jobop.py +5 -5
- mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +3 -2
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobop.py +5 -5
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +85 -18
- mistralai/models/jobs_api_routes_fine_tuning_start_fine_tuning_jobop.py +5 -5
- mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +5 -5
- mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +10 -6
- mistralai/models/jobsout.py +13 -5
- mistralai/models/legacyjobmetadataout.py +55 -9
- mistralai/models/listfilesout.py +7 -3
- mistralai/models/metricout.py +12 -8
- mistralai/models/modelcapabilities.py +9 -4
- mistralai/models/modellist.py +21 -7
- mistralai/models/responseformat.py +7 -8
- mistralai/models/responseformats.py +8 -0
- mistralai/models/retrieve_model_v1_models_model_id_getop.py +25 -6
- mistralai/models/retrievefileout.py +25 -15
- mistralai/models/sampletype.py +6 -2
- mistralai/models/security.py +14 -5
- mistralai/models/source.py +3 -2
- mistralai/models/systemmessage.py +10 -9
- mistralai/models/textchunk.py +14 -5
- mistralai/models/tool.py +10 -9
- mistralai/models/toolcall.py +10 -8
- mistralai/models/toolchoice.py +29 -0
- mistralai/models/toolchoiceenum.py +7 -0
- mistralai/models/toolmessage.py +13 -6
- mistralai/models/tooltypes.py +8 -0
- mistralai/models/trainingfile.py +4 -4
- mistralai/models/trainingparameters.py +34 -8
- mistralai/models/trainingparametersin.py +36 -10
- mistralai/models/unarchiveftmodelout.py +15 -5
- mistralai/models/updateftmodelin.py +9 -6
- mistralai/models/uploadfileout.py +22 -15
- mistralai/models/usageinfo.py +4 -3
- mistralai/models/usermessage.py +42 -10
- mistralai/models/validationerror.py +5 -3
- mistralai/models/wandbintegration.py +23 -7
- mistralai/models/wandbintegrationout.py +23 -8
- mistralai/models_.py +416 -294
- mistralai/sdk.py +31 -19
- mistralai/sdkconfiguration.py +9 -11
- mistralai/utils/__init__.py +14 -1
- mistralai/utils/annotations.py +13 -2
- mistralai/utils/logger.py +4 -1
- mistralai/utils/retries.py +2 -1
- mistralai/utils/security.py +13 -6
- mistralai/utils/serializers.py +25 -0
- {mistralai-1.0.3.dist-info → mistralai-1.2.0.dist-info}/METADATA +171 -66
- mistralai-1.2.0.dist-info/RECORD +276 -0
- {mistralai-1.0.3.dist-info → mistralai-1.2.0.dist-info}/WHEEL +1 -1
- mistralai_azure/__init__.py +4 -0
- mistralai_azure/_hooks/sdkhooks.py +23 -4
- mistralai_azure/_hooks/types.py +27 -9
- mistralai_azure/_version.py +12 -0
- mistralai_azure/basesdk.py +91 -6
- mistralai_azure/chat.py +308 -166
- mistralai_azure/models/__init__.py +164 -16
- mistralai_azure/models/assistantmessage.py +29 -11
- mistralai_azure/models/chatcompletionchoice.py +15 -6
- mistralai_azure/models/chatcompletionrequest.py +94 -22
- mistralai_azure/models/chatcompletionresponse.py +8 -4
- mistralai_azure/models/chatcompletionstreamrequest.py +96 -22
- mistralai_azure/models/completionchunk.py +12 -5
- mistralai_azure/models/completionevent.py +2 -3
- mistralai_azure/models/completionresponsestreamchoice.py +19 -8
- mistralai_azure/models/contentchunk.py +4 -11
- mistralai_azure/models/deltamessage.py +30 -12
- mistralai_azure/models/function.py +5 -4
- mistralai_azure/models/functioncall.py +4 -3
- mistralai_azure/models/functionname.py +17 -0
- mistralai_azure/models/httpvalidationerror.py +1 -3
- mistralai_azure/models/responseformat.py +7 -8
- mistralai_azure/models/responseformats.py +8 -0
- mistralai_azure/models/security.py +13 -5
- mistralai_azure/models/systemmessage.py +10 -9
- mistralai_azure/models/textchunk.py +14 -5
- mistralai_azure/models/tool.py +10 -9
- mistralai_azure/models/toolcall.py +10 -8
- mistralai_azure/models/toolchoice.py +29 -0
- mistralai_azure/models/toolchoiceenum.py +7 -0
- mistralai_azure/models/toolmessage.py +20 -7
- mistralai_azure/models/tooltypes.py +8 -0
- mistralai_azure/models/usageinfo.py +4 -3
- mistralai_azure/models/usermessage.py +42 -10
- mistralai_azure/models/validationerror.py +5 -3
- mistralai_azure/sdkconfiguration.py +9 -11
- mistralai_azure/utils/__init__.py +16 -3
- mistralai_azure/utils/annotations.py +13 -2
- mistralai_azure/utils/forms.py +10 -9
- mistralai_azure/utils/headers.py +8 -8
- mistralai_azure/utils/logger.py +6 -0
- mistralai_azure/utils/queryparams.py +16 -14
- mistralai_azure/utils/retries.py +2 -1
- mistralai_azure/utils/security.py +12 -6
- mistralai_azure/utils/serializers.py +42 -8
- mistralai_azure/utils/url.py +13 -8
- mistralai_azure/utils/values.py +6 -0
- mistralai_gcp/__init__.py +4 -0
- mistralai_gcp/_hooks/sdkhooks.py +23 -4
- mistralai_gcp/_hooks/types.py +27 -9
- mistralai_gcp/_version.py +12 -0
- mistralai_gcp/basesdk.py +91 -6
- mistralai_gcp/chat.py +308 -166
- mistralai_gcp/fim.py +198 -132
- mistralai_gcp/models/__init__.py +186 -18
- mistralai_gcp/models/assistantmessage.py +29 -11
- mistralai_gcp/models/chatcompletionchoice.py +15 -6
- mistralai_gcp/models/chatcompletionrequest.py +91 -22
- mistralai_gcp/models/chatcompletionresponse.py +8 -4
- mistralai_gcp/models/chatcompletionstreamrequest.py +93 -22
- mistralai_gcp/models/completionchunk.py +12 -5
- mistralai_gcp/models/completionevent.py +2 -3
- mistralai_gcp/models/completionresponsestreamchoice.py +19 -8
- mistralai_gcp/models/contentchunk.py +4 -11
- mistralai_gcp/models/deltamessage.py +30 -12
- mistralai_gcp/models/fimcompletionrequest.py +51 -17
- mistralai_gcp/models/fimcompletionresponse.py +8 -4
- mistralai_gcp/models/fimcompletionstreamrequest.py +51 -17
- mistralai_gcp/models/function.py +5 -4
- mistralai_gcp/models/functioncall.py +4 -3
- mistralai_gcp/models/functionname.py +17 -0
- mistralai_gcp/models/httpvalidationerror.py +1 -3
- mistralai_gcp/models/responseformat.py +7 -8
- mistralai_gcp/models/responseformats.py +8 -0
- mistralai_gcp/models/security.py +13 -5
- mistralai_gcp/models/systemmessage.py +10 -9
- mistralai_gcp/models/textchunk.py +14 -5
- mistralai_gcp/models/tool.py +10 -9
- mistralai_gcp/models/toolcall.py +10 -8
- mistralai_gcp/models/toolchoice.py +29 -0
- mistralai_gcp/models/toolchoiceenum.py +7 -0
- mistralai_gcp/models/toolmessage.py +20 -7
- mistralai_gcp/models/tooltypes.py +8 -0
- mistralai_gcp/models/usageinfo.py +4 -3
- mistralai_gcp/models/usermessage.py +42 -10
- mistralai_gcp/models/validationerror.py +5 -3
- mistralai_gcp/sdk.py +6 -7
- mistralai_gcp/sdkconfiguration.py +9 -11
- mistralai_gcp/utils/__init__.py +16 -3
- mistralai_gcp/utils/annotations.py +13 -2
- mistralai_gcp/utils/forms.py +10 -9
- mistralai_gcp/utils/headers.py +8 -8
- mistralai_gcp/utils/logger.py +6 -0
- mistralai_gcp/utils/queryparams.py +16 -14
- mistralai_gcp/utils/retries.py +2 -1
- mistralai_gcp/utils/security.py +12 -6
- mistralai_gcp/utils/serializers.py +42 -8
- mistralai_gcp/utils/url.py +13 -8
- mistralai_gcp/utils/values.py +6 -0
- mistralai-1.0.3.dist-info/RECORD +0 -236
- {mistralai-1.0.3.dist-info → mistralai-1.2.0.dist-info}/LICENSE +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mistralai
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: Python Client SDK for the Mistral AI API.
|
|
5
|
+
Home-page: https://github.com/mistralai/client-python.git
|
|
5
6
|
Author: Mistral
|
|
6
7
|
Requires-Python: >=3.8,<4.0
|
|
7
8
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -10,21 +11,24 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
10
11
|
Classifier: Programming Language :: Python :: 3.10
|
|
11
12
|
Classifier: Programming Language :: Python :: 3.11
|
|
12
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
15
|
Provides-Extra: gcp
|
|
16
|
+
Requires-Dist: eval-type-backport (>=0.2.0,<0.3.0)
|
|
14
17
|
Requires-Dist: google-auth (==2.27.0) ; extra == "gcp"
|
|
15
18
|
Requires-Dist: httpx (>=0.27.0,<0.28.0)
|
|
16
19
|
Requires-Dist: jsonpath-python (>=1.0.6,<2.0.0)
|
|
17
|
-
Requires-Dist: pydantic (>=2.
|
|
18
|
-
Requires-Dist: python-dateutil (
|
|
20
|
+
Requires-Dist: pydantic (>=2.9.0,<3.0.0)
|
|
21
|
+
Requires-Dist: python-dateutil (==2.8.2)
|
|
19
22
|
Requires-Dist: requests (>=2.32.3,<3.0.0) ; extra == "gcp"
|
|
20
23
|
Requires-Dist: typing-inspect (>=0.9.0,<0.10.0)
|
|
24
|
+
Project-URL: Repository, https://github.com/mistralai/client-python.git
|
|
21
25
|
Description-Content-Type: text/markdown
|
|
22
26
|
|
|
23
27
|
# Mistral Python Client
|
|
24
28
|
|
|
25
29
|
## Migration warning
|
|
26
30
|
|
|
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)
|
|
31
|
+
This documentation is for Mistral AI SDK v1. You can find more details on how to migrate from v0 to v1 [here](https://github.com/mistralai/client-python/blob/master/MIGRATION.md)
|
|
28
32
|
|
|
29
33
|
## API Key Setup
|
|
30
34
|
|
|
@@ -41,15 +45,46 @@ $ echo 'export MISTRAL_API_KEY=[your_key_here]' >> ~/.zshenv
|
|
|
41
45
|
$ source ~/.zshenv
|
|
42
46
|
```
|
|
43
47
|
|
|
48
|
+
<!-- Start Summary [summary] -->
|
|
49
|
+
## Summary
|
|
50
|
+
|
|
51
|
+
Mistral AI API: Our Chat Completion and Embeddings APIs specification. Create your account on [La Plateforme](https://console.mistral.ai) to get access and read the [docs](https://docs.mistral.ai) to learn how to use it.
|
|
52
|
+
<!-- End Summary [summary] -->
|
|
53
|
+
|
|
54
|
+
<!-- Start Table of Contents [toc] -->
|
|
55
|
+
## Table of Contents
|
|
56
|
+
|
|
57
|
+
* [SDK Installation](https://github.com/mistralai/client-python/blob/master/#sdk-installation)
|
|
58
|
+
* [IDE Support](https://github.com/mistralai/client-python/blob/master/#ide-support)
|
|
59
|
+
* [SDK Example Usage](https://github.com/mistralai/client-python/blob/master/#sdk-example-usage)
|
|
60
|
+
* [Available Resources and Operations](https://github.com/mistralai/client-python/blob/master/#available-resources-and-operations)
|
|
61
|
+
* [Server-sent event streaming](https://github.com/mistralai/client-python/blob/master/#server-sent-event-streaming)
|
|
62
|
+
* [File uploads](https://github.com/mistralai/client-python/blob/master/#file-uploads)
|
|
63
|
+
* [Retries](https://github.com/mistralai/client-python/blob/master/#retries)
|
|
64
|
+
* [Error Handling](https://github.com/mistralai/client-python/blob/master/#error-handling)
|
|
65
|
+
* [Server Selection](https://github.com/mistralai/client-python/blob/master/#server-selection)
|
|
66
|
+
* [Custom HTTP Client](https://github.com/mistralai/client-python/blob/master/#custom-http-client)
|
|
67
|
+
* [Authentication](https://github.com/mistralai/client-python/blob/master/#authentication)
|
|
68
|
+
* [Debugging](https://github.com/mistralai/client-python/blob/master/#debugging)
|
|
69
|
+
<!-- End Table of Contents [toc] -->
|
|
70
|
+
|
|
44
71
|
<!-- Start SDK Installation [installation] -->
|
|
45
72
|
## SDK Installation
|
|
46
73
|
|
|
47
|
-
|
|
74
|
+
The SDK can be installed with either *pip* or *poetry* package managers.
|
|
75
|
+
|
|
76
|
+
### PIP
|
|
77
|
+
|
|
78
|
+
*PIP* is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.
|
|
79
|
+
|
|
48
80
|
```bash
|
|
49
81
|
pip install mistralai
|
|
50
82
|
```
|
|
51
83
|
|
|
52
|
-
Poetry
|
|
84
|
+
### Poetry
|
|
85
|
+
|
|
86
|
+
*Poetry* is a modern tool that simplifies dependency management and package publishing by using a single `pyproject.toml` file to handle project metadata and dependencies.
|
|
87
|
+
|
|
53
88
|
```bash
|
|
54
89
|
poetry add mistralai
|
|
55
90
|
```
|
|
@@ -71,7 +106,6 @@ s = Mistral(
|
|
|
71
106
|
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
72
107
|
)
|
|
73
108
|
|
|
74
|
-
|
|
75
109
|
res = s.chat.complete(model="mistral-small-latest", messages=[
|
|
76
110
|
{
|
|
77
111
|
"content": "Who is the best French painter? Answer in one short sentence.",
|
|
@@ -123,10 +157,9 @@ s = Mistral(
|
|
|
123
157
|
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
124
158
|
)
|
|
125
159
|
|
|
126
|
-
|
|
127
160
|
res = s.files.upload(file={
|
|
128
|
-
"file_name": "
|
|
129
|
-
"content": open("
|
|
161
|
+
"file_name": "example.file",
|
|
162
|
+
"content": open("example.file", "rb"),
|
|
130
163
|
})
|
|
131
164
|
|
|
132
165
|
if res is not None:
|
|
@@ -148,8 +181,8 @@ async def main():
|
|
|
148
181
|
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
149
182
|
)
|
|
150
183
|
res = await s.files.upload_async(file={
|
|
151
|
-
"file_name": "
|
|
152
|
-
"content": open("
|
|
184
|
+
"file_name": "example.file",
|
|
185
|
+
"content": open("example.file", "rb"),
|
|
153
186
|
})
|
|
154
187
|
if res is not None:
|
|
155
188
|
# handle response
|
|
@@ -171,7 +204,6 @@ s = Mistral(
|
|
|
171
204
|
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
172
205
|
)
|
|
173
206
|
|
|
174
|
-
|
|
175
207
|
res = s.agents.complete(messages=[
|
|
176
208
|
{
|
|
177
209
|
"content": "Who is the best French painter? Answer in one short sentence.",
|
|
@@ -207,6 +239,53 @@ async def main():
|
|
|
207
239
|
# handle response
|
|
208
240
|
pass
|
|
209
241
|
|
|
242
|
+
asyncio.run(main())
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Create Embedding Request
|
|
246
|
+
|
|
247
|
+
This example shows how to create embedding request.
|
|
248
|
+
|
|
249
|
+
```python
|
|
250
|
+
# Synchronous Example
|
|
251
|
+
from mistralai import Mistral
|
|
252
|
+
import os
|
|
253
|
+
|
|
254
|
+
s = Mistral(
|
|
255
|
+
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
res = s.embeddings.create(inputs=[
|
|
259
|
+
"Embed this sentence.",
|
|
260
|
+
"As well as this one.",
|
|
261
|
+
], model="Wrangler")
|
|
262
|
+
|
|
263
|
+
if res is not None:
|
|
264
|
+
# handle response
|
|
265
|
+
pass
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
</br>
|
|
269
|
+
|
|
270
|
+
The same SDK client can also be used to make asychronous requests by importing asyncio.
|
|
271
|
+
```python
|
|
272
|
+
# Asynchronous Example
|
|
273
|
+
import asyncio
|
|
274
|
+
from mistralai import Mistral
|
|
275
|
+
import os
|
|
276
|
+
|
|
277
|
+
async def main():
|
|
278
|
+
s = Mistral(
|
|
279
|
+
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
280
|
+
)
|
|
281
|
+
res = await s.embeddings.create_async(inputs=[
|
|
282
|
+
"Embed this sentence.",
|
|
283
|
+
"As well as this one.",
|
|
284
|
+
], model="Wrangler")
|
|
285
|
+
if res is not None:
|
|
286
|
+
# handle response
|
|
287
|
+
pass
|
|
288
|
+
|
|
210
289
|
asyncio.run(main())
|
|
211
290
|
```
|
|
212
291
|
<!-- End SDK Example Usage [usage] -->
|
|
@@ -226,7 +305,7 @@ You can run the examples in the `examples/` directory using `poetry run` or by e
|
|
|
226
305
|
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.
|
|
227
306
|
See [instructions for deploying Mistral on Azure AI here](https://docs.mistral.ai/deployment/cloud/azure/).
|
|
228
307
|
|
|
229
|
-
Here's a basic example to get you started. You can also run [the example in the `examples` directory](/examples/azure).
|
|
308
|
+
Here's a basic example to get you started. You can also run [the example in the `examples` directory](https://github.com/mistralai/client-python/blob/master//examples/azure).
|
|
230
309
|
|
|
231
310
|
```python
|
|
232
311
|
import asyncio
|
|
@@ -254,7 +333,7 @@ async def main() -> None:
|
|
|
254
333
|
|
|
255
334
|
asyncio.run(main())
|
|
256
335
|
```
|
|
257
|
-
The documentation for the Azure SDK is available [here](packages/mistralai_azure/README.md).
|
|
336
|
+
The documentation for the Azure SDK is available [here](https://github.com/mistralai/client-python/blob/master/packages/mistralai_azure/README.md).
|
|
258
337
|
|
|
259
338
|
### Google Cloud
|
|
260
339
|
|
|
@@ -303,55 +382,79 @@ async def main() -> None:
|
|
|
303
382
|
asyncio.run(main())
|
|
304
383
|
```
|
|
305
384
|
|
|
306
|
-
The documentation for the GCP SDK is available [here](packages/mistralai_gcp/README.md).
|
|
385
|
+
The documentation for the GCP SDK is available [here](https://github.com/mistralai/client-python/blob/master/packages/mistralai_gcp/README.md).
|
|
307
386
|
|
|
308
387
|
|
|
309
388
|
<!-- Start Available Resources and Operations [operations] -->
|
|
310
389
|
## Available Resources and Operations
|
|
311
390
|
|
|
312
|
-
|
|
391
|
+
<details open>
|
|
392
|
+
<summary>Available methods</summary>
|
|
393
|
+
|
|
394
|
+
### [agents](https://github.com/mistralai/client-python/blob/master/docs/sdks/agents/README.md)
|
|
395
|
+
|
|
396
|
+
* [complete](https://github.com/mistralai/client-python/blob/master/docs/sdks/agents/README.md#complete) - Agents Completion
|
|
397
|
+
* [stream](https://github.com/mistralai/client-python/blob/master/docs/sdks/agents/README.md#stream) - Stream Agents completion
|
|
398
|
+
|
|
399
|
+
### [batch](https://github.com/mistralai/client-python/blob/master/docs/sdks/batch/README.md)
|
|
313
400
|
|
|
314
|
-
* [list](docs/sdks/models/README.md#list) - List Models
|
|
315
|
-
* [retrieve](docs/sdks/models/README.md#retrieve) - Retrieve Model
|
|
316
|
-
* [delete](docs/sdks/models/README.md#delete) - Delete Model
|
|
317
|
-
* [update](docs/sdks/models/README.md#update) - Update Fine Tuned Model
|
|
318
|
-
* [archive](docs/sdks/models/README.md#archive) - Archive Fine Tuned Model
|
|
319
|
-
* [unarchive](docs/sdks/models/README.md#unarchive) - Unarchive Fine Tuned Model
|
|
320
401
|
|
|
321
|
-
|
|
402
|
+
#### [batch.jobs](https://github.com/mistralai/client-python/blob/master/docs/sdks/mistraljobs/README.md)
|
|
322
403
|
|
|
323
|
-
* [
|
|
324
|
-
* [
|
|
325
|
-
* [
|
|
326
|
-
* [
|
|
404
|
+
* [list](https://github.com/mistralai/client-python/blob/master/docs/sdks/mistraljobs/README.md#list) - Get Batch Jobs
|
|
405
|
+
* [create](https://github.com/mistralai/client-python/blob/master/docs/sdks/mistraljobs/README.md#create) - Create Batch Job
|
|
406
|
+
* [get](https://github.com/mistralai/client-python/blob/master/docs/sdks/mistraljobs/README.md#get) - Get Batch Job
|
|
407
|
+
* [cancel](https://github.com/mistralai/client-python/blob/master/docs/sdks/mistraljobs/README.md#cancel) - Cancel Batch Job
|
|
327
408
|
|
|
409
|
+
### [chat](https://github.com/mistralai/client-python/blob/master/docs/sdks/chat/README.md)
|
|
328
410
|
|
|
329
|
-
|
|
411
|
+
* [complete](https://github.com/mistralai/client-python/blob/master/docs/sdks/chat/README.md#complete) - Chat Completion
|
|
412
|
+
* [stream](https://github.com/mistralai/client-python/blob/master/docs/sdks/chat/README.md#stream) - Stream chat completion
|
|
330
413
|
|
|
331
|
-
|
|
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
|
|
414
|
+
### [classifiers](https://github.com/mistralai/client-python/blob/master/docs/sdks/classifiers/README.md)
|
|
336
415
|
|
|
337
|
-
|
|
416
|
+
* [moderate](https://github.com/mistralai/client-python/blob/master/docs/sdks/classifiers/README.md#moderate) - Moderations
|
|
417
|
+
* [moderate_chat](https://github.com/mistralai/client-python/blob/master/docs/sdks/classifiers/README.md#moderate_chat) - Moderations Chat
|
|
338
418
|
|
|
339
|
-
|
|
340
|
-
* [stream](docs/sdks/chat/README.md#stream) - Stream chat completion
|
|
419
|
+
### [embeddings](https://github.com/mistralai/client-python/blob/master/docs/sdks/embeddings/README.md)
|
|
341
420
|
|
|
342
|
-
|
|
421
|
+
* [create](https://github.com/mistralai/client-python/blob/master/docs/sdks/embeddings/README.md#create) - Embeddings
|
|
343
422
|
|
|
344
|
-
|
|
345
|
-
* [stream](docs/sdks/fim/README.md#stream) - Stream fim completion
|
|
423
|
+
### [files](https://github.com/mistralai/client-python/blob/master/docs/sdks/files/README.md)
|
|
346
424
|
|
|
347
|
-
|
|
425
|
+
* [upload](https://github.com/mistralai/client-python/blob/master/docs/sdks/files/README.md#upload) - Upload File
|
|
426
|
+
* [list](https://github.com/mistralai/client-python/blob/master/docs/sdks/files/README.md#list) - List Files
|
|
427
|
+
* [retrieve](https://github.com/mistralai/client-python/blob/master/docs/sdks/files/README.md#retrieve) - Retrieve File
|
|
428
|
+
* [delete](https://github.com/mistralai/client-python/blob/master/docs/sdks/files/README.md#delete) - Delete File
|
|
429
|
+
* [download](https://github.com/mistralai/client-python/blob/master/docs/sdks/files/README.md#download) - Download File
|
|
348
430
|
|
|
349
|
-
|
|
350
|
-
* [stream](docs/sdks/agents/README.md#stream) - Stream Agents completion
|
|
431
|
+
### [fim](https://github.com/mistralai/client-python/blob/master/docs/sdks/fim/README.md)
|
|
351
432
|
|
|
352
|
-
|
|
433
|
+
* [complete](https://github.com/mistralai/client-python/blob/master/docs/sdks/fim/README.md#complete) - Fim Completion
|
|
434
|
+
* [stream](https://github.com/mistralai/client-python/blob/master/docs/sdks/fim/README.md#stream) - Stream fim completion
|
|
353
435
|
|
|
354
|
-
|
|
436
|
+
### [fine_tuning](https://github.com/mistralai/client-python/blob/master/docs/sdks/finetuning/README.md)
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
#### [fine_tuning.jobs](https://github.com/mistralai/client-python/blob/master/docs/sdks/jobs/README.md)
|
|
440
|
+
|
|
441
|
+
* [list](https://github.com/mistralai/client-python/blob/master/docs/sdks/jobs/README.md#list) - Get Fine Tuning Jobs
|
|
442
|
+
* [create](https://github.com/mistralai/client-python/blob/master/docs/sdks/jobs/README.md#create) - Create Fine Tuning Job
|
|
443
|
+
* [get](https://github.com/mistralai/client-python/blob/master/docs/sdks/jobs/README.md#get) - Get Fine Tuning Job
|
|
444
|
+
* [cancel](https://github.com/mistralai/client-python/blob/master/docs/sdks/jobs/README.md#cancel) - Cancel Fine Tuning Job
|
|
445
|
+
* [start](https://github.com/mistralai/client-python/blob/master/docs/sdks/jobs/README.md#start) - Start Fine Tuning Job
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
### [models](https://github.com/mistralai/client-python/blob/master/docs/sdks/models/README.md)
|
|
449
|
+
|
|
450
|
+
* [list](https://github.com/mistralai/client-python/blob/master/docs/sdks/models/README.md#list) - List Models
|
|
451
|
+
* [retrieve](https://github.com/mistralai/client-python/blob/master/docs/sdks/models/README.md#retrieve) - Retrieve Model
|
|
452
|
+
* [delete](https://github.com/mistralai/client-python/blob/master/docs/sdks/models/README.md#delete) - Delete Model
|
|
453
|
+
* [update](https://github.com/mistralai/client-python/blob/master/docs/sdks/models/README.md#update) - Update Fine Tuned Model
|
|
454
|
+
* [archive](https://github.com/mistralai/client-python/blob/master/docs/sdks/models/README.md#archive) - Archive Fine Tuned Model
|
|
455
|
+
* [unarchive](https://github.com/mistralai/client-python/blob/master/docs/sdks/models/README.md#unarchive) - Unarchive Fine Tuned Model
|
|
456
|
+
|
|
457
|
+
</details>
|
|
355
458
|
<!-- End Available Resources and Operations [operations] -->
|
|
356
459
|
|
|
357
460
|
<!-- Start Server-sent event streaming [eventstream] -->
|
|
@@ -371,7 +474,6 @@ s = Mistral(
|
|
|
371
474
|
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
372
475
|
)
|
|
373
476
|
|
|
374
|
-
|
|
375
477
|
res = s.chat.stream(model="mistral-small-latest", messages=[
|
|
376
478
|
{
|
|
377
479
|
"content": "Who is the best French painter? Answer in one short sentence.",
|
|
@@ -408,10 +510,9 @@ s = Mistral(
|
|
|
408
510
|
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
409
511
|
)
|
|
410
512
|
|
|
411
|
-
|
|
412
513
|
res = s.files.upload(file={
|
|
413
|
-
"file_name": "
|
|
414
|
-
"content": open("
|
|
514
|
+
"file_name": "example.file",
|
|
515
|
+
"content": open("example.file", "rb"),
|
|
415
516
|
})
|
|
416
517
|
|
|
417
518
|
if res is not None:
|
|
@@ -436,7 +537,6 @@ s = Mistral(
|
|
|
436
537
|
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
437
538
|
)
|
|
438
539
|
|
|
439
|
-
|
|
440
540
|
res = s.models.list(,
|
|
441
541
|
RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
|
|
442
542
|
|
|
@@ -457,7 +557,6 @@ s = Mistral(
|
|
|
457
557
|
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
458
558
|
)
|
|
459
559
|
|
|
460
|
-
|
|
461
560
|
res = s.models.list()
|
|
462
561
|
|
|
463
562
|
if res is not None:
|
|
@@ -470,12 +569,23 @@ if res is not None:
|
|
|
470
569
|
<!-- Start Error Handling [errors] -->
|
|
471
570
|
## Error Handling
|
|
472
571
|
|
|
473
|
-
Handling errors in this SDK should largely match your expectations.
|
|
572
|
+
Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception.
|
|
573
|
+
|
|
574
|
+
By default, an API error will raise a models.SDKError exception, which has the following properties:
|
|
575
|
+
|
|
576
|
+
| Property | Type | Description |
|
|
577
|
+
|-----------------|------------------|-----------------------|
|
|
578
|
+
| `.status_code` | *int* | The HTTP status code |
|
|
579
|
+
| `.message` | *str* | The error message |
|
|
580
|
+
| `.raw_response` | *httpx.Response* | The raw HTTP response |
|
|
581
|
+
| `.body` | *str* | The response content |
|
|
582
|
+
|
|
583
|
+
When custom error responses are specified for an operation, the SDK may also raise their associated exceptions. You can refer to respective *Errors* tables in SDK docs for more details on possible exception types for each operation. For example, the `list_async` method may raise the following exceptions:
|
|
474
584
|
|
|
475
|
-
| Error
|
|
585
|
+
| Error Type | Status Code | Content Type |
|
|
476
586
|
| -------------------------- | -------------------------- | -------------------------- |
|
|
477
587
|
| models.HTTPValidationError | 422 | application/json |
|
|
478
|
-
| models.SDKError |
|
|
588
|
+
| models.SDKError | 4XX, 5XX | \*/\* |
|
|
479
589
|
|
|
480
590
|
### Example
|
|
481
591
|
|
|
@@ -491,17 +601,16 @@ res = None
|
|
|
491
601
|
try:
|
|
492
602
|
res = s.models.list()
|
|
493
603
|
|
|
604
|
+
if res is not None:
|
|
605
|
+
# handle response
|
|
606
|
+
pass
|
|
607
|
+
|
|
494
608
|
except models.HTTPValidationError as e:
|
|
495
|
-
# handle
|
|
609
|
+
# handle e.data: models.HTTPValidationErrorData
|
|
496
610
|
raise(e)
|
|
497
611
|
except models.SDKError as e:
|
|
498
612
|
# handle exception
|
|
499
613
|
raise(e)
|
|
500
|
-
|
|
501
|
-
if res is not None:
|
|
502
|
-
# handle response
|
|
503
|
-
pass
|
|
504
|
-
|
|
505
614
|
```
|
|
506
615
|
<!-- End Error Handling [errors] -->
|
|
507
616
|
|
|
@@ -514,7 +623,7 @@ You can override the default server globally by passing a server name to the `se
|
|
|
514
623
|
|
|
515
624
|
| Name | Server | Variables |
|
|
516
625
|
| ----- | ------ | --------- |
|
|
517
|
-
| `
|
|
626
|
+
| `eu` | `https://api.mistral.ai` | None |
|
|
518
627
|
|
|
519
628
|
#### Example
|
|
520
629
|
|
|
@@ -523,11 +632,10 @@ from mistralai import Mistral
|
|
|
523
632
|
import os
|
|
524
633
|
|
|
525
634
|
s = Mistral(
|
|
526
|
-
server="
|
|
635
|
+
server="eu",
|
|
527
636
|
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
528
637
|
)
|
|
529
638
|
|
|
530
|
-
|
|
531
639
|
res = s.models.list()
|
|
532
640
|
|
|
533
641
|
if res is not None:
|
|
@@ -549,7 +657,6 @@ s = Mistral(
|
|
|
549
657
|
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
550
658
|
)
|
|
551
659
|
|
|
552
|
-
|
|
553
660
|
res = s.models.list()
|
|
554
661
|
|
|
555
662
|
if res is not None:
|
|
@@ -660,7 +767,6 @@ s = Mistral(
|
|
|
660
767
|
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
661
768
|
)
|
|
662
769
|
|
|
663
|
-
|
|
664
770
|
res = s.models.list()
|
|
665
771
|
|
|
666
772
|
if res is not None:
|
|
@@ -705,4 +811,3 @@ Generally, the SDK will work well with most IDEs out of the box. However, when u
|
|
|
705
811
|
|
|
706
812
|
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.
|
|
707
813
|
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.
|
|
708
|
-
|