@@ -467,8 +467,7 @@ std::pair<long, std::vector<char>> common_remote_get_content(const std::string &
467467 return { res_code, std::move (res_buffer) };
468468}
469469
470- #else
471- #ifdef LLAMA_USE_HTTPLIB
470+ #elif defined(LLAMA_USE_HTTPLIB)
472471
473472static bool is_output_a_tty () {
474473#if defined(_WIN32)
@@ -712,29 +711,10 @@ std::pair<long, std::vector<char>> common_remote_get_content(const std::string
712711 return { res->status , std::move (buf) };
713712}
714713
715- #else // no httplib
716-
717- bool common_has_curl () {
718- return false ;
719- }
720-
721- static bool common_download_file_single_online (const std::string &, const std::string &, const std::string &) {
722- LOG_ERR (" error: built without CURL, cannot download model from internet\n " );
723- return false ;
724- }
725-
726- std::pair<long , std::vector<char >> common_remote_get_content (const std::string & url, const common_remote_params &) {
727- if (!url.empty ()) {
728- throw std::runtime_error (" error: built without CURL, cannot download model from the internet" );
729- }
730-
731- return {};
732- }
733- #endif
734-
735-
736714#endif // LLAMA_USE_CURL
737715
716+ #if defined(LLAMA_USE_CURL) || defined(LLAMA_USE_HTTPLIB)
717+
738718static bool common_download_file_single (const std::string & url,
739719 const std::string & path,
740720 const std::string & bearer_token,
@@ -929,33 +909,6 @@ common_hf_file_res common_get_hf_file(const std::string & hf_repo_with_tag, cons
929909 return { hf_repo, ggufFile, mmprojFile };
930910}
931911
932- std::vector<common_cached_model_info> common_list_cached_models () {
933- std::vector<common_cached_model_info> models;
934- const std::string cache_dir = fs_get_cache_directory ();
935- const std::vector<common_file_info> files = fs_list_files (cache_dir);
936- for (const auto & file : files) {
937- if (string_starts_with (file.name , " manifest=" ) && string_ends_with (file.name , " .json" )) {
938- common_cached_model_info model_info;
939- model_info.manifest_path = file.path ;
940- std::string fname = file.name ;
941- string_replace_all (fname, " .json" , " " ); // remove extension
942- auto parts = string_split<std::string>(fname, ' =' );
943- if (parts.size () == 4 ) {
944- // expect format: manifest=<user>=<model>=<tag>=<other>
945- model_info.user = parts[1 ];
946- model_info.model = parts[2 ];
947- model_info.tag = parts[3 ];
948- } else {
949- // invalid format
950- continue ;
951- }
952- model_info.size = 0 ; // TODO: get GGUF size, not manifest size
953- models.push_back (model_info);
954- }
955- }
956- return models;
957- }
958-
959912//
960913// Docker registry functions
961914//
@@ -1074,3 +1027,46 @@ std::string common_docker_resolve_model(const std::string & docker) {
10741027 throw ;
10751028 }
10761029}
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