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

Method SearchRemoteModels

apps/mnncli/src/model_manager.cpp:31–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29using namespace mnn::downloader;
30
31int ModelManager::SearchRemoteModels(const std::string &keyword, bool verbose,
32 const std::string &cache_dir_override) {
33 try {
34 // Get cache directory from override, config, or use default
35 auto &config_mgr = ConfigManager::GetInstance();
36 auto config = config_mgr.LoadConfig();
37 std::string cache_dir;
38 if (!cache_dir_override.empty()) {
39 cache_dir = cache_dir_override;
40 } else {
41 cache_dir = config.cache_dir;
42 if (cache_dir.empty()) {
43 cache_dir = config_mgr.GetBaseCacheDir();
44 }
45 }
46
47 // Get current download provider from config
48 std::string current_provider = config.download_provider;
49 if (current_provider.empty()) {
50 current_provider = mnn::downloader::ModelSources::SOURCE_HUGGING_FACE; // Default provider
51 }
52
53 // Create ModelRepository instance
54 auto &model_repo = mnncli::ModelRepository::GetInstance(cache_dir);
55 model_repo.SetDownloadProvider(current_provider);
56
57 // Show search information
58 std::cout << "🔍 Searching for LLM models with keyword: '" << keyword
59 << "'\n";
60 std::cout << " Current provider: " << current_provider << "\n";
61 std::cout << " Cache directory: " << cache_dir << "\n\n";
62
63 LOG_DEBUG_TAG("Starting model search", "ModelSearch");
64 LOG_DEBUG_TAG("Keyword: " + keyword, "ModelSearch");
65 LOG_DEBUG_TAG("Provider: " + current_provider, "ModelSearch");
66 LOG_DEBUG_TAG("Cache directory: " + cache_dir, "ModelSearch");
67
68 // Perform search
69 auto searchResults = model_repo.SearchModels(keyword);
70
71 if (searchResults.empty()) {
72 if (keyword.empty()) {
73 std::cout << "No LLM models found for provider: " << current_provider
74 << "\n";
75 } else {
76 std::cout << "No LLM models found matching keyword: '" << keyword
77 << "' for provider: " << current_provider << "\n";
78 }
79 std::cout << "\n💡 Try:\n";
80 std::cout << " • Use a different keyword\n";
81 std::cout << " • Change download provider: export "
82 "MNN_DOWNLOAD_PROVIDER=<provider>\n";
83 std::cout
84 << " • Available providers: " << mnn::downloader::ModelSources::SOURCE_HUGGING_FACE << ", " << mnn::downloader::ModelSources::SOURCE_MODEL_SCOPE << ", " << mnn::downloader::ModelSources::SOURCE_MODELERS << "\n";
85 } else {
86 std::cout << "Found " << searchResults.size()
87 << " matching LLM model(s):\n\n";
88

Callers

nothing calls this directly

Calls 9

LoadConfigMethod · 0.80
SetDownloadProviderMethod · 0.80
SearchModelsMethod · 0.80
stringFunction · 0.50
to_stringFunction · 0.50
emptyMethod · 0.45
GetBaseCacheDirMethod · 0.45
sizeMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected