Skip to content

Commit

Permalink
generation with new version
Browse files Browse the repository at this point in the history
  • Loading branch information
GaspardBT committed Sep 13, 2024
1 parent 1d406df commit 541a2b4
Show file tree
Hide file tree
Showing 196 changed files with 6,515 additions and 3,097 deletions.
670 changes: 412 additions & 258 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.4
version: 1.1.0
additionalDependencies:
dev:
pytest: ^8.2.2
Expand Down
7 changes: 2 additions & 5 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
speakeasyVersion: 1.382.0
speakeasyVersion: 1.396.6
sources:
mistral-azure-source:
sourceNamespace: mistral-openapi-azure
Expand All @@ -24,22 +24,19 @@ targets:
sourceNamespace: mistral-openapi-azure
sourceRevisionDigest: sha256:3dec9e900243dab5f6fecb4780a74e5cd26bf5660d1db0268964689cb4da043a
sourceBlobDigest: sha256:867fabbb7c8662a2f10861eb9505990aea59e4677631291989d06afb3cf497bc
outLocation: ./packages/mistralai_azure
mistralai-gcp-sdk:
source: mistral-google-cloud-source
sourceNamespace: mistral-openapi-google-cloud
sourceRevisionDigest: sha256:caf6467696dddae2736fef96d8967b8a02a1e10e405d22d2901d0459172b739c
sourceBlobDigest: sha256:d6650e668064690efa947a29ec1712566252e3283940b67a3c602323df461cf6
outLocation: ./packages/mistralai_gcp
mistralai-sdk:
source: mistral-openapi
sourceNamespace: mistral-openapi
sourceRevisionDigest: sha256:4b17326b6b91a95870383242c971996d6c6671d180b40c96f75b09c7cb1cc9c0
sourceBlobDigest: sha256:6e345b52897fc37bf0cae3ff6ddd58a09484cc0f2130387ddf41af6a76eda19f
outLocation: /Users/gaspard/public-mistral/client-python
workflow:
workflowVersion: 1.0.0
speakeasyVersion: 1.382.0
speakeasyVersion: latest
sources:
mistral-azure-source:
inputs:
Expand Down
2 changes: 1 addition & 1 deletion .speakeasy/workflow.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
workflowVersion: 1.0.0
speakeasyVersion: 1.382.0
speakeasyVersion: latest
sources:
mistral-azure-source:
inputs:
Expand Down
145 changes: 86 additions & 59 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 All @@ -450,10 +481,10 @@ if res is not None:

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.

| Error Object | Status Code | Content Type |
| -------------------------- | ----------- | ---------------- |
| models.HTTPValidationError | 422 | application/json |
| models.SDKError | 4xx-5xx | */* |
| Error Object | Status Code | Content Type |
| -------------------------- | -------------------------- | -------------------------- |
| models.HTTPValidationError | 422 | application/json |
| models.SDKError | 4xx-5xx | */* |

### Example

Expand All @@ -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 @@ -490,9 +520,9 @@ if res is not None:

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:

| Name | Server | Variables |
| ------ | ------------------------ | --------- |
| `prod` | `https://api.mistral.ai` | None |
| Name | Server | Variables |
| ----- | ------ | --------- |
| `prod` | `https://api.mistral.ai` | None |

#### Example

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 @@ -625,9 +653,9 @@ s = Mistral(async_client=CustomClient(httpx.AsyncClient()))

This SDK supports the following security scheme globally:

| Name | Type | Scheme | Environment Variable |
| --------- | ---- | ----------- | -------------------- |
| `api_key` | http | HTTP Bearer | `MISTRAL_API_KEY` |
| Name | Type | Scheme | Environment Variable |
| -------------------- | -------------------- | -------------------- | -------------------- |
| `api_key` | http | HTTP Bearer | `MISTRAL_API_KEY` |

To authenticate with the API the `api_key` parameter must be set when initializing the SDK client instance. For example:
```python
Expand All @@ -638,7 +666,6 @@ s = Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
)


res = s.models.list()

if res is not None:
Expand Down
16 changes: 8 additions & 8 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ s = Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
)


res = s.chat.complete(model="mistral-small-latest", messages=[

])
Expand All @@ -36,7 +35,10 @@ async def main():
api_key=os.getenv("MISTRAL_API_KEY", ""),
)
res = await s.chat.complete_async(model="mistral-small-latest", messages=[

{
"content": "Who is the best French painter? Answer in one short sentence.",
"role": "user",
},
])
if res is not None:
# handle response
Expand All @@ -58,10 +60,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 @@ -83,8 +84,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 @@ -106,7 +107,6 @@ 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.",
Expand Down
Loading

0 comments on commit 541a2b4

Please sign in to comment.