Skip to content

Commit 55889e9

Browse files
committed
People search for ollama models using the web ui, this change allows one to copy the url from the browser and for it to be compatible with llama-run. Signed-off-by: Eric Curtin <[email protected]>
1 parent b636228 commit 55889e9

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

examples/run/run.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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,9 +694,9 @@ 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 project_path = repo_parts[2];
700700
for (size_t i = 3; i < repo_parts.size(); ++i) {
701701
project_path += "/" + repo_parts[i];
702702
}
@@ -735,19 +735,20 @@ class LlamaData {
735735
}
736736

737737
const std::string bn = basename(model_);
738-
if (string_starts_with(model_, "hf://") || string_starts_with(model_, "huggingface://")) {
738+
if (string_starts_with(model_, "hf://") || string_starts_with(model_, "huggingface://") ||
739+
string_starts_with(model_, "hf.co/")) {
739740
rm_until_substring(model_, "://");
740-
ret = huggingface_dl(model_, bn);
741-
} else if (string_starts_with(model_, "hf.co/")) {
742741
rm_until_substring(model_, "hf.co/");
743742
ret = huggingface_dl(model_, bn);
744-
} else if (string_starts_with(model_, "https://") || string_starts_with(model_, "http://")) {
743+
} else if ((string_starts_with(model_, "https://") || string_starts_with(model_, "http://")) &&
744+
!string_starts_with(model_, "https://ollama.com/library/")) {
745745
ret = download(model_, bn, true);
746746
} else if (string_starts_with(model_, "github:") || string_starts_with(model_, "github://")) {
747747
rm_until_substring(model_, "github://");
748748
rm_until_substring(model_, "github:");
749749
ret = github_dl(model_, bn);
750750
} else { // ollama:// or nothing
751+
rm_until_substring(model_, "ollama.com/library/");
751752
rm_until_substring(model_, "://");
752753
ret = ollama_dl(model_, bn);
753754
}

0 commit comments

Comments
 (0)