pub struct ApiRepo { /* private fields */ }
Expand description
Shorthand for accessing things within a particular repo
Implementations§
source§impl ApiRepo
impl ApiRepo
sourcepub fn url(&self, filename: &str) -> String
pub fn url(&self, filename: &str) -> String
Get the fully qualified URL of the remote filename
let api = Api::new().unwrap();
let url = api.model("gpt2".to_string()).url("model.safetensors");
assert_eq!(url, "https://huggingface.co/gpt2/resolve/main/model.safetensors");
sourcepub fn get(&self, filename: &str) -> Result<PathBuf, ApiError>
pub fn get(&self, filename: &str) -> Result<PathBuf, ApiError>
This will attempt the fetch the file locally first, then [Api.download
]
if the file is not present.
use hf_hub::{api::sync::Api};
let api = Api::new().unwrap();
let local_filename = api.model("gpt2".to_string()).get("model.safetensors").unwrap();
sourcepub fn download(&self, filename: &str) -> Result<PathBuf, ApiError>
pub fn download(&self, filename: &str) -> Result<PathBuf, ApiError>
Downloads a remote file (if not already present) into the cache directory to be used locally. This functions require internet access to verify if new versions of the file exist, even if a file is already on disk at location.
let api = Api::new().unwrap();
let local_filename = api.model("gpt2".to_string()).download("model.safetensors").unwrap();
sourcepub fn info(&self) -> Result<RepoInfo, ApiError>
pub fn info(&self) -> Result<RepoInfo, ApiError>
Get information about the Repo
use hf_hub::{api::sync::Api};
let api = Api::new().unwrap();
api.model("gpt2".to_string()).info();
sourcepub fn info_request(&self) -> Request
pub fn info_request(&self) -> Request
Get the raw ureq::Request
with the url and method already set
let api = Api::new().unwrap();
api.model("gpt2".to_owned())
.info_request()
.query("blobs", "true")
.call();
Auto Trait Implementations§
impl !RefUnwindSafe for ApiRepo
impl Send for ApiRepo
impl Sync for ApiRepo
impl Unpin for ApiRepo
impl !UnwindSafe for ApiRepo
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