Skip to content

Commit fcec503

Browse files
author
Andrea Onofrei
committed
Add __init__.py bridge that discovers and loads the installed mistral-workflows
package, enabling
1 parent f3ad2f1 commit fcec503

File tree

8 files changed

+59
-18
lines changed

8 files changed

+59
-18
lines changed

.genignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ examples/*
44
src/mistral/extra/*
55
pylintrc
66
scripts/prepare_readme.py
7+
./workflows

.speakeasy/gen.lock

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ management:
55
docVersion: 1.0.0
66
speakeasyVersion: 1.606.10
77
generationVersion: 2.687.13
8-
releaseVersion: 1.10.0
9-
configChecksum: 1446aab5f184e7184590fe5756b556a8
8+
releaseVersion: 1.10.8
9+
configChecksum: c98f5eef0bfbde89016fa6fba58a5534
1010
repoURL: https://github.com/mistralai/client-python.git
1111
installationURL: https://github.com/mistralai/client-python.git
1212
published: true
@@ -474,9 +474,7 @@ generatedFiles:
474474
- docs/sdks/models/README.md
475475
- docs/sdks/ocr/README.md
476476
- docs/sdks/transcriptions/README.md
477-
- poetry.toml
478477
- py.typed
479-
- scripts/prepare_readme.py
480478
- scripts/publish.sh
481479
- src/mistralai/__init__.py
482480
- src/mistralai/_hooks/__init__.py
@@ -1531,4 +1529,3 @@ examples:
15311529
application/json: {}
15321530
examplesVersion: 1.0.2
15331531
generatedTests: {}
1534-
releaseNotes: "## SDK Changes Detected:\n* `mistral.beta.libraries.create()`: `response.owner_id` **Changed** **Breaking** :warning:\n* `mistral.beta.libraries.documents.get()`: `response` **Changed** **Breaking** :warning:\n* `mistral.models.list()`: \n * `response.data.[].[base].capabilities` **Changed**\n * `error.status[422]` **Removed** **Breaking** :warning:\n* `mistral.files.list()`: \n * `request.include_total` **Added**\n * `response.total` **Changed** **Breaking** :warning:\n* `mistral.beta.conversations.start()`: \n * `request` **Changed** **Breaking** :warning:\n * `response.outputs.[].[tool_execution_entry].name` **Changed** **Breaking** :warning:\n* `mistral.beta.libraries.accesses.delete()`: \n * `request.org_id` **Changed**\n * `response.share_with_uuid` **Changed** **Breaking** :warning:\n* `mistral.beta.libraries.accesses.update_or_create()`: \n * `request.org_id` **Changed**\n * `response.share_with_uuid` **Changed** **Breaking** :warning:\n* `mistral.beta.conversations.append()`: \n * `request.inputs.[array].[].[tool_execution_entry].name` **Changed** **Breaking** :warning:\n * `response.outputs.[].[tool_execution_entry].name` **Changed** **Breaking** :warning:\n* `mistral.beta.libraries.accesses.list()`: `response.data.[].share_with_uuid` **Changed** **Breaking** :warning:\n* `mistral.beta.conversations.restart()`: \n * `request` **Changed** **Breaking** :warning:\n * `response.outputs.[].[tool_execution_entry].name` **Changed** **Breaking** :warning:\n* `mistral.beta.libraries.documents.update()`: \n * `request.attributes` **Added**\n * `response` **Changed** **Breaking** :warning:\n* `mistral.beta.libraries.documents.upload()`: `response` **Changed** **Breaking** :warning:\n* `mistral.beta.libraries.documents.list()`: \n * `request.filters_attributes` **Added**\n * `response.data.[]` **Changed** **Breaking** :warning:\n* `mistral.beta.libraries.update()`: `response.owner_id` **Changed** **Breaking** :warning:\n* `mistral.beta.libraries.delete()`: `response.owner_id` **Changed** **Breaking** :warning:\n* `mistral.beta.libraries.get()`: `response.owner_id` **Changed** **Breaking** :warning:\n* `mistral.beta.conversations.get_history()`: `response.entries.[].[tool_execution_entry].name` **Changed** **Breaking** :warning:\n* `mistral.beta.libraries.list()`: `response.data.[].owner_id` **Changed** **Breaking** :warning:\n* `mistral.models.retrieve()`: `response.[base].capabilities` **Changed**\n* `mistral.agents.complete()`: `request.metadata` **Added**\n* `mistral.beta.agents.get()`: \n * `request.agent_version` **Added**\n * `response` **Changed**\n* `mistral.beta.agents.list()`: \n * `request` **Changed**\n * `response.[]` **Changed**\n* `mistral.beta.agents.update_version()`: `response` **Changed**\n* `mistral.beta.agents.delete()`: **Added**\n* `mistral.beta.conversations.list()`: \n * `request.metadata` **Added**\n * `response.[]` **Changed**\n* `mistral.beta.conversations.get()`: `response` **Changed**\n* `mistral.beta.agents.update()`: \n * `request` **Changed**\n * `response` **Changed**\n* `mistral.beta.conversations.delete()`: **Added**\n* `mistral.chat.complete()`: `request.metadata` **Added**\n* `mistral.fim.complete()`: `request.metadata` **Added**\n* `mistral.beta.agents.create()`: \n * `request.metadata` **Added**\n * `response` **Changed**\n* `mistral.ocr.process()`: \n * `request` **Changed**\n * `response.pages.[]` **Changed**\n"

.speakeasy/gen.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ generation:
2121
generateNewTests: false
2222
skipResponseBodyAssertions: false
2323
python:
24-
version: 1.10.0
24+
version: 1.10.8
2525
additionalDependencies:
2626
dev:
2727
pytest: ^8.2.2
2828
pytest-asyncio: ^0.23.7
29+
main:
30+
mistral-workflows: ^1.2.2
2931
allowedRedefinedBuiltins:
3032
- id
3133
- object

.speakeasy/workflow.lock

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ sources:
1818
sourceBlobDigest: sha256:f0caa06fb9bcadc35b097aa5ff69bb5020937652df311722b5e44a282bd95d6d
1919
tags:
2020
- latest
21-
- speakeasy-sdk-regen-1765914268
2221
targets:
2322
mistralai-azure-sdk:
2423
source: mistral-azure-source
@@ -40,7 +39,7 @@ targets:
4039
sourceRevisionDigest: sha256:cb63bd997cefe7b3b36e91a475df57cb779bf79f183340e0713d8ffb16a2dabc
4140
sourceBlobDigest: sha256:f0caa06fb9bcadc35b097aa5ff69bb5020937652df311722b5e44a282bd95d6d
4241
codeSamplesNamespace: mistral-openapi-code-samples
43-
codeSamplesRevisionDigest: sha256:b1eacff97275a14ab0c2143e07bdfa4f4bd58f5370b2f106bcc6ada92b754d08
42+
codeSamplesRevisionDigest: sha256:f1f5f6d78a0c0e0bd0ef062537a279938ebd4706be0c3745b8d3460c975f2565
4443
workflow:
4544
workflowVersion: 1.0.0
4645
speakeasyVersion: 1.606.10

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,15 @@ Mistral AI API: Our Chat Completion and Embeddings APIs specification. Create yo
5858
>
5959
> Once a Python version reaches its [official end of life date](https://devguide.python.org/versions/), a 3-month grace period is provided for users to upgrade. Following this grace period, the minimum python version supported in the SDK will be updated.
6060
61-
The SDK can be installed with either *pip* or *uv* package managers.
61+
The SDK can be installed with *uv*, *pip*, or *poetry* package managers.
62+
63+
### uv
64+
65+
*uv* is a fast Python package installer and resolver, designed as a drop-in replacement for pip and pip-tools. It's recommended for its speed and modern Python tooling capabilities.
66+
67+
```bash
68+
uv add mistralai
69+
```
6270

6371
### PIP
6472

@@ -68,12 +76,12 @@ The SDK can be installed with either *pip* or *uv* package managers.
6876
pip install mistralai
6977
```
7078

71-
### UV
79+
### Poetry
7280

73-
*UV* is an extremely fast Python package and project manager. You can use it to add the SDK to your project:
81+
*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.
7482

7583
```bash
76-
uv add mistralai
84+
poetry add mistralai
7785
```
7886

7987
### Shell and script usage with `uv`
@@ -89,7 +97,7 @@ It's also possible to write a standalone Python script without needing to set up
8997
```python
9098
#!/usr/bin/env -S uv run --script
9199
# /// script
92-
# requires-python = ">=3.10"
100+
# requires-python = ">=3.9"
93101
# dependencies = [
94102
# "mistralai",
95103
# ]

scripts/publish.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env bash
2-
export UV_PUBLISH_TOKEN=${PYPI_TOKEN}
32

4-
uv run python scripts/prepare_readme.py -- uv build
5-
uv publish
3+
uv run python scripts/prepare_readme.py
4+
5+
uv build
6+
uv publish --token $PYPI_TOKEN

src/mistralai/_version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import importlib.metadata
44

55
__title__: str = "mistralai"
6-
__version__: str = "1.10.0"
6+
__version__: str = "1.10.8"
77
__openapi_doc_version__: str = "1.0.0"
88
__gen_version__: str = "2.687.13"
9-
__user_agent__: str = "speakeasy-sdk/python 1.10.0 2.687.13 1.0.0 mistralai"
9+
__user_agent__: str = "speakeasy-sdk/python 1.10.8 2.687.13 1.0.0 mistralai"
1010

1111
try:
1212
if __package__ is not None:
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import importlib.util
2+
import os
3+
import sys
4+
from types import ModuleType
5+
6+
# Find and import the installed mistral-workflows package
7+
bridge_path = os.path.abspath(__file__)
8+
sys.modules.pop(__name__, None) # Remove bridge to avoid recursion
9+
10+
try:
11+
# Search for the installed package (skip this bridge file)
12+
for path in sys.path:
13+
if not path:
14+
continue
15+
target = os.path.join(path, "mistralai", "workflows", "__init__.py")
16+
if os.path.exists(target) and os.path.abspath(target) != bridge_path:
17+
spec = importlib.util.spec_from_file_location("mistralai.workflows", target)
18+
if spec and spec.loader:
19+
workflows: ModuleType = importlib.util.module_from_spec(spec)
20+
sys.modules["mistralai.workflows"] = workflows
21+
spec.loader.exec_module(workflows)
22+
globals().update(
23+
{name: getattr(workflows, name) for name in workflows.__all__}
24+
)
25+
break
26+
else:
27+
raise ImportError(
28+
"mistral-workflows not installed. Run: pip install mistral-workflows"
29+
)
30+
finally:
31+
current_module = sys.modules.get("mistralai.workflows") or sys.modules.get(__name__)
32+
if current_module is not None:
33+
sys.modules[__name__] = current_module

0 commit comments

Comments
 (0)