From e1caeb8ed34f2d242735b26a1cec5ecb27b8c04a Mon Sep 17 00:00:00 2001 From: James Date: Tue, 10 Sep 2024 15:44:04 +0700 Subject: [PATCH] chore: update engine list --- .github/workflows/cortex-cpp-quality-gate.yml | 2 +- .github/workflows/nightly-build.yml | 2 +- .../workflows/platform-openai-coverage.yml | 2 +- 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 + 7 files changed, 32 insertions(+), 41 deletions(-) diff --git a/.github/workflows/cortex-cpp-quality-gate.yml b/.github/workflows/cortex-cpp-quality-gate.yml index 49bc0637b..b10bbff2f 100644 --- a/.github/workflows/cortex-cpp-quality-gate.yml +++ b/.github/workflows/cortex-cpp-quality-gate.yml @@ -90,7 +90,7 @@ jobs: make package - name: Upload Artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: cortex-cpp-${{ matrix.os }}-${{ matrix.name }} path: ./engine/cortex-cpp diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.yml index 759181bc7..1d68b129a 100644 --- a/.github/workflows/nightly-build.yml +++ b/.github/workflows/nightly-build.yml @@ -151,7 +151,7 @@ jobs: make package - name: Upload Artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: cortex-cpp-${{ matrix.os }}-${{ matrix.name }} path: ./cortex-cpp/cortex-cpp diff --git a/.github/workflows/platform-openai-coverage.yml b/.github/workflows/platform-openai-coverage.yml index 010113f53..c432066a6 100644 --- a/.github/workflows/platform-openai-coverage.yml +++ b/.github/workflows/platform-openai-coverage.yml @@ -95,7 +95,7 @@ jobs: AWS_EC2_METADATA_DISABLED: "true" - name: Upload Artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: report path: | 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;