@@ -228,6 +228,7 @@ static bool common_download_file_single(const std::string & url, const std::stri
228228    curl_easy_setopt (curl.get (), CURLOPT_URL, url.c_str ());
229229    curl_easy_setopt (curl.get (), CURLOPT_FOLLOWLOCATION, 1L );
230230
231+     http_headers.ptr  = curl_slist_append (http_headers.ptr , " User-Agent: llama-cpp"  );
231232    //  Check if hf-token or bearer-token was specified
232233    if  (!bearer_token.empty ()) {
233234        std::string auth_header = " Authorization: Bearer "   + bearer_token;
@@ -374,7 +375,6 @@ static bool common_download_file_single(const std::string & url, const std::stri
374375
375376        //   display download progress
376377        curl_easy_setopt (curl.get (), CURLOPT_NOPROGRESS, 0L );
377-         curl_easy_setopt (curl.get (), CURLOPT_USERAGENT, " llama.cpp/1.0"  );
378378
379379
380380        //  helper function to hide password in URL
@@ -547,12 +547,7 @@ static struct common_hf_file_res common_get_hf_file(const std::string & hf_repo_
547547    curl_slist_ptr http_headers;
548548    std::string res_str;
549549
550-     std::string model_endpoint = " https://huggingface.co/"  ;
551-     const  char  * model_endpoint_env = getenv (" MODEL_ENDPOINT"  );
552-     if  (model_endpoint_env) {
553-         model_endpoint = model_endpoint_env;
554-         if  (model_endpoint.back () != ' /'  ) model_endpoint += ' /'  ;
555-     }
550+     std::string model_endpoint = get_model_endpoint ();
556551
557552    std::string url = model_endpoint + " v2/"   + hf_repo + " /manifests/"   + tag;
558553    curl_easy_setopt (curl.get (), CURLOPT_URL, url.c_str ());
@@ -669,12 +664,7 @@ static void common_params_handle_model(
669664                }
670665            }
671666
672-             std::string model_endpoint = " https://huggingface.co/"  ;
673-             const  char  * model_endpoint_env = getenv (" MODEL_ENDPOINT"  );
674-             if  (model_endpoint_env) {
675-                 model_endpoint = model_endpoint_env;
676-                 if  (model_endpoint.back () != ' /'  ) model_endpoint += ' /'  ;
677-             }
667+             std::string model_endpoint = get_model_endpoint ();
678668            model.url  = model_endpoint + model.hf_repo  + " /resolve/main/"   + model.hf_file ;
679669            //  make sure model path is present (for caching purposes)
680670            if  (model.path .empty ()) {
0 commit comments