gpt4all icon indicating copy to clipboard operation
gpt4all copied to clipboard

[Feature] Able to operate when temporarily offline if model is already cached

Open jithware opened this issue 1 year ago • 1 comments

Description

When a model is already cached, it would be better if the python interface continued to operate even when temporarily offline. Currently when model.generate(...) is used, a request to /models/models3.json is made every time. Though this is good for usage statistics, it would be preferable that the python interface first checked if the model has already been cached and if so, do not request models3.json again. This presumably would allow the application to continue to operate should network connectivity be disrupted temporarily.

Steps to reproduce

Call model.generate(...)

python -c 'from gpt4all import GPT4All
model = GPT4All("Meta-Llama-3-8B-Instruct.Q4_0.gguf") # downloads / loads a 4.66GB LLM
with model.chat_session():
    print(model.generate("Can gpt4all be used offline?", max_tokens=1024))'

GPT-4 is a cloud-based AI model, which means it requires an internet connection to function. As such, GPT-4 cannot be used entirely offline...

Verify model is cached

ls ~/.cache/gpt4all/
Meta-Llama-3-8B-Instruct.Q4_0.gguf

Disconnect network temporarily

Call model.generate(...) again

python -c 'from gpt4all import GPT4All
model = GPT4All("Meta-Llama-3-8B-Instruct.Q4_0.gguf") # downloads / loads a 4.66GB LLM
with model.chat_session():
    print(model.generate("Can gpt4all be used offline?", max_tokens=1024))'

raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='gpt4all.io', port=443): Max retries exceeded with url: /models/models3.json (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f01e6c0f7d0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))

Expected result

GPT4all continues to operate even during temporary network connectivity loss.

jithware avatar Sep 12 '24 12:09 jithware