@@ -634,20 +634,20 @@ class LlamaData {
634634 return path.substr (pos + 1 );
635635 }
636636
637- int remove_proto (std::string & model_) {
638- const std::string::size_type pos = model_.find (" :// " );
637+ int rm_until_substring (std::string & model_, const std::string & substring ) {
638+ const std::string::size_type pos = model_.find (substring );
639639 if (pos == std::string::npos) {
640640 return 1 ;
641641 }
642642
643- model_ = model_.substr (pos + 3 ) ; // Skip past "://"
643+ model_ = model_.substr (pos + substring. size ()) ; // Skip past the substring
644644 return 0 ;
645645 }
646646
647647 int resolve_model (std::string & model_) {
648648 int ret = 0 ;
649649 if (string_starts_with (model_, " file://" ) || std::filesystem::exists (model_)) {
650- remove_proto (model_);
650+ rm_until_substring (model_, " :// " );
651651
652652 return ret;
653653 }
@@ -656,13 +656,16 @@ class LlamaData {
656656 const std::vector<std::string> headers = { " --header" ,
657657 " Accept: application/vnd.docker.distribution.manifest.v2+json" };
658658 if (string_starts_with (model_, " hf://" ) || string_starts_with (model_, " huggingface://" )) {
659- remove_proto (model_);
659+ rm_until_substring (model_, " ://" );
660+ ret = huggingface_dl (model_, headers, bn);
661+ } else if (string_starts_with (model_, " hf.co/" )) {
662+ rm_until_substring (model_, " hf.co/" );
660663 ret = huggingface_dl (model_, headers, bn);
661664 } else if (string_starts_with (model_, " ollama://" )) {
662- remove_proto (model_);
665+ rm_until_substring (model_, " :// " );
663666 ret = ollama_dl (model_, headers, bn);
664667 } else if (string_starts_with (model_, " https://" )) {
665- download (model_, headers, bn, true );
668+ ret = download (model_, headers, bn, true );
666669 } else {
667670 ret = ollama_dl (model_, headers, bn);
668671 }
0 commit comments