[Rust Frontend] Add /version endpoint using engine-reported value (#43854)
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
This commit is contained in:
@@ -6,6 +6,7 @@ mod load;
|
||||
mod metrics;
|
||||
pub(crate) mod openai;
|
||||
mod sleep;
|
||||
mod version;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -35,6 +36,7 @@ fn build_router_with_dev_mode(state: Arc<AppState>, dev_mode_enabled: bool) -> R
|
||||
.route("/health", get(health::health))
|
||||
.route("/metrics", get(metrics::scrape))
|
||||
.route("/load", get(load::load))
|
||||
.route("/version", get(version::version))
|
||||
// OpenAI-compatible endpoints
|
||||
.route("/v1/models", get(openai::list_models))
|
||||
.route("/v1/completions", post(openai::completions))
|
||||
|
||||
@@ -994,6 +994,27 @@ async fn list_models_returns_configured_model() {
|
||||
assert_eq!(json["data"][0]["id"], "Qwen/Qwen1.5-0.5B-Chat");
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
#[serial]
|
||||
async fn version_returns_engine_vllm_version() {
|
||||
let mut app = test_app().await;
|
||||
let response = app
|
||||
.call(Request::builder().uri("/version").body(Body::empty()).expect("build request"))
|
||||
.await
|
||||
.expect("call app");
|
||||
|
||||
assert_eq!(response.status(), StatusCode::OK);
|
||||
let body = to_bytes(response.into_body(), usize::MAX).await.expect("read body");
|
||||
let json: serde_json::Value = serde_json::from_slice(&body).expect("decode json");
|
||||
assert_eq!(
|
||||
json,
|
||||
json!({
|
||||
"version": "test-vllm-version",
|
||||
"rust_frontend_version": env!("CARGO_PKG_VERSION"),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
#[serial]
|
||||
async fn http_metrics_record_list_models_requests() {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use axum::Json;
|
||||
use axum::extract::State;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::state::AppState;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub(crate) struct VersionResponse {
|
||||
version: String,
|
||||
rust_frontend_version: &'static str,
|
||||
}
|
||||
|
||||
/// Get engine and Rust frontend version metadata.
|
||||
pub async fn version(State(state): State<Arc<AppState>>) -> Json<VersionResponse> {
|
||||
let version = state.engine_core_client().vllm_version().to_string();
|
||||
|
||||
Json(VersionResponse {
|
||||
version,
|
||||
rust_frontend_version: env!("CARGO_PKG_VERSION"),
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user