mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2024-12-24 10:24:35 +00:00
server : add /v1/completions
endpoint (#5914)
* add-`/v1/completions`-endpoint * add legacy comment to `/completion` endpoint
This commit is contained in:
parent
2002bc96bf
commit
55a2a900ff
@ -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;
|
||||
@ -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", [¶ms, &model_meta](const httplib::Request & req, httplib::Response & res) {
|
||||
res.set_header("Access-Control-Allow-Origin", req.get_header_value("Origin"));
|
||||
|
Loading…
Reference in New Issue
Block a user