mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-21 23:57:58 +01:00
Downloader: don't assume that huggingface_hub is installed
This commit is contained in:
parent
89f6036e98
commit
ee65f4f014
@ -20,7 +20,6 @@ import requests
|
||||
import tqdm
|
||||
from requests.adapters import HTTPAdapter
|
||||
from tqdm.contrib.concurrent import thread_map
|
||||
from huggingface_hub import get_token
|
||||
|
||||
base = "https://huggingface.co"
|
||||
|
||||
@ -31,10 +30,18 @@ class ModelDownloader:
|
||||
if max_retries:
|
||||
self.session.mount('https://cdn-lfs.huggingface.co', HTTPAdapter(max_retries=max_retries))
|
||||
self.session.mount('https://huggingface.co', HTTPAdapter(max_retries=max_retries))
|
||||
|
||||
if os.getenv('HF_USER') is not None and os.getenv('HF_PASS') is not None:
|
||||
self.session.auth = (os.getenv('HF_USER'), os.getenv('HF_PASS'))
|
||||
if get_token() is not None:
|
||||
self.session.headers = {'authorization': f'Bearer {get_token()}'}
|
||||
|
||||
try:
|
||||
from huggingface_hub import get_token
|
||||
token = get_token()
|
||||
except ImportError:
|
||||
token = os.getenv("HF_TOKEN")
|
||||
|
||||
if token is not None:
|
||||
self.session.headers = {'authorization': f'Bearer {token}'}
|
||||
|
||||
def sanitize_model_and_branch_names(self, model, branch):
|
||||
if model[-1] == '/':
|
||||
|
Loading…
Reference in New Issue
Block a user