Skip to content

Commit 44f3ec0

Browse files
enhance about section API with llm information (#493)
also removes the separate isllm configured API/route Co-authored-by: Satyam Singh <[email protected]>
1 parent 2a02816 commit 44f3ec0

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

server/src/banner.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,23 @@ fn status_info(config: &Config, scheme: &str, id: Uid) {
5959
credentials = "\"Using default creds admin, admin. Please set credentials with P_USERNAME and P_PASSWORD.\"".red().to_string();
6060
}
6161

62+
let llm_status = match &config.parseable.open_ai_key {
63+
Some(_) => "OpenAI Configured".green(),
64+
None => "Not Configured".grey(),
65+
};
66+
6267
eprintln!(
6368
"
6469
{}
6570
URL: {}
6671
Credentials: {}
67-
Deployment UID: \"{}\"",
72+
Deployment UID: \"{}\"
73+
LLM Status: \"{}\"",
6874
"Server:".to_string().bold(),
6975
url,
7076
credentials,
7177
id.to_string(),
78+
llm_status
7279
);
7380
}
7481

server/src/handlers/http.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -231,19 +231,13 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) {
231231
),
232232
);
233233

234-
let llm_query_api = web::scope("/llm")
235-
.service(
236-
web::resource("").route(
237-
web::post()
238-
.to(llm::make_llm_request)
239-
.authorize(Action::Query),
240-
),
241-
)
242-
.service(
243-
// to check if the API key for an LLM has been set up as env var
244-
web::resource("isactive")
245-
.route(web::post().to(llm::is_llm_active).authorize(Action::Query)),
246-
);
234+
let llm_query_api = web::scope("/llm").service(
235+
web::resource("").route(
236+
web::post()
237+
.to(llm::make_llm_request)
238+
.authorize(Action::Query),
239+
),
240+
);
247241

248242
// Deny request if username is same as the env variable P_USERNAME.
249243
cfg.service(

server/src/handlers/http/about.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,19 @@ pub async fn about() -> Json<serde_json::Value> {
4040
let deployment_id = meta.deployment_id.to_string();
4141
let mode = CONFIG.mode_string();
4242
let staging = CONFIG.staging_dir();
43+
4344
let store = CONFIG.storage().get_endpoint();
45+
let is_llm_active = &CONFIG.parseable.open_ai_key.is_some();
46+
let llm_provider = is_llm_active.then_some("OpenAI");
4447

4548
Json(json!({
4649
"version": current_version,
4750
"commit": commit,
4851
"deploymentId": deployment_id,
4952
"updateAvailable": update_available,
5053
"latestVersion": latest_release,
54+
"llmActive": is_llm_active,
55+
"llmProvider": llm_provider,
5156
"license": "AGPL-3.0-only",
5257
"mode": mode,
5358
"staging": staging,

server/src/handlers/http/llm.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,6 @@ pub async fn make_llm_request(body: web::Json<AiPrompt>) -> Result<HttpResponse,
139139
}
140140
}
141141

142-
pub async fn is_llm_active() -> HttpResponse {
143-
let is_active = matches!(&CONFIG.parseable.open_ai_key, Some(api_key) if api_key.len() > 3);
144-
HttpResponse::Ok()
145-
.content_type("application/json")
146-
.json(json!({"is_active": is_active}))
147-
}
148-
149142
#[derive(Debug, thiserror::Error)]
150143
pub enum LLMError {
151144
#[error("Either OpenAI key was not provided or was invalid")]

0 commit comments

Comments
 (0)