Skip to content

Commit e214ee7

Browse files
authored
Add support for MistralAI (#823)
* Add support for MistralAI * embeddings * lint
1 parent ab3e9eb commit e214ee7

File tree

5 files changed

+39
-3
lines changed

5 files changed

+39
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ in JupyterLab and the Jupyter Notebook. More specifically, Jupyter AI offers:
1010
This works anywhere the IPython kernel runs (JupyterLab, Jupyter Notebook, Google Colab, Kaggle, VSCode, etc.).
1111
* A native chat UI in JupyterLab that enables you to work with generative AI as a conversational assistant.
1212
* Support for a wide range of generative model providers, including AI21, Anthropic, AWS, Cohere,
13-
Gemini, Hugging Face, NVIDIA, and OpenAI.
13+
Gemini, Hugging Face, MistralAI, NVIDIA, and OpenAI.
1414
* Local model support through GPT4All, enabling use of generative AI models on consumer grade machines
1515
with ease and privacy.
1616

docs/source/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ in JupyterLab and the Jupyter Notebook. More specifically, Jupyter AI offers:
88
This works anywhere the IPython kernel runs (JupyterLab, Jupyter Notebook, Google Colab, VSCode, etc.).
99
* A native chat UI in JupyterLab that enables you to work with generative AI as a conversational assistant.
1010
* Support for a wide range of generative model providers and models
11-
(AI21, Anthropic, Cohere, Gemini, Hugging Face, OpenAI, SageMaker, NVIDIA, etc.).
11+
(AI21, Anthropic, Cohere, Gemini, Hugging Face, MistralAI, OpenAI, SageMaker, NVIDIA, etc.).
1212

1313
<img src="_static/jupyter-ai-screenshot.png"
1414
alt='A screenshot of Jupyter AI showing the chat interface and the magic commands'

docs/source/users/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ Jupyter AI supports the following model providers:
148148
| Gemini | `gemini` | `GOOGLE_API_KEY` | `langchain-google-genai` |
149149
| GPT4All | `gpt4all` | N/A | `gpt4all` |
150150
| Hugging Face Hub | `huggingface_hub` | `HUGGINGFACEHUB_API_TOKEN` | `huggingface_hub`, `ipywidgets`, `pillow` |
151+
| MistralAI | `mistralai` | `MISTRAL_API_KEY` | `langchain-mistralai` |
151152
| NVIDIA | `nvidia-chat` | `NVIDIA_API_KEY` | `langchain_nvidia_ai_endpoints` |
152153
| OpenAI | `openai` | `OPENAI_API_KEY` | `langchain-openai` |
153154
| OpenAI (chat) | `openai-chat` | `OPENAI_API_KEY` | `langchain-openai` |
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from jupyter_ai_magics.providers import BaseProvider, EnvAuthStrategy
2+
from langchain_mistralai import ChatMistralAI, MistralAIEmbeddings
3+
4+
from ..embedding_providers import BaseEmbeddingsProvider
5+
6+
7+
class MistralAIProvider(BaseProvider, ChatMistralAI):
8+
id = "mistralai"
9+
name = "MistralAI"
10+
models = [
11+
"open-mistral-7b",
12+
"open-mixtral-8x7b",
13+
"open-mixtral-8x22b",
14+
"mistral-small-latest",
15+
"mistral-medium-latest",
16+
"mistral-large-latest",
17+
"codestral-latest",
18+
]
19+
model_id_key = "model"
20+
auth_strategy = EnvAuthStrategy(name="MISTRAL_API_KEY")
21+
pypi_package_deps = ["langchain-mistralai"]
22+
23+
24+
class MistralAIEmbeddingsProvider(BaseEmbeddingsProvider, MistralAIEmbeddings):
25+
id = "mistralai"
26+
name = "MistralAI"
27+
models = [
28+
"mistral-embed",
29+
]
30+
model_id_key = "model"
31+
pypi_package_deps = ["langchain-mistralai"]
32+
auth_strategy = EnvAuthStrategy(name="MISTRAL_API_KEY")

packages/jupyter-ai-magics/pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ all = [
4141
"huggingface_hub",
4242
"ipywidgets",
4343
"langchain_anthropic",
44+
"langchain-mistralai",
4445
"langchain_nvidia_ai_endpoints",
46+
"langchain-google-genai",
4547
"langchain-openai",
4648
"pillow",
4749
"boto3",
4850
"qianfan",
4951
"together",
50-
"langchain-google-genai",
5152
]
5253

5354
[project.entry-points."jupyter_ai.model_providers"]
@@ -67,10 +68,12 @@ qianfan = "jupyter_ai_magics:QianfanProvider"
6768
nvidia-chat = "jupyter_ai_magics.partner_providers.nvidia:ChatNVIDIAProvider"
6869
together-ai = "jupyter_ai_magics:TogetherAIProvider"
6970
gemini = "jupyter_ai_magics.partner_providers.gemini:GeminiProvider"
71+
mistralai = "jupyter_ai_magics.partner_providers.mistralai:MistralAIProvider"
7072

7173
[project.entry-points."jupyter_ai.embeddings_model_providers"]
7274
bedrock = "jupyter_ai_magics:BedrockEmbeddingsProvider"
7375
cohere = "jupyter_ai_magics:CohereEmbeddingsProvider"
76+
mistralai = "jupyter_ai_magics.partner_providers.mistralai:MistralAIEmbeddingsProvider"
7477
gpt4all = "jupyter_ai_magics:GPT4AllEmbeddingsProvider"
7578
huggingface_hub = "jupyter_ai_magics:HfHubEmbeddingsProvider"
7679
openai = "jupyter_ai_magics.partner_providers.openai:OpenAIEmbeddingsProvider"

0 commit comments

Comments
 (0)