diff --git a/Cargo.lock b/Cargo.lock index 923b5cbe..3522fc3f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3762,7 +3762,7 @@ dependencies = [ [[package]] name = "text-generation-benchmark" -version = "2.1.2-dev0" +version = "2.2.1-dev0" dependencies = [ "average", "clap", @@ -3783,7 +3783,7 @@ dependencies = [ [[package]] name = "text-generation-client" -version = "2.1.2-dev0" +version = "2.2.1-dev0" dependencies = [ "async-trait", "base64 0.22.1", @@ -3801,7 +3801,7 @@ dependencies = [ [[package]] name = "text-generation-launcher" -version = "2.1.2-dev0" +version = "2.2.1-dev0" dependencies = [ "clap", "ctrlc", @@ -3820,7 +3820,7 @@ dependencies = [ [[package]] name = "text-generation-router" -version = "2.1.2-dev0" +version = "2.2.1-dev0" dependencies = [ "async-stream", "axum 0.7.5", diff --git a/launcher/src/main.rs b/launcher/src/main.rs index 19e3440f..be7ae4b0 100644 --- a/launcher/src/main.rs +++ b/launcher/src/main.rs @@ -1,5 +1,8 @@ use clap::{Parser, ValueEnum}; -use hf_hub::{api::sync::Api, Repo, RepoType}; +use hf_hub::{ + api::sync::{Api, ApiBuilder}, + Repo, RepoType, +}; use nix::sys::signal::{self, Signal}; use nix::unistd::Pid; use serde::Deserialize; @@ -1401,7 +1404,13 @@ fn main() -> Result<(), LauncherError> { let mut path = std::path::Path::new(&args.model_id).to_path_buf(); let filename = if !path.exists() { // Assume it's a hub id - let api = Api::new()?; + + let api = if let Ok(token) = std::env::var("HF_TOKEN") { + // env variable has precedence over on file token. + ApiBuilder::new().with_token(Some(token)).build()? + } else { + Api::new()? + }; let repo = if let Some(ref revision) = args.revision { api.repo(Repo::with_revision( model_id,