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

Commit f866d5f

Browse files
committed
fix: handle macos 12 variants
1 parent 6d0215d commit f866d5f

File tree

4 files changed

+54
-10
lines changed

4 files changed

+54
-10
lines changed

engine/cli/main.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ int main(int argc, char* argv[]) {
148148
std::chrono::hours(24);
149149
should_check_for_latest_llamacpp_version = now > last_check;
150150
}
151-
151+
152152
if (should_check_for_latest_llamacpp_version) {
153153
std::thread t1([]() {
154154
// TODO: namh current we only check for llamacpp. Need to add support for other engine
@@ -171,7 +171,7 @@ int main(int argc, char* argv[]) {
171171
};
172172

173173
auto res = get_latest_version();
174-
174+
175175
if (res.has_error()) {
176176
CTL_ERR("Failed to get latest llama.cpp version: " << res.error());
177177
return;

engine/extensions/local-engine/local_engine.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,4 +1001,4 @@ void LocalEngine::HandleNonOpenAiChatCompletion(
10011001
}
10021002
}
10031003

1004-
} // namespace cortex::local
1004+
} // namespace cortex::local

engine/extensions/local-engine/local_engine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@ class LocalEngine : public EngineI {
7171
TaskQueue& q_;
7272
};
7373

74-
} // namespace cortex::local
74+
} // namespace cortex::local

engine/services/engine_service.cc

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "utils/engine_matcher_utils.h"
1818
#include "utils/file_manager_utils.h"
1919
#include "utils/github_release_utils.h"
20+
#include "utils/hardware/os_info.h"
2021
#include "utils/logging_utils.h"
2122
#include "utils/normalize_engine.h"
2223
#include "utils/result.hpp"
@@ -528,16 +529,59 @@ EngineService::GetEngineVariants(const std::string& engine,
528529

529530
std::vector<EngineVariant> compatible_variants;
530531
std::vector<github_release_utils::GitHubAsset> assets;
532+
533+
auto get_os_major = []() -> int {
534+
auto os_info = cortex::hw::GetOSInfo();
535+
// Get os major version
536+
size_t dot_pos = os_info.version.find_first_of(".");
537+
if (dot_pos != std::string::npos) {
538+
try {
539+
return std::stoi(os_info.version.substr(0, dot_pos));
540+
} catch (const std::exception& e) {
541+
return 0;
542+
}
543+
} else {
544+
// No version found
545+
return 0;
546+
}
547+
};
548+
531549
if (engine_release_menlo.has_value()) {
532-
assets.insert(std::end(assets),
533-
std::begin(engine_release_menlo.value().assets),
534-
std::end(engine_release_menlo.value().assets));
550+
// In case of macos, if os version is 12, we get binary from menlo
551+
std::copy_if(
552+
engine_release_menlo.value().assets.begin(),
553+
engine_release_menlo.value().assets.end(), std::back_inserter(assets),
554+
[get_os_major](const github_release_utils::GitHubAsset& assets) {
555+
#if defined(__APPLE__) && defined(__MACH__)
556+
if (get_os_major() == 12 &&
557+
assets.name.find(kMacOs) != std::string::npos) {
558+
return true;
559+
}
560+
return false;
561+
#else
562+
return true;
563+
#endif
564+
});
535565
}
566+
536567
if (engine_release_ggml.has_value()) {
537-
assets.insert(std::end(assets),
538-
std::begin(engine_release_ggml.value().assets),
539-
std::end(engine_release_ggml.value().assets));
568+
// In case of macos, if os version is 12, we get binary from menlo
569+
std::copy_if(
570+
engine_release_ggml.value().assets.begin(),
571+
engine_release_ggml.value().assets.end(), std::back_inserter(assets),
572+
[get_os_major](const github_release_utils::GitHubAsset& assets) {
573+
#if defined(__APPLE__) && defined(__MACH__)
574+
if (get_os_major() > 12 &&
575+
assets.name.find(kMacOs) != std::string::npos) {
576+
return true;
577+
}
578+
return false;
579+
#else
580+
return true;
581+
#endif
582+
});
540583
}
584+
541585
for (const auto& variant : assets) {
542586
CTL_INF("content_type: " << variant.content_type
543587
<< ", name: " << variant.name);

0 commit comments

Comments
 (0)