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

Commit b239378

Browse files
committed
fix: add start time for model
1 parent aba833e commit b239378

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

engine/extensions/local-engine/local_engine.cc

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,8 @@ void LocalEngine::LoadModel(std::shared_ptr<Json::Value> json_body,
566566

567567
s.process_info = result.value();
568568
if (wait_for_server_up(model_id, s.host, s.port)) {
569+
s.start_time = std::chrono::system_clock::now().time_since_epoch() /
570+
std::chrono::milliseconds(1);
569571
Json::Value response;
570572
response["status"] = "Model loaded successfully with pid: " +
571573
std::to_string(s.process_info.pid);
@@ -665,7 +667,35 @@ void LocalEngine::GetModelStatus(std::shared_ptr<Json::Value> json_body,
665667
}
666668

667669
void LocalEngine::GetModels(std::shared_ptr<Json::Value> json_body,
668-
http_callback&& callback) {}
670+
http_callback&& callback) {
671+
Json::Value json_resp;
672+
Json::Value model_array(Json::arrayValue);
673+
{
674+
for (const auto& [m, s] : server_map_) {
675+
Json::Value val;
676+
val["id"] = m;
677+
val["engine"] = kLlamaEngine;
678+
val["start_time"] = s.start_time;
679+
val["model_size"] = 0u;
680+
val["vram"] = 0u;
681+
val["ram"] = 0u;
682+
val["object"] = "model";
683+
model_array.append(val);
684+
}
685+
}
686+
687+
json_resp["object"] = "list";
688+
json_resp["data"] = model_array;
689+
690+
Json::Value status;
691+
status["is_done"] = true;
692+
status["has_error"] = false;
693+
status["is_stream"] = false;
694+
status["status_code"] = 200;
695+
callback(std::move(status), std::move(json_resp));
696+
CTL_INF("Running models responded");
697+
(void)json_body;
698+
}
669699

670700
void LocalEngine::HandleOpenAiChatCompletion(
671701
std::shared_ptr<Json::Value> json_body, http_callback&& callback,

engine/extensions/local-engine/local_engine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ struct ServerAddress {
2121
std::string user_prompt;
2222
std::string ai_prompt;
2323
std::string system_prompt;
24+
uint64_t start_time;
2425
};
2526

2627
class LocalEngine : public EngineI {

0 commit comments

Comments
 (0)