Skip to content

Commit a200520

Browse files
committed
simplify top_n init since no need to return error
result to test : ./tests.sh unit/test_rerank.py -v -x ==================================================== test session starts ===================================================== platform linux -- Python 3.12.3, pytest-8.3.5, pluggy-1.6.0 -- /home/yann/dev/yann/llama.cpp/tools/server/tests/test/bin/python3 cachedir: .pytest_cache rootdir: /home/yann/dev/yann/llama.cpp/tools/server/tests configfile: pytest.ini plugins: anyio-4.11.0 collected 8 items unit/test_rerank.py::test_rerank PASSED [ 12%] unit/test_rerank.py::test_rerank_tei_format PASSED [ 25%] unit/test_rerank.py::test_invalid_rerank_req[documents0] PASSED [ 37%] unit/test_rerank.py::test_invalid_rerank_req[None] PASSED [ 50%] unit/test_rerank.py::test_invalid_rerank_req[123] PASSED [ 62%] unit/test_rerank.py::test_invalid_rerank_req[documents3] PASSED [ 75%] unit/test_rerank.py::test_rerank_usage[Machine learning is-A machine-Learning is-19] PASSED [ 87%] unit/test_rerank.py::test_rerank_usage[Which city?-Machine learning is -Paris, capitale de la-26] PASSED [100%] ===================================================== 8 passed in 4.31s ======================================================
1 parent fd143c7 commit a200520

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

tools/server/server.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5084,10 +5084,7 @@ int main(int argc, char ** argv) {
50845084
return;
50855085
}
50865086

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-
}
5087+
int top_n = json_value(body, "top_n", (int)documents.size());
50915088

50925089
// create and queue the task
50935090
json responses = json::array();

0 commit comments

Comments
 (0)