From 21b70babf759f30b52cef6cb4ef1a206e56ca70e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobi=20L=C3=BCtke?= Date: Fri, 24 Nov 2023 11:22:39 -0500 Subject: [PATCH] straightforward /v1/models endpoint --- examples/server/server.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/examples/server/server.cpp b/examples/server/server.cpp index b5f3f38d4..50f124b13 100644 --- a/examples/server/server.cpp +++ b/examples/server/server.cpp @@ -2660,6 +2660,26 @@ int main(int argc, char **argv) }); + + svr.Get("/v1/models", [¶ms](const httplib::Request&, httplib::Response& res) + { + std::time_t t = std::time(0); + + json models = { + {"object", "list"}, + {"data", { + { + {"id", params.model_alias}, + {"object", "model"}, + {"created", t}, + {"owned_by", "llamacpp"} + }, + }} + }; + + res.set_content(models.dump(), "application/json"); + }); + // TODO: add mount point without "/v1" prefix -- how? svr.Post("/v1/chat/completions", [&llama](const httplib::Request &req, httplib::Response &res) {