summaryrefslogtreecommitdiff
path: root/examples/server/utils.hpp
diff options
context:
space:
mode:
authorXuan Son Nguyen <thichthat@gmail.com>2024-03-13 11:39:11 +0100
committerGitHub <noreply@github.com>2024-03-13 11:39:11 +0100
commit99b71c068f624521ad977e08e41589e2971fa1c7 (patch)
tree0ad0e41dcd7505e90f4cc1163a053dececf76307 /examples/server/utils.hpp
parent306d34be7ad19e768975409fc80791a274ea0230 (diff)
Server: Use multi-task for embeddings endpoint (#6001)
* use multitask for embd endpoint * specify types * remove redundant {"n_predict", 0}
Diffstat (limited to 'examples/server/utils.hpp')
-rw-r--r--examples/server/utils.hpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/examples/server/utils.hpp b/examples/server/utils.hpp
index 48aeef4e..2ddb2cd2 100644
--- a/examples/server/utils.hpp
+++ b/examples/server/utils.hpp
@@ -529,6 +529,16 @@ static std::vector<json> format_partial_response_oaicompat(json result, const st
}
static json format_embeddings_response_oaicompat(const json & request, const json & embeddings) {
+ json data = json::array();
+ int i = 0;
+ for (auto & elem : embeddings) {
+ data.push_back(json{
+ {"embedding", json_value(elem, "embedding", json::array())},
+ {"index", i++},
+ {"object", "embedding"}
+ });
+ }
+
json res = json {
{"model", json_value(request, "model", std::string(DEFAULT_OAICOMPAT_MODEL))},
{"object", "list"},
@@ -536,7 +546,7 @@ static json format_embeddings_response_oaicompat(const json & request, const jso
{"prompt_tokens", 0},
{"total_tokens", 0}
}},
- {"data", embeddings}
+ {"data", data}
};
return res;