Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions engine/services/model_source_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,10 @@ cpp::result<bool, std::string> ModelSourceService::AddCortexsoRepo(
}

auto author = hub_author;
auto model_author = hu::GetModelAuthorCortexsoHub(model_name);
if (auto model_author = hu::GetModelAuthorCortexsoHub(model_name);
model_author.has_value() && !model_author->empty()) {
author = *model_author;
model_author.has_value() && !model_author.value().empty()) {
author = model_author.value();
}

// Get models from db
Expand All @@ -443,6 +444,10 @@ cpp::result<bool, std::string> ModelSourceService::AddCortexsoRepo(
std::unordered_set<std::string> updated_model_list;
std::vector<std::future<std::string>> tasks;
for (auto const& [branch, _] : branches.value()) {
if (!model_author.has_error() && branch == "main") {
CTL_DBG("Skip main branch");
continue;
}
CTL_DBG(branch);
tasks.push_back(std::async(std::launch::async, [&, branch = branch] {
return AddCortexsoRepoBranch(model_source, author, model_name, branch,
Expand Down
8 changes: 4 additions & 4 deletions engine/utils/huggingface_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,23 +312,23 @@ inline std::optional<std::string> GetDefaultBranch(
}
}

inline std::optional<std::string> GetModelAuthorCortexsoHub(
inline cpp::result<std::string, std::string> GetModelAuthorCortexsoHub(
const std::string& model_name) {
try {
auto remote_yml = curl_utils::ReadRemoteYaml(GetMetadataUrl(model_name));

if (remote_yml.has_error()) {
return std::nullopt;
return cpp::fail(remote_yml.error());
}

auto metadata = remote_yml.value();
auto author = metadata["author"];
if (author.IsDefined()) {
return author.as<std::string>();
}
return std::nullopt;
return "";
} catch (const std::exception& e) {
return std::nullopt;
return "";
}
}
} // namespace huggingface_utils
Loading