Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
remove unused config vars
Browse files Browse the repository at this point in the history
  • Loading branch information
ggordonhall authored and anastasiya1155 committed Apr 23, 2024
1 parent cf233a8 commit efe964d
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 75 deletions.
22 changes: 0 additions & 22 deletions server/bleep/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ pub struct Configuration {
//
// External dependencies
//
#[clap(long, default_value_t = default_answer_api_url())]
#[serde(default = "default_answer_api_url")]
/// URL for the answer-api
pub answer_api_url: String,

#[clap(long)]
/// Path to dynamic libraries used in the app.
pub dylib_dir: Option<PathBuf>,
Expand Down Expand Up @@ -156,11 +151,6 @@ pub struct Configuration {
#[clap(long)]
pub bloop_instance_org: Option<String>,

#[clap(long)]
#[serde(serialize_with = "serialize_secret_opt_str", default)]
/// Bot secret token
pub bot_secret: Option<SecretString>,

//
// Cloud deployment values
//
Expand Down Expand Up @@ -304,12 +294,6 @@ impl Configuration {

qdrant_url: right_if_default!(b.qdrant_url, a.qdrant_url, String::new()),

answer_api_url: right_if_default!(
b.answer_api_url,
a.answer_api_url,
default_answer_api_url()
),

cognito_userpool_id: b.cognito_userpool_id.or(a.cognito_userpool_id),

cognito_client_id: b.cognito_client_id.or(a.cognito_client_id),
Expand All @@ -326,8 +310,6 @@ impl Configuration {

instance_domain: b.instance_domain.or(a.instance_domain),

bot_secret: b.bot_secret.or(a.bot_secret),

dylib_dir: b.dylib_dir.or(a.dylib_dir),
}
}
Expand Down Expand Up @@ -404,10 +386,6 @@ fn default_qdrant_url() -> String {
String::from("http://127.0.0.1:6334")
}

fn default_answer_api_url() -> String {
String::from("http://127.0.0.1:7879")
}

fn default_max_chunk_tokens() -> usize {
256
}
Expand Down
8 changes: 1 addition & 7 deletions server/bleep/src/ee/webserver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use crate::{
background::SyncConfig,
repo::FilterUpdate,
webserver::{
middleware::User,
prelude::*,
repos::{RepoParams, ReposResponse},
},
Expand All @@ -19,9 +18,8 @@ use crate::{
//
pub(crate) async fn patch_repository(
Query(RepoParams { repo, .. }): Query<RepoParams>,
user: Extension<User>,
State(app): State<Application>,
Json(mut patch): Json<FilterUpdate>,
Json(patch): Json<FilterUpdate>,
) -> impl IntoResponse {
if let Some(ref file_filter) = patch.file_filter {
_ = crate::repo::iterator::FileFilter::from(file_filter);
Expand All @@ -31,10 +29,6 @@ pub(crate) async fn patch_repository(
_ = crate::repo::iterator::BranchFilter::from(branch_filter);
}

if !user.paid_features(&app).await {
patch.branch_filter = None;
}

if patch.file_filter.is_some() || patch.branch_filter.is_some() {
app.write_index()
.enqueue(SyncConfig::new(app, repo).filter_updates(patch.into()))
Expand Down
2 changes: 0 additions & 2 deletions server/bleep/src/webserver/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub(super) struct ConfigResponse {
bloop_version: String,
bloop_commit: String,
credentials_upgrade: bool,
paid: bool,
}

impl super::ApiResponse for ConfigResponse {}
Expand Down Expand Up @@ -48,7 +47,6 @@ pub(super) async fn get(
bloop_commit: git_version::git_version!(fallback = "unknown").into(),
bloop_user_profile: user_profile,
credentials_upgrade: app.config.source.exists("credentials.json"),
paid: user.paid_features(&app).await,
user_login,
github_user,
org_name,
Expand Down
44 changes: 0 additions & 44 deletions server/bleep/src/webserver/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use axum::{
};
use axum_extra::extract::CookieJar;
use jwt_authorizer::JwtClaims;
use tracing::error;

#[derive(Serialize, Clone)]
pub enum User {
Expand Down Expand Up @@ -59,49 +58,6 @@ impl User {

Ok(llm::client::Client::new(app.clone()))
}

pub(crate) async fn paid_features(&self, app: &Application) -> bool {
let access_token = match self {
User::Desktop { access_token, .. } => access_token,
User::Cloud { .. } => return true,
_ => return false,
};

let Ok(response) = reqwest::Client::new()
.get(format!("{}/v2/get-usage-quota", app.config.answer_api_url))
.bearer_auth(access_token)
.send()
.await
else {
error!("failed to get quota for user");
return false;
};

if response.status().is_success() {
let response: serde_json::Value =
response.json().await.expect("answer_api proto bad or down");

response
.get("upgraded")
.and_then(serde_json::Value::as_bool)
.unwrap_or_default()
} else {
let status = response.status();
match response.text().await {
Ok(body) if !body.is_empty() => {
error!(?status, ?body, "request failed with status code")
}
Ok(_) => error!(?status, "request failed; response had no body"),
Err(err) => error!(
?status,
?err,
"request failed; failed to retrieve response body",
),
}

false
}
}
}

pub fn local_user(router: Router, app: Application) -> Router {
Expand Down

0 comments on commit efe964d

Please sign in to comment.