Skip to content

Commit

Permalink
Add GGUF as supported expand[] parameter (#2545)
Browse files Browse the repository at this point in the history
* Add GGUF as supported expand[] parameter

* typo
  • Loading branch information
Wauplin authored Sep 16, 2024
1 parent c9458ad commit a9adf8f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/huggingface_hub/hf_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
"downloads",
"downloadsAllTime",
"gated",
"gguf",
"inference",
"lastModified",
"library_name",
Expand Down Expand Up @@ -777,6 +778,7 @@ class ModelInfo:
downloads: Optional[int]
downloads_all_time: Optional[int]
gated: Optional[Literal["auto", "manual", False]]
gguf: Optional[Dict]
inference: Optional[Literal["warm", "cold", "frozen"]]
likes: Optional[int]
library_name: Optional[str]
Expand Down Expand Up @@ -808,6 +810,7 @@ def __init__(self, **kwargs):
self.downloads_all_time = kwargs.pop("downloadsAllTime", None)
self.likes = kwargs.pop("likes", None)
self.library_name = kwargs.pop("library_name", None)
self.gguf = kwargs.pop("gguf", None)
self.inference = kwargs.pop("inference", None)
self.tags = kwargs.pop("tags", None)
self.pipeline_tag = kwargs.pop("pipeline_tag", None)
Expand Down Expand Up @@ -1715,7 +1718,7 @@ def list_models(
expand (`List[ExpandModelProperty_T]`, *optional*):
List properties to return in the response. When used, only the properties in the list will be returned.
This parameter cannot be used if `full`, `cardData` or `fetch_config` are passed.
Possible values are `"author"`, `"baseModels"`, `"cardData"`, `"childrenModelCount"`, `"config"`, `"createdAt"`, `"disabled"`, `"downloads"`, `"downloadsAllTime"`, `"gated"`, `"inference"`, `"lastModified"`, `"library_name"`, `"likes"`, `"mask_token"`, `"model-index"`, `"pipeline_tag"`, `"private"`, `"safetensors"`, `"sha"`, `"siblings"`, `"spaces"`, `"tags"`, `"transformersInfo"`, `"trendingScore"` and `"widgetData"`.
Possible values are `"author"`, `"baseModels"`, `"cardData"`, `"childrenModelCount"`, `"config"`, `"createdAt"`, `"disabled"`, `"downloads"`, `"downloadsAllTime"`, `"gated"`, `"gguf"`, `"inference"`, `"lastModified"`, `"library_name"`, `"likes"`, `"mask_token"`, `"model-index"`, `"pipeline_tag"`, `"private"`, `"safetensors"`, `"sha"`, `"siblings"`, `"spaces"`, `"tags"`, `"transformersInfo"`, `"trendingScore"` and `"widgetData"`.
full (`bool`, *optional*):
Whether to fetch all model data, including the `last_modified`,
the `sha`, the files and the `tags`. This is set to `True` by
Expand Down Expand Up @@ -2413,7 +2416,7 @@ def model_info(
expand (`List[ExpandModelProperty_T]`, *optional*):
List properties to return in the response. When used, only the properties in the list will be returned.
This parameter cannot be used if `securityStatus` or `files_metadata` are passed.
Possible values are `"author"`, `"baseModels"`, `"cardData"`, `"childrenModelCount"`, `"config"`, `"createdAt"`, `"disabled"`, `"downloads"`, `"downloadsAllTime"`, `"gated"`, `"inference"`, `"lastModified"`, `"library_name"`, `"likes"`, `"mask_token"`, `"model-index"`, `"pipeline_tag"`, `"private"`, `"safetensors"`, `"sha"`, `"siblings"`, `"spaces"`, `"tags"`, `"transformersInfo"`, `"trendingScore"` and `"widgetData"`.
Possible values are `"author"`, `"baseModels"`, `"cardData"`, `"childrenModelCount"`, `"config"`, `"createdAt"`, `"disabled"`, `"downloads"`, `"downloadsAllTime"`, `"gated"`, `"gguf"`, `"inference"`, `"lastModified"`, `"library_name"`, `"likes"`, `"mask_token"`, `"model-index"`, `"pipeline_tag"`, `"private"`, `"safetensors"`, `"sha"`, `"siblings"`, `"spaces"`, `"tags"`, `"transformersInfo"`, `"trendingScore"` and `"widgetData"`.
token (Union[bool, str, None], optional):
A valid user access token (string). Defaults to the locally saved
token, which is the recommended method for authentication (see
Expand Down
2 changes: 1 addition & 1 deletion tests/test_hf_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4222,7 +4222,7 @@ def _check_expand_property_is_up_to_date(self, repo_url: RepoUrl):
if should_be_added:
msg += f"\nNew arg(s) to support: {', '.join(should_be_added)}"
msg += f"\nPlease open a PR to update `./src/huggingface_hub/hf_api.py` accordingly. `{property_type_name}` should be updated as well as `{repo_type}_info` and `list_{repo_type}s` docstrings."
msg += "\nThanks you in advance!"
msg += "\nThank you in advance!"
raise ValueError(msg)


Expand Down

0 comments on commit a9adf8f

Please sign in to comment.