pub struct Client { /* private fields */ }Expand description
Async client for Hugging Face Hub
Implementations§
Source§impl Client
impl Client
Sourcepub async fn arxiv_paper(&self, req: ArxivPaperReq<'_>) -> Result<ArxivPaperRes>
pub async fn arxiv_paper(&self, req: ArxivPaperReq<'_>) -> Result<ArxivPaperRes>
Get the API equivalent of the Paper page, i.e., metadata like authors, summary, and discussion comments
Endpoint: GET /api/papers/{arxiv_id}
Sourcepub async fn arxiv_repos(&self, req: ArxivReposReq<'_>) -> Result<ArxivReposRes>
pub async fn arxiv_repos(&self, req: ArxivReposReq<'_>) -> Result<ArxivReposRes>
Get all the models, datasets, and Spaces that refer to a paper
Endpoint: GET /api/arxiv/{arxiv_id}/repos
Sourcepub async fn arxiv_daily(&self) -> Result<ArxivDailyRes>
pub async fn arxiv_daily(&self) -> Result<ArxivDailyRes>
Get the daily papers curated by AK and the community
Endpoint: GET /api/daily_papers
TODO: support filter on date
Source§impl Client
impl Client
Sourcepub async fn get_collections(
&self,
req: GetCollectionsReq<'_>,
) -> Result<GetCollectionsRes>
pub async fn get_collections( &self, req: GetCollectionsReq<'_>, ) -> Result<GetCollectionsRes>
List collections from the Hub, based on some criteria
Endpoint: GET /api/collections
Sourcepub async fn get_collection(
&self,
req: GetCollectionReq<'_>,
) -> Result<GetCollectionRes>
pub async fn get_collection( &self, req: GetCollectionReq<'_>, ) -> Result<GetCollectionRes>
Get information about a collection
Endpoint: GET /api/collections/{namespace}/{slug}-{id}
Sourcepub async fn create_collection(
&self,
req: CreateCollectionReq<'_>,
) -> Result<GetCollectionRes>
pub async fn create_collection( &self, req: CreateCollectionReq<'_>, ) -> Result<GetCollectionRes>
Create a new collection on the Hub with a title
Endpoint: POST /api/collections
Sourcepub async fn delete_collection(
&self,
req: DeleteCollectionReq<'_>,
) -> Result<DeleteCollectionRes>
pub async fn delete_collection( &self, req: DeleteCollectionReq<'_>, ) -> Result<DeleteCollectionRes>
Delete a collection, cannot be restored.
Endpoint: DELETE /api/collections/{namespace}/{slug}-{id}
Sourcepub async fn modify_collection(
&self,
req: ModifyCollectionReq<'_>,
) -> Result<ModifyCollectionRes>
pub async fn modify_collection( &self, req: ModifyCollectionReq<'_>, ) -> Result<ModifyCollectionRes>
Update the metadata of a collection on the Hub
Endpoint: PATCH /api/collections/{namespace}/{slug}-{id}
Sourcepub async fn create_collection_item(
&self,
req: CreateCollectionItemReq<'_>,
) -> Result<CreateCollectionItemRes>
pub async fn create_collection_item( &self, req: CreateCollectionItemReq<'_>, ) -> Result<CreateCollectionItemRes>
Add an item to a collection
Endpoint: POST /api/collections/{namespace}/{slug}-{id}/items
Sourcepub async fn modify_collection_item(
&self,
req: ModifyCollectionItemReq<'_>,
) -> Result<ModifyCollectionItemRes>
pub async fn modify_collection_item( &self, req: ModifyCollectionItemReq<'_>, ) -> Result<ModifyCollectionItemRes>
Update an item in a collection
Endpoint: PATCH /api/collections/{namespace}/{slug}-{id}/items
Sourcepub async fn delete_collection_item(
&self,
req: DeleteCollectionItemReq<'_>,
) -> Result<DeleteCollectionItemRes>
pub async fn delete_collection_item( &self, req: DeleteCollectionItemReq<'_>, ) -> Result<DeleteCollectionItemRes>
Remove an item from a collection
Endpoint: Delete /api/collections/{namespace}/{slug}-{id}/items
Source§impl Client
impl Client
Sourcepub async fn get_members(&self, req: GetMembersReq<'_>) -> Result<GetMembersRes>
pub async fn get_members(&self, req: GetMembersReq<'_>) -> Result<GetMembersRes>
Get a list of the Organization members.
Endpoint: GET /api/organizations/{organization_name}/members
Source§impl Client
impl Client
Sourcepub async fn search_model(
&self,
req: SearchModelReq<'_>,
) -> Result<SearchModelRes>
pub async fn search_model( &self, req: SearchModelReq<'_>, ) -> Result<SearchModelRes>
Get information from all models in the Hub
Endpoint: GET /api/models
Sourcepub async fn get_model(&self, req: GetModelReq<'_>) -> Result<GetModelRes>
pub async fn get_model(&self, req: GetModelReq<'_>) -> Result<GetModelRes>
Get all information for a specific model
Endpoint: GET /api/models/{repo_id} or
Endpoint: GET /api/models/{repo_id}/revision/{revision}
Gets all the available model tags hosted in the Hub
Endpoint: GET /api/models-tags-by-type
Sourcepub async fn search_dataset(
&self,
req: SearchDatasetReq<'_>,
) -> Result<SearchDatasetRes>
pub async fn search_dataset( &self, req: SearchDatasetReq<'_>, ) -> Result<SearchDatasetRes>
Get information from all datasets in the Hub
Endpoint: GET /api/datasets
Sourcepub async fn get_dataset(&self, req: GetDatasetReq<'_>) -> Result<GetDatasetRes>
pub async fn get_dataset(&self, req: GetDatasetReq<'_>) -> Result<GetDatasetRes>
Get all information for a specific dataset
Endpoint: GET /api/datasets/{repo_id} or
Endpoint: GET /api/datasets/{repo_id}/revision/{revision}
Gets all the available dataset tags hosted in the Hub
Endpoint: GET /api/datasets-tags-by-type
Sourcepub async fn search_space(
&self,
req: SearchSpaceReq<'_>,
) -> Result<SearchSpaceRes>
pub async fn search_space( &self, req: SearchSpaceReq<'_>, ) -> Result<SearchSpaceRes>
Get information from all spaces in the Hub
Endpoint: GET /api/spaces
Sourcepub async fn get_space(&self, req: GetSpaceReq<'_>) -> Result<GetSpaceRes>
pub async fn get_space(&self, req: GetSpaceReq<'_>) -> Result<GetSpaceRes>
Get all information for a specific space
Endpoint: GET /api/spaces/{repo_id} or
Endpoint: GET /api/spaces/{repo_id}/revision/{revision}
Sourcepub async fn create_repo(&self, req: CreateRepoReq<'_>) -> Result<CreateRepoRes>
pub async fn create_repo(&self, req: CreateRepoReq<'_>) -> Result<CreateRepoRes>
Create a repository, model repo by default
Endpoint: POST /api/repos/create
Sourcepub async fn delete_repo(&self, req: DeleteRepoReq<'_>) -> Result<()>
pub async fn delete_repo(&self, req: DeleteRepoReq<'_>) -> Result<()>
Delete a repository, model repo by default
Endpoint: DELETE /api/repos/delete
Sourcepub async fn move_repo(&self, req: MoveRepoReq<'_>) -> Result<()>
pub async fn move_repo(&self, req: MoveRepoReq<'_>) -> Result<()>
Move a repository (rename within the same namespace or transfer from user to organization).
Endpoint: POST /api/repos/move
Sourcepub async fn get_metrics(&self) -> Result<GetMetricsRes>
pub async fn get_metrics(&self) -> Result<GetMetricsRes>
Gets all the available metrics in the Hub
Endpoint: GET /api/metrics
Sourcepub async fn get_parquet(&self, req: GetParquetReq<'_>) -> Result<GetParquetRes>
pub async fn get_parquet(&self, req: GetParquetReq<'_>) -> Result<GetParquetRes>
Get the list of auto-converted parquet files
Endpoint: GET /api/datasets/{repo_id}/parquet
Endpoint: GET /api/datasets/{repo_id}/parquet/{subset}
Endpoint: GET /api/datasets/{repo_id}/parquet/{subset}/{split}
Sourcepub async fn download_parquet(
&self,
req: DownloadParquetReq<'_>,
) -> impl Stream<Item = Result<Bytes>>
pub async fn download_parquet( &self, req: DownloadParquetReq<'_>, ) -> impl Stream<Item = Result<Bytes>>
Get the nth shard of the auto-converted parquet files, for a specific subset (also called “config”) and split.
Endpoint: GET /api/datasets/{repo_id}/parquet/{subset}/{split}/{n}.parquet
Sourcepub async fn download_parquet_by_url(
&self,
url: impl AsRef<str>,
) -> impl Stream<Item = Result<Bytes>>
pub async fn download_parquet_by_url( &self, url: impl AsRef<str>, ) -> impl Stream<Item = Result<Bytes>>
Get the nth shard of the auto-converted parquet files, same as Client::download_parquet
url: full url of parquet file, you can get this from Client::get_parquet,
this is an example: https://huggingface.co/api/datasets/DMindAI/DMind_Benchmark/parquet/objective_infrastructure/Infrastructrue/0.parquet
Source§impl Client
impl Client
Sourcepub async fn get_userinfo(&self) -> Result<GetUserInfoRes>
pub async fn get_userinfo(&self) -> Result<GetUserInfoRes>
Get username and organizations the user belongs to
Endpoint: GET /api/whoami-v2
Source§impl Client
impl Client
Sourcepub fn new(option: ClientOption) -> Result<Self>
pub fn new(option: ClientOption) -> Result<Self>
Create Client instance with ClientOption
use hugging_face_client::client::Client;
use hugging_face_client::client::ClientOption;
use std::time::Duration;
fn main() {
let option = ClientOption::new("HUGGING_FACE_TOKEN")
.timeout(Duration::from_secs(5));
let client = Client::new(option);
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more