mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 23:48:56 +01:00
Do not try downloading model from GPT4All if the user is not connected to the internet
This commit is contained in:
parent
3ff4e19dd2
commit
f9e09ba490
1 changed files with 6 additions and 0 deletions
|
@ -29,6 +29,12 @@ def download_model(model_name: str):
|
|||
|
||||
filename = os.path.expanduser(f"~/.cache/gpt4all/{model_name}")
|
||||
if os.path.exists(filename):
|
||||
# Check if the user is connected to the internet
|
||||
try:
|
||||
requests.get("https://www.google.com/", timeout=5)
|
||||
except:
|
||||
logger.debug("User is offline. Disabling allowed download flag")
|
||||
return GPT4All(model_name, allow_download=False)
|
||||
return GPT4All(model_name)
|
||||
|
||||
# Download the model to a tmp file. Once the download is completed, move the tmp file to the actual file
|
||||
|
|
Loading…
Reference in a new issue