From c5e97fe0a2587d101d0fe11d2f514f6c0f06310d Mon Sep 17 00:00:00 2001 From: tikikun Date: Mon, 13 Nov 2023 09:54:11 +0700 Subject: [PATCH] feat: add model status and information dump --- controllers/llamaCPP.cc | 12 ++++++++++++ controllers/llamaCPP.h | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/controllers/llamaCPP.cc b/controllers/llamaCPP.cc index 680916494..19c3b30d4 100644 --- a/controllers/llamaCPP.cc +++ b/controllers/llamaCPP.cc @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -214,6 +215,17 @@ void llamaCPP::unloadModel( callback(resp); return; } +void llamaCPP::modelStatus( + const HttpRequestPtr &req, + std::function &&callback) { + Json::Value jsonResp; + jsonResp["model_loaded"] = this->model_loaded.load(); + jsonResp["model_data"] = llama.get_model_props().dump(); + + auto resp = nitro_utils::nitroHttpJsonResponse(jsonResp); + callback(resp); + return; +} void llamaCPP::loadModel( const HttpRequestPtr &req, diff --git a/controllers/llamaCPP.h b/controllers/llamaCPP.h index 03999b18a..6826785d7 100644 --- a/controllers/llamaCPP.h +++ b/controllers/llamaCPP.h @@ -2125,6 +2125,7 @@ class llamaCPP : public drogon::HttpController { METHOD_ADD(llamaCPP::embedding, "embedding", Post); METHOD_ADD(llamaCPP::loadModel, "loadmodel", Post); METHOD_ADD(llamaCPP::unloadModel, "unloadmodel", Get); + METHOD_ADD(llamaCPP::modelStatus, "modelstatus", Get); // PATH_ADD("/llama/chat_completion", Post); METHOD_LIST_END @@ -2136,6 +2137,10 @@ class llamaCPP : public drogon::HttpController { std::function &&callback); void unloadModel(const HttpRequestPtr &req, std::function &&callback); + + void modelStatus(const HttpRequestPtr &req, + std::function &&callback); + void warmupModel(); void backgroundTask();