Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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