Skip to content

Commit 4595041

Browse files
authored
server : fix endpoint checks (#10135)
ggml-ci
1 parent 1926d6e commit 4595041

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

examples/server/server.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,8 +2703,8 @@ int main(int argc, char ** argv) {
27032703
};
27042704

27052705
const auto handle_completions_generic = [&ctx_server, &res_error, &res_ok](server_task_inf_type inf_type, json & data, httplib::Response & res) {
2706-
if (ctx_server.params.embedding || ctx_server.params.reranking) {
2707-
res_error(res, format_error_response("This server does not support completions. Start it without `--embeddings` or `--reranking`", ERROR_TYPE_NOT_SUPPORTED));
2706+
if (ctx_server.params.embedding) {
2707+
res_error(res, format_error_response("This server does not support completions. Start it without `--embeddings`", ERROR_TYPE_NOT_SUPPORTED));
27082708
return;
27092709
}
27102710

@@ -2809,8 +2809,8 @@ int main(int argc, char ** argv) {
28092809

28102810
// TODO: maybe merge this function with "handle_completions_generic"
28112811
const auto handle_chat_completions = [&ctx_server, &params, &res_error, &res_ok, verbose](const httplib::Request & req, httplib::Response & res) {
2812-
if (ctx_server.params.embedding || ctx_server.params.reranking) {
2813-
res_error(res, format_error_response("This server does not support completions. Start it without `--embeddings` or `--reranking`", ERROR_TYPE_NOT_SUPPORTED));
2812+
if (ctx_server.params.embedding) {
2813+
res_error(res, format_error_response("This server does not support completions. Start it without `--embeddings`", ERROR_TYPE_NOT_SUPPORTED));
28142814
return;
28152815
}
28162816

@@ -2935,11 +2935,6 @@ int main(int argc, char ** argv) {
29352935
};
29362936

29372937
const auto handle_embeddings = [&ctx_server, &res_error, &res_ok](const httplib::Request & req, httplib::Response & res) {
2938-
// TODO: somehow clean up this checks in the future
2939-
if (!ctx_server.params.embedding || ctx_server.params.reranking) {
2940-
res_error(res, format_error_response("This server does not support embeddings. Start it with `--embeddings` and without `--reranking`", ERROR_TYPE_NOT_SUPPORTED));
2941-
return;
2942-
}
29432938
const json body = json::parse(req.body);
29442939
bool is_openai = false;
29452940

@@ -2991,10 +2986,11 @@ int main(int argc, char ** argv) {
29912986
};
29922987

29932988
const auto handle_rerank = [&ctx_server, &res_error, &res_ok](const httplib::Request & req, httplib::Response & res) {
2994-
if (!ctx_server.params.reranking) {
2995-
res_error(res, format_error_response("This server does not support reranking. Start it with `--reranking`", ERROR_TYPE_NOT_SUPPORTED));
2989+
if (!ctx_server.params.reranking || ctx_server.params.embedding) {
2990+
res_error(res, format_error_response("This server does not support reranking. Start it with `--reranking` and without `--embedding`", ERROR_TYPE_NOT_SUPPORTED));
29962991
return;
29972992
}
2993+
29982994
const json body = json::parse(req.body);
29992995

30002996
// TODO: implement

0 commit comments

Comments
 (0)