From bb6d0c83aeff2d376270bf63dd96a81fc9acb408 Mon Sep 17 00:00:00 2001 From: Arjun Bingly Date: Thu, 2 May 2024 17:27:59 -0400 Subject: [PATCH] Huggingface-cli login response handling --- src/grag/quantize/utils.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/grag/quantize/utils.py b/src/grag/quantize/utils.py index 66dff09..1dda7da 100644 --- a/src/grag/quantize/utils.py +++ b/src/grag/quantize/utils.py @@ -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