Skip to content

Commit 2765347

Browse files
committed
change to MODEL_ENDPOINT
1 parent 76f48ed commit 2765347

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,9 @@ The [Hugging Face](https://huggingface.co) platform hosts a [number of LLMs](htt
267267

268268
You can either manually download the GGUF file or directly use any `llama.cpp`-compatible models from Hugging Face by using this CLI argument: `-hf <user>/<model>[:quant]`
269269

270-
LLAMA.CPP has supported a environment variable `HF_ENDPOINT`, you can set this to change the downloading url:
271-
- By default, HF_ENDPOINT=https://huggingface.co/
272-
- To use ModelScope, you can change to HF_ENDPOINT=https://www.modelscope.cn/
270+
LLAMA.CPP supports an environment variable `MODEL_ENDPOINT`, use this to change the downloading endpoint:
271+
- By default, MODEL_ENDPOINT=https://huggingface.co/
272+
- To use ModelScope, change to MODEL_ENDPOINT=https://www.modelscope.cn/
273273

274274
After downloading a model, use the CLI tools to run it locally - see below.
275275

common/arg.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -547,14 +547,14 @@ static struct common_hf_file_res common_get_hf_file(const std::string & hf_repo_
547547
curl_slist_ptr http_headers;
548548
std::string res_str;
549549

550-
std::string hf_endpoint = "https://huggingface.co/";
551-
const char * hf_endpoint_env = getenv("HF_ENDPOINT");
552-
if (hf_endpoint_env) {
553-
hf_endpoint = hf_endpoint_env;
554-
if (hf_endpoint.back() != '/') hf_endpoint += '/';
550+
std::string model_endpoint = "https://huggingface.co/";
551+
const char * model_endpoint_env = getenv("MODEL_ENDPOINT");
552+
if (model_endpoint_env) {
553+
model_endpoint = model_endpoint_env;
554+
if (model_endpoint.back() != '/') model_endpoint += '/';
555555
}
556556

557-
std::string url = hf_endpoint + "v2/" + hf_repo + "/manifests/" + tag;
557+
std::string url = model_endpoint + "v2/" + hf_repo + "/manifests/" + tag;
558558
curl_easy_setopt(curl.get(), CURLOPT_URL, url.c_str());
559559
curl_easy_setopt(curl.get(), CURLOPT_NOPROGRESS, 1L);
560560
typedef size_t(*CURLOPT_WRITEFUNCTION_PTR)(void * ptr, size_t size, size_t nmemb, void * data);
@@ -669,13 +669,13 @@ static void common_params_handle_model(
669669
}
670670
}
671671

672-
std::string hf_endpoint = "https://huggingface.co/";
673-
const char * hf_endpoint_env = getenv("HF_ENDPOINT");
674-
if (hf_endpoint_env) {
675-
hf_endpoint = hf_endpoint_env;
676-
if (hf_endpoint.back() != '/') hf_endpoint += '/';
672+
std::string model_endpoint = "https://huggingface.co/";
673+
const char * model_endpoint_env = getenv("MODEL_ENDPOINT");
674+
if (model_endpoint_env) {
675+
model_endpoint = model_endpoint_env;
676+
if (model_endpoint.back() != '/') model_endpoint += '/';
677677
}
678-
model.url = hf_endpoint + model.hf_repo + "/resolve/main/" + model.hf_file;
678+
model.url = model_endpoint + model.hf_repo + "/resolve/main/" + model.hf_file;
679679
// make sure model path is present (for caching purposes)
680680
if (model.path.empty()) {
681681
// this is to avoid different repo having same file name, or same file name in different subdirs
@@ -2377,7 +2377,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
23772377
? std::string("model path from which to load base model")
23782378
: string_format(
23792379
"model path (default: `models/$filename` with filename from `--hf-file` "
2380-
"or `--model-url` if set, otherwise %s), or with a protocol prefix: hf://model-id, ms://model-id", DEFAULT_MODEL_PATH
2380+
"or `--model-url` if set, otherwise %s)", DEFAULT_MODEL_PATH
23812381
),
23822382
[](common_params & params, const std::string & value) {
23832383
params.model.path = value;

examples/run/run.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -697,15 +697,15 @@ class LlamaData {
697697
std::vector<std::string> headers = { "User-Agent: llama-cpp", "Accept: application/json" };
698698
std::string url;
699699

700-
std::string hf_endpoint = "https://huggingface.co/";
701-
const char * hf_endpoint_env = getenv("HF_ENDPOINT");
702-
if (hf_endpoint_env) {
703-
hf_endpoint = hf_endpoint_env;
704-
if (hf_endpoint.back() != '/') hf_endpoint += '/';
700+
std::string model_endpoint = "https://huggingface.co/";
701+
const char * model_endpoint_env = getenv("MODEL_ENDPOINT");
702+
if (model_endpoint_env) {
703+
model_endpoint = model_endpoint_env;
704+
if (model_endpoint.back() != '/') model_endpoint += '/';
705705
}
706706

707707
if (pos == std::string::npos) {
708-
auto [model_name, manifest_url] = extract_model_and_tag(model, hf_endpoint + "v2/");
708+
auto [model_name, manifest_url] = extract_model_and_tag(model, model_endpoint + "v2/");
709709
hfr = model_name;
710710

711711
nlohmann::json manifest;
@@ -720,7 +720,7 @@ class LlamaData {
720720
hff = model.substr(pos + 1);
721721
}
722722

723-
url = hf_endpoint + hfr + "/resolve/main/" + hff;
723+
url = model_endpoint + hfr + "/resolve/main/" + hff;
724724

725725
return download(url, bn, true, headers);
726726
}

0 commit comments

Comments
 (0)