simonw / llm-gpt4all

Plugin for LLM adding support for the GPT4All collection of models
Apache License 2.0
218 stars 20 forks source link

Catch NameResolutionError when fetching models while offline #9

Closed RangerMauve closed 1 year ago

RangerMauve commented 1 year ago

Thanks for putting this together! Been experimenting with this in offline-first context.

Currently when I try to run a gpt4 model while offline I get the following stack trace on Linux:

➜  ~ llm -m orca-mini-3b "Write a python map from NATO phonetic alphabet to its letter"
Error: HTTPSConnectionPool(host='gpt4all.io', port=443): Max retries exceeded with url: /models/models.json (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f6aa1f25f10>: Failed to resolve 'gpt4all.io' ([Errno -3] Temporary failure in name resolution)"))

This PR attempts to catch that exception and continue with the "load from file" logic.

To be clear, this is after having successfully run the command while online and having the model and the models.json file cached on my filesystem.

simonw commented 1 year ago

Thanks very much!