Skip to content

Commit

Permalink
Huggingface-cli login response handling
Browse files Browse the repository at this point in the history
  • Loading branch information
arjbingly committed May 2, 2024
1 parent 26037b8 commit bb6d0c8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/grag/quantize/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,20 @@ def fetch_model_repo(repo_id: str, model_path: Union[str, Path] = './grag-quanti
except GatedRepoError:
print(
"This model comes under gated repository. You must be authenticated to download the model. For more: https://huggingface.co/docs/hub/en/models-gated")
resp = input("If you have auth token, please provide it here ['n' or enter to exit]: ")
if resp == 'n' or resp == '':
print("No token provided, exiting.")
resp = input("You will be redirected to hugginface-cli to login. [To exit, enter 'n']: ")
if resp.lower() == "n":
print("User exited.")
exit(0)
else:
login(resp)
elif resp == "":
login()
snapshot_download(
repo_id=repo_id,
local_dir=local_dir,
local_dir_use_symlinks="auto",
resume_download=True,
)
else:
raise ValueError('Invalid response received.')
print(f"Model downloaded in {local_dir}")
return local_dir

Expand Down

0 comments on commit bb6d0c8

Please sign in to comment.