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

Return the liked users for for a huggingface model #1705

Closed
abstrcode opened this issue Oct 2, 2023 · 4 comments · Fixed by #1715
Closed

Return the liked users for for a huggingface model #1705

abstrcode opened this issue Oct 2, 2023 · 4 comments · Fixed by #1715
Labels
good first issue Good for newcomers

Comments

@abstrcode
Copy link

Currently, the is a function "list_liked_repos" to list user-liked models by inputting the user name. It would be better to have a function that outputs the list of liked users for a given model.

@Wauplin
Copy link
Contributor

Wauplin commented Oct 2, 2023

Hi @abstrcode, thanks for raising the question. It is currently not possible to get this information in huggingface_hub but an API endpoints exists for it. For example for mistralai/Mistral-7B-v0.1 model: https://huggingface.co/api/models/mistralai/Mistral-7B-v0.1/likers.

We can definitely add a method in huggingface_hub to wrap it:

class HfApi:
    (...)

    def list_repo_likers(self, repo_id: str, *, repo_type: Optional[str] = None, token: Optional[str] = None) -> List[User]:
        (...)

Would you like to open a PR for that? I can give some guidance about what to update and where. First step would be to implement this method and create a User data type for the returned value (with fullname, avatarUrl and name). Then a test should be added in tests/test_hf_api.py.

WDYT?

@julien-c julien-c added the good first issue Good for newcomers label Oct 2, 2023
@julien-c
Copy link
Member

julien-c commented Oct 2, 2023

yes, would be a good first issue Good for newcomers

@issamarabi
Copy link
Contributor

issamarabi commented Oct 5, 2023

Hi @Wauplin, would you be able to provide more info about how to call the API?

@Wauplin
Copy link
Contributor

Wauplin commented Oct 5, 2023

Hi @issamarabi , the implementation would be very similar to get_spaces_variables for example (see code here). You have to build the URL given an endpoint+repo_id+repo_type, build the headers given the token and make the call (no parameters/no payload). Then the output must be parsed correctly as a User dataclass (that has to be defined as well). Would you be interested in opening a PR?

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

Successfully merging a pull request may close this issue.

4 participants