mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2024-10-01 01:06:10 -04:00
Fix models not getting downloaded in Python bindings (#1262)
- custom callbacks & session improvements PR (v1.0.6) had one too many checks - remove the problematic config['url'] check - add a crude test - fixes #1261
This commit is contained in:
parent
2befff83d6
commit
6431d46776
@ -168,10 +168,6 @@ class GPT4All:
|
||||
|
||||
# If model file does not exist, download
|
||||
elif allow_download:
|
||||
# Make sure valid model filename before attempting download
|
||||
|
||||
if "url" not in config:
|
||||
raise ValueError(f"Model filename not in model list: {model_filename}")
|
||||
url = config.pop("url", None)
|
||||
|
||||
config["path"] = GPT4All.download_model(
|
||||
|
@ -1,5 +1,6 @@
|
||||
import sys
|
||||
from io import StringIO
|
||||
from pathlib import Path
|
||||
|
||||
from gpt4all import GPT4All, Embed4All
|
||||
import time
|
||||
@ -114,3 +115,15 @@ def test_empty_embedding():
|
||||
embedder = Embed4All()
|
||||
with pytest.raises(ValueError):
|
||||
output = embedder.embed(text)
|
||||
|
||||
def test_download_model(tmp_path: Path):
|
||||
import gpt4all.gpt4all
|
||||
old_default_dir = gpt4all.gpt4all.DEFAULT_MODEL_DIRECTORY
|
||||
gpt4all.gpt4all.DEFAULT_MODEL_DIRECTORY = tmp_path # temporary pytest directory to ensure a download happens
|
||||
try:
|
||||
model = GPT4All(model_name='ggml-all-MiniLM-L6-v2-f16.bin')
|
||||
model_path = tmp_path / model.config['filename']
|
||||
assert model_path.absolute() == Path(model.config['path']).absolute()
|
||||
assert model_path.stat().st_size == int(model.config['filesize'])
|
||||
finally:
|
||||
gpt4all.gpt4all.DEFAULT_MODEL_DIRECTORY = old_default_dir
|
||||
|
Loading…
Reference in New Issue
Block a user