Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion server/src/banner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,23 @@ fn status_info(config: &Config, scheme: &str, id: Uid) {
credentials = "\"Using default creds admin, admin. Please set credentials with P_USERNAME and P_PASSWORD.\"".red().to_string();
}

let llm_status = match &config.parseable.open_ai_key {
Some(_) => "OpenAI Configured".green(),
None => "Not Configured".grey(),
};

eprintln!(
"
{}
URL: {}
Credentials: {}
Deployment UID: \"{}\"",
Deployment UID: \"{}\"
LLM Status: \"{}\"",
"Server:".to_string().bold(),
url,
credentials,
id.to_string(),
llm_status
);
}

Expand Down
20 changes: 7 additions & 13 deletions server/src/handlers/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,19 +231,13 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) {
),
);

let llm_query_api = web::scope("/llm")
.service(
web::resource("").route(
web::post()
.to(llm::make_llm_request)
.authorize(Action::Query),
),
)
.service(
// to check if the API key for an LLM has been set up as env var
web::resource("isactive")
.route(web::post().to(llm::is_llm_active).authorize(Action::Query)),
);
let llm_query_api = web::scope("/llm").service(
web::resource("").route(
web::post()
.to(llm::make_llm_request)
.authorize(Action::Query),
),
);

// Deny request if username is same as the env variable P_USERNAME.
cfg.service(
Expand Down
5 changes: 5 additions & 0 deletions server/src/handlers/http/about.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,19 @@ pub async fn about() -> Json<serde_json::Value> {
let deployment_id = meta.deployment_id.to_string();
let mode = CONFIG.mode_string();
let staging = CONFIG.staging_dir();

let store = CONFIG.storage().get_endpoint();
let is_llm_active = &CONFIG.parseable.open_ai_key.is_some();
let llm_provider = is_llm_active.then_some("OpenAI");

Json(json!({
"version": current_version,
"commit": commit,
"deploymentId": deployment_id,
"updateAvailable": update_available,
"latestVersion": latest_release,
"llmActive": is_llm_active,
"llmProvider": llm_provider,
"license": "AGPL-3.0-only",
"mode": mode,
"staging": staging,
Expand Down
7 changes: 0 additions & 7 deletions server/src/handlers/http/llm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,6 @@ pub async fn make_llm_request(body: web::Json<AiPrompt>) -> Result<HttpResponse,
}
}

pub async fn is_llm_active() -> HttpResponse {
let is_active = matches!(&CONFIG.parseable.open_ai_key, Some(api_key) if api_key.len() > 3);
HttpResponse::Ok()
.content_type("application/json")
.json(json!({"is_active": is_active}))
}

#[derive(Debug, thiserror::Error)]
pub enum LLMError {
#[error("Either OpenAI key was not provided or was invalid")]
Expand Down