Concise model matching

This commit is contained in:
Konstantin Gukov 2023-05-25 17:29:13 +02:00 committed by Richard Guo
parent c1f3dd310c
commit a067f38544

View File

@ -96,12 +96,8 @@ class GPT4All():
# If model file does not exist, download # If model file does not exist, download
elif allow_download: elif allow_download:
# Make sure valid model filename before attempting download # Make sure valid model filename before attempting download
model_match = False available_models = GPT4All.list_models()
for item in GPT4All.list_models(): if model_filename not in (m["filename"] for m in available_models):
if model_filename == item["filename"]:
model_match = True
break
if not model_match:
raise ValueError(f"Model filename not in model list: {model_filename}") raise ValueError(f"Model filename not in model list: {model_filename}")
return GPT4All.download_model(model_filename, model_path) return GPT4All.download_model(model_filename, model_path)
else: else: