From a9adf8f1a923ef7a12dd82a3c93fa44827a32f46 Mon Sep 17 00:00:00 2001 From: Lucain Date: Mon, 16 Sep 2024 11:56:48 +0200 Subject: [PATCH] Add GGUF as supported expand[] parameter (#2545) * Add GGUF as supported expand[] parameter * typo --- src/huggingface_hub/hf_api.py | 7 +++++-- tests/test_hf_api.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/huggingface_hub/hf_api.py b/src/huggingface_hub/hf_api.py index 50643fa626..e8ee98c381 100644 --- a/src/huggingface_hub/hf_api.py +++ b/src/huggingface_hub/hf_api.py @@ -154,6 +154,7 @@ "downloads", "downloadsAllTime", "gated", + "gguf", "inference", "lastModified", "library_name", @@ -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] @@ -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) @@ -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 @@ -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 diff --git a/tests/test_hf_api.py b/tests/test_hf_api.py index 44e228871f..1ab7734615 100644 --- a/tests/test_hf_api.py +++ b/tests/test_hf_api.py @@ -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)