Skip to content

Commit

Permalink
fix: always set default headers
Browse files Browse the repository at this point in the history
  • Loading branch information
mcharytoniuk committed Nov 23, 2024
1 parent aa8902f commit 02f5401
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/llamacpp/llamacpp_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,16 @@ impl LlamacppClient {
header::HeaderValue::from_static("application/json"),
);

builder = match api_key {
Some(api_key) => {
let mut auth_value = header::HeaderValue::from_str(&format!("Bearer {}", api_key))?;
if let Some(api_key_value) = api_key {
let mut auth_value =
header::HeaderValue::from_str(&format!("Bearer {}", api_key_value))?;

auth_value.set_sensitive(true);
auth_value.set_sensitive(true);

headers.insert(header::AUTHORIZATION, auth_value);
headers.insert(header::AUTHORIZATION, auth_value);
}

builder.default_headers(headers)
}
None => builder,
};
builder = builder.default_headers(headers);

Ok(Self {
client: builder.build()?,
Expand Down

0 comments on commit 02f5401

Please sign in to comment.