Skip to content

Commit 290e1bf

Browse files
authored
[API-47] Images support and other updates (#144)
* fix gcp * spec update * generation with new version * add image example * fix typo * use correct method * fix typo * fix message role
1 parent c3b2f84 commit 290e1bf

File tree

273 files changed

+7638
-3444
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

273 files changed

+7638
-3444
lines changed

.speakeasy/gen.lock

Lines changed: 413 additions & 241 deletions
Large diffs are not rendered by default.

.speakeasy/gen.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ generation:
1212
auth:
1313
oAuth2ClientCredentialsEnabled: true
1414
python:
15-
version: 1.0.3
15+
version: 1.1.1
1616
additionalDependencies:
1717
dev:
1818
pytest: ^8.2.2

.speakeasy/workflow.lock

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,39 @@
1-
speakeasyVersion: 1.382.0
1+
speakeasyVersion: 1.396.7
22
sources:
33
mistral-azure-source:
44
sourceNamespace: mistral-openapi-azure
5-
sourceRevisionDigest: sha256:becb324b11dfc5155aa0cc420ca312d0af5aecfcbad22fe90066a09561ae4e6a
6-
sourceBlobDigest: sha256:84928a6297c3a838dce719ffa3da1e221cba968ce4a6c74d5c3bb41bf86a7e5d
5+
sourceRevisionDigest: sha256:4e9539e6903e630aa69e48af190a24d3702f6038c7b7a92472c7942597c2a6f5
6+
sourceBlobDigest: sha256:3ace0709471c04a040c9763097fef0081d6c21a1be0b694dfe5991c045b76d18
77
tags:
88
- latest
99
mistral-google-cloud-source:
1010
sourceNamespace: mistral-openapi-google-cloud
11-
sourceRevisionDigest: sha256:7fee22ae1a434b8919112c7feae87af7f1378952fcc6bde081deb55f65e5bfc2
12-
sourceBlobDigest: sha256:a4c011f461c73809a7d6cf1c9823d3c51d5050895aad246287ff14ac971efb8c
11+
sourceRevisionDigest: sha256:3047ad3ff8797fded89618b375d1398d48924a3a5f9ea1000c4284a110567c43
12+
sourceBlobDigest: sha256:02bbcef310f965d7ad089fb46d57b39f45b47cbc8f5cf90f728db03e960bdbca
1313
tags:
1414
- latest
1515
mistral-openapi:
1616
sourceNamespace: mistral-openapi
17-
sourceRevisionDigest: sha256:421a4bd55fd50ba00d6ebf2db603888009e9996b642b0499110c223fd6ca21c2
18-
sourceBlobDigest: sha256:1c87b4b8287f6a3083167c13ab59c5e7ac180ab7e19ad1532f3f46495cc12a26
17+
sourceRevisionDigest: sha256:8e2d62b2242960d958406ba266eda41a013c1459dbac67195f8e2662c04cd05f
18+
sourceBlobDigest: sha256:9fbff48fe087e3b2f950b1cfa52b6a25143982741dc7e6750dd14d9c5bed4041
1919
tags:
2020
- latest
21-
- main
2221
targets:
2322
mistralai-azure-sdk:
2423
source: mistral-azure-source
2524
sourceNamespace: mistral-openapi-azure
26-
sourceRevisionDigest: sha256:becb324b11dfc5155aa0cc420ca312d0af5aecfcbad22fe90066a09561ae4e6a
27-
sourceBlobDigest: sha256:84928a6297c3a838dce719ffa3da1e221cba968ce4a6c74d5c3bb41bf86a7e5d
28-
outLocation: ./packages/mistralai_azure
25+
sourceRevisionDigest: sha256:4e9539e6903e630aa69e48af190a24d3702f6038c7b7a92472c7942597c2a6f5
26+
sourceBlobDigest: sha256:3ace0709471c04a040c9763097fef0081d6c21a1be0b694dfe5991c045b76d18
2927
mistralai-gcp-sdk:
3028
source: mistral-google-cloud-source
3129
sourceNamespace: mistral-openapi-google-cloud
32-
sourceRevisionDigest: sha256:7fee22ae1a434b8919112c7feae87af7f1378952fcc6bde081deb55f65e5bfc2
33-
sourceBlobDigest: sha256:a4c011f461c73809a7d6cf1c9823d3c51d5050895aad246287ff14ac971efb8c
34-
outLocation: ./packages/mistralai_gcp
30+
sourceRevisionDigest: sha256:3047ad3ff8797fded89618b375d1398d48924a3a5f9ea1000c4284a110567c43
31+
sourceBlobDigest: sha256:02bbcef310f965d7ad089fb46d57b39f45b47cbc8f5cf90f728db03e960bdbca
3532
mistralai-sdk:
3633
source: mistral-openapi
3734
sourceNamespace: mistral-openapi
38-
sourceRevisionDigest: sha256:421a4bd55fd50ba00d6ebf2db603888009e9996b642b0499110c223fd6ca21c2
39-
sourceBlobDigest: sha256:1c87b4b8287f6a3083167c13ab59c5e7ac180ab7e19ad1532f3f46495cc12a26
40-
outLocation: /github/workspace/repo
35+
sourceRevisionDigest: sha256:8e2d62b2242960d958406ba266eda41a013c1459dbac67195f8e2662c04cd05f
36+
sourceBlobDigest: sha256:9fbff48fe087e3b2f950b1cfa52b6a25143982741dc7e6750dd14d9c5bed4041
4137
workflow:
4238
workflowVersion: 1.0.0
4339
speakeasyVersion: latest

MIGRATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ async def main():
229229
# content="What is the best French cheese?",
230230
# ),
231231
# ]
232-
async_response = await client.chat.completstream_asynce_async(
232+
async_response = await client.chat.stream_async(
233233
messages=messages,
234234
model="mistral-large-latest",
235235
)

README.md

Lines changed: 76 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,46 @@ $ echo 'export MISTRAL_API_KEY=[your_key_here]' >> ~/.zshenv
1919
$ source ~/.zshenv
2020
```
2121

22+
<!-- Start Summary [summary] -->
23+
## Summary
24+
25+
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.
26+
<!-- End Summary [summary] -->
27+
28+
<!-- Start Table of Contents [toc] -->
29+
## Table of Contents
30+
31+
* [SDK Installation](#sdk-installation)
32+
* [IDE Support](#ide-support)
33+
* [SDK Example Usage](#sdk-example-usage)
34+
* [Available Resources and Operations](#available-resources-and-operations)
35+
* [Server-sent event streaming](#server-sent-event-streaming)
36+
* [File uploads](#file-uploads)
37+
* [Retries](#retries)
38+
* [Error Handling](#error-handling)
39+
* [Server Selection](#server-selection)
40+
* [Custom HTTP Client](#custom-http-client)
41+
* [Authentication](#authentication)
42+
* [Debugging](#debugging)
43+
<!-- End Table of Contents [toc] -->
44+
2245
<!-- Start SDK Installation [installation] -->
2346
## SDK Installation
2447

25-
PIP
48+
The SDK can be installed with either *pip* or *poetry* package managers.
49+
50+
### PIP
51+
52+
*PIP* is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.
53+
2654
```bash
2755
pip install mistralai
2856
```
2957

30-
Poetry
58+
### Poetry
59+
60+
*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.
61+
3162
```bash
3263
poetry add mistralai
3364
```
@@ -49,7 +80,6 @@ s = Mistral(
4980
api_key=os.getenv("MISTRAL_API_KEY", ""),
5081
)
5182

52-
5383
res = s.chat.complete(model="mistral-small-latest", messages=[
5484
{
5585
"content": "Who is the best French painter? Answer in one short sentence.",
@@ -101,10 +131,9 @@ s = Mistral(
101131
api_key=os.getenv("MISTRAL_API_KEY", ""),
102132
)
103133

104-
105134
res = s.files.upload(file={
106-
"file_name": "your_file_here",
107-
"content": open("<file_path>", "rb"),
135+
"file_name": "example.file",
136+
"content": open("example.file", "rb"),
108137
})
109138

110139
if res is not None:
@@ -126,8 +155,8 @@ async def main():
126155
api_key=os.getenv("MISTRAL_API_KEY", ""),
127156
)
128157
res = await s.files.upload_async(file={
129-
"file_name": "your_file_here",
130-
"content": open("<file_path>", "rb"),
158+
"file_name": "example.file",
159+
"content": open("example.file", "rb"),
131160
})
132161
if res is not None:
133162
# handle response
@@ -149,11 +178,9 @@ s = Mistral(
149178
api_key=os.getenv("MISTRAL_API_KEY", ""),
150179
)
151180

152-
153181
res = s.agents.complete(messages=[
154182
{
155-
"content": "Who is the best French painter? Answer in one short sentence.",
156-
"role": "user",
183+
"content": "<value>",
157184
},
158185
], agent_id="<value>")
159186

@@ -287,14 +314,22 @@ The documentation for the GCP SDK is available [here](packages/mistralai_gcp/REA
287314
<!-- Start Available Resources and Operations [operations] -->
288315
## Available Resources and Operations
289316

290-
### [models](docs/sdks/models/README.md)
317+
<details open>
318+
<summary>Available methods</summary>
291319

292-
* [list](docs/sdks/models/README.md#list) - List Models
293-
* [retrieve](docs/sdks/models/README.md#retrieve) - Retrieve Model
294-
* [delete](docs/sdks/models/README.md#delete) - Delete Model
295-
* [update](docs/sdks/models/README.md#update) - Update Fine Tuned Model
296-
* [archive](docs/sdks/models/README.md#archive) - Archive Fine Tuned Model
297-
* [unarchive](docs/sdks/models/README.md#unarchive) - Unarchive Fine Tuned Model
320+
### [agents](docs/sdks/agents/README.md)
321+
322+
* [complete](docs/sdks/agents/README.md#complete) - Agents Completion
323+
* [stream](docs/sdks/agents/README.md#stream) - Stream Agents completion
324+
325+
### [chat](docs/sdks/chat/README.md)
326+
327+
* [complete](docs/sdks/chat/README.md#complete) - Chat Completion
328+
* [stream](docs/sdks/chat/README.md#stream) - Stream chat completion
329+
330+
### [embeddings](docs/sdks/embeddings/README.md)
331+
332+
* [create](docs/sdks/embeddings/README.md#create) - Embeddings
298333

299334
### [files](docs/sdks/files/README.md)
300335

@@ -303,33 +338,33 @@ The documentation for the GCP SDK is available [here](packages/mistralai_gcp/REA
303338
* [retrieve](docs/sdks/files/README.md#retrieve) - Retrieve File
304339
* [delete](docs/sdks/files/README.md#delete) - Delete File
305340

341+
### [fim](docs/sdks/fim/README.md)
306342

307-
### [fine_tuning.jobs](docs/sdks/jobs/README.md)
343+
* [complete](docs/sdks/fim/README.md#complete) - Fim Completion
344+
* [stream](docs/sdks/fim/README.md#stream) - Stream fim completion
345+
346+
### [fine_tuning](docs/sdks/finetuning/README.md)
347+
348+
349+
#### [fine_tuning.jobs](docs/sdks/jobs/README.md)
308350

309351
* [list](docs/sdks/jobs/README.md#list) - Get Fine Tuning Jobs
310352
* [create](docs/sdks/jobs/README.md#create) - Create Fine Tuning Job
311353
* [get](docs/sdks/jobs/README.md#get) - Get Fine Tuning Job
312354
* [cancel](docs/sdks/jobs/README.md#cancel) - Cancel Fine Tuning Job
313355
* [start](docs/sdks/jobs/README.md#start) - Start Fine Tuning Job
314356

315-
### [chat](docs/sdks/chat/README.md)
316-
317-
* [complete](docs/sdks/chat/README.md#complete) - Chat Completion
318-
* [stream](docs/sdks/chat/README.md#stream) - Stream chat completion
319-
320-
### [fim](docs/sdks/fim/README.md)
321-
322-
* [complete](docs/sdks/fim/README.md#complete) - Fim Completion
323-
* [stream](docs/sdks/fim/README.md#stream) - Stream fim completion
324-
325-
### [agents](docs/sdks/agents/README.md)
326357

327-
* [complete](docs/sdks/agents/README.md#complete) - Agents Completion
328-
* [stream](docs/sdks/agents/README.md#stream) - Stream Agents completion
358+
### [models](docs/sdks/models/README.md)
329359

330-
### [embeddings](docs/sdks/embeddings/README.md)
360+
* [list](docs/sdks/models/README.md#list) - List Models
361+
* [retrieve](docs/sdks/models/README.md#retrieve) - Retrieve Model
362+
* [delete](docs/sdks/models/README.md#delete) - Delete Model
363+
* [update](docs/sdks/models/README.md#update) - Update Fine Tuned Model
364+
* [archive](docs/sdks/models/README.md#archive) - Archive Fine Tuned Model
365+
* [unarchive](docs/sdks/models/README.md#unarchive) - Unarchive Fine Tuned Model
331366

332-
* [create](docs/sdks/embeddings/README.md#create) - Embeddings
367+
</details>
333368
<!-- End Available Resources and Operations [operations] -->
334369

335370
<!-- Start Server-sent event streaming [eventstream] -->
@@ -349,7 +384,6 @@ s = Mistral(
349384
api_key=os.getenv("MISTRAL_API_KEY", ""),
350385
)
351386

352-
353387
res = s.chat.stream(model="mistral-small-latest", messages=[
354388
{
355389
"content": "Who is the best French painter? Answer in one short sentence.",
@@ -386,10 +420,9 @@ s = Mistral(
386420
api_key=os.getenv("MISTRAL_API_KEY", ""),
387421
)
388422

389-
390423
res = s.files.upload(file={
391-
"file_name": "your_file_here",
392-
"content": open("<file_path>", "rb"),
424+
"file_name": "example.file",
425+
"content": open("example.file", "rb"),
393426
})
394427

395428
if res is not None:
@@ -414,7 +447,6 @@ s = Mistral(
414447
api_key=os.getenv("MISTRAL_API_KEY", ""),
415448
)
416449

417-
418450
res = s.models.list(,
419451
RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
420452

@@ -435,7 +467,6 @@ s = Mistral(
435467
api_key=os.getenv("MISTRAL_API_KEY", ""),
436468
)
437469

438-
439470
res = s.models.list()
440471

441472
if res is not None:
@@ -469,17 +500,16 @@ res = None
469500
try:
470501
res = s.models.list()
471502

503+
if res is not None:
504+
# handle response
505+
pass
506+
472507
except models.HTTPValidationError as e:
473-
# handle exception
508+
# handle e.data: models.HTTPValidationErrorData
474509
raise(e)
475510
except models.SDKError as e:
476511
# handle exception
477512
raise(e)
478-
479-
if res is not None:
480-
# handle response
481-
pass
482-
483513
```
484514
<!-- End Error Handling [errors] -->
485515

@@ -505,7 +535,6 @@ s = Mistral(
505535
api_key=os.getenv("MISTRAL_API_KEY", ""),
506536
)
507537

508-
509538
res = s.models.list()
510539

511540
if res is not None:
@@ -527,7 +556,6 @@ s = Mistral(
527556
api_key=os.getenv("MISTRAL_API_KEY", ""),
528557
)
529558

530-
531559
res = s.models.list()
532560

533561
if res is not None:
@@ -638,7 +666,6 @@ s = Mistral(
638666
api_key=os.getenv("MISTRAL_API_KEY", ""),
639667
)
640668

641-
642669
res = s.models.list()
643670

644671
if res is not None:

0 commit comments

Comments
 (0)