Do not try downloading model from GPT4All if the user is not connected to the internet

This commit is contained in:
sabaimran 2023-08-19 19:08:09 -07:00
parent 3ff4e19dd2
commit f9e09ba490

View file

@ -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