Skip to content
Closed
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
63 changes: 27 additions & 36 deletions .github/workflows/update_speakeasy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ on:
required: true
type: string
targets:
description: 'Targets to update. If not provided, all targets will be updated.'
description: 'Targets to update.'
required: true
type: choice
options:
- mistralai-sdk
- mistralai-azure-sdk
- mistralai-gcp-sdk
- all

jobs:
update-sdks:
Expand All @@ -40,16 +42,25 @@ jobs:

- name: Install dependencies
run: |
cp README.md README-PYPI.md
poetry install --with dev

- name: Install Speakeasy CLI
run: |
curl -fsSL https://go.speakeasy.com/cli-install.sh | sh
speakeasy --version

- name: Configure Git
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git config --local --type bool push.autoSetupRemote true

- name: Create branch
run: |
git checkout -b update-speakeasy-to-${{ github.event.inputs.version }}-${{ github.run_id }}
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
echo "TIMESTAMP=$TIMESTAMP" >> $GITHUB_ENV
git checkout -b update-speakeasy-to-${{ github.event.inputs.version }}-$TIMESTAMP

- name: Update Speakeasy SDKs
run: |
Expand All @@ -62,6 +73,8 @@ jobs:
poetry run inv update-speakeasy \
--version "${{ github.event.inputs.version }}" \
$TARGETS_ARGS
env:
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}

- name: Check for changes
id: check-changes
Expand All @@ -84,43 +97,21 @@ jobs:
Targets updated: ${{ github.event.inputs.targets }}

This PR was automatically generated by the Update Speakeasy workflow."
git push origin ${{ github.event.inputs.branch_name }}
git push origin update-speakeasy-to-${{ github.event.inputs.version }}-${{ env.TIMESTAMP }}

- name: Create Pull Request
if: steps.check-changes.outputs.has_changes == 'true'
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
with:
token: ${{ secrets.GITHUB_TOKEN }}
base: main
branch: ${{ github.event.inputs.branch_name }}
title: "Update Speakeasy SDKs to version ${{ github.event.inputs.version }}"
body: |
## Summary

This PR updates the Speakeasy SDKs to version `${{ github.event.inputs.version }}`.

## Changes

- **Version**: Updated to `${{ github.event.inputs.version }}`
- **Targets**: ${{ github.event.inputs.targets }}

## Files Updated

The following SDK files have been regenerated:
- Generated SDK code files
- Updated dependencies and configurations

## How to Review

1. Check that the generated files look correct
2. Verify that the version update is appropriate
3. Ensure all target SDKs are properly updated

---

*This PR was automatically generated by the [Update Speakeasy workflow](.github/workflows/update_speakeasy.yaml)*
labels: automated
assignees: ${{ github.actor }}
run: |
gh pr create \
--base main \
--head update-speakeasy-to-${{ github.event.inputs.version }}-${{ env.TIMESTAMP }} \
--title "Update Speakeasy SDKs to version ${{ github.event.inputs.version }}" \
--body "This PR updates the Speakeasy SDKs to version `${{ github.event.inputs.version }}`.\n\nIt was automatically generated by the [Update Speakeasy workflow](.github/workflows/update_speakeasy.yaml)." \
--label automated \
--label speakeasy-update \
--assignee ${{ github.actor }}
env:
GITHUB_TOKEN: ${{ secrets.SPEAKEASY_WORKFLOW_GITHUB_PAT }}

- name: Comment on workflow run
if: steps.check-changes.outputs.has_changes == 'false'
Expand Down
13 changes: 8 additions & 5 deletions .speakeasy/gen.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ id: 2d045ec7-2ebb-4f4d-ad25-40953b132161
management:
docChecksum: c33c788946fa446bfcf90b60f68abde9
docVersion: 1.0.0
speakeasyVersion: 1.568.2
generationVersion: 2.634.2
speakeasyVersion: 1.580.2
generationVersion: 2.656.5
releaseVersion: 1.9.3
configChecksum: 0f65a9bdd8df5ae03eaaaea3ab055bf1
repoURL: https://github.com/mistralai/client-python.git
Expand All @@ -15,13 +15,13 @@ features:
additionalDependencies: 1.0.0
additionalProperties: 1.0.1
constsAndDefaults: 1.0.5
core: 5.19.3
core: 5.19.4
customCodeRegions: 0.1.1
defaultEnabledRetries: 0.2.0
downloadStreams: 1.0.1
enumUnions: 0.1.0
envVarSecurityUsage: 0.3.2
examples: 3.0.1
examples: 3.0.2
flatRequests: 1.0.1
flattening: 3.1.1
globalSecurity: 3.0.3
Expand All @@ -43,7 +43,6 @@ features:
uploadStreams: 1.0.0
generatedFiles:
- .gitattributes
- .python-version
- .vscode/settings.json
- USAGE.md
- docs/models/agent.md
Expand Down Expand Up @@ -663,12 +662,14 @@ generatedFiles:
- src/mistralai/models/messageoutputentry.py
- src/mistralai/models/messageoutputevent.py
- src/mistralai/models/metricout.py
- src/mistralai/models/mistralerror.py
- src/mistralai/models/mistralpromptmode.py
- src/mistralai/models/modelcapabilities.py
- src/mistralai/models/modelconversation.py
- src/mistralai/models/modellist.py
- src/mistralai/models/moderationobject.py
- src/mistralai/models/moderationresponse.py
- src/mistralai/models/no_response_error.py
- src/mistralai/models/ocrimageobject.py
- src/mistralai/models/ocrpagedimensions.py
- src/mistralai/models/ocrpageobject.py
Expand All @@ -685,6 +686,7 @@ generatedFiles:
- src/mistralai/models/responseformat.py
- src/mistralai/models/responseformats.py
- src/mistralai/models/responsestartedevent.py
- src/mistralai/models/responsevalidationerror.py
- src/mistralai/models/retrieve_model_v1_models_model_id_getop.py
- src/mistralai/models/retrievefileout.py
- src/mistralai/models/sampletype.py
Expand Down Expand Up @@ -753,6 +755,7 @@ generatedFiles:
- src/mistralai/utils/retries.py
- src/mistralai/utils/security.py
- src/mistralai/utils/serializers.py
- src/mistralai/utils/unmarshal_json_response.py
- src/mistralai/utils/url.py
- src/mistralai/utils/values.py
examples:
Expand Down
14 changes: 7 additions & 7 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
speakeasyVersion: 1.568.2
speakeasyVersion: 1.580.2
sources:
mistral-azure-source:
sourceNamespace: mistral-openapi-azure
Expand All @@ -18,7 +18,7 @@ sources:
sourceBlobDigest: sha256:f3322d8a44d0bf1515b5c1c078525dbf00ff90e6110644de4c03b0b0e9050350
tags:
- latest
- speakeasy-sdk-regen-1753290410
- amenasria-speakeasy-update-workflow-fix
targets:
mistralai-azure-sdk:
source: mistral-azure-source
Expand All @@ -40,20 +40,20 @@ targets:
sourceRevisionDigest: sha256:22d8044215dc1331ba83f3d25598409bc82fdc04d68033fb05e0133a13cc4dad
sourceBlobDigest: sha256:f3322d8a44d0bf1515b5c1c078525dbf00ff90e6110644de4c03b0b0e9050350
codeSamplesNamespace: mistral-openapi-code-samples
codeSamplesRevisionDigest: sha256:1fd9897fdd851557c592b8fd46232518359401d15a6574933c43be63ec2edb53
codeSamplesRevisionDigest: sha256:8f80114b4a120a17d17bf510fc022ceb8ee0dcd470e560781e60337189bbebb8
workflow:
workflowVersion: 1.0.0
speakeasyVersion: 1.568.2
speakeasyVersion: 1.580.2
sources:
mistral-azure-source:
inputs:
- location: registry.speakeasyapi.dev/mistral-dev/mistral-dev/mistral-openapi-azure:main
- location: registry.speakeasyapi.dev/mistral-dev/mistral-dev/mistral-openapi-azure:sha256:c5931a7e0cc2db844149d71db57dfc2178665f0400bc26c90ee113795ea2872f
mistral-google-cloud-source:
inputs:
- location: registry.speakeasyapi.dev/mistral-dev/mistral-dev/mistral-openapi-google-cloud:main
- location: registry.speakeasyapi.dev/mistral-dev/mistral-dev/mistral-openapi-google-cloud:sha256:4a5343e63c6a78152e472b00ccc46d7bcb15594496bc94c8040039d3a9d4c5f8
mistral-openapi:
inputs:
- location: registry.speakeasyapi.dev/mistral-dev/mistral-dev/mistral-openapi:main
- location: registry.speakeasyapi.dev/mistral-dev/mistral-dev/mistral-openapi:sha256:22d8044215dc1331ba83f3d25598409bc82fdc04d68033fb05e0133a13cc4dad
targets:
mistralai-azure-sdk:
target: python
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.568.2
speakeasyVersion: 1.580.2
sources:
mistral-azure-source:
inputs:
Expand Down
67 changes: 44 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -680,27 +680,20 @@ with Mistral(
<!-- Start Error Handling [errors] -->
## Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception.
[`MistralError`](./src/mistralai/models/mistralerror.py) is the base class for all HTTP error responses. It has the following properties:

By default, an API error will raise a models.SDKError exception, which has the following properties:

| Property | Type | Description |
|-----------------|------------------|-----------------------|
| `.status_code` | *int* | The HTTP status code |
| `.message` | *str* | The error message |
| `.raw_response` | *httpx.Response* | The raw HTTP response |
| `.body` | *str* | The response content |

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:

| Error Type | Status Code | Content Type |
| -------------------------- | ----------- | ---------------- |
| models.HTTPValidationError | 422 | application/json |
| models.SDKError | 4XX, 5XX | \*/\* |
| Property | Type | Description |
| ------------------ | ---------------- | --------------------------------------------------------------------------------------- |
| `err.message` | `str` | Error message |
| `err.status_code` | `int` | HTTP response status code eg `404` |
| `err.headers` | `httpx.Headers` | HTTP response headers |
| `err.body` | `str` | HTTP body. Can be empty string if no body is returned. |
| `err.raw_response` | `httpx.Response` | Raw HTTP response |
| `err.data` | | Optional. Some errors may contain structured data. [See Error Classes](#error-classes). |

### Example

```python
import mistralai
from mistralai import Mistral, models
import os

Expand All @@ -716,13 +709,41 @@ with Mistral(
# Handle response
print(res)

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

except models.MistralError as e:
# The base class for HTTP error responses
print(e.message)
print(e.status_code)
print(e.body)
print(e.headers)
print(e.raw_response)

# Depending on the method different errors may be thrown
if isinstance(e, models.HTTPValidationError):
print(e.data.detail) # Optional[List[mistralai.ValidationError]]
```

### Error Classes
**Primary error:**
* [`MistralError`](./src/mistralai/models/mistralerror.py): The base class for HTTP error responses.

<details><summary>Less common errors (6)</summary>

<br />

**Network errors:**
* [`httpx.RequestError`](https://www.python-httpx.org/exceptions/#httpx.RequestError): Base class for request errors.
* [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server.
* [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out.


**Inherit from [`MistralError`](./src/mistralai/models/mistralerror.py)**:
* [`HTTPValidationError`](./src/mistralai/models/httpvalidationerror.py): Validation Error. Status code `422`. Applicable to 47 of 68 methods.*
* [`ResponseValidationError`](./src/mistralai/models/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute.

</details>

\* Check [the method documentation](#available-resources-and-operations) to see if the error is applicable.
<!-- End Error Handling [errors] -->

<!-- Start Server Selection [server] -->
Expand Down
4 changes: 2 additions & 2 deletions src/mistralai/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
__title__: str = "mistralai"
__version__: str = "1.9.3"
__openapi_doc_version__: str = "1.0.0"
__gen_version__: str = "2.634.2"
__user_agent__: str = "speakeasy-sdk/python 1.9.3 2.634.2 1.0.0 mistralai"
__gen_version__: str = "2.656.5"
__user_agent__: str = "speakeasy-sdk/python 1.9.3 2.656.5 1.0.0 mistralai"

try:
if __package__ is not None:
Expand Down
Loading
Loading