mirror of
https://github.com/nomic-ai/gpt4all
synced 2024-11-18 03:25:46 +00:00
one funcion to append .bin suffix
This commit is contained in:
parent
659244f0a2
commit
a6f3e94458
@ -14,6 +14,7 @@ from . import pyllmodel
|
||||
# TODO: move to config
|
||||
DEFAULT_MODEL_DIRECTORY = os.path.join(str(Path.home()), ".cache", "gpt4all").replace("\\", "\\\\")
|
||||
|
||||
|
||||
class GPT4All():
|
||||
"""Python API for retrieving and interacting with GPT4All models.
|
||||
|
||||
@ -58,7 +59,8 @@ class GPT4All():
|
||||
return requests.get("https://gpt4all.io/models/models.json").json()
|
||||
|
||||
@staticmethod
|
||||
def retrieve_model(model_name: str, model_path: str = None, allow_download: bool = True, verbose: bool = True) -> str:
|
||||
def retrieve_model(model_name: str, model_path: str = None, allow_download: bool = True,
|
||||
verbose: bool = True) -> str:
|
||||
"""
|
||||
Find model file, and if it doesn't exist, download the model.
|
||||
|
||||
@ -73,9 +75,7 @@ class GPT4All():
|
||||
Model file destination.
|
||||
"""
|
||||
|
||||
model_filename = model_name
|
||||
if not model_filename.endswith(".bin"):
|
||||
model_filename += ".bin"
|
||||
model_filename = append_bin_suffix_if_missing(model_name)
|
||||
|
||||
# Validate download directory
|
||||
if model_path is None:
|
||||
@ -221,7 +221,7 @@ class GPT4All():
|
||||
"model": self.model.model_name,
|
||||
"usage": {"prompt_tokens": len(full_prompt),
|
||||
"completion_tokens": len(response),
|
||||
"total_tokens" : len(full_prompt) + len(response)},
|
||||
"total_tokens": len(full_prompt) + len(response)},
|
||||
"choices": [
|
||||
{
|
||||
"message": {
|
||||
@ -284,8 +284,7 @@ class GPT4All():
|
||||
# This needs to be updated for each new model
|
||||
|
||||
# NOTE: We are doing this preprocessing a lot, maybe there's a better way to organize
|
||||
if ".bin" not in model_name:
|
||||
model_name += ".bin"
|
||||
model_name = append_bin_suffix_if_missing(model_name)
|
||||
|
||||
GPTJ_MODELS = [
|
||||
"ggml-gpt4all-j-v1.3-groovy.bin",
|
||||
@ -320,3 +319,9 @@ class GPT4All():
|
||||
f"If this is a custom model, make sure to specify a valid model_type.\n")
|
||||
|
||||
raise ValueError(err_msg)
|
||||
|
||||
|
||||
def append_bin_suffix_if_missing(model_name):
|
||||
if not model_name.endswith(".bin"):
|
||||
model_name += ".bin"
|
||||
return model_name
|
||||
|
Loading…
Reference in New Issue
Block a user