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

Commit 7b5f2a1

Browse files
committed
update
1 parent 12f9a52 commit 7b5f2a1

File tree

4 files changed

+18
-88
lines changed

4 files changed

+18
-88
lines changed

engine/controllers/engines.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,13 @@ void Engines::ListEngine(
8080
void Engines::UninstallEngine(
8181
const HttpRequestPtr& req,
8282
std::function<void(const HttpResponsePtr&)>&& callback,
83-
const std::string& engine) {
83+
const std::string& engine, const std::string& version,
84+
const std::string& variant) {
8485

85-
auto result = engine_service_->UninstallEngine(engine);
86-
Json::Value ret;
86+
auto result =
87+
engine_service_->UninstallEngineVariant(engine, variant, version);
8788

89+
Json::Value ret;
8890
if (result.has_error()) {
8991
CTL_INF(result.error());
9092
ret["message"] = result.error();

engine/controllers/engines.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Engines : public drogon::HttpController<Engines, false> {
1414

1515
// TODO: update this API
1616
METHOD_ADD(Engines::InstallEngine, "/install/{1}", Post);
17-
METHOD_ADD(Engines::UninstallEngine, "/{1}", Delete);
17+
METHOD_ADD(Engines::UninstallEngine, "/{1}/{2}/{3}", Delete);
1818
METHOD_ADD(Engines::ListEngine, "", Get);
1919

2020
METHOD_ADD(Engines::GetEngineVersions, "/{1}/versions", Get);
@@ -31,7 +31,7 @@ class Engines : public drogon::HttpController<Engines, false> {
3131
METHOD_ADD(Engines::UnloadEngine, "/{1}/load", Delete);
3232

3333
ADD_METHOD_TO(Engines::InstallEngine, "/v1/engines/install/{1}", Post);
34-
ADD_METHOD_TO(Engines::UninstallEngine, "/v1/engines/{1}", Delete);
34+
ADD_METHOD_TO(Engines::UninstallEngine, "/v1/engines/{1}/{2}/{3}", Delete);
3535

3636
METHOD_LIST_END
3737

@@ -47,7 +47,8 @@ class Engines : public drogon::HttpController<Engines, false> {
4747

4848
void UninstallEngine(const HttpRequestPtr& req,
4949
std::function<void(const HttpResponsePtr&)>&& callback,
50-
const std::string& engine);
50+
const std::string& engine, const std::string& version,
51+
const std::string& variant);
5152

5253
void GetEngineVersions(const HttpRequestPtr& req,
5354
std::function<void(const HttpResponsePtr&)>&& callback,

engine/services/engine_service.cc

Lines changed: 6 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -59,81 +59,6 @@ std::string GetEnginePath(std::string_view e) {
5959
};
6060
} // namespace
6161

62-
// cpp::result<EngineInfo, std::string> EngineService::GetEngineInfo(
63-
// const std::string& engine) const {
64-
//
65-
// if (std::find(kSupportEngines.begin(), kSupportEngines.end(), engine) ==
66-
// kSupportEngines.end()) {
67-
// return cpp::fail("Engine " + engine + " is not supported!");
68-
// }
69-
//
70-
// auto engine_status_list = GetEngineInfoList();
71-
//
72-
// return *std::find_if(
73-
// engine_status_list.begin(), engine_status_list.end(),
74-
// [&engine](const EngineInfo& e) { return e.name == engine; });
75-
// }
76-
77-
// std::vector<EngineInfo> EngineService::GetEngineInfoList() const {
78-
// auto ecp = file_manager_utils::GetEnginesContainerPath();
79-
//
80-
// std::string onnx_status{kIncompatible};
81-
// std::string llamacpp_status =
82-
// std::filesystem::exists(ecp / kLlamaRepo) ? kReady : kNotInstalled;
83-
// std::string tensorrt_status{kIncompatible};
84-
//
85-
// #ifdef _WIN32
86-
// onnx_status =
87-
// std::filesystem::exists(ecp / kOnnxRepo) ? kReady : kNotInstalled;
88-
// tensorrt_status =
89-
// std::filesystem::exists(ecp / kTrtLlmRepo) ? kReady : kNotInstalled;
90-
// #elif defined(__linux__)
91-
// tensorrt_status =
92-
// std::filesystem::exists(ecp / kTrtLlmRepo) ? kReady : kNotInstalled;
93-
// #endif
94-
// std::vector<EngineInfo> engines = {
95-
// {.name = kOnnxEngine,
96-
// .description = "This extension enables chat completion API calls using "
97-
// "the Onnx engine",
98-
// .format = "ONNX",
99-
// .product_name = kOnnxEngine,
100-
// .status = onnx_status},
101-
// {.name = kLlamaEngine,
102-
// .description = "This extension enables chat completion API calls using "
103-
// "the LlamaCPP engine",
104-
// .format = "GGUF",
105-
// .product_name = kLlamaEngine,
106-
// .status = llamacpp_status},
107-
// {.name = kTrtLlmEngine,
108-
// .description = "This extension enables chat completion API calls using "
109-
// "the TensorrtLLM engine",
110-
// .format = "TensorRT Engines",
111-
// .product_name = kTrtLlmEngine,
112-
// .status = tensorrt_status},
113-
// };
114-
//
115-
// for (auto& engine : engines) {
116-
// if (engine.status == kReady) {
117-
// // try to read the version.txt
118-
// auto engine_info_path = file_manager_utils::GetEnginesContainerPath() /
119-
// NormalizeEngine(engine.name) / "version.txt";
120-
// if (!std::filesystem::exists(engine_info_path)) {
121-
// continue;
122-
// }
123-
// try {
124-
// auto node = YAML::LoadFile(engine_info_path.string());
125-
// engine.version = node["version"].as<std::string>();
126-
// engine.variant = node["name"].as<std::string>();
127-
// } catch (const YAML::Exception& e) {
128-
// CTL_ERR("Error reading version.txt: " << e.what());
129-
// continue;
130-
// }
131-
// }
132-
// }
133-
//
134-
// return engines;
135-
// }
136-
13762
cpp::result<bool, std::string> EngineService::InstallEngine(
13863
const std::string& engine, const std::string& version,
13964
const std::string& src) {
@@ -246,12 +171,13 @@ cpp::result<bool, std::string> EngineService::UnzipEngine(
246171
return true;
247172
}
248173

249-
cpp::result<bool, std::string> EngineService::UninstallEngine(
250-
const std::string& engine) {
174+
cpp::result<bool, std::string> EngineService::UninstallEngineVariant(
175+
const std::string& engine, const std::string& variant,
176+
const std::string& version) {
251177
auto ne = NormalizeEngine(engine);
252-
auto ecp = file_manager_utils::GetEnginesContainerPath();
253-
auto engine_path = ecp / ne;
254-
178+
auto engine_path =
179+
file_manager_utils::GetEnginesContainerPath() / ne / variant / version;
180+
std::cout << "engine_path: " << engine_path.string() << std::endl;
255181
if (!std::filesystem::exists(engine_path)) {
256182
return cpp::fail("Engine " + ne + " is not installed!");
257183
}
@@ -374,7 +300,6 @@ cpp::result<bool, std::string> EngineService::DownloadEngine(
374300
// CTL_INF("No GitHub token found. Sending request without authentication.");
375301
// }
376302

377-
// TODO: namh add back the github_token
378303
auto res = GetEngineVariants(engine, version);
379304
if (res.has_error()) {
380305
return cpp::fail("Failed to fetch engine releases: " + res.error());

engine/services/engine_service.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ class EngineService {
9292
const std::string& engine, const std::string& version,
9393
const std::string& variant_name);
9494

95-
cpp::result<bool, std::string> UninstallEngine(const std::string& engine);
95+
cpp::result<bool, std::string> UninstallEngineVariant(
96+
const std::string& engine, const std::string& variant,
97+
const std::string& version);
9698

9799
cpp::result<std::vector<EngineRelease>, std::string> GetEngineReleases(
98100
const std::string& engine) const;

0 commit comments

Comments
 (0)