Crate hugging_face_client

Source
Expand description

§Create Client

use std::time::Duration;
use hugging_face_client::client::{Client, ClientOption};

#[tokio::main(flavor = "current_thread")]
async fn main() {
  let access_token = std::env::var("HUGGING_FACE_TOKEN").unwrap();
  let access_proxy = std::env::var("HUGGING_FACE_PROXY").unwrap();
  let option = ClientOption::new(access_token)
    .proxy(access_proxy)
    .timeout(Duration::from_secs(5));
  let client = Client::new(option).unwrap();
}

§Get Model

use hugging_face_client::api::GetModelReq;
use hugging_face_client::client::{Client, ClientOption};

#[tokio::main(flavor = "current_thread")]
async fn main() {
  let option = ClientOption::new("HUGGING_FACE_TOKEN");
  let client = Client::new(option).unwrap();

  // get model
  let req = GetModelReq::new("microsoft/bitnet-b1.58-2B-4T");
  let res = client.get_model(req).await.unwrap();
  println!("{:#?}", res);
}
// Model { _id: "67fddfa9a7fe1f21ec1d3026", id: "microsoft/bitnet-b1.58-2B-4T", model_id: None ... }

More usage examples, can be seen hugging-face-client/examples

Modules§

api
Request and response
client
Async hub client
errors

Enums§

RepoType