From 036978c016d18462ce185e244a5fac95c7d7b8ae Mon Sep 17 00:00:00 2001 From: James Date: Tue, 10 Sep 2024 15:44:04 +0700 Subject: [PATCH] chore: update engine list --- engine/commands/engine_get_cmd.cc | 7 +++--- engine/commands/engine_list_cmd.cc | 22 +++--------------- engine/services/engine_service.cc | 37 ++++++++++++++++++------------ engine/services/engine_service.h | 1 + 4 files changed, 29 insertions(+), 38 deletions(-) diff --git a/engine/commands/engine_get_cmd.cc b/engine/commands/engine_get_cmd.cc index 17ffeaf66..a7ec8fbc1 100644 --- a/engine/commands/engine_get_cmd.cc +++ b/engine/commands/engine_get_cmd.cc @@ -13,10 +13,9 @@ void EngineGetCmd::Exec() const { try { auto status = engine_service.GetEngineInfo(engine_); tabulate::Table table; - table.add_row({"name", "description", "version", "product name", "status"}); - table.format().font_color(tabulate::Color::green); - table.add_row({status.name, status.description, status.version, - status.product_name, status.status}); + table.add_row({"Name", "Supported Formats", "Version", "Status"}); + table.add_row( + {status.product_name, status.format, status.version, status.status}); std::cout << table << std::endl; } catch (const std::runtime_error& e) { std::cerr << "Engine " << engine_ << " is not supported!" << "\n"; diff --git a/engine/commands/engine_list_cmd.cc b/engine/commands/engine_list_cmd.cc index 21220e7e4..4fe1b1321 100644 --- a/engine/commands/engine_list_cmd.cc +++ b/engine/commands/engine_list_cmd.cc @@ -9,28 +9,12 @@ bool EngineListCmd::Exec() { auto status_list = engine_service.GetEngineInfoList(); tabulate::Table table; - table.format().font_color(tabulate::Color::green); - table.add_row( - {"(Index)", "name", "description", "version", "product name", "status"}); + table.add_row({"#", "Name", "Supported Formats", "Version", "Status"}); for (int i = 0; i < status_list.size(); i++) { auto status = status_list[i]; std::string index = std::to_string(i + 1); - table.add_row({index, status.name, status.description, status.version, - status.product_name, status.status}); - } - - for (int i = 0; i < 6; i++) { - table[0][i] - .format() - .font_color(tabulate::Color::white) // Set font color - .font_style({tabulate::FontStyle::bold}) - .font_align(tabulate::FontAlign::center); - } - for (int i = 1; i < 4; i++) { - table[i][0] - .format() - .font_color(tabulate::Color::white) // Set font color - .font_align(tabulate::FontAlign::center); + table.add_row({index, status.product_name, status.format, status.version, + status.status}); } std::cout << table << std::endl; diff --git a/engine/services/engine_service.cc b/engine/services/engine_service.cc index 836a3c10c..10a76e5e7 100644 --- a/engine/services/engine_service.cc +++ b/engine/services/engine_service.cc @@ -3,6 +3,12 @@ #include "algorithm" #include "utils/file_manager_utils.h" +namespace { +constexpr static auto kIncompatible = "Incompatible"; +constexpr static auto kReady = "Ready"; +constexpr static auto kNotInstalled = "Not Installed"; +} // namespace + EngineInfo EngineService::GetEngineInfo(const std::string& engine) const { // if engine is not found in kSupportEngine, throw runtime error if (std::find(kSupportEngines.begin(), kSupportEngines.end(), engine) == @@ -21,42 +27,43 @@ EngineInfo EngineService::GetEngineInfo(const std::string& engine) const { std::vector EngineService::GetEngineInfoList() const { auto ecp = file_manager_utils::GetEnginesContainerPath(); - std::string onnx_status{"not_supported"}; - std::string llamacpp_status = std::filesystem::exists(ecp / "cortex.llamacpp") - ? "ready" - : "not_initialized"; - std::string tensorrt_status{"not_supported"}; + std::string onnx_status{kIncompatible}; + std::string llamacpp_status = + std::filesystem::exists(ecp / "cortex.llamacpp") ? kReady : kNotInstalled; + std::string tensorrt_status{kIncompatible}; #ifdef _WIN32 - onnx_status = std::filesystem::exists(ecp / "cortex.onnx") - ? "ready" - : "not_initialized"; + onnx_status = + std::filesystem::exists(ecp / "cortex.onnx") ? kReady : kNotInstalled; tensorrt_status = std::filesystem::exists(ecp / "cortex.tensorrt-llm") - ? "ready" - : "not_initialized"; + ? kReady + : kNotInstalled; #elif defined(__linux__) tensorrt_status = std::filesystem::exists(ecp / "cortex.tensorrt-llm") - ? "ready" - : "not_initialized"; + ? kReady + : kNotInstalled; #endif std::vector engines = { {.name = "cortex.onnx", .description = "This extension enables chat completion API calls using " "the Onnx engine", + .format = "ONNX", .version = "0.0.1", - .product_name = "Onnx Inference Engine", + .product_name = "ONNXRuntime", .status = onnx_status}, {.name = "cortex.llamacpp", .description = "This extension enables chat completion API calls using " "the LlamaCPP engine", + .format = "GGUF", .version = "0.0.1", - .product_name = "LlamaCPP Inference Engine", + .product_name = "llama.cpp", .status = llamacpp_status}, {.name = "cortex.tensorrt-llm", .description = "This extension enables chat completion API calls using " "the TensorrtLLM engine", + .format = "TensorRT Engines", .version = "0.0.1", - .product_name = "TensorrtLLM Inference Engine", + .product_name = "TensorRT-LLM", .status = tensorrt_status}, }; diff --git a/engine/services/engine_service.h b/engine/services/engine_service.h index 3a9a91876..c6bd4f83a 100644 --- a/engine/services/engine_service.h +++ b/engine/services/engine_service.h @@ -7,6 +7,7 @@ struct EngineInfo { std::string name; std::string description; + std::string format; std::string version; std::string product_name; std::string status;