Skip to content

Commit

Permalink
fix: use current engine if does not specify in request
Browse files Browse the repository at this point in the history
  • Loading branch information
vansangpfiev authored and sangjanai committed Jun 13, 2024
1 parent 5618917 commit a36c218
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cortex-cpp/controllers/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void server::ChatCompletion(
const HttpRequestPtr& req,
std::function<void(const HttpResponsePtr&)>&& callback) {
auto engine_type =
(*(req->getJsonObject())).get("engine", kLlamaEngine).asString();
(*(req->getJsonObject())).get("engine", cur_engine_type_).asString();
if (!IsEngineLoaded(engine_type)) {
Json::Value res;
res["message"] = "Engine is not loaded yet";
Expand Down Expand Up @@ -92,7 +92,7 @@ void server::UnloadModel(
const HttpRequestPtr& req,
std::function<void(const HttpResponsePtr&)>&& callback) {
auto engine_type =
(*(req->getJsonObject())).get("engine", kLlamaEngine).asString();
(*(req->getJsonObject())).get("engine", cur_engine_type_).asString();
if (!IsEngineLoaded(engine_type)) {
Json::Value res;
res["message"] = "Engine is not loaded yet";
Expand All @@ -119,7 +119,7 @@ void server::ModelStatus(
const HttpRequestPtr& req,
std::function<void(const HttpResponsePtr&)>&& callback) {
auto engine_type =
(*(req->getJsonObject())).get("engine", kLlamaEngine).asString();
(*(req->getJsonObject())).get("engine", cur_engine_type_).asString();
if (!IsEngineLoaded(engine_type)) {
Json::Value res;
res["message"] = "Engine is not loaded yet";
Expand Down Expand Up @@ -262,6 +262,8 @@ void server::LoadModel(const HttpRequestPtr& req,
auto get_engine_path = [](std::string_view e) {
if (e == kLlamaEngine) {
return cortex_utils::kLlamaLibPath;
} else if(e == kOnnxEngine) {
return cortex_utils::kOnnxLibPath;
}
return cortex_utils::kLlamaLibPath;
};
Expand Down

0 comments on commit a36c218

Please sign in to comment.