pub struct ApiBuilder { /* private fields */ }
Expand description
Helper to create Api
with all the options.
Implementations§
Source§impl ApiBuilder
impl ApiBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Default api builder
use hf_hub::api::tokio::ApiBuilder;
let api = ApiBuilder::new().build().unwrap();
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Creates API with values potentially from environment variables. HF_HOME decides the location of the cache folder HF_ENDPOINT modifies the URL for the huggingface location to download files from.
use hf_hub::api::tokio::ApiBuilder;
let api = ApiBuilder::from_env().build().unwrap();
Sourcepub fn high(self) -> Self
pub fn high(self) -> Self
High CPU download
This may cause issues on regular desktops as it will saturate CPUs by multiplexing the downloads. However on high CPU machines on the cloud, this may help saturate the bandwidth (>500MB/s) better.
use hf_hub::api::tokio::ApiBuilder;
let api = ApiBuilder::new().high().build().unwrap();
Sourcepub fn from_cache(cache: Cache) -> Self
pub fn from_cache(cache: Cache) -> Self
From a given cache
use hf_hub::{api::tokio::ApiBuilder, Cache};
let path = std::path::PathBuf::from("/tmp");
let cache = Cache::new(path);
let api = ApiBuilder::from_cache(cache).build().unwrap();
Sourcepub fn with_progress(self, progress: bool) -> Self
pub fn with_progress(self, progress: bool) -> Self
Wether to show a progressbar
Sourcepub fn with_endpoint(self, endpoint: String) -> Self
pub fn with_endpoint(self, endpoint: String) -> Self
Changes the endpoint of the API. Default is https://huggingface.co
.
Sourcepub fn with_cache_dir(self, cache_dir: PathBuf) -> Self
pub fn with_cache_dir(self, cache_dir: PathBuf) -> Self
Changes the location of the cache directory. Defaults is ~/.cache/huggingface/
.
Sourcepub fn with_token(self, token: Option<String>) -> Self
pub fn with_token(self, token: Option<String>) -> Self
Sets the token to be used in the API
Sourcepub fn with_max_files(self, max_files: usize) -> Self
pub fn with_max_files(self, max_files: usize) -> Self
Sets the number of open files
Sourcepub fn with_chunk_size(self, chunk_size: Option<usize>) -> Self
pub fn with_chunk_size(self, chunk_size: Option<usize>) -> Self
Sets the size of each chunk