From dafa80ae3beb87d44b9690c775d185ee1d470a83 Mon Sep 17 00:00:00 2001 From: tikikun Date: Mon, 27 Nov 2023 13:48:11 +0700 Subject: [PATCH 1/2] bug: fix the model loaded result in error --- controllers/llamaCPP.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/controllers/llamaCPP.cc b/controllers/llamaCPP.cc index 881b9632c..aed1e1cb9 100644 --- a/controllers/llamaCPP.cc +++ b/controllers/llamaCPP.cc @@ -8,6 +8,7 @@ #include #include #include +#include using namespace inferences; using json = nlohmann::json; @@ -149,6 +150,15 @@ void llamaCPP::chatCompletion( const HttpRequestPtr &req, std::function &&callback) { + if (!model_loaded) { + Json::Value jsonResp; + jsonResp["message"] = + "Model has not been loaded, please load model into nitro"; + auto resp = nitro_utils::nitroHttpJsonResponse(jsonResp); + resp->setStatusCode(drogon::k409Conflict); + callback(resp); + } + const auto &jsonBody = req->getJsonObject(); std::string formatted_output = pre_prompt; @@ -338,6 +348,16 @@ void llamaCPP::loadModel( const HttpRequestPtr &req, std::function &&callback) { + if (model_loaded) { + LOG_INFO << "model loaded"; + Json::Value jsonResp; + jsonResp["message"] = "Model already loaded"; + auto resp = nitro_utils::nitroHttpJsonResponse(jsonResp); + resp->setStatusCode(drogon::k409Conflict); + callback(resp); + return; + } + const auto &jsonBody = req->getJsonObject(); gpt_params params; From 2835f900707107e87a941fd5896a591a21b3b8bb Mon Sep 17 00:00:00 2001 From: tikikun Date: Mon, 27 Nov 2023 13:49:09 +0700 Subject: [PATCH 2/2] remove redundant include --- controllers/llamaCPP.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/controllers/llamaCPP.cc b/controllers/llamaCPP.cc index aed1e1cb9..f264a25e2 100644 --- a/controllers/llamaCPP.cc +++ b/controllers/llamaCPP.cc @@ -8,7 +8,6 @@ #include #include #include -#include using namespace inferences; using json = nlohmann::json;