mistralai 0.5.5a50__py3-none-any.whl → 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. mistralai/agents.py +434 -0
  2. mistralai/basesdk.py +43 -6
  3. mistralai/chat.py +29 -34
  4. mistralai/client.py +1 -1
  5. mistralai/embeddings.py +4 -4
  6. mistralai/files.py +10 -10
  7. mistralai/fim.py +17 -18
  8. mistralai/fine_tuning.py +10 -849
  9. mistralai/jobs.py +844 -0
  10. mistralai/models/__init__.py +6 -4
  11. mistralai/models/agentscompletionrequest.py +96 -0
  12. mistralai/models/agentscompletionstreamrequest.py +92 -0
  13. mistralai/models/assistantmessage.py +4 -9
  14. mistralai/models/chatcompletionchoice.py +4 -15
  15. mistralai/models/chatcompletionrequest.py +11 -16
  16. mistralai/models/chatcompletionstreamrequest.py +11 -16
  17. mistralai/models/completionresponsestreamchoice.py +4 -9
  18. mistralai/models/delete_model_v1_models_model_id_deleteop.py +2 -0
  19. mistralai/models/deltamessage.py +4 -9
  20. mistralai/models/detailedjobout.py +4 -9
  21. mistralai/models/embeddingrequest.py +4 -9
  22. mistralai/models/eventout.py +4 -9
  23. mistralai/models/fileschema.py +4 -9
  24. mistralai/models/fimcompletionrequest.py +11 -16
  25. mistralai/models/fimcompletionstreamrequest.py +11 -16
  26. mistralai/models/ftmodelout.py +4 -9
  27. mistralai/models/functioncall.py +9 -3
  28. mistralai/models/githubrepositoryin.py +4 -9
  29. mistralai/models/githubrepositoryout.py +4 -9
  30. mistralai/models/httpvalidationerror.py +1 -1
  31. mistralai/models/jobin.py +4 -9
  32. mistralai/models/jobmetadataout.py +4 -9
  33. mistralai/models/jobout.py +4 -9
  34. mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +2 -0
  35. mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +1 -59
  36. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +4 -9
  37. mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +2 -0
  38. mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +2 -0
  39. mistralai/models/legacyjobmetadataout.py +4 -9
  40. mistralai/models/metricout.py +4 -9
  41. mistralai/models/modelcard.py +4 -9
  42. mistralai/models/retrieve_model_v1_models_model_id_getop.py +2 -0
  43. mistralai/models/retrievefileout.py +4 -9
  44. mistralai/models/security.py +4 -4
  45. mistralai/models/toolmessage.py +4 -9
  46. mistralai/models/trainingparameters.py +4 -9
  47. mistralai/models/trainingparametersin.py +4 -9
  48. mistralai/models/updateftmodelin.py +4 -9
  49. mistralai/models/uploadfileout.py +4 -9
  50. mistralai/models/wandbintegration.py +4 -9
  51. mistralai/models/wandbintegrationout.py +4 -9
  52. mistralai/models_.py +24 -24
  53. mistralai/sdk.py +14 -6
  54. mistralai/sdkconfiguration.py +5 -4
  55. mistralai/types/basemodel.py +10 -6
  56. mistralai/utils/__init__.py +4 -0
  57. mistralai/utils/eventstreaming.py +8 -9
  58. mistralai/utils/logger.py +16 -0
  59. mistralai/utils/retries.py +2 -2
  60. mistralai/utils/security.py +5 -2
  61. {mistralai-0.5.5a50.dist-info → mistralai-1.0.0.dist-info}/METADATA +136 -67
  62. {mistralai-0.5.5a50.dist-info → mistralai-1.0.0.dist-info}/RECORD +105 -98
  63. mistralai_azure/basesdk.py +42 -4
  64. mistralai_azure/chat.py +15 -20
  65. mistralai_azure/models/__init__.py +3 -3
  66. mistralai_azure/models/assistantmessage.py +4 -9
  67. mistralai_azure/models/chatcompletionchoice.py +4 -15
  68. mistralai_azure/models/chatcompletionrequest.py +7 -12
  69. mistralai_azure/models/chatcompletionstreamrequest.py +7 -12
  70. mistralai_azure/models/completionresponsestreamchoice.py +4 -9
  71. mistralai_azure/models/deltamessage.py +4 -9
  72. mistralai_azure/models/functioncall.py +9 -3
  73. mistralai_azure/models/httpvalidationerror.py +1 -1
  74. mistralai_azure/models/toolmessage.py +4 -9
  75. mistralai_azure/sdk.py +7 -2
  76. mistralai_azure/sdkconfiguration.py +5 -4
  77. mistralai_azure/types/basemodel.py +10 -6
  78. mistralai_azure/utils/__init__.py +4 -0
  79. mistralai_azure/utils/eventstreaming.py +8 -9
  80. mistralai_azure/utils/logger.py +16 -0
  81. mistralai_azure/utils/retries.py +2 -2
  82. mistralai_gcp/basesdk.py +42 -4
  83. mistralai_gcp/chat.py +12 -17
  84. mistralai_gcp/fim.py +12 -13
  85. mistralai_gcp/models/__init__.py +3 -3
  86. mistralai_gcp/models/assistantmessage.py +4 -9
  87. mistralai_gcp/models/chatcompletionchoice.py +4 -15
  88. mistralai_gcp/models/chatcompletionrequest.py +9 -14
  89. mistralai_gcp/models/chatcompletionstreamrequest.py +9 -14
  90. mistralai_gcp/models/completionresponsestreamchoice.py +4 -9
  91. mistralai_gcp/models/deltamessage.py +4 -9
  92. mistralai_gcp/models/fimcompletionrequest.py +11 -16
  93. mistralai_gcp/models/fimcompletionstreamrequest.py +11 -16
  94. mistralai_gcp/models/functioncall.py +9 -3
  95. mistralai_gcp/models/httpvalidationerror.py +1 -1
  96. mistralai_gcp/models/toolmessage.py +4 -9
  97. mistralai_gcp/sdk.py +9 -0
  98. mistralai_gcp/sdkconfiguration.py +5 -4
  99. mistralai_gcp/types/basemodel.py +10 -6
  100. mistralai_gcp/utils/__init__.py +4 -0
  101. mistralai_gcp/utils/eventstreaming.py +8 -9
  102. mistralai_gcp/utils/logger.py +16 -0
  103. mistralai_gcp/utils/retries.py +2 -2
  104. {mistralai-0.5.5a50.dist-info → mistralai-1.0.0.dist-info}/LICENSE +0 -0
  105. {mistralai-0.5.5a50.dist-info → mistralai-1.0.0.dist-info}/WHEEL +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mistralai
3
- Version: 0.5.5a50
3
+ Version: 1.0.0
4
4
  Summary: Python Client SDK for the Mistral AI API.
5
5
  Author: Mistral
6
6
  Requires-Python: >=3.8,<4.0
@@ -20,16 +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
- # mistralai
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
- TODO: provide more details
32
- This documentation is for Mistralai SDK v1. You can find more details on how to migrate from v0 to v1 [here](MIGRATION.md)
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
+ ```
33
43
 
34
44
  <!-- Start SDK Installation [installation] -->
35
45
  ## SDK Installation
@@ -62,12 +72,12 @@ s = Mistral(
62
72
  )
63
73
 
64
74
 
65
- res = s.chat.create(messages=[
75
+ res = s.chat.complete(model="mistral-small-latest", messages=[
66
76
  {
67
77
  "content": "Who is the best French painter? Answer in one short sentence.",
68
78
  "role": "user",
69
79
  },
70
- ], model="mistral-small-latest")
80
+ ])
71
81
 
72
82
  if res is not None:
73
83
  # handle response
@@ -87,12 +97,12 @@ async def main():
87
97
  s = Mistral(
88
98
  api_key=os.getenv("MISTRAL_API_KEY", ""),
89
99
  )
90
- res = await s.chat.create_async(messages=[
100
+ res = await s.chat.complete_async(model="mistral-small-latest", messages=[
91
101
  {
92
102
  "content": "Who is the best French painter? Answer in one short sentence.",
93
103
  "role": "user",
94
104
  },
95
- ], model="mistral-small-latest")
105
+ ])
96
106
  if res is not None:
97
107
  # handle response
98
108
  pass
@@ -145,19 +155,78 @@ async def main():
145
155
  # handle response
146
156
  pass
147
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
+
148
210
  asyncio.run(main())
149
211
  ```
150
212
  <!-- End SDK Example Usage [usage] -->
151
213
 
152
- ### Azure AI
153
214
 
154
- TODO ADJUST LINKS
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
+
222
+ ### Azure AI
155
223
 
156
224
  **Prerequisites**
225
+
157
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.
158
227
  See [instructions for deploying Mistral on Azure AI here](https://docs.mistral.ai/deployment/cloud/azure/).
159
228
 
160
- Here's a basic example to get you started. You can also run [the example in the `examples` directory](/examples/azure.py).
229
+ Here's a basic example to get you started. You can also run [the example in the `examples` directory](/examples/azure).
161
230
 
162
231
  ```python
163
232
  import asyncio
@@ -167,35 +236,32 @@ from mistralai_azure import MistralAzure
167
236
 
168
237
  client = MistralAzure(
169
238
  azure_api_key=os.getenv("AZURE_API_KEY", ""),
170
- azure_endpoint="your_azure_endpoint"
239
+ azure_endpoint=os.getenv("AZURE_ENDPOINT", "")
171
240
  )
172
241
 
173
242
  async def main() -> None:
174
- res = await client.chat.create_async(
175
- request={
176
- "max_tokens": 100,
177
- "temperature": 0.5,
178
- "messages": [
179
- {
180
- "content": "Hello there!",
181
- "role": "user"
182
- }
183
- ]
184
- }
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
+ ]
185
252
  )
186
253
  print(res)
187
254
 
188
255
  asyncio.run(main())
189
256
  ```
190
- The documentation for the Azure SDK is available [GCP](packages/mistralai-azure/README.md).
257
+ The documentation for the Azure SDK is available [here](packages/mistralai_azure/README.md).
191
258
 
192
259
  ### Google Cloud
193
260
 
194
- TODO ADJUST LINKS
195
261
 
196
262
  **Prerequisites**
197
263
 
198
- 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/google/).
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/).
199
265
 
200
266
  To run this locally you will also need to ensure you are authenticated with Google Cloud. You can do this by running
201
267
 
@@ -223,23 +289,21 @@ client = MistralGoogleCloud()
223
289
 
224
290
 
225
291
  async def main() -> None:
226
- res = await client.chat.create_async(
227
- request={
228
- "model": "mistral-small-2402",
229
- "messages": [
230
- {
231
- "content": "Hello there!",
232
- "role": "user"
233
- }
234
- ]
235
- }
292
+ res = await client.chat.complete_async(
293
+ model= "mistral-small-2402",
294
+ messages= [
295
+ {
296
+ "content": "Hello there!",
297
+ "role": "user"
298
+ }
299
+ ]
236
300
  )
237
301
  print(res)
238
302
 
239
303
  asyncio.run(main())
240
304
  ```
241
305
 
242
- The documentation for the GCP SDK is available [GCP](packages/mistralai_gcp/README.md).
306
+ The documentation for the GCP SDK is available [here](packages/mistralai_gcp/README.md).
243
307
 
244
308
 
245
309
  <!-- Start Available Resources and Operations [operations] -->
@@ -261,24 +325,30 @@ The documentation for the GCP SDK is available [GCP](packages/mistralai_gcp/READ
261
325
  * [retrieve](docs/sdks/files/README.md#retrieve) - Retrieve File
262
326
  * [delete](docs/sdks/files/README.md#delete) - Delete File
263
327
 
264
- ### [fine_tuning](docs/sdks/finetuning/README.md)
265
328
 
266
- * [list_jobs](docs/sdks/finetuning/README.md#list_jobs) - Get Fine Tuning Jobs
267
- * [create_job](docs/sdks/finetuning/README.md#create_job) - Create Fine Tuning Job
268
- * [get_job](docs/sdks/finetuning/README.md#get_job) - Get Fine Tuning Job
269
- * [cancel_job](docs/sdks/finetuning/README.md#cancel_job) - Cancel Fine Tuning Job
270
- * [start_job](docs/sdks/finetuning/README.md#start_job) - Start Fine Tuning Job
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
271
336
 
272
337
  ### [chat](docs/sdks/chat/README.md)
273
338
 
274
- * [create](docs/sdks/chat/README.md#create) - Chat Completion
339
+ * [complete](docs/sdks/chat/README.md#complete) - Chat Completion
275
340
  * [stream](docs/sdks/chat/README.md#stream) - Stream chat completion
276
341
 
277
342
  ### [fim](docs/sdks/fim/README.md)
278
343
 
279
- * [create](docs/sdks/fim/README.md#create) - Fim Completion
344
+ * [complete](docs/sdks/fim/README.md#complete) - Fim Completion
280
345
  * [stream](docs/sdks/fim/README.md#stream) - Stream fim completion
281
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
+
282
352
  ### [embeddings](docs/sdks/embeddings/README.md)
283
353
 
284
354
  * [create](docs/sdks/embeddings/README.md#create) - Embeddings
@@ -302,12 +372,12 @@ s = Mistral(
302
372
  )
303
373
 
304
374
 
305
- res = s.chat.stream(messages=[
375
+ res = s.chat.stream(model="mistral-small-latest", messages=[
306
376
  {
307
377
  "content": "Who is the best French painter? Answer in one short sentence.",
308
378
  "role": "user",
309
379
  },
310
- ], model="mistral-small-latest")
380
+ ])
311
381
 
312
382
  if res is not None:
313
383
  for event in res:
@@ -577,11 +647,11 @@ s = Mistral(async_client=CustomClient(httpx.AsyncClient()))
577
647
 
578
648
  This SDK supports the following security scheme globally:
579
649
 
580
- | Name | Type | Scheme |
581
- | ----------- | ----------- | ----------- |
582
- | `api_key` | http | HTTP Bearer |
650
+ | Name | Type | Scheme | Environment Variable |
651
+ | -------------------- | -------------------- | -------------------- | -------------------- |
652
+ | `api_key` | http | HTTP Bearer | `MISTRAL_API_KEY` |
583
653
 
584
- To authenticate with the API the `api_key` parameter must be set when initializing the SDK client instance. For example:
654
+ To authenticate with the API the `null` parameter must be set when initializing the SDK client instance. For example:
585
655
  ```python
586
656
  from mistralai import Mistral
587
657
  import os
@@ -599,28 +669,27 @@ if res is not None:
599
669
 
600
670
  ```
601
671
  <!-- End Authentication [security] -->
602
- ## Providers Support
603
672
 
604
- We also provide provider specific SDK for:
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.
605
677
 
606
- - [GCP](packages/mistralai_gcp/README.md)
607
- - [Azure](packages/mistralai_azure/README.md)
678
+ ```python
679
+ from mistralai import Mistral
680
+ import logging
608
681
 
682
+ logging.basicConfig(level=logging.DEBUG)
683
+ s = Mistral(debug_logger=logging.getLogger("mistralai"))
684
+ ```
685
+ <!-- End Debugging [debug] -->
609
686
 
610
687
  <!-- Placeholder for Future Speakeasy SDK Sections -->
611
688
 
612
689
  # Development
613
690
 
614
- ## Maturity
615
-
616
- This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
617
- to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally
618
- looking for the latest version.
619
-
620
691
  ## Contributions
621
692
 
622
693
  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.
623
694
  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.
624
695
 
625
- ### SDK Created by [Speakeasy](https://docs.speakeasyapi.dev/docs/using-speakeasy/client-sdks)
626
-