From 5c59712d252c7ac1e7d3b6d7e0eff3291aa05dff Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Sun, 9 Jun 2024 18:51:19 +0200 Subject: [PATCH 1/3] Add support for MistralAI --- README.md | 2 +- docs/source/index.md | 2 +- docs/source/users/index.md | 1 + .../partner_providers/mistralai.py | 20 +++++++++++++++++++ packages/jupyter-ai-magics/pyproject.toml | 4 +++- 5 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 packages/jupyter-ai-magics/jupyter_ai_magics/partner_providers/mistralai.py diff --git a/README.md b/README.md index a1a71424b..f6d9c3faf 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ in JupyterLab and the Jupyter Notebook. More specifically, Jupyter AI offers: This works anywhere the IPython kernel runs (JupyterLab, Jupyter Notebook, Google Colab, Kaggle, VSCode, etc.). * A native chat UI in JupyterLab that enables you to work with generative AI as a conversational assistant. * Support for a wide range of generative model providers, including AI21, Anthropic, AWS, Cohere, - Gemini, Hugging Face, NVIDIA, and OpenAI. + Gemini, Hugging Face, MistralAI, NVIDIA, and OpenAI. * Local model support through GPT4All, enabling use of generative AI models on consumer grade machines with ease and privacy. diff --git a/docs/source/index.md b/docs/source/index.md index a2c060f6a..d3d29164e 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -8,7 +8,7 @@ in JupyterLab and the Jupyter Notebook. More specifically, Jupyter AI offers: This works anywhere the IPython kernel runs (JupyterLab, Jupyter Notebook, Google Colab, VSCode, etc.). * A native chat UI in JupyterLab that enables you to work with generative AI as a conversational assistant. * Support for a wide range of generative model providers and models - (AI21, Anthropic, Cohere, Gemini, Hugging Face, OpenAI, SageMaker, NVIDIA, etc.). + (AI21, Anthropic, Cohere, Gemini, Hugging Face, MistralAI, OpenAI, SageMaker, NVIDIA, etc.). A screenshot of Jupyter AI showing the chat interface and the magic commands Date: Sun, 9 Jun 2024 19:51:23 +0200 Subject: [PATCH 2/3] embeddings --- .../partner_providers/mistralai.py | 16 ++++++++++++++-- packages/jupyter-ai-magics/pyproject.toml | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/jupyter-ai-magics/jupyter_ai_magics/partner_providers/mistralai.py b/packages/jupyter-ai-magics/jupyter_ai_magics/partner_providers/mistralai.py index 913a73f15..48261a70e 100644 --- a/packages/jupyter-ai-magics/jupyter_ai_magics/partner_providers/mistralai.py +++ b/packages/jupyter-ai-magics/jupyter_ai_magics/partner_providers/mistralai.py @@ -1,5 +1,7 @@ from jupyter_ai_magics.providers import BaseProvider, EnvAuthStrategy -from langchain_mistralai import ChatMistralAI +from langchain_mistralai import ChatMistralAI, MistralAIEmbeddings + +from ..embedding_providers import BaseEmbeddingsProvider class MistralAIProvider(BaseProvider, ChatMistralAI): @@ -12,9 +14,19 @@ class MistralAIProvider(BaseProvider, ChatMistralAI): "mistral-small-latest", "mistral-medium-latest", "mistral-large-latest", - "mistral-embed", "codestral-latest", ] model_id_key = "model" auth_strategy = EnvAuthStrategy(name="MISTRAL_API_KEY") pypi_package_deps = ["langchain-mistralai"] + + +class MistralAIEmbeddingsProvider(BaseEmbeddingsProvider, MistralAIEmbeddings): + id = "mistralai" + name = "MistralAI" + models = [ + "mistral-embed", + ] + model_id_key = "model" + pypi_package_deps = ["langchain-mistralai"] + auth_strategy = EnvAuthStrategy(name="MISTRAL_API_KEY") \ No newline at end of file diff --git a/packages/jupyter-ai-magics/pyproject.toml b/packages/jupyter-ai-magics/pyproject.toml index b675780e7..941d17ba6 100644 --- a/packages/jupyter-ai-magics/pyproject.toml +++ b/packages/jupyter-ai-magics/pyproject.toml @@ -73,6 +73,7 @@ mistralai = "jupyter_ai_magics.partner_providers.mistralai:MistralAIProvider" [project.entry-points."jupyter_ai.embeddings_model_providers"] bedrock = "jupyter_ai_magics:BedrockEmbeddingsProvider" cohere = "jupyter_ai_magics:CohereEmbeddingsProvider" +mistralai = "jupyter_ai_magics.partner_providers.mistralai:MistralAIEmbeddingsProvider" gpt4all = "jupyter_ai_magics:GPT4AllEmbeddingsProvider" huggingface_hub = "jupyter_ai_magics:HfHubEmbeddingsProvider" openai = "jupyter_ai_magics.partner_providers.openai:OpenAIEmbeddingsProvider" From 5658fbeec45ac4df9d2b43a09e57fd24a8f51189 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Sun, 9 Jun 2024 19:51:50 +0200 Subject: [PATCH 3/3] lint --- .../jupyter_ai_magics/partner_providers/mistralai.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jupyter-ai-magics/jupyter_ai_magics/partner_providers/mistralai.py b/packages/jupyter-ai-magics/jupyter_ai_magics/partner_providers/mistralai.py index 48261a70e..6d7f84006 100644 --- a/packages/jupyter-ai-magics/jupyter_ai_magics/partner_providers/mistralai.py +++ b/packages/jupyter-ai-magics/jupyter_ai_magics/partner_providers/mistralai.py @@ -29,4 +29,4 @@ class MistralAIEmbeddingsProvider(BaseEmbeddingsProvider, MistralAIEmbeddings): ] model_id_key = "model" pypi_package_deps = ["langchain-mistralai"] - auth_strategy = EnvAuthStrategy(name="MISTRAL_API_KEY") \ No newline at end of file + auth_strategy = EnvAuthStrategy(name="MISTRAL_API_KEY")