MCPcopy Create free account
hub / github.com/alibaba/MNN / GetModelIdForDownload

Method GetModelIdForDownload

apps/mnncli/src/model_repository.cpp:98–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98std::optional<std::string> ModelRepository::GetModelIdForDownload(const std::string& modelName, const std::string& downloadProvider) {
99 if (modelName.empty()) {
100 LOG_DEBUG_TAG("Model name is empty", kTag);
101 return std::nullopt;
102 }
103
104 // Find model by name
105 auto model = FindModelByName(modelName);
106 if (!model) {
107 LOG_DEBUG_TAG("Model not found: " + modelName, kTag);
108 return std::nullopt;
109 }
110
111 // Check if the specified download provider is available (case-insensitive)
112 std::string foundProvider;
113 std::string foundRepoPath;
114 bool providerFound = false;
115
116 for (const auto& [source, repoPath] : model->sources) {
117 if (CaseInsensitiveEquals(source, downloadProvider)) {
118 foundProvider = source;
119 foundRepoPath = repoPath;
120 providerFound = true;
121 break;
122 }
123 }
124
125 if (!providerFound) {
126 LOG_DEBUG_TAG("Download provider '" + downloadProvider + "' not available for model: " + modelName, kTag);
127 return std::nullopt;
128 }
129
130 // Create model ID in format: "HuggingFace/taobao-mnn/gpt-oss-20b-MNN"
131 std::string modelId = CreateModelId(foundProvider, foundRepoPath);
132
133 LOG_DEBUG_TAG("Created model ID: " + modelId + " for model: " + modelName, kTag);
134
135 return modelId;
136}
137
138std::string ModelRepository::GetModelType(const std::string& modelId) {
139 try {

Callers 1

DownloadModelMethod · 0.80

Calls 2

CaseInsensitiveEqualsFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected