Skip to content

Commit b86bfdb

Browse files
committed
Make the retro compatible if no top_n will return
all results here is a script to make some test ```script URL=${1:-http://127.0.0.1:8181} curl "$URL/v1/rerank" -H "Content-Type: application/json" \ -d '{ "model": "M", "query": "What is the recipe to make bread ?", "return_text" : true, "texts" : true, "top_n": 6, "documents": [ "voici la recette pour faire du pain, il faut de la farine de l eau et du levain et du sel", "it is a bear", "bread recipe : floor, water, yest, salt", "The giant panda (Ailuropoda melanoleuca), sometimes called a panda bear or simply panda, is a bear species endemic to China.", "here is the ingedients to bake bread : 500g floor, 350g water, 120g fresh refresh yest, 15g salt", "recipe to make cookies : floor, eggs, water, chocolat", "here is the recipe to make bread : 500g floor, 350g water, 120g fresh refresh yest, 15g salt", "il fait tres beau aujourd hui", "je n ai pas faim, je ne veux pas manger", "je suis a paris" ] }' | jq ```
1 parent 374b648 commit b86bfdb

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

tools/server/server.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5060,15 +5060,6 @@ int main(int argc, char ** argv) {
50605060

50615061
const json body = json::parse(req.body);
50625062

5063-
// TODO: implement
5064-
int top_n = 1;
5065-
if (body.count("top_n") == 1) {
5066-
top_n = body.at("top_n");
5067-
} else {
5068-
res_error(res, format_error_response("\"top_n\" must be provided", ERROR_TYPE_INVALID_REQUEST));
5069-
return;
5070-
}
5071-
50725063
// if true, use TEI API format, otherwise use Jina API format
50735064
// Jina: https://jina.ai/reranker/
50745065
// TEI: https://huggingface.github.io/text-embeddings-inference/#/Text%20Embeddings%20Inference/rerank
@@ -5093,6 +5084,11 @@ int main(int argc, char ** argv) {
50935084
return;
50945085
}
50955086

5087+
int top_n = documents.size(); // no top_n will return all the documents
5088+
if (body.count("top_n") == 1) {
5089+
top_n = body.at("top_n");
5090+
}
5091+
50965092
// create and queue the task
50975093
json responses = json::array();
50985094
bool error = false;

0 commit comments

Comments
 (0)