Skip to content

Commit 4a73f73

Browse files
authored
Merge pull request #712 from Mirascope/release/v1.10
Release/v1.10
2 parents 5a5473c + 61f2a14 commit 4a73f73

Some content is hidden

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

58 files changed

+919
-440
lines changed

docs/WELCOME.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Make your first call to an LLM to extract the title and author of a book from th
8888
{% if provider == "Anthropic" %}
8989
```python hl_lines="19-38 43"
9090
{% elif provider == "Mistral" %}
91-
```python hl_lines="19-40 45"
91+
```python hl_lines="21-46 51"
9292
{% elif provider == "Gemini" %}
9393
```python hl_lines="19-57 62"
9494
{% elif provider == "Cohere" %}

docs/WHY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Let's compare structured outputs using Mirascope vs. the official SDKs:
9494
{% if provider == "Anthropic" %}
9595
```python hl_lines="19-38 43"
9696
{% elif provider == "Mistral" %}
97-
```python hl_lines="19-40 45"
97+
```python hl_lines="21-46 51"
9898
{% elif provider == "Gemini" %}
9999
```python hl_lines="19-57 62"
100100
{% elif provider == "Cohere" %}

docs/learn/async.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,14 @@ __Decorator Parameter:__
176176

177177
{% if provider == "LiteLLM" %}
178178
```python
179-
{% elif provider in ["OpenAI", "Mistral", "Vertex AI"] %}
179+
{% elif provider in ["OpenAI", "Vertex AI"] %}
180180
```python hl_lines="2 5"
181181
{% elif provider == "Azure AI" %}
182182
```python hl_lines="1-2 8-10"
183183
{% elif provider == "Bedrock" %}
184184
```python hl_lines="7-10 14"
185+
{% elif provider == "Mistral" %}
186+
```python hl_lines="4 8"
185187
{% else %}
186188
```python hl_lines="1 5"
187189
{% endif %}
@@ -203,12 +205,14 @@ __Dynamic Configuration:__
203205

204206
{% if provider == "LiteLLM" %}
205207
```python
206-
{% elif provider in ["OpenAI", "Mistral", "Vertex AI"] %}
208+
{% elif provider in ["OpenAI", "Vertex AI"] %}
207209
```python hl_lines="2 11"
208210
{% elif provider == "Azure AI" %}
209211
```python hl_lines="1-2 12-14"
210212
{% elif provider == "Bedrock" %}
211213
```python hl_lines="5-8 17"
214+
{% elif provider == "Mistral" %}
215+
```python hl_lines="4 15"
212216
{% else %}
213217
```python hl_lines="1 11"
214218
{% endif %}
@@ -222,12 +226,14 @@ __Dynamic Configuration:__
222226

223227
{% if provider == "LiteLLM" %}
224228
```python
225-
{% elif provider in ["OpenAI", "Mistral", "Vertex AI"] %}
229+
{% elif provider in ["OpenAI", "Vertex AI"] %}
226230
```python hl_lines="2 9"
227231
{% elif provider == "Azure AI" %}
228232
```python hl_lines="1-2 10-12"
229233
{% elif provider == "Bedrock" %}
230234
```python hl_lines="5-8 15"
235+
{% elif provider == "Mistral" %}
236+
```python hl_lines="4 11"
231237
{% else %}
232238
```python hl_lines="1 9"
233239
{% endif %}

docs/learn/calls.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ Let's take a look at a basic example using Mirascope vs. official provider SDKs:
6363
```python hl_lines="5-9"
6464
{% elif provider == "Azure AI" %}
6565
```python hl_lines="11-18"
66+
{% elif provider == "Mistral" %}
67+
```python hl_lines="10-15"
6668
{% else %}
6769
```python hl_lines="7-11"
6870
{% endif %}
@@ -365,12 +367,14 @@ You can pass a client to the `call` decorator using the `client` parameter:
365367

366368
{% if provider == "LiteLLM" %}
367369
```python
368-
{% elif provider in ["OpenAI", "Mistral", "Vertex AI"] %}
370+
{% elif provider in ["OpenAI", "Vertex AI"] %}
369371
```python hl_lines="2 5"
370372
{% elif provider == "Azure AI" %}
371373
```python hl_lines="1-2 8-10"
372374
{% elif provider == "Bedrock" %}
373375
```python hl_lines="1 6"
376+
{% elif provider == "Mistral" %}
377+
```python hl_lines="4 8"
374378
{% else %}
375379
```python hl_lines="1 5"
376380
{% endif %}
@@ -398,6 +402,8 @@ You can also configure the client dynamically at runtime through the dynamic con
398402
```python hl_lines="1-2 12-14"
399403
{% elif provider == "Bedrock" %}
400404
```python hl_lines="1 11"
405+
{% elif provider == "Mistral" %}
406+
```python hl_lines="4 13"
401407
{% else %}
402408
```python hl_lines="2 11"
403409
{% endif %}
@@ -415,6 +421,8 @@ You can also configure the client dynamically at runtime through the dynamic con
415421
```python hl_lines="1-2 10-11"
416422
{% elif provider == "Bedrock" %}
417423
```python hl_lines="1 11"
424+
{% elif provider == "Mistral" %}
425+
```python hl_lines="4 11"
418426
{% else %}
419427
```python hl_lines="2 9"
420428
{% endif %}

docs/learn/response_models.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Let's take a look at a basic example using Mirascope vs. official provider SDKs:
4747
{% if provider == "Anthropic" %}
4848
```python hl_lines="19-38 43"
4949
{% elif provider == "Mistral" %}
50-
```python hl_lines="19-40 45"
50+
```python hl_lines="21-46 51"
5151
{% elif provider == "Gemini" %}
5252
```python hl_lines="19-57 62"
5353
{% elif provider == "Cohere" %}

docs/learn/tools.md

+2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ Let's take a look at a basic example of each using Mirascope vs. official provid
100100
```python hl_lines="16-22 31-43 45-47"
101101
{% elif provider == "Vertex AI" %}
102102
```python hl_lines="6-12 18-34 36-43"
103+
{% elif provider == "Mistral" %}
104+
```python hl_lines="10-16 23-36 38-44"
103105
{% else %}
104106
```python hl_lines="8-14 21-34 36-38"
105107
{% endif %}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import os
2+
13
from mirascope.core import BaseMessageParam, mistral
2-
from mistralai.async_client import MistralAsyncClient
4+
from mistralai import Mistral
35

46

5-
@mistral.call("mistral-large-latest", client=MistralAsyncClient())
7+
@mistral.call(
8+
"mistral-large-latest", client=Mistral(api_key=os.environ["MISTRAL_API_KEY"])
9+
)
610
async def recommend_book_async(genre: str) -> list[BaseMessageParam]:
711
return [BaseMessageParam(role="user", content=f"Recommend a {genre} book")]
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import os
2+
13
from mirascope.core import Messages, mistral
2-
from mistralai.async_client import MistralAsyncClient
4+
from mistralai import Mistral
35

46

5-
@mistral.call("mistral-large-latest", client=MistralAsyncClient())
7+
@mistral.call(
8+
"mistral-large-latest", client=Mistral(api_key=os.environ["MISTRAL_API_KEY"])
9+
)
610
async def recommend_book_async(genre: str) -> Messages.Type:
711
return Messages.User(f"Recommend a {genre} book")
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import os
2+
13
from mirascope.core import mistral
2-
from mistralai.async_client import MistralAsyncClient
4+
from mistralai import Mistral
35

46

5-
@mistral.call("mistral-large-latest", client=MistralAsyncClient())
7+
@mistral.call(
8+
"mistral-large-latest", client=Mistral(api_key=os.environ["MISTRAL_API_KEY"])
9+
)
610
async def recommend_book_async(genre: str) -> str:
711
return f"Recommend a {genre} book"
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import os
2+
13
from mirascope.core import mistral, prompt_template
2-
from mistralai.async_client import MistralAsyncClient
4+
from mistralai import Mistral
35

46

5-
@mistral.call("mistral-large-latest", client=MistralAsyncClient())
7+
@mistral.call(
8+
"mistral-large-latest", client=Mistral(api_key=os.environ["MISTRAL_API_KEY"])
9+
)
610
@prompt_template("Recommend a {genre} book")
711
async def recommend_book_async(genre: str): ...
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
import os
2+
13
from mirascope.core import BaseMessageParam, mistral
2-
from mistralai.async_client import MistralAsyncClient
4+
from mistralai import Mistral
35

46

57
@mistral.call("mistral-large-latest")
6-
async def recommend_book(genre: str) -> mistral.AsyncMistralDynamicConfig:
8+
async def recommend_book(genre: str) -> mistral.MistralDynamicConfig:
79
return {
810
"messages": [
911
BaseMessageParam(role="user", content=f"Recommend a {genre} book")
1012
],
11-
"client": MistralAsyncClient(),
13+
"client": Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
1214
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import os
2+
13
from mirascope.core import Messages, mistral
2-
from mistralai.async_client import MistralAsyncClient
4+
from mistralai import Mistral
35

46

57
@mistral.call("mistral-large-latest")
6-
async def recommend_book(genre: str) -> mistral.AsyncMistralDynamicConfig:
8+
async def recommend_book(genre: str) -> mistral.MistralDynamicConfig:
79
return {
810
"messages": [Messages.User(f"Recommend a {genre} book")],
9-
"client": MistralAsyncClient(),
11+
"client": Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
1012
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import os
2+
13
from mirascope.core import mistral, Messages
2-
from mistralai.async_client import MistralAsyncClient
4+
from mistralai import Mistral
35

46

57
@mistral.call("mistral-large-latest")
6-
async def recommend_book(genre: str) -> mistral.AsyncMistralDynamicConfig:
8+
async def recommend_book(genre: str) -> mistral.MistralDynamicConfig:
79
return {
810
"messages": [Messages.User(f"Recommend a {genre} book")],
9-
"client": MistralAsyncClient(),
11+
"client": Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
1012
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import os
2+
13
from mirascope.core import mistral, prompt_template
2-
from mistralai.async_client import MistralAsyncClient
4+
from mistralai import Mistral
35

46

57
@mistral.call("mistral-large-latest")
68
@prompt_template("Recommend a {genre} book")
7-
async def recommend_book(genre: str) -> mistral.AsyncMistralDynamicConfig:
9+
async def recommend_book(genre: str) -> mistral.MistralDynamicConfig:
810
return {
9-
"client": MistralAsyncClient(),
11+
"client": Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
1012
}

examples/learn/calls/basic_usage/mistral/official_sdk_call.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
from mistralai.client import MistralClient
1+
import os
2+
from typing import cast
23

3-
client = MistralClient()
4+
from mistralai import Mistral
45

6+
client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])
57

6-
def recommend_book(genre: str) -> str:
7-
completion = client.chat(
8+
9+
def recommend_book(genre: str) -> str | None:
10+
completion = client.chat.complete(
811
model="mistral-large-latest",
912
messages=[{"role": "user", "content": f"Recommend a {genre} book"}],
1013
)
11-
return completion.choices[0].message.content
14+
if completion and (choices := completion.choices):
15+
return cast(str, choices[0].message.content)
1216

1317

1418
output = recommend_book("fantasy")
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1+
import os
2+
13
from mirascope.core import BaseMessageParam, mistral
2-
from mistralai.client import MistralClient
4+
from mistralai import Mistral
35

46

5-
@mistral.call("mistral-large-latest", client=MistralClient())
7+
@mistral.call(
8+
"mistral-large-latest",
9+
client=Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
10+
)
611
def recommend_book(genre: str) -> list[BaseMessageParam]:
712
return [BaseMessageParam(role="user", content=f"Recommend a {genre} book")]
13+
14+
15+
@mistral.call(
16+
"mistral-large-latest",
17+
client=Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
18+
)
19+
async def recommend_book_async(genre: str) -> list[BaseMessageParam]:
20+
return [BaseMessageParam(role="user", content=f"Recommend a {genre} book")]
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1+
import os
2+
13
from mirascope.core import Messages, mistral
2-
from mistralai.client import MistralClient
4+
from mistralai import Mistral
35

46

5-
@mistral.call("mistral-large-latest", client=MistralClient())
7+
@mistral.call(
8+
"mistral-large-latest",
9+
client=Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
10+
)
611
def recommend_book(genre: str) -> Messages.Type:
712
return Messages.User(f"Recommend a {genre} book")
13+
14+
15+
@mistral.call(
16+
"mistral-large-latest",
17+
client=Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
18+
)
19+
async def recommend_book_async(genre: str) -> Messages.Type:
20+
return Messages.User(f"Recommend a {genre} book")
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1+
import os
2+
13
from mirascope.core import mistral
2-
from mistralai.client import MistralClient
4+
from mistralai import Mistral
35

46

5-
@mistral.call("mistral-large-latest", client=MistralClient())
7+
@mistral.call(
8+
"mistral-large-latest",
9+
client=Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
10+
)
611
def recommend_book(genre: str) -> str:
712
return f"Recommend a {genre} book"
13+
14+
15+
@mistral.call(
16+
"mistral-large-latest",
17+
client=Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
18+
)
19+
async def recommend_book_async(genre: str) -> str:
20+
return f"Recommend a {genre} book"
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1+
import os
2+
13
from mirascope.core import mistral, prompt_template
2-
from mistralai.client import MistralClient
4+
from mistralai import Mistral
35

46

5-
@mistral.call("mistral-large-latest", client=MistralClient())
7+
@mistral.call(
8+
"mistral-large-latest",
9+
client=Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
10+
)
611
@prompt_template("Recommend a {genre} book")
712
def recommend_book(genre: str): ...
13+
14+
15+
@mistral.call(
16+
"mistral-large-latest",
17+
client=Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
18+
)
19+
@prompt_template("Recommend a {genre} book")
20+
async def recommend_book_async(genre: str): ...
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import os
2+
13
from mirascope.core import BaseMessageParam, mistral
2-
from mistralai.client import MistralClient
4+
from mistralai import Mistral
35

46

57
@mistral.call("mistral-large-latest")
@@ -8,5 +10,5 @@ def recommend_book(genre: str) -> mistral.MistralDynamicConfig:
810
"messages": [
911
BaseMessageParam(role="user", content=f"Recommend a {genre} book")
1012
],
11-
"client": MistralClient(),
13+
"client": Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
1214
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import os
2+
13
from mirascope.core import Messages, mistral
2-
from mistralai.client import MistralClient
4+
from mistralai import Mistral
35

46

57
@mistral.call("mistral-large-latest")
68
def recommend_book(genre: str) -> mistral.MistralDynamicConfig:
79
return {
810
"messages": [Messages.User(f"Recommend a {genre} book")],
9-
"client": MistralClient(),
11+
"client": Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
1012
}

0 commit comments

Comments
 (0)