Skip to content

Commit 21937dc

Browse files
author
matteo
committed
api version endpoint for ollama vscode client
1 parent 9de9672 commit 21937dc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tools/server/server.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4593,6 +4593,12 @@ int main(int argc, char ** argv) {
45934593
res_ok(res, health);
45944594
};
45954595

4596+
const auto handle_version = [&](const httplib::Request &, httplib::Response & res) {
4597+
// returns the build number
4598+
json version = {{"version", std::to_string(LLAMA_BUILD_NUMBER)}};
4599+
res_ok(res, version);
4600+
};
4601+
45964602
const auto handle_slots = [&](const httplib::Request & req, httplib::Response & res) {
45974603
if (!params.endpoint_slots) {
45984604
res_error(res, format_error_response("This server does not support slots endpoint. Start it with `--slots`", ERROR_TYPE_NOT_SUPPORTED));
@@ -5582,6 +5588,7 @@ int main(int argc, char ** argv) {
55825588
svr->Get (params.api_prefix + "/models", handle_models); // public endpoint (no API key check)
55835589
svr->Get (params.api_prefix + "/v1/models", handle_models); // public endpoint (no API key check)
55845590
svr->Get (params.api_prefix + "/api/tags", handle_models); // ollama specific endpoint. public endpoint (no API key check)
5591+
svr->Get (params.api_prefix + "/api/version", handle_version); // ollama endpoint, for compatibility with vscode
55855592
svr->Post(params.api_prefix + "/completion", handle_completions); // legacy
55865593
svr->Post(params.api_prefix + "/completions", handle_completions);
55875594
svr->Post(params.api_prefix + "/v1/completions", handle_completions_oai);

0 commit comments

Comments
 (0)