mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-07-17 17:02:09 +00:00
python: always check status code of HTTP responses (#1502)
This commit is contained in:
parent
afaa291eab
commit
aed2068342
@ -113,7 +113,10 @@ class GPT4All:
|
|||||||
Returns:
|
Returns:
|
||||||
Model list in JSON format.
|
Model list in JSON format.
|
||||||
"""
|
"""
|
||||||
return requests.get("https://gpt4all.io/models/models2.json").json()
|
resp = requests.get("https://gpt4all.io/models/models2.json")
|
||||||
|
if resp.status_code != 200:
|
||||||
|
raise ValueError(f'Request failed: HTTP {resp.status_code} {resp.reason}')
|
||||||
|
return resp.json()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def retrieve_model(
|
def retrieve_model(
|
||||||
@ -215,6 +218,9 @@ class GPT4All:
|
|||||||
download_url = get_download_url(model_filename)
|
download_url = get_download_url(model_filename)
|
||||||
|
|
||||||
response = requests.get(download_url, stream=True)
|
response = requests.get(download_url, stream=True)
|
||||||
|
if response.status_code != 200:
|
||||||
|
raise ValueError(f'Request failed: HTTP {response.status_code} {response.reason}')
|
||||||
|
|
||||||
total_size_in_bytes = int(response.headers.get("content-length", 0))
|
total_size_in_bytes = int(response.headers.get("content-length", 0))
|
||||||
block_size = 2**20 # 1 MB
|
block_size = 2**20 # 1 MB
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user