From 86b907f82ad1cc5eb16e919d6cb5830765d73be4 Mon Sep 17 00:00:00 2001 From: royjhan <65097070+royjhan@users.noreply.github.com> Date: Mon, 5 Aug 2024 19:55:34 -0400 Subject: [PATCH] sort batch results (#6189) --- llm/ext_server/server.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/llm/ext_server/server.cpp b/llm/ext_server/server.cpp index d72bb1b1..071fe1e7 100644 --- a/llm/ext_server/server.cpp +++ b/llm/ext_server/server.cpp @@ -44,6 +44,7 @@ #include #endif +#include #include #include #include @@ -1220,6 +1221,7 @@ struct llama_server_context res.result_json = json { + {"id", res.id}, {"embedding", std::vector(embd, embd + n_embd)}, {"timings", slot.get_formated_timings()}, }; @@ -3203,6 +3205,10 @@ int main(int argc, char **argv) { } responses = result.result_json.value("results", std::vector{result.result_json}); + std::sort(responses.begin(), responses.end(), [](const json& a, const json& b) { + return a["id"] < b["id"]; + }); + json embeddings = json::array(); int prompt_n = 0;