mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-06 13:22:12 +00:00
Do not try downloading model from GPT4All if the user is not connected to the internet
This commit is contained in:
@@ -29,6 +29,12 @@ def download_model(model_name: str):
|
|||||||
|
|
||||||
filename = os.path.expanduser(f"~/.cache/gpt4all/{model_name}")
|
filename = os.path.expanduser(f"~/.cache/gpt4all/{model_name}")
|
||||||
if os.path.exists(filename):
|
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)
|
return GPT4All(model_name)
|
||||||
|
|
||||||
# Download the model to a tmp file. Once the download is completed, move the tmp file to the actual file
|
# Download the model to a tmp file. Once the download is completed, move the tmp file to the actual file
|
||||||
|
|||||||
Reference in New Issue
Block a user