1
1
"""
2
2
Python only API for running all GPT4All models.
3
3
"""
4
+ from __future__ import annotations
5
+
4
6
import os
5
7
import sys
6
8
import time
@@ -60,7 +62,7 @@ class GPT4All:
60
62
def __init__ (
61
63
self ,
62
64
model_name : str ,
63
- model_path : Optional [str ] = None ,
65
+ model_path : Optional [Union [ str , os . PathLike [ str ]] ] = None ,
64
66
model_type : Optional [str ] = None ,
65
67
allow_download : bool = True ,
66
68
n_threads : Optional [int ] = None ,
@@ -115,7 +117,7 @@ def list_models() -> List[ConfigType]:
115
117
@staticmethod
116
118
def retrieve_model (
117
119
model_name : str ,
118
- model_path : Optional [str ] = None ,
120
+ model_path : Optional [Union [ str , os . PathLike [ str ]] ] = None ,
119
121
allow_download : bool = True ,
120
122
verbose : bool = True ,
121
123
) -> ConfigType :
@@ -160,7 +162,7 @@ def retrieve_model(
160
162
)
161
163
model_path = DEFAULT_MODEL_DIRECTORY
162
164
else :
163
- model_path = model_path .replace ("\\ " , "\\ \\ " )
165
+ model_path = str ( model_path ) .replace ("\\ " , "\\ \\ " )
164
166
165
167
if not os .path .exists (model_path ):
166
168
raise ValueError (f"Invalid model directory: { model_path } " )
@@ -185,7 +187,7 @@ def retrieve_model(
185
187
@staticmethod
186
188
def download_model (
187
189
model_filename : str ,
188
- model_path : str ,
190
+ model_path : Union [ str , os . PathLike [ str ]] ,
189
191
verbose : bool = True ,
190
192
url : Optional [str ] = None ,
191
193
) -> str :
0 commit comments