@@ -674,9 +674,9 @@ class LlamaData {
674674 }
675675
676676 int github_dl (const std::string & model, const std::string & bn) {
677- std::string repository = model;
678- std::string branch = " main" ;
679- size_t at_pos = model.find (' @' );
677+ std::string repository = model;
678+ std::string branch = " main" ;
679+ const size_t at_pos = model.find (' @' );
680680 if (at_pos != std::string::npos) {
681681 repository = model.substr (0 , at_pos);
682682 branch = model.substr (at_pos + 1 );
@@ -694,16 +694,14 @@ class LlamaData {
694694 return 1 ;
695695 }
696696
697- const std::string org = repo_parts[0 ];
698- const std::string project = repo_parts[1 ];
699- std::string project_path = repo_parts[2 ];
697+ const std::string & org = repo_parts[0 ];
698+ const std::string & project = repo_parts[1 ];
699+ std::string url =
700+ " https://raw.githubusercontent.com/" + org + " /" + project + " /" + branch + " /" + repo_parts[2 ];
700701 for (size_t i = 3 ; i < repo_parts.size (); ++i) {
701- project_path += " /" + repo_parts[i];
702+ url += " /" + repo_parts[i];
702703 }
703704
704- const std::string url =
705- " https://raw.githubusercontent.com/" + org + " /" + project + " /" + branch + " /" + project_path;
706-
707705 return download (url, bn, true );
708706 }
709707
@@ -735,19 +733,20 @@ class LlamaData {
735733 }
736734
737735 const std::string bn = basename (model_);
738- if (string_starts_with (model_, " hf://" ) || string_starts_with (model_, " huggingface://" )) {
739- rm_until_substring (model_, " ://" );
740- ret = huggingface_dl (model_, bn);
741- } else if (string_starts_with (model_, " hf.co/" )) {
736+ if (string_starts_with (model_, " hf://" ) || string_starts_with (model_, " huggingface://" ) ||
737+ string_starts_with (model_, " hf.co/" )) {
742738 rm_until_substring (model_, " hf.co/" );
739+ rm_until_substring (model_, " ://" );
743740 ret = huggingface_dl (model_, bn);
744- } else if (string_starts_with (model_, " https://" ) || string_starts_with (model_, " http://" )) {
741+ } else if ((string_starts_with (model_, " https://" ) || string_starts_with (model_, " http://" )) &&
742+ !string_starts_with (model_, " https://ollama.com/library/" )) {
745743 ret = download (model_, bn, true );
746744 } else if (string_starts_with (model_, " github:" ) || string_starts_with (model_, " github://" )) {
747- rm_until_substring (model_, " github://" );
748745 rm_until_substring (model_, " github:" );
746+ rm_until_substring (model_, " ://" );
749747 ret = github_dl (model_, bn);
750748 } else { // ollama:// or nothing
749+ rm_until_substring (model_, " ollama.com/library/" );
751750 rm_until_substring (model_, " ://" );
752751 ret = ollama_dl (model_, bn);
753752 }
0 commit comments