Skip to content

Commit 11eb2be

Browse files
committed
Treat hf.co/ prefix the same as hf://
ollama uses hf.co/ to specify huggingface prefix, like RamaLama uses hf:// Treat them similarly. Signed-off-by: Eric Curtin <[email protected]>
1 parent 96f4053 commit 11eb2be

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

examples/run/run.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,17 @@ class LlamaData {
640640
return 1;
641641
}
642642

643-
model_ = model_.substr(pos + 3); // Skip past "://"
643+
model_ = model_.substr(pos + sizeof("://") - 1); // Skip past "://"
644+
return 0;
645+
}
646+
647+
int remove_hf_co(std::string & model_) {
648+
const std::string::size_type pos = model_.find("hf.co/");
649+
if (pos == std::string::npos) {
650+
return 1;
651+
}
652+
653+
model_ = model_.substr(pos + sizeof("hf.co/") - 1); // Skip past "hf.co/"
644654
return 0;
645655
}
646656

@@ -658,11 +668,14 @@ class LlamaData {
658668
if (string_starts_with(model_, "hf://") || string_starts_with(model_, "huggingface://")) {
659669
remove_proto(model_);
660670
ret = huggingface_dl(model_, headers, bn);
671+
} else if (string_starts_with(model_, "hf.co/")) {
672+
remove_hf_co(model_);
673+
ret = huggingface_dl(model_, headers, bn);
661674
} else if (string_starts_with(model_, "ollama://")) {
662675
remove_proto(model_);
663676
ret = ollama_dl(model_, headers, bn);
664677
} else if (string_starts_with(model_, "https://")) {
665-
download(model_, headers, bn, true);
678+
ret = download(model_, headers, bn, true);
666679
} else {
667680
ret = ollama_dl(model_, headers, bn);
668681
}

0 commit comments

Comments
 (0)