-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a util for loading Mistral API key
- Loading branch information
1 parent
6602329
commit 63bcfb8
Showing
9 changed files
with
23 additions
and
24 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
examples/learn/calls/basic_usage/mistral/official_sdk_call.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
examples/learn/calls/custom_client/mistral/base_message_param.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
import os | ||
|
||
from mirascope.core import BaseMessageParam, mistral | ||
from mistralai import Mistral | ||
|
||
|
||
@mistral.call( | ||
"mistral-large-latest", | ||
client=Mistral(api_key=os.environ.get("MISTRAL_API_KEY", "")), | ||
client=Mistral(api_key=mistral.load_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.get("MISTRAL_API_KEY", "")), | ||
client=Mistral(api_key=mistral.load_api_key()), | ||
) | ||
async def recommend_book_async(genre: str) -> list[BaseMessageParam]: | ||
return [BaseMessageParam(role="user", content=f"Recommend a {genre} book")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
import os | ||
|
||
from mirascope.core import Messages, mistral | ||
from mistralai import Mistral | ||
|
||
|
||
@mistral.call( | ||
"mistral-large-latest", | ||
client=Mistral(api_key=os.environ.get("MISTRAL_API_KEY", "")), | ||
client=Mistral(api_key=mistral.load_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.get("MISTRAL_API_KEY", "")), | ||
client=Mistral(api_key=mistral.load_api_key()), | ||
) | ||
async def recommend_book_async(genre: str) -> Messages.Type: | ||
return Messages.User(f"Recommend a {genre} book") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
import os | ||
|
||
from mirascope.core import mistral | ||
from mistralai import Mistral | ||
|
||
|
||
@mistral.call( | ||
"mistral-large-latest", | ||
client=Mistral(api_key=os.environ.get("MISTRAL_API_KEY", "")), | ||
client=Mistral(api_key=mistral.load_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.get("MISTRAL_API_KEY", "")), | ||
client=Mistral(api_key=mistral.load_api_key()), | ||
) | ||
async def recommend_book_async(genre: str) -> str: | ||
return f"Recommend a {genre} book" |
6 changes: 2 additions & 4 deletions
6
examples/learn/calls/custom_client/mistral/string_template.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
import os | ||
|
||
from mirascope.core import mistral, prompt_template | ||
from mistralai import Mistral | ||
|
||
|
||
@mistral.call( | ||
"mistral-large-latest", | ||
client=Mistral(api_key=os.environ.get("MISTRAL_API_KEY", "")), | ||
client=Mistral(api_key=mistral.load_api_key()), | ||
) | ||
@prompt_template("Recommend a {genre} book") | ||
def recommend_book(genre: str): ... | ||
|
||
|
||
@mistral.call( | ||
"mistral-large-latest", | ||
client=Mistral(api_key=os.environ.get("MISTRAL_API_KEY", "")), | ||
client=Mistral(api_key=mistral.load_api_key()), | ||
) | ||
@prompt_template("Recommend a {genre} book") | ||
async def recommend_book_async(genre: str): ... |
7 changes: 3 additions & 4 deletions
7
examples/learn/response_models/basic_usage/mistral/official_sdk.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import os | ||
|
||
|
||
def load_api_key() -> str: | ||
"""Load the API key from the standard environment variable.""" | ||
return os.environ.get("MISTRAL_API_KEY", "") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters