|
20 | 20 | #if defined(LLAMA_USE_CURL) |
21 | 21 | #include <curl/curl.h> |
22 | 22 | #include <curl/easy.h> |
23 | | -#else |
| 23 | +#elif defined(LLAMA_USE_HTTPLIB) |
24 | 24 | #include "http.h" |
25 | 25 | #endif |
26 | 26 |
|
@@ -467,7 +467,7 @@ std::pair<long, std::vector<char>> common_remote_get_content(const std::string & |
467 | 467 | return { res_code, std::move(res_buffer) }; |
468 | 468 | } |
469 | 469 |
|
470 | | -#else |
| 470 | +#elif defined(LLAMA_USE_HTTPLIB) |
471 | 471 |
|
472 | 472 | static bool is_output_a_tty() { |
473 | 473 | #if defined(_WIN32) |
@@ -713,6 +713,8 @@ std::pair<long, std::vector<char>> common_remote_get_content(const std::string |
713 | 713 |
|
714 | 714 | #endif // LLAMA_USE_CURL |
715 | 715 |
|
| 716 | +#if defined(LLAMA_USE_CURL) || defined(LLAMA_USE_HTTPLIB) |
| 717 | + |
716 | 718 | static bool common_download_file_single(const std::string & url, |
717 | 719 | const std::string & path, |
718 | 720 | const std::string & bearer_token, |
@@ -907,33 +909,6 @@ common_hf_file_res common_get_hf_file(const std::string & hf_repo_with_tag, cons |
907 | 909 | return { hf_repo, ggufFile, mmprojFile }; |
908 | 910 | } |
909 | 911 |
|
910 | | -std::vector<common_cached_model_info> common_list_cached_models() { |
911 | | - std::vector<common_cached_model_info> models; |
912 | | - const std::string cache_dir = fs_get_cache_directory(); |
913 | | - const std::vector<common_file_info> files = fs_list_files(cache_dir); |
914 | | - for (const auto & file : files) { |
915 | | - if (string_starts_with(file.name, "manifest=") && string_ends_with(file.name, ".json")) { |
916 | | - common_cached_model_info model_info; |
917 | | - model_info.manifest_path = file.path; |
918 | | - std::string fname = file.name; |
919 | | - string_replace_all(fname, ".json", ""); // remove extension |
920 | | - auto parts = string_split<std::string>(fname, '='); |
921 | | - if (parts.size() == 4) { |
922 | | - // expect format: manifest=<user>=<model>=<tag>=<other> |
923 | | - model_info.user = parts[1]; |
924 | | - model_info.model = parts[2]; |
925 | | - model_info.tag = parts[3]; |
926 | | - } else { |
927 | | - // invalid format |
928 | | - continue; |
929 | | - } |
930 | | - model_info.size = 0; // TODO: get GGUF size, not manifest size |
931 | | - models.push_back(model_info); |
932 | | - } |
933 | | - } |
934 | | - return models; |
935 | | -} |
936 | | - |
937 | 912 | // |
938 | 913 | // Docker registry functions |
939 | 914 | // |
@@ -1052,3 +1027,46 @@ std::string common_docker_resolve_model(const std::string & docker) { |
1052 | 1027 | throw; |
1053 | 1028 | } |
1054 | 1029 | } |
| 1030 | + |
| 1031 | +#else |
| 1032 | + |
| 1033 | +common_hf_file_res common_get_hf_file(const std::string &, const std::string &, bool) { |
| 1034 | + throw std::runtime_error("download functionality is not enabled in this build"); |
| 1035 | +} |
| 1036 | + |
| 1037 | +bool common_download_model(const common_params_model &, const std::string &, bool) { |
| 1038 | + throw std::runtime_error("download functionality is not enabled in this build"); |
| 1039 | +} |
| 1040 | + |
| 1041 | +std::string common_docker_resolve_model(const std::string &) { |
| 1042 | + throw std::runtime_error("download functionality is not enabled in this build"); |
| 1043 | +} |
| 1044 | + |
| 1045 | +#endif // LLAMA_USE_CURL || LLAMA_USE_HTTPLIB |
| 1046 | + |
| 1047 | +std::vector<common_cached_model_info> common_list_cached_models() { |
| 1048 | + std::vector<common_cached_model_info> models; |
| 1049 | + const std::string cache_dir = fs_get_cache_directory(); |
| 1050 | + const std::vector<common_file_info> files = fs_list_files(cache_dir); |
| 1051 | + for (const auto & file : files) { |
| 1052 | + if (string_starts_with(file.name, "manifest=") && string_ends_with(file.name, ".json")) { |
| 1053 | + common_cached_model_info model_info; |
| 1054 | + model_info.manifest_path = file.path; |
| 1055 | + std::string fname = file.name; |
| 1056 | + string_replace_all(fname, ".json", ""); // remove extension |
| 1057 | + auto parts = string_split<std::string>(fname, '='); |
| 1058 | + if (parts.size() == 4) { |
| 1059 | + // expect format: manifest=<user>=<model>=<tag>=<other> |
| 1060 | + model_info.user = parts[1]; |
| 1061 | + model_info.model = parts[2]; |
| 1062 | + model_info.tag = parts[3]; |
| 1063 | + } else { |
| 1064 | + // invalid format |
| 1065 | + continue; |
| 1066 | + } |
| 1067 | + model_info.size = 0; // TODO: get GGUF size, not manifest size |
| 1068 | + models.push_back(model_info); |
| 1069 | + } |
| 1070 | + } |
| 1071 | + return models; |
| 1072 | +} |
0 commit comments