Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API-47] Images support and other updates #144

Merged
merged 8 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
654 changes: 413 additions & 241 deletions .speakeasy/gen.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ generation:
auth:
oAuth2ClientCredentialsEnabled: true
python:
version: 1.0.3
version: 1.1.1
additionalDependencies:
dev:
pytest: ^8.2.2
Expand Down
30 changes: 13 additions & 17 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
@@ -1,43 +1,39 @@
speakeasyVersion: 1.382.0
speakeasyVersion: 1.396.7
sources:
mistral-azure-source:
sourceNamespace: mistral-openapi-azure
sourceRevisionDigest: sha256:becb324b11dfc5155aa0cc420ca312d0af5aecfcbad22fe90066a09561ae4e6a
sourceBlobDigest: sha256:84928a6297c3a838dce719ffa3da1e221cba968ce4a6c74d5c3bb41bf86a7e5d
sourceRevisionDigest: sha256:4e9539e6903e630aa69e48af190a24d3702f6038c7b7a92472c7942597c2a6f5
sourceBlobDigest: sha256:3ace0709471c04a040c9763097fef0081d6c21a1be0b694dfe5991c045b76d18
tags:
- latest
mistral-google-cloud-source:
sourceNamespace: mistral-openapi-google-cloud
sourceRevisionDigest: sha256:7fee22ae1a434b8919112c7feae87af7f1378952fcc6bde081deb55f65e5bfc2
sourceBlobDigest: sha256:a4c011f461c73809a7d6cf1c9823d3c51d5050895aad246287ff14ac971efb8c
sourceRevisionDigest: sha256:3047ad3ff8797fded89618b375d1398d48924a3a5f9ea1000c4284a110567c43
sourceBlobDigest: sha256:02bbcef310f965d7ad089fb46d57b39f45b47cbc8f5cf90f728db03e960bdbca
tags:
- latest
mistral-openapi:
sourceNamespace: mistral-openapi
sourceRevisionDigest: sha256:421a4bd55fd50ba00d6ebf2db603888009e9996b642b0499110c223fd6ca21c2
sourceBlobDigest: sha256:1c87b4b8287f6a3083167c13ab59c5e7ac180ab7e19ad1532f3f46495cc12a26
sourceRevisionDigest: sha256:8e2d62b2242960d958406ba266eda41a013c1459dbac67195f8e2662c04cd05f
sourceBlobDigest: sha256:9fbff48fe087e3b2f950b1cfa52b6a25143982741dc7e6750dd14d9c5bed4041
tags:
- latest
- main
targets:
mistralai-azure-sdk:
source: mistral-azure-source
sourceNamespace: mistral-openapi-azure
sourceRevisionDigest: sha256:becb324b11dfc5155aa0cc420ca312d0af5aecfcbad22fe90066a09561ae4e6a
sourceBlobDigest: sha256:84928a6297c3a838dce719ffa3da1e221cba968ce4a6c74d5c3bb41bf86a7e5d
outLocation: ./packages/mistralai_azure
sourceRevisionDigest: sha256:4e9539e6903e630aa69e48af190a24d3702f6038c7b7a92472c7942597c2a6f5
sourceBlobDigest: sha256:3ace0709471c04a040c9763097fef0081d6c21a1be0b694dfe5991c045b76d18
mistralai-gcp-sdk:
source: mistral-google-cloud-source
sourceNamespace: mistral-openapi-google-cloud
sourceRevisionDigest: sha256:7fee22ae1a434b8919112c7feae87af7f1378952fcc6bde081deb55f65e5bfc2
sourceBlobDigest: sha256:a4c011f461c73809a7d6cf1c9823d3c51d5050895aad246287ff14ac971efb8c
outLocation: ./packages/mistralai_gcp
sourceRevisionDigest: sha256:3047ad3ff8797fded89618b375d1398d48924a3a5f9ea1000c4284a110567c43
sourceBlobDigest: sha256:02bbcef310f965d7ad089fb46d57b39f45b47cbc8f5cf90f728db03e960bdbca
mistralai-sdk:
source: mistral-openapi
sourceNamespace: mistral-openapi
sourceRevisionDigest: sha256:421a4bd55fd50ba00d6ebf2db603888009e9996b642b0499110c223fd6ca21c2
sourceBlobDigest: sha256:1c87b4b8287f6a3083167c13ab59c5e7ac180ab7e19ad1532f3f46495cc12a26
outLocation: /github/workspace/repo
sourceRevisionDigest: sha256:8e2d62b2242960d958406ba266eda41a013c1459dbac67195f8e2662c04cd05f
sourceBlobDigest: sha256:9fbff48fe087e3b2f950b1cfa52b6a25143982741dc7e6750dd14d9c5bed4041
workflow:
workflowVersion: 1.0.0
speakeasyVersion: latest
Expand Down
2 changes: 1 addition & 1 deletion MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ async def main():
# content="What is the best French cheese?",
# ),
# ]
async_response = await client.chat.completstream_asynce_async(
async_response = await client.chat.stream_async(
messages=messages,
model="mistral-large-latest",
)
Expand Down
125 changes: 76 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,46 @@ $ echo 'export MISTRAL_API_KEY=[your_key_here]' >> ~/.zshenv
$ source ~/.zshenv
```

<!-- Start Summary [summary] -->
## Summary

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.
<!-- End Summary [summary] -->

<!-- Start Table of Contents [toc] -->
## Table of Contents

* [SDK Installation](#sdk-installation)
* [IDE Support](#ide-support)
* [SDK Example Usage](#sdk-example-usage)
* [Available Resources and Operations](#available-resources-and-operations)
* [Server-sent event streaming](#server-sent-event-streaming)
* [File uploads](#file-uploads)
* [Retries](#retries)
* [Error Handling](#error-handling)
* [Server Selection](#server-selection)
* [Custom HTTP Client](#custom-http-client)
* [Authentication](#authentication)
* [Debugging](#debugging)
<!-- End Table of Contents [toc] -->

<!-- Start SDK Installation [installation] -->
## SDK Installation

PIP
The SDK can be installed with either *pip* or *poetry* package managers.

### PIP

*PIP* is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.

```bash
pip install mistralai
```

Poetry
### Poetry

*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.

```bash
poetry add mistralai
```
Expand All @@ -49,7 +80,6 @@ s = Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
)


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


res = s.files.upload(file={
"file_name": "your_file_here",
"content": open("<file_path>", "rb"),
"file_name": "example.file",
"content": open("example.file", "rb"),
})

if res is not None:
Expand All @@ -126,8 +155,8 @@ async def main():
api_key=os.getenv("MISTRAL_API_KEY", ""),
)
res = await s.files.upload_async(file={
"file_name": "your_file_here",
"content": open("<file_path>", "rb"),
"file_name": "example.file",
"content": open("example.file", "rb"),
})
if res is not None:
# handle response
Expand All @@ -149,11 +178,9 @@ s = Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
)


res = s.agents.complete(messages=[
{
"content": "Who is the best French painter? Answer in one short sentence.",
"role": "user",
"content": "<value>",
},
], agent_id="<value>")

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

### [models](docs/sdks/models/README.md)
<details open>
<summary>Available methods</summary>

* [list](docs/sdks/models/README.md#list) - List Models
* [retrieve](docs/sdks/models/README.md#retrieve) - Retrieve Model
* [delete](docs/sdks/models/README.md#delete) - Delete Model
* [update](docs/sdks/models/README.md#update) - Update Fine Tuned Model
* [archive](docs/sdks/models/README.md#archive) - Archive Fine Tuned Model
* [unarchive](docs/sdks/models/README.md#unarchive) - Unarchive Fine Tuned Model
### [agents](docs/sdks/agents/README.md)

* [complete](docs/sdks/agents/README.md#complete) - Agents Completion
* [stream](docs/sdks/agents/README.md#stream) - Stream Agents completion

### [chat](docs/sdks/chat/README.md)

* [complete](docs/sdks/chat/README.md#complete) - Chat Completion
* [stream](docs/sdks/chat/README.md#stream) - Stream chat completion

### [embeddings](docs/sdks/embeddings/README.md)

* [create](docs/sdks/embeddings/README.md#create) - Embeddings

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

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

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

### [fine_tuning.jobs](docs/sdks/jobs/README.md)
* [complete](docs/sdks/fim/README.md#complete) - Fim Completion
* [stream](docs/sdks/fim/README.md#stream) - Stream fim completion

### [fine_tuning](docs/sdks/finetuning/README.md)


#### [fine_tuning.jobs](docs/sdks/jobs/README.md)

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

### [chat](docs/sdks/chat/README.md)

* [complete](docs/sdks/chat/README.md#complete) - Chat Completion
* [stream](docs/sdks/chat/README.md#stream) - Stream chat completion

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

* [complete](docs/sdks/fim/README.md#complete) - Fim Completion
* [stream](docs/sdks/fim/README.md#stream) - Stream fim completion

### [agents](docs/sdks/agents/README.md)

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

### [embeddings](docs/sdks/embeddings/README.md)
* [list](docs/sdks/models/README.md#list) - List Models
* [retrieve](docs/sdks/models/README.md#retrieve) - Retrieve Model
* [delete](docs/sdks/models/README.md#delete) - Delete Model
* [update](docs/sdks/models/README.md#update) - Update Fine Tuned Model
* [archive](docs/sdks/models/README.md#archive) - Archive Fine Tuned Model
* [unarchive](docs/sdks/models/README.md#unarchive) - Unarchive Fine Tuned Model

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

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


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


res = s.files.upload(file={
"file_name": "your_file_here",
"content": open("<file_path>", "rb"),
"file_name": "example.file",
"content": open("example.file", "rb"),
})

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


res = s.models.list(,
RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))

Expand All @@ -435,7 +467,6 @@ s = Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
)


res = s.models.list()

if res is not None:
Expand Down Expand Up @@ -469,17 +500,16 @@ res = None
try:
res = s.models.list()

if res is not None:
# handle response
pass

except models.HTTPValidationError as e:
# handle exception
# handle e.data: models.HTTPValidationErrorData
raise(e)
except models.SDKError as e:
# handle exception
raise(e)

if res is not None:
# handle response
pass

```
<!-- End Error Handling [errors] -->

Expand All @@ -505,7 +535,6 @@ s = Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
)


res = s.models.list()

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


res = s.models.list()

if res is not None:
Expand Down Expand Up @@ -638,7 +666,6 @@ s = Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
)


res = s.models.list()

if res is not None:
Expand Down
Loading