Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit c18c650

Browse files
fix: auto-reload model for remote engine (#1971)
Co-authored-by: sangjanai <[email protected]>
1 parent 0991133 commit c18c650

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

engine/controllers/engines.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,19 +379,21 @@ void Engines::UpdateEngine(
379379
metadata = (*exist_engine).metadata;
380380
}
381381

382-
(void) engine_service_->UnloadEngine(engine);
382+
(void)engine_service_->UnloadEngine(engine);
383383

384384
auto upd_res =
385385
engine_service_->UpsertEngine(engine, type, api_key, url, version,
386386
"all-platforms", status, metadata);
387387
if (upd_res.has_error()) {
388388
Json::Value res;
389389
res["message"] = upd_res.error();
390+
CTL_WRN("Error: " << upd_res.error());
390391
auto resp = cortex_utils::CreateCortexHttpJsonResponse(res);
391392
resp->setStatusCode(k400BadRequest);
392393
callback(resp);
393394
} else {
394395
Json::Value res;
396+
CTL_INF("Remote Engine update successfully!");
395397
res["message"] = "Remote Engine update successfully!";
396398
auto resp = cortex_utils::CreateCortexHttpJsonResponse(res);
397399
resp->setStatusCode(k200OK);
@@ -400,6 +402,7 @@ void Engines::UpdateEngine(
400402
} else {
401403
Json::Value res;
402404
res["message"] = "Request body is empty!";
405+
CTL_WRN("Error: Request body is empty!");
403406
auto resp = cortex_utils::CreateCortexHttpJsonResponse(res);
404407
resp->setStatusCode(k400BadRequest);
405408
callback(resp);

engine/services/inference_service.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ cpp::result<void, InferResult> InferenceService::HandleChatCompletion(
3838
LOG_WARN << "Engine is not loaded yet";
3939
return cpp::fail(std::make_pair(stt, res));
4040
}
41-
41+
4242
if (!model_id.empty()) {
4343
if (auto model_service = model_service_.lock()) {
4444
auto metadata_ptr = model_service->GetCachedModelMetadata(model_id);
@@ -72,7 +72,6 @@ cpp::result<void, InferResult> InferenceService::HandleChatCompletion(
7272
}
7373
}
7474

75-
7675
CTL_DBG("Json body inference: " + json_body->toStyledString());
7776

7877
auto cb = [q, tool_choice](Json::Value status, Json::Value res) {
@@ -217,10 +216,9 @@ InferResult InferenceService::LoadModel(
217216
std::get<RemoteEngineI*>(engine_result.value())
218217
->LoadModel(json_body, std::move(cb));
219218
}
220-
if (!engine_service_->IsRemoteEngine(engine_type)) {
221-
auto model_id = json_body->get("model", "").asString();
222-
saved_models_[model_id] = json_body;
223-
}
219+
// Save model config to reload if needed
220+
auto model_id = json_body->get("model", "").asString();
221+
saved_models_[model_id] = json_body;
224222
return std::make_pair(stt, r);
225223
}
226224

0 commit comments

Comments
 (0)