@@ -652,7 +652,17 @@ bool fs_validate_filename(const std::string & filename) {
652652
653653 std::u32string filename_utf32;
654654 try {
655+ #if defined(__clang__)
656+ // disable C++17 deprecation warning for std::codecvt_utf8
657+ # pragma clang diagnostic push
658+ # pragma clang diagnostic ignored "-Wdeprecated-declarations"
659+ #endif
655660 std::wstring_convert<std::codecvt_utf8<char32_t >, char32_t > converter;
661+
662+ #if defined(__clang__)
663+ # pragma clang diagnostic pop
664+ #endif
665+
656666 filename_utf32 = converter.from_bytes (filename);
657667
658668 // If the reverse conversion mismatches, it means overlong UTF-8 sequences were used,
@@ -829,9 +839,9 @@ struct common_init_result common_init_from_params(common_params & params) {
829839 llama_model * model = nullptr ;
830840
831841 if (!params.hf_repo .empty () && !params.hf_file .empty ()) {
832- model = common_load_model_from_hf (params.hf_repo . c_str () , params.hf_file . c_str () , params.model . c_str () , params.hf_token . c_str () , mparams);
842+ model = common_load_model_from_hf (params.hf_repo , params.hf_file , params.model , params.hf_token , mparams);
833843 } else if (!params.model_url .empty ()) {
834- model = common_load_model_from_url (params.model_url . c_str () , params.model . c_str () , params.hf_token . c_str () , mparams);
844+ model = common_load_model_from_url (params.model_url , params.model , params.hf_token , mparams);
835845 } else {
836846 model = llama_load_model_from_file (params.model .c_str (), mparams);
837847 }
@@ -1342,17 +1352,17 @@ static bool common_download_file(const std::string & url, const std::string & pa
13421352}
13431353
13441354struct llama_model * common_load_model_from_url (
1345- const char * model_url,
1346- const char * path_model ,
1347- const char * hf_token,
1355+ const std::string & model_url,
1356+ const std::string & local_path ,
1357+ const std::string & hf_token,
13481358 const struct llama_model_params & params) {
13491359 // Basic validation of the model_url
1350- if (! model_url || strlen (model_url) == 0 ) {
1360+ if (model_url. empty () ) {
13511361 LOG_ERR (" %s: invalid model_url\n " , __func__);
13521362 return NULL ;
13531363 }
13541364
1355- if (!common_download_file (model_url, path_model , hf_token)) {
1365+ if (!common_download_file (model_url, local_path , hf_token)) {
13561366 return NULL ;
13571367 }
13581368
@@ -1363,9 +1373,9 @@ struct llama_model * common_load_model_from_url(
13631373 /* .no_alloc = */ true ,
13641374 /* .ctx = */ NULL ,
13651375 };
1366- auto * ctx_gguf = gguf_init_from_file (path_model , gguf_params);
1376+ auto * ctx_gguf = gguf_init_from_file (local_path. c_str () , gguf_params);
13671377 if (!ctx_gguf) {
1368- LOG_ERR (" \n %s: failed to load input GGUF from %s\n " , __func__, path_model );
1378+ LOG_ERR (" \n %s: failed to load input GGUF from %s\n " , __func__, local_path. c_str () );
13691379 return NULL ;
13701380 }
13711381
@@ -1384,13 +1394,13 @@ struct llama_model * common_load_model_from_url(
13841394 // Verify the first split file format
13851395 // and extract split URL and PATH prefixes
13861396 {
1387- if (!llama_split_prefix (split_prefix, sizeof (split_prefix), path_model , 0 , n_split)) {
1388- LOG_ERR (" \n %s: unexpected model file name: %s n_split=%d\n " , __func__, path_model , n_split);
1397+ if (!llama_split_prefix (split_prefix, sizeof (split_prefix), local_path. c_str () , 0 , n_split)) {
1398+ LOG_ERR (" \n %s: unexpected model file name: %s n_split=%d\n " , __func__, local_path. c_str () , n_split);
13891399 return NULL ;
13901400 }
13911401
1392- if (!llama_split_prefix (split_url_prefix, sizeof (split_url_prefix), model_url, 0 , n_split)) {
1393- LOG_ERR (" \n %s: unexpected model url: %s n_split=%d\n " , __func__, model_url, n_split);
1402+ if (!llama_split_prefix (split_url_prefix, sizeof (split_url_prefix), model_url. c_str () , 0 , n_split)) {
1403+ LOG_ERR (" \n %s: unexpected model url: %s n_split=%d\n " , __func__, model_url. c_str () , n_split);
13941404 return NULL ;
13951405 }
13961406 }
@@ -1417,14 +1427,14 @@ struct llama_model * common_load_model_from_url(
14171427 }
14181428 }
14191429
1420- return llama_load_model_from_file (path_model , params);
1430+ return llama_load_model_from_file (local_path. c_str () , params);
14211431}
14221432
14231433struct llama_model * common_load_model_from_hf (
1424- const char * repo,
1425- const char * model ,
1426- const char * path_model ,
1427- const char * hf_token,
1434+ const std::string & repo,
1435+ const std::string & remote_path ,
1436+ const std::string & local_path ,
1437+ const std::string & hf_token,
14281438 const struct llama_model_params & params) {
14291439 // construct hugging face model url:
14301440 //
@@ -1438,27 +1448,27 @@ struct llama_model * common_load_model_from_hf(
14381448 std::string model_url = " https://huggingface.co/" ;
14391449 model_url += repo;
14401450 model_url += " /resolve/main/" ;
1441- model_url += model ;
1451+ model_url += remote_path ;
14421452
1443- return common_load_model_from_url (model_url. c_str (), path_model , hf_token, params);
1453+ return common_load_model_from_url (model_url, local_path , hf_token, params);
14441454}
14451455
14461456#else
14471457
14481458struct llama_model * common_load_model_from_url (
1449- const char * /* model_url*/ ,
1450- const char * /* path_model */ ,
1451- const char * /* hf_token*/ ,
1459+ const std::string & /* model_url*/ ,
1460+ const std::string & /* local_path */ ,
1461+ const std::string & /* hf_token*/ ,
14521462 const struct llama_model_params & /* params*/ ) {
14531463 LOG_WRN (" %s: llama.cpp built without libcurl, downloading from an url not supported.\n " , __func__);
14541464 return nullptr ;
14551465}
14561466
14571467struct llama_model * common_load_model_from_hf (
1458- const char * /* repo*/ ,
1459- const char * /* model */ ,
1460- const char * /* path_model */ ,
1461- const char * /* hf_token*/ ,
1468+ const std::string & /* repo*/ ,
1469+ const std::string & /* remote_path */ ,
1470+ const std::string & /* local_path */ ,
1471+ const std::string & /* hf_token*/ ,
14621472 const struct llama_model_params & /* params*/ ) {
14631473 LOG_WRN (" %s: llama.cpp built without libcurl, downloading from Hugging Face not supported.\n " , __func__);
14641474 return nullptr ;
0 commit comments