server: refactor: clean up http code
This commit is contained in:
parent
59850f18e5
commit
65cb1fbbf9
1 changed files with 3 additions and 1 deletions
|
@ -2945,7 +2945,7 @@ int main(int argc, char ** argv) {
|
||||||
if (!result.error && result.stop) {
|
if (!result.error && result.stop) {
|
||||||
res.set_content(result.data.dump(-1, ' ', false, json::error_handler_t::replace), "application/json; charset=utf-8");
|
res.set_content(result.data.dump(-1, ' ', false, json::error_handler_t::replace), "application/json; charset=utf-8");
|
||||||
} else {
|
} else {
|
||||||
res.status = 404;
|
res.status = 400;
|
||||||
res.set_content(result.data["content"], "text/plain; charset=utf-8");
|
res.set_content(result.data["content"], "text/plain; charset=utf-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3202,6 +3202,7 @@ int main(int argc, char ** argv) {
|
||||||
svr.Post("/embedding", [¶ms, &llama](const httplib::Request & req, httplib::Response & res) {
|
svr.Post("/embedding", [¶ms, &llama](const httplib::Request & req, httplib::Response & res) {
|
||||||
res.set_header("Access-Control-Allow-Origin", req.get_header_value("Origin"));
|
res.set_header("Access-Control-Allow-Origin", req.get_header_value("Origin"));
|
||||||
if (!params.embedding) {
|
if (!params.embedding) {
|
||||||
|
res.status = 400;
|
||||||
res.set_content("This server does not support embeddings. Start it with `--embeddings`", "text/plain; charset=utf-8");
|
res.set_content("This server does not support embeddings. Start it with `--embeddings`", "text/plain; charset=utf-8");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3232,6 +3233,7 @@ int main(int argc, char ** argv) {
|
||||||
svr.Post("/v1/embeddings", [¶ms, &llama](const httplib::Request & req, httplib::Response & res) {
|
svr.Post("/v1/embeddings", [¶ms, &llama](const httplib::Request & req, httplib::Response & res) {
|
||||||
res.set_header("Access-Control-Allow-Origin", req.get_header_value("Origin"));
|
res.set_header("Access-Control-Allow-Origin", req.get_header_value("Origin"));
|
||||||
if (!params.embedding) {
|
if (!params.embedding) {
|
||||||
|
res.status = 400;
|
||||||
res.set_content("This server does not support embeddings. Start it with `--embeddings`", "text/plain; charset=utf-8");
|
res.set_content("This server does not support embeddings. Start it with `--embeddings`", "text/plain; charset=utf-8");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue