-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
218 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,28 @@ | ||
#include "engine_get_cmd.h" | ||
#include <iostream> | ||
#include <tabulate/table.hpp> | ||
#include "utils/file_manager_utils.h" | ||
#include "services/engine_service.h" | ||
#include "utils/logging_utils.h" | ||
|
||
namespace commands { | ||
|
||
void EngineGetCmd::Exec() const { | ||
CTL_INF("[EneingeGetCmd] engine: " << engine_); | ||
CTL_INF("[EngineGetCmd] engine: " << engine_); | ||
|
||
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"}; | ||
|
||
#ifdef _WIN32 | ||
onnx_status = std::filesystem::exists(ecp / "cortex.onnx") | ||
? "ready" | ||
: "not_initialized"; | ||
tensorrt_status = std::filesystem::exists(ecp / "cortex.tensorrt-llm") | ||
? "ready" | ||
: "not_initialized"; | ||
#elif defined(__linux__) | ||
tensorrt_status = std::filesystem::exists(ecp / "cortex.tensorrt-llm") | ||
? "ready" | ||
: "not_initialized"; | ||
#endif | ||
std::vector<EngineInfo> engines = { | ||
{.name = "cortex.onnx", | ||
.description = "This extension enables chat completion API calls using " | ||
"the Onnx engine", | ||
.version = "0.0.1", | ||
.product_name = "Onnx Inference Engine", | ||
.status = onnx_status}, | ||
{.name = "cortex.llamacpp", | ||
.description = "This extension enables chat completion API calls using " | ||
"the LlamaCPP engine", | ||
.version = "0.0.1", | ||
.product_name = "LlamaCPP Inference Engine", | ||
.status = llamacpp_status}, | ||
{.name = "cortex.tensorrt-llm", | ||
.description = "This extension enables chat completion API calls using " | ||
"the TensorrtLLM engine", | ||
.version = "0.0.1", | ||
.product_name = "TensorrtLLM Inference Engine", | ||
.status = tensorrt_status}, | ||
}; | ||
|
||
tabulate::Table table; | ||
table.add_row({"name", "description", "version", "product name", "status"}); | ||
table.format().font_color(tabulate::Color::green); | ||
for (auto& engine : engines) { | ||
if (engine.name == engine_) { | ||
table.add_row({engine.name, engine.description, engine.version, | ||
engine.product_name, engine.status}); | ||
} | ||
auto engine_service = EngineService(); | ||
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}); | ||
std::cout << table << std::endl; | ||
} catch (const std::runtime_error& e) { | ||
std::cerr << "Engine " << engine_ << " is not supported!" << "\n"; | ||
} catch (const std::exception& e) { | ||
std::cerr << "Failed to get engine info for " << engine_ << ": " << e.what() | ||
<< "\n"; | ||
} | ||
|
||
std::cout << table << std::endl; | ||
} | ||
}; // namespace commands |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.