Skip to content

Commit

Permalink
feat: add model status and information dump
Browse files Browse the repository at this point in the history
  • Loading branch information
tikikun committed Nov 13, 2023
1 parent f49bd78 commit c5e97fe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions controllers/llamaCPP.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <drogon/HttpResponse.h>
#include <drogon/HttpTypes.h>
#include <regex>
#include <string>
#include <thread>
#include <trantor/utils/Logger.h>

Expand Down Expand Up @@ -214,6 +215,17 @@ void llamaCPP::unloadModel(
callback(resp);
return;
}
void llamaCPP::modelStatus(
const HttpRequestPtr &req,
std::function<void(const HttpResponsePtr &)> &&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,
Expand Down
5 changes: 5 additions & 0 deletions controllers/llamaCPP.h
Original file line number Diff line number Diff line change
Expand Up @@ -2125,6 +2125,7 @@ class llamaCPP : public drogon::HttpController<llamaCPP> {
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
Expand All @@ -2136,6 +2137,10 @@ class llamaCPP : public drogon::HttpController<llamaCPP> {
std::function<void(const HttpResponsePtr &)> &&callback);
void unloadModel(const HttpRequestPtr &req,
std::function<void(const HttpResponsePtr &)> &&callback);

void modelStatus(const HttpRequestPtr &req,
std::function<void(const HttpResponsePtr &)> &&callback);

void warmupModel();

void backgroundTask();
Expand Down

0 comments on commit c5e97fe

Please sign in to comment.