Skip to content

Commit 687e477

Browse files
NarsilHugoch
andauthored
Add api key support (#19)
* Suggest removing the docker, and instead installing the CLI. * Putting back the profile. * Getting the API from environment (to catch other things like `HF_HOME`). * Since we want a URL from the start we can actually use a URL all the way. Fixing. * Fixing the URL handling. * Api key support. --------- Co-authored-by: Hugo Larcher <[email protected]>
1 parent cc569c7 commit 687e477

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ mod writers;
3434

3535
pub struct RunConfiguration {
3636
pub url: Url,
37+
pub api_key: String,
3738
pub tokenizer_name: String,
3839
pub profile: Option<String>,
3940
pub max_vus: u64,
@@ -85,7 +86,7 @@ pub async fn run(mut run_config: RunConfiguration, stop_sender: Sender<()>) -> a
8586
};
8687
let tokenizer = Arc::new(tokenizer);
8788
let backend = OpenAITextGenerationBackend::try_new(
88-
"".to_string(),
89+
run_config.api_key,
8990
run_config.url,
9091
run_config.model_name.clone(),
9192
tokenizer,

src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ struct Args {
4747
#[clap(default_value = "http://localhost:8000", short, long, env)]
4848
url: Url,
4949

50+
/// The api key send to the [`url`] as Header "Authorization: Bearer {API_KEY}".
51+
#[clap(default_value = "", short, long, env)]
52+
api_key: String,
53+
5054
/// Disable console UI
5155
#[clap(short, long, env)]
5256
no_console: bool,
@@ -203,7 +207,8 @@ async fn main() {
203207
.run_id
204208
.unwrap_or(uuid::Uuid::new_v4().to_string()[..7].to_string());
205209
let run_config = RunConfiguration {
206-
url: args.url.clone(),
210+
url: args.url,
211+
api_key: args.api_key,
207212
profile: args.profile.clone(),
208213
tokenizer_name: args.tokenizer_name.clone(),
209214
max_vus: args.max_vus,

0 commit comments

Comments
 (0)