-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added extra Option to To control HF Token #898
Added extra Option to To control HF Token #898
Conversation
Thank you for your contribution! There are many ways that users can authenticate with Hugging Face.
There are also several scenarios for when the token is needed or not needed.
Given this information, I think we should change the behavior of how the Hugging Face token is obtained to the following. # For the `Model` class
self.hf_token = parse_hf_token(extra_options.get("hf_token", "true")) # For `create_model`
hf_token = parse_hf_token(extra_options.get("hf_token", "true")) def parse_hf_token(hf_token):
"""
Returns the authentication token needed for Hugging Face.
Token is obtained either from the user or the environment.
"""
if hf_token.lower() in {"false", "0"}:
# Default is `None` for disabling authentication
return None
if hf_token.lower() in {"true", "1"}:
# Return token in environment
return os.environ["HF_TOKEN"]
# Return user-provided token as string
return hf_token Then, the two options for The What do you think? |
Co-authored-by: kunal-vaishnavi <[email protected]>
Co-authored-by: kunal-vaishnavi <[email protected]>
Co-authored-by: kunal-vaishnavi <[email protected]>
…er/onnxruntime-genai into features/disable_hf_login
You are absolutely right and your feedback is very appreciated ! I implemented the changes you proposed. @kunal-vaishnavi are we sure that the I think we should return def parse_hf_token(hf_token):
"""
Returns the authentication token needed for Hugging Face.
Token is obtained either from the user or the environment.
"""
if hf_token.lower() in {"false", "0"}:
# Default is `None` for disabling authentication
return None
if hf_token.lower() in {"true", "1"}:
# Return token in true
return True
# Return user-provided token as string
return hf_token |
No worries and happy to review!
Upon further testing, it appears that the environment variables are not always set. I agree that returning According to Hugging Face's documentation, the |
Co-authored-by: kunal-vaishnavi <[email protected]>
Co-authored-by: kunal-vaishnavi <[email protected]>
In the README, can you add a new section in "Extra Options" after "Use 8 Bits Quantization in QMoE" to show how to use this new extra option? onnxruntime-genai/src/python/py/models/README.md Lines 176 to 186 in 1764869
Once added, can you also add a reference to the new section in the table of contents after "Use 8 Bits Quantization in QMoE"? onnxruntime-genai/src/python/py/models/README.md Lines 15 to 20 in 1764869
|
…er/onnxruntime-genai into features/disable_hf_login
This PR looks good to me now! It appears you need to resolve two conflicting files as those files were recently updated by another PR. Once those conflicts are resolved, I can approve and merge your changes! |
I merged the changes, i was not sure what is your desired order for the chapters in the |
fixes #830.
I've added a new option
hf_token
in the extra options, the user can pass a Token or True or False.Also i upgraded
use_auth_token
totoken
.