From b1a6c8bc24aca0cce50ff0c7690c5b85c59b2955 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Fri, 11 Apr 2025 16:32:34 +0300 Subject: [PATCH 1/2] server : add VSCode's Github Copilot Chat support --- examples/server/server.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/examples/server/server.cpp b/examples/server/server.cpp index 1bf1ee876b40f..efa97d933e1b8 100644 --- a/examples/server/server.cpp +++ b/examples/server/server.cpp @@ -3907,6 +3907,21 @@ int main(int argc, char ** argv) { res_ok(res, {{ "success", true }}); }; + const auto handle_api = [&ctx_server, &res_ok](const httplib::Request &, httplib::Response & res) { + json data = { + { + "template", common_chat_templates_source(ctx_server.chat_templates.get()), + }, + { + "model_info", { + { "llama.context_length", ctx_server.slots.back().n_ctx, }, + } + }, + }; + + res_ok(res, data); + }; + // handle completion-like requests (completion, chat, infill) // we can optionally provide a custom format for partial results and final results const auto handle_completions_impl = [&ctx_server, &res_error, &res_ok]( @@ -4471,6 +4486,7 @@ int main(int argc, char ** argv) { svr->Get ("/metrics", handle_metrics); svr->Get ("/props", handle_props); svr->Post("/props", handle_props_change); + svr->Post("/api/show", handle_api); svr->Get ("/models", handle_models); // public endpoint (no API key check) svr->Get ("/v1/models", handle_models); // public endpoint (no API key check) svr->Post("/completion", handle_completions); // legacy From 359cf643fd4e5f8a98c0d3015337d5b963ac201e Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Fri, 11 Apr 2025 23:32:43 +0300 Subject: [PATCH 2/2] cont : update handler name --- examples/server/server.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/server/server.cpp b/examples/server/server.cpp index efa97d933e1b8..d87bda1a0d5af 100644 --- a/examples/server/server.cpp +++ b/examples/server/server.cpp @@ -3907,7 +3907,7 @@ int main(int argc, char ** argv) { res_ok(res, {{ "success", true }}); }; - const auto handle_api = [&ctx_server, &res_ok](const httplib::Request &, httplib::Response & res) { + const auto handle_api_show = [&ctx_server, &res_ok](const httplib::Request &, httplib::Response & res) { json data = { { "template", common_chat_templates_source(ctx_server.chat_templates.get()), @@ -4486,7 +4486,7 @@ int main(int argc, char ** argv) { svr->Get ("/metrics", handle_metrics); svr->Get ("/props", handle_props); svr->Post("/props", handle_props_change); - svr->Post("/api/show", handle_api); + svr->Post("/api/show", handle_api_show); svr->Get ("/models", handle_models); // public endpoint (no API key check) svr->Get ("/v1/models", handle_models); // public endpoint (no API key check) svr->Post("/completion", handle_completions); // legacy