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::sync::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::sync::ApiBuilder;
let api = ApiBuilder::from_env().build().unwrap();
Sourcepub fn from_cache(cache: Cache) -> Self
pub fn from_cache(cache: Cache) -> Self
From a given cache
use hf_hub::{api::sync::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_retries(self, max_retries: usize) -> Self
pub fn with_retries(self, max_retries: usize) -> Self
Sets the number of times the API will retry to download a file
Trait Implementations§
Source§impl Debug for ApiBuilder
impl Debug for ApiBuilder
Auto Trait Implementations§
impl Freeze for ApiBuilder
impl RefUnwindSafe for ApiBuilder
impl Send for ApiBuilder
impl Sync for ApiBuilder
impl Unpin for ApiBuilder
impl UnwindSafe for ApiBuilder
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
Mutably borrows from an owned value. Read more