mistral-gradio
is a Python package that makes it very easy for developers to create machine learning apps that are powered by Mistral's API.
Installation
You can install mistral-gradio directly using pip:
pip install mistral-gradio
That's it!
Basic Usage
Just like if you were to use the mistralai API, you should first save your Mistral API key to this environment variable:
export MISTRAL_API_KEY=<your token>
Then in a Python file, write:
import gradio as gr
import mistral_gradio
gr.load(
name='mistral-large-latest',
src=mistral_gradio.registry,
).launch()
Run the Python file, and you should see a Gradio Interface connected to the model on Mistral!
Customization
Once you can create a Gradio UI from an Mistral endpoint, you can customize it by setting your own input and output components, or any other arguments to gr.Interface. For example, the screenshot below was generated with:
import gradio as gr
import mistral_gradio
gr.load(
name='mistral-large-latest',
src=mistral_gradio.registry,
title='Mistral-Gradio Integration',
description="Chat with Mistral's large model.",
examples=["Explain quantum gravity to a 5-year old.", "How many R are there in the word Strawberry?"]
).launch()
Composition
Or use your loaded Interface within larger Gradio Web UIs, e.g.
import gradio as gr
import mistral_gradio
with gr.Blocks() as demo:
with gr.Tab("mistral-large"):
gr.load('mistral-large-latest', src=mistral_gradio.registry)
with gr.Tab("mistral-medium"):
gr.load('mistral-medium-latest', src=mistral_gradio.registry)
demo.launch()
Under the Hood
The mistral-gradio Python library has two dependencies: mistralai and gradio. It defines a "registry" function mistral_gradio.registry, which takes in a model name and returns a Gradio app.
Supported Models in Mistral
All chat API models supported by Mistral are compatible with this integration. For a comprehensive list of available models and their specifications, please refer to the Mistral Models documentation.
Note: if you are getting a 401 authentication error, then the Mistral API Client is not able to get the API token from the environment variable. This happened to me as well, in which case save it in your Python session, like this:
import os
os.environ["MISTRAL_API_KEY"] = ...
Metadata
Release files for mistral-gradio 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mistral_gradio-0.0.2.tar.gz | 159.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mistral_gradio-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 163.7 kB
Release files / mistral_gradio-0.0.2.tar.gz
| Download URL | mistral_gradio-0.0.2.tar.gz |
|---|---|
| Size | 159.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f015f040274e9c1e1908f78270d4464060bd03973d78de7917892981a556b69d
|
|
BLAKE2b-256 checksum How to use checksums |
ec02d6b670ece4a314b864bd882fc59eb77f8a06eb880708dfe2173b75fc2b69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.6
|
Release files / mistral_gradio-0.0.2-py3-none-any.whl
| Download URL | mistral_gradio-0.0.2-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
19f9c93a7cb10bdd848c886502e4e0dd57fdb2bd4eb3e9630394b8331b6d5d7b
|
|
BLAKE2b-256 checksum How to use checksums |
f682ad8117622c57d3fd526e190af1f1bb1d0a889bd9a9be55fd5ffc1d6d21bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.6
|
Security for mistral-gradio 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.