Skip to content
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

[hub] - hf hub internal api no longer returns an error for invalid access tokens when using listFiles for a gated model #945

Closed
phudtran opened this issue Oct 5, 2024 · 4 comments

Comments

@phudtran
Copy link
Contributor

phudtran commented Oct 5, 2024

Issue

Hi, not sure if this is the correct place to post this issue since it seems to be an internal api change.

Previously, listing files in a gated repo using listFiles with an invalid or undefined access token would throw an authentication error. Now the authentication error is not thrown until an attempt is made to download one of the gated files with said invalid token.

Would it be possible/within scope to add some kind of hint to specify whether or not the user provided access token used in listModels/listFiles is able to access the gated model.

Example

image

For example, when going to https://huggingface.co/google/gemma-2b/tree/main, I am immediately informed whether or not I have access to the gated model.

Use case

Jellybox allows users to input their access token to download gated models after accepting the model conditions.

image
@coyotte508
Copy link
Member

Hi @phudtran

The thing is that it's now possible to list gated files with the API.

If you want to check if a model is gated, I just created a PR adding modelInfo: #946

You can then do:

const info = await modelInfo({name: "some-model"});
console.log(info.gated);

coyotte508 added a commit that referenced this issue Oct 5, 2024
@coyotte508
Copy link
Member

Available in @huggingface/hub@0.18.0 :)

coyotte508 added a commit that referenced this issue Oct 5, 2024
More helpers for
#945

Introduces `checkRepoAccess` to check if user has read access to repo
@coyotte508
Copy link
Member

coyotte508 commented Oct 5, 2024

And await checkRepoAccess({repo: <model name>, accessToken: "..."}) is available in 0.18.1: #947

@phudtran
Copy link
Contributor Author

phudtran commented Oct 5, 2024

And await checkRepoAccess({repo: <model name>, accessToken: "..."}) is available in 0.18.1: #947

Got it! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants