Skip to content

Commit

Permalink
Merge pull request #712 from Mirascope/release/v1.10
Browse files Browse the repository at this point in the history
Release/v1.10
  • Loading branch information
willbakst authored Nov 22, 2024
2 parents 5a5473c + 61f2a14 commit 4a73f73
Show file tree
Hide file tree
Showing 58 changed files with 919 additions and 440 deletions.
2 changes: 1 addition & 1 deletion docs/WELCOME.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Make your first call to an LLM to extract the title and author of a book from th
{% if provider == "Anthropic" %}
```python hl_lines="19-38 43"
{% elif provider == "Mistral" %}
```python hl_lines="19-40 45"
```python hl_lines="21-46 51"
{% elif provider == "Gemini" %}
```python hl_lines="19-57 62"
{% elif provider == "Cohere" %}
Expand Down
2 changes: 1 addition & 1 deletion docs/WHY.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Let's compare structured outputs using Mirascope vs. the official SDKs:
{% if provider == "Anthropic" %}
```python hl_lines="19-38 43"
{% elif provider == "Mistral" %}
```python hl_lines="19-40 45"
```python hl_lines="21-46 51"
{% elif provider == "Gemini" %}
```python hl_lines="19-57 62"
{% elif provider == "Cohere" %}
Expand Down
12 changes: 9 additions & 3 deletions docs/learn/async.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,14 @@ __Decorator Parameter:__

{% if provider == "LiteLLM" %}
```python
{% elif provider in ["OpenAI", "Mistral", "Vertex AI"] %}
{% elif provider in ["OpenAI", "Vertex AI"] %}
```python hl_lines="2 5"
{% elif provider == "Azure AI" %}
```python hl_lines="1-2 8-10"
{% elif provider == "Bedrock" %}
```python hl_lines="7-10 14"
{% elif provider == "Mistral" %}
```python hl_lines="4 8"
{% else %}
```python hl_lines="1 5"
{% endif %}
Expand All @@ -203,12 +205,14 @@ __Dynamic Configuration:__

{% if provider == "LiteLLM" %}
```python
{% elif provider in ["OpenAI", "Mistral", "Vertex AI"] %}
{% elif provider in ["OpenAI", "Vertex AI"] %}
```python hl_lines="2 11"
{% elif provider == "Azure AI" %}
```python hl_lines="1-2 12-14"
{% elif provider == "Bedrock" %}
```python hl_lines="5-8 17"
{% elif provider == "Mistral" %}
```python hl_lines="4 15"
{% else %}
```python hl_lines="1 11"
{% endif %}
Expand All @@ -222,12 +226,14 @@ __Dynamic Configuration:__

{% if provider == "LiteLLM" %}
```python
{% elif provider in ["OpenAI", "Mistral", "Vertex AI"] %}
{% elif provider in ["OpenAI", "Vertex AI"] %}
```python hl_lines="2 9"
{% elif provider == "Azure AI" %}
```python hl_lines="1-2 10-12"
{% elif provider == "Bedrock" %}
```python hl_lines="5-8 15"
{% elif provider == "Mistral" %}
```python hl_lines="4 11"
{% else %}
```python hl_lines="1 9"
{% endif %}
Expand Down
10 changes: 9 additions & 1 deletion docs/learn/calls.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Let's take a look at a basic example using Mirascope vs. official provider SDKs:
```python hl_lines="5-9"
{% elif provider == "Azure AI" %}
```python hl_lines="11-18"
{% elif provider == "Mistral" %}
```python hl_lines="10-15"
{% else %}
```python hl_lines="7-11"
{% endif %}
Expand Down Expand Up @@ -365,12 +367,14 @@ You can pass a client to the `call` decorator using the `client` parameter:

{% if provider == "LiteLLM" %}
```python
{% elif provider in ["OpenAI", "Mistral", "Vertex AI"] %}
{% elif provider in ["OpenAI", "Vertex AI"] %}
```python hl_lines="2 5"
{% elif provider == "Azure AI" %}
```python hl_lines="1-2 8-10"
{% elif provider == "Bedrock" %}
```python hl_lines="1 6"
{% elif provider == "Mistral" %}
```python hl_lines="4 8"
{% else %}
```python hl_lines="1 5"
{% endif %}
Expand Down Expand Up @@ -398,6 +402,8 @@ You can also configure the client dynamically at runtime through the dynamic con
```python hl_lines="1-2 12-14"
{% elif provider == "Bedrock" %}
```python hl_lines="1 11"
{% elif provider == "Mistral" %}
```python hl_lines="4 13"
{% else %}
```python hl_lines="2 11"
{% endif %}
Expand All @@ -415,6 +421,8 @@ You can also configure the client dynamically at runtime through the dynamic con
```python hl_lines="1-2 10-11"
{% elif provider == "Bedrock" %}
```python hl_lines="1 11"
{% elif provider == "Mistral" %}
```python hl_lines="4 11"
{% else %}
```python hl_lines="2 9"
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion docs/learn/response_models.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Let's take a look at a basic example using Mirascope vs. official provider SDKs:
{% if provider == "Anthropic" %}
```python hl_lines="19-38 43"
{% elif provider == "Mistral" %}
```python hl_lines="19-40 45"
```python hl_lines="21-46 51"
{% elif provider == "Gemini" %}
```python hl_lines="19-57 62"
{% elif provider == "Cohere" %}
Expand Down
2 changes: 2 additions & 0 deletions docs/learn/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ Let's take a look at a basic example of each using Mirascope vs. official provid
```python hl_lines="16-22 31-43 45-47"
{% elif provider == "Vertex AI" %}
```python hl_lines="6-12 18-34 36-43"
{% elif provider == "Mistral" %}
```python hl_lines="10-16 23-36 38-44"
{% else %}
```python hl_lines="8-14 21-34 36-38"
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import os

from mirascope.core import BaseMessageParam, mistral
from mistralai.async_client import MistralAsyncClient
from mistralai import Mistral


@mistral.call("mistral-large-latest", client=MistralAsyncClient())
@mistral.call(
"mistral-large-latest", client=Mistral(api_key=os.environ["MISTRAL_API_KEY"])
)
async def recommend_book_async(genre: str) -> list[BaseMessageParam]:
return [BaseMessageParam(role="user", content=f"Recommend a {genre} book")]
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import os

from mirascope.core import Messages, mistral
from mistralai.async_client import MistralAsyncClient
from mistralai import Mistral


@mistral.call("mistral-large-latest", client=MistralAsyncClient())
@mistral.call(
"mistral-large-latest", client=Mistral(api_key=os.environ["MISTRAL_API_KEY"])
)
async def recommend_book_async(genre: str) -> Messages.Type:
return Messages.User(f"Recommend a {genre} book")
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import os

from mirascope.core import mistral
from mistralai.async_client import MistralAsyncClient
from mistralai import Mistral


@mistral.call("mistral-large-latest", client=MistralAsyncClient())
@mistral.call(
"mistral-large-latest", client=Mistral(api_key=os.environ["MISTRAL_API_KEY"])
)
async def recommend_book_async(genre: str) -> str:
return f"Recommend a {genre} book"
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import os

from mirascope.core import mistral, prompt_template
from mistralai.async_client import MistralAsyncClient
from mistralai import Mistral


@mistral.call("mistral-large-latest", client=MistralAsyncClient())
@mistral.call(
"mistral-large-latest", client=Mistral(api_key=os.environ["MISTRAL_API_KEY"])
)
@prompt_template("Recommend a {genre} book")
async def recommend_book_async(genre: str): ...
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import os

from mirascope.core import BaseMessageParam, mistral
from mistralai.async_client import MistralAsyncClient
from mistralai import Mistral


@mistral.call("mistral-large-latest")
async def recommend_book(genre: str) -> mistral.AsyncMistralDynamicConfig:
async def recommend_book(genre: str) -> mistral.MistralDynamicConfig:
return {
"messages": [
BaseMessageParam(role="user", content=f"Recommend a {genre} book")
],
"client": MistralAsyncClient(),
"client": Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import os

from mirascope.core import Messages, mistral
from mistralai.async_client import MistralAsyncClient
from mistralai import Mistral


@mistral.call("mistral-large-latest")
async def recommend_book(genre: str) -> mistral.AsyncMistralDynamicConfig:
async def recommend_book(genre: str) -> mistral.MistralDynamicConfig:
return {
"messages": [Messages.User(f"Recommend a {genre} book")],
"client": MistralAsyncClient(),
"client": Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import os

from mirascope.core import mistral, Messages
from mistralai.async_client import MistralAsyncClient
from mistralai import Mistral


@mistral.call("mistral-large-latest")
async def recommend_book(genre: str) -> mistral.AsyncMistralDynamicConfig:
async def recommend_book(genre: str) -> mistral.MistralDynamicConfig:
return {
"messages": [Messages.User(f"Recommend a {genre} book")],
"client": MistralAsyncClient(),
"client": Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import os

from mirascope.core import mistral, prompt_template
from mistralai.async_client import MistralAsyncClient
from mistralai import Mistral


@mistral.call("mistral-large-latest")
@prompt_template("Recommend a {genre} book")
async def recommend_book(genre: str) -> mistral.AsyncMistralDynamicConfig:
async def recommend_book(genre: str) -> mistral.MistralDynamicConfig:
return {
"client": MistralAsyncClient(),
"client": Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
}
14 changes: 9 additions & 5 deletions examples/learn/calls/basic_usage/mistral/official_sdk_call.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
from mistralai.client import MistralClient
import os
from typing import cast

client = MistralClient()
from mistralai import Mistral

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

def recommend_book(genre: str) -> str:
completion = client.chat(

def recommend_book(genre: str) -> str | None:
completion = client.chat.complete(
model="mistral-large-latest",
messages=[{"role": "user", "content": f"Recommend a {genre} book"}],
)
return completion.choices[0].message.content
if completion and (choices := completion.choices):
return cast(str, choices[0].message.content)


output = recommend_book("fantasy")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
import os

from mirascope.core import BaseMessageParam, mistral
from mistralai.client import MistralClient
from mistralai import Mistral


@mistral.call("mistral-large-latest", client=MistralClient())
@mistral.call(
"mistral-large-latest",
client=Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
)
def recommend_book(genre: str) -> list[BaseMessageParam]:
return [BaseMessageParam(role="user", content=f"Recommend a {genre} book")]


@mistral.call(
"mistral-large-latest",
client=Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
)
async def recommend_book_async(genre: str) -> list[BaseMessageParam]:
return [BaseMessageParam(role="user", content=f"Recommend a {genre} book")]
17 changes: 15 additions & 2 deletions examples/learn/calls/custom_client/decorator/mistral/messages.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
import os

from mirascope.core import Messages, mistral
from mistralai.client import MistralClient
from mistralai import Mistral


@mistral.call("mistral-large-latest", client=MistralClient())
@mistral.call(
"mistral-large-latest",
client=Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
)
def recommend_book(genre: str) -> Messages.Type:
return Messages.User(f"Recommend a {genre} book")


@mistral.call(
"mistral-large-latest",
client=Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
)
async def recommend_book_async(genre: str) -> Messages.Type:
return Messages.User(f"Recommend a {genre} book")
17 changes: 15 additions & 2 deletions examples/learn/calls/custom_client/decorator/mistral/shorthand.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
import os

from mirascope.core import mistral
from mistralai.client import MistralClient
from mistralai import Mistral


@mistral.call("mistral-large-latest", client=MistralClient())
@mistral.call(
"mistral-large-latest",
client=Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
)
def recommend_book(genre: str) -> str:
return f"Recommend a {genre} book"


@mistral.call(
"mistral-large-latest",
client=Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
)
async def recommend_book_async(genre: str) -> str:
return f"Recommend a {genre} book"
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
import os

from mirascope.core import mistral, prompt_template
from mistralai.client import MistralClient
from mistralai import Mistral


@mistral.call("mistral-large-latest", client=MistralClient())
@mistral.call(
"mistral-large-latest",
client=Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
)
@prompt_template("Recommend a {genre} book")
def recommend_book(genre: str): ...


@mistral.call(
"mistral-large-latest",
client=Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
)
@prompt_template("Recommend a {genre} book")
async def recommend_book_async(genre: str): ...
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os

from mirascope.core import BaseMessageParam, mistral
from mistralai.client import MistralClient
from mistralai import Mistral


@mistral.call("mistral-large-latest")
Expand All @@ -8,5 +10,5 @@ def recommend_book(genre: str) -> mistral.MistralDynamicConfig:
"messages": [
BaseMessageParam(role="user", content=f"Recommend a {genre} book")
],
"client": MistralClient(),
"client": Mistral(api_key=os.environ["MISTRAL_API_KEY"]),
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import os

from mirascope.core import Messages, mistral
from mistralai.client import MistralClient
from mistralai import Mistral


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

0 comments on commit 4a73f73

Please sign in to comment.