Skip to content

Commit 872d816

Browse files
authored
Merge branch 'jupyterlab:main' into selected-model-not-present
2 parents 9c22c77 + 56b189c commit 872d816

File tree

6 files changed

+56
-6
lines changed

6 files changed

+56
-6
lines changed

docs/source/users/index.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ Jupyter AI supports the following model providers:
120120
| Bedrock | `bedrock` | N/A | `boto3` |
121121
| Bedrock (chat) | `bedrock-chat` | N/A | `boto3` |
122122
| Cohere | `cohere` | `COHERE_API_KEY` | `cohere` |
123+
| GPT4All | `gpt4all` | N/A | `gpt4all` |
123124
| Hugging Face Hub | `huggingface_hub` | `HUGGINGFACEHUB_API_TOKEN` | `huggingface_hub`, `ipywidgets`, `pillow` |
124125
| OpenAI | `openai` | `OPENAI_API_KEY` | `openai` |
125126
| OpenAI (chat) | `openai-chat` | `OPENAI_API_KEY` | `openai` |
@@ -352,13 +353,25 @@ response. In this example, the endpoint returns an object with the schema
352353
### GPT4All usage (early-stage)
353354

354355
Currently, we offer experimental support for GPT4All. To get started, first
355-
decide which models you will use. We currently offer three models from GPT4All:
356+
decide which models you will use. We currently offer the following models from GPT4All:
356357

357358
| Model name | Model size | Model bin URL |
358-
|------------------------------|------------|------------------------------------------------------------|
359-
| `ggml-gpt4all-l13b-snoozy` | 7.6 GB | `http://gpt4all.io/models/ggml-gpt4all-l13b-snoozy.bin` |
360-
| `ggml-gpt4all-j-v1.2-jazzy` | 3.8 GB | `https://gpt4all.io/models/ggml-gpt4all-j-v1.2-jazzy.bin` |
361-
| `ggml-gpt4all-j-v1.3-groovy` | 3.8 GB | `https://gpt4all.io/models/ggml-gpt4all-j-v1.3-groovy.bin` |
359+
|---------------------------------|------------|------------------------------------------------------------|
360+
| `ggml-gpt4all-l13b-snoozy` | 7.6 GB | `http://gpt4all.io/models/ggml-gpt4all-l13b-snoozy.bin` |
361+
| `ggml-gpt4all-j-v1.2-jazzy` | 3.8 GB | `https://gpt4all.io/models/ggml-gpt4all-j-v1.2-jazzy.bin` |
362+
| `ggml-gpt4all-j-v1.3-groovy` | 3.8 GB | `https://gpt4all.io/models/ggml-gpt4all-j-v1.3-groovy.bin` |
363+
| `mistral-7b-openorca.Q4_0` | 3.8 GB | `https://gpt4all.io/models/gguf/mistral-7b-openorca.Q4_0.gguf` |
364+
| `mistral-7b-instruct-v0.1.Q4_0` | 3.8 GB | `https://gpt4all.io/models/gguf/mistral-7b-instruct-v0.1.Q4_0.gguf` |
365+
| `gpt4all-falcon-q4_0` | 3.9 GB | `https://gpt4all.io/models/gguf/gpt4all-falcon-q4_0.gguf` |
366+
| `wizardlm-13b-v1.2.Q4_0` | 6.9 GB | `https://gpt4all.io/models/gguf/wizardlm-13b-v1.2.Q4_0.gguf` |
367+
| `nous-hermes-llama2-13b.Q4_0` | 6.9 GB | `https://gpt4all.io/models/gguf/nous-hermes-llama2-13b.Q4_0.gguf` |
368+
| `gpt4all-13b-snoozy-q4_0` | 6.9 GB | `https://gpt4all.io/models/gguf/gpt4all-13b-snoozy-q4_0.gguf` |
369+
| `mpt-7b-chat-merges-q4_0` | 3.5 GB | `https://gpt4all.io/models/gguf/mpt-7b-chat-merges-q4_0.gguf` |
370+
| `orca-mini-3b-gguf2-q4_0` | 1.8 GB | `https://gpt4all.io/models/gguf/orca-mini-3b-gguf2-q4_0.gguf` |
371+
| `starcoder-q4_0` | 8.4 GB | `https://gpt4all.io/models/gguf/starcoder-q4_0.gguf` |
372+
| `rift-coder-v0-7b-q4_0` | 3.6 GB | `https://gpt4all.io/models/gguf/rift-coder-v0-7b-q4_0.gguf` |
373+
| `all-MiniLM-L6-v2-f16` | 44 MB | `https://gpt4all.io/models/gguf/all-MiniLM-L6-v2-f16.gguf` |
374+
| `em_german_mistral_v01.Q4_0` | 3.8 GB | `https://huggingface.co/TheBloke/em_german_mistral_v01-GGUF/resolve/main/em_german_mistral_v01.Q4_0.gguf` |
362375

363376

364377
Note that each model comes with its own license, and that users are themselves

packages/jupyter-ai-magics/jupyter_ai_magics/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from .embedding_providers import (
55
BedrockEmbeddingsProvider,
66
CohereEmbeddingsProvider,
7+
GPT4AllEmbeddingsProvider,
78
HfHubEmbeddingsProvider,
89
OpenAIEmbeddingsProvider,
910
)

packages/jupyter-ai-magics/jupyter_ai_magics/embedding_providers.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from typing import ClassVar, List
23

34
from jupyter_ai_magics.providers import (
@@ -9,6 +10,7 @@
910
from langchain.embeddings import (
1011
BedrockEmbeddings,
1112
CohereEmbeddings,
13+
GPT4AllEmbeddings,
1214
HuggingFaceHubEmbeddings,
1315
OpenAIEmbeddings,
1416
)
@@ -103,3 +105,25 @@ class BedrockEmbeddingsProvider(BaseEmbeddingsProvider, BedrockEmbeddings):
103105
model_id_key = "model_id"
104106
pypi_package_deps = ["boto3"]
105107
auth_strategy = AwsAuthStrategy()
108+
109+
110+
class GPT4AllEmbeddingsProvider(BaseEmbeddingsProvider, GPT4AllEmbeddings):
111+
def __init__(self, **kwargs):
112+
from gpt4all import GPT4All
113+
114+
model_name = kwargs.get("model_id").split(":")[-1]
115+
116+
# GPT4AllEmbeddings doesn't allow any kwargs at the moment
117+
# This will cause the class to start downloading the model
118+
# if the model file is not present. Calling retrieve_model
119+
# here will throw an exception if the file is not present.
120+
GPT4All.retrieve_model(model_name=model_name, allow_download=False)
121+
122+
kwargs["allow_download"] = False
123+
super().__init__(**kwargs)
124+
125+
id = "gpt4all"
126+
name = "GPT4All Embeddings"
127+
models = ["all-MiniLM-L6-v2-f16"]
128+
model_id_key = "model_id"
129+
pypi_package_deps = ["gpt4all"]

packages/jupyter-ai-magics/jupyter_ai_magics/providers.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,17 @@ def __init__(self, **kwargs):
342342
"ggml-gpt4all-j-v1.3-groovy",
343343
# this one needs llama backend and has licence restriction
344344
"ggml-gpt4all-l13b-snoozy",
345+
"mistral-7b-openorca.Q4_0",
346+
"mistral-7b-instruct-v0.1.Q4_0",
347+
"gpt4all-falcon-q4_0",
348+
"wizardlm-13b-v1.2.Q4_0",
349+
"nous-hermes-llama2-13b.Q4_0",
350+
"gpt4all-13b-snoozy-q4_0",
351+
"mpt-7b-chat-merges-q4_0",
352+
"orca-mini-3b-gguf2-q4_0",
353+
"starcoder-q4_0",
354+
"rift-coder-v0-7b-q4_0",
355+
"em_german_mistral_v01.Q4_0",
345356
]
346357
model_id_key = "model"
347358
pypi_package_deps = ["gpt4all"]

packages/jupyter-ai-magics/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ amazon-bedrock-chat = "jupyter_ai_magics:BedrockChatProvider"
7272
[project.entry-points."jupyter_ai.embeddings_model_providers"]
7373
bedrock = "jupyter_ai_magics:BedrockEmbeddingsProvider"
7474
cohere = "jupyter_ai_magics:CohereEmbeddingsProvider"
75+
gpt4all = "jupyter_ai_magics:GPT4AllEmbeddingsProvider"
7576
huggingface_hub = "jupyter_ai_magics:HfHubEmbeddingsProvider"
7677
openai = "jupyter_ai_magics:OpenAIEmbeddingsProvider"
7778

packages/jupyter-ai/jupyter_ai/chat_handlers/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ async def handle_exc(self, e: Exception, message: HumanChatMessage):
6868
implementation is provided, however chat handlers (subclasses) should
6969
implement this method to provide a more helpful error response.
7070
"""
71-
self._default_handle_exc(e, message)
71+
await self._default_handle_exc(e, message)
7272

7373
async def _default_handle_exc(self, e: Exception, message: HumanChatMessage):
7474
"""

0 commit comments

Comments
 (0)