Skip to content

Commit

Permalink
server : add /v1/completions endpoint (#5914)
Browse files Browse the repository at this point in the history
* add-`/v1/completions`-endpoint

* add legacy comment to `/completion` endpoint
  • Loading branch information
mscheong01 authored Mar 7, 2024
1 parent 2002bc9 commit 55a2a90
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions examples/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2923,7 +2923,7 @@ int main(int argc, char ** argv) {
res.set_content(data.dump(), "application/json; charset=utf-8");
});

svr.Post("/completion", [&ctx_server, &validate_api_key](const httplib::Request & req, httplib::Response & res) {
const auto completions = [&ctx_server, &validate_api_key](const httplib::Request & req, httplib::Response & res) {
res.set_header("Access-Control-Allow-Origin", req.get_header_value("Origin"));
if (!validate_api_key(req, res)) {
return;
Expand Down Expand Up @@ -3001,7 +3001,11 @@ int main(int argc, char ** argv) {

res.set_chunked_content_provider("text/event-stream", chunked_content_provider, on_complete);
}
});
};

svr.Post("/completion", completions); // legacy
svr.Post("/completions", completions);
svr.Post("/v1/completions", completions);

svr.Get("/v1/models", [&params, &model_meta](const httplib::Request & req, httplib::Response & res) {
res.set_header("Access-Control-Allow-Origin", req.get_header_value("Origin"));
Expand Down

0 comments on commit 55a2a90

Please sign in to comment.