Skip to content

Commit

Permalink
feat(ui): always display chat api endpoints in swagger doc (#784)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsxiaoys authored Nov 14, 2023
1 parent 6236566 commit bd072d8
Showing 1 changed file with 1 addition and 22 deletions.
23 changes: 1 addition & 22 deletions crates/tabby/src/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,9 @@ pub async fn main(config: &Config, args: &ServeArgs) {

info!("Starting server, this might takes a few minutes...");

let mut doc = ApiDoc::openapi();
doc.override_doc(args);

let app = Router::new()
.merge(api_router(args, config).await)
.merge(SwaggerUi::new("/swagger-ui").url("/api-docs/openapi.json", doc));
.merge(SwaggerUi::new("/swagger-ui").url("/api-docs/openapi.json", ApiDoc::openapi()));

let app = attach_webserver(app).await;

Expand Down Expand Up @@ -217,21 +214,3 @@ fn start_heartbeat(args: &ServeArgs) {
}
});
}

trait OpenApiOverride {
fn override_doc(&mut self, args: &ServeArgs);
}

impl OpenApiOverride for utoipa::openapi::OpenApi {
fn override_doc(&mut self, args: &ServeArgs) {
if args.chat_model.is_none() {
self.paths.paths.remove("/v1beta/chat/completions");

if let Some(components) = self.components.as_mut() {
components.schemas.remove("ChatCompletionRequest");
components.schemas.remove("ChatCompletionChunk");
components.schemas.remove("Message");
}
}
}
}

0 comments on commit bd072d8

Please sign in to comment.