feat: add /v1/health (#226)

* feat: add /v1/health

* fix fmt
improve-workflow
Meng Zhang 2023-06-10 22:37:42 -07:00 committed by GitHub
parent 6718afbf67
commit 6180b32980
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 2 deletions

View File

@ -29,13 +29,13 @@ OpenAPI documentation for [tabby](https://github.com/TabbyML/tabby), a self-host
(url = "https://app.tabbyml.com/api/workspace/tabbyml/tabby", description = "Local server"), (url = "https://app.tabbyml.com/api/workspace/tabbyml/tabby", description = "Local server"),
(url = "http://localhost:8080", description = "Local server"), (url = "http://localhost:8080", description = "Local server"),
), ),
paths(events::log_event, completions::completion,), paths(events::log_event, completions::completion, health),
components(schemas( components(schemas(
events::LogEventRequest, events::LogEventRequest,
completions::CompletionRequest, completions::CompletionRequest,
completions::CompletionResponse, completions::CompletionResponse,
completions::Segments, completions::Segments,
completions::Choice completions::Choice,
)) ))
)] )]
struct ApiDoc; struct ApiDoc;
@ -106,6 +106,7 @@ pub async fn main(args: &ServeArgs) {
fn api_router(args: &ServeArgs) -> Router { fn api_router(args: &ServeArgs) -> Router {
Router::new() Router::new()
.route("/events", routing::post(events::log_event)) .route("/events", routing::post(events::log_event))
.route("/health", routing::post(health))
.route( .route(
"/completions", "/completions",
routing::post(completions::completion) routing::post(completions::completion)
@ -131,3 +132,13 @@ fn valid_args(args: &ServeArgs) {
fatal!("CPU device only supports device indices = [0]"); fatal!("CPU device only supports device indices = [0]");
} }
} }
#[utoipa::path(
post,
path = "/v1/health",
tag = "v1",
responses(
(status = 200, description = "Health"),
)
)]
async fn health() {}