Skip to content

Commit

Permalink
python: support Path in GPT4All.__init__ (#1462)
Browse files Browse the repository at this point in the history
  • Loading branch information
cebtenzzre authored Oct 11, 2023
1 parent 0436171 commit f81b4b4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions gpt4all-bindings/python/gpt4all/gpt4all.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
Python only API for running all GPT4All models.
"""
from __future__ import annotations

import os
import sys
import time
Expand Down Expand Up @@ -60,7 +62,7 @@ class GPT4All:
def __init__(
self,
model_name: str,
model_path: Optional[str] = None,
model_path: Optional[Union[str, os.PathLike[str]]] = None,
model_type: Optional[str] = None,
allow_download: bool = True,
n_threads: Optional[int] = None,
Expand Down Expand Up @@ -115,7 +117,7 @@ def list_models() -> List[ConfigType]:
@staticmethod
def retrieve_model(
model_name: str,
model_path: Optional[str] = None,
model_path: Optional[Union[str, os.PathLike[str]]] = None,
allow_download: bool = True,
verbose: bool = True,
) -> ConfigType:
Expand Down Expand Up @@ -160,7 +162,7 @@ def retrieve_model(
)
model_path = DEFAULT_MODEL_DIRECTORY
else:
model_path = model_path.replace("\\", "\\\\")
model_path = str(model_path).replace("\\", "\\\\")

if not os.path.exists(model_path):
raise ValueError(f"Invalid model directory: {model_path}")
Expand All @@ -185,7 +187,7 @@ def retrieve_model(
@staticmethod
def download_model(
model_filename: str,
model_path: str,
model_path: Union[str, os.PathLike[str]],
verbose: bool = True,
url: Optional[str] = None,
) -> str:
Expand Down

0 comments on commit f81b4b4

Please sign in to comment.