Added --hf-token argument support

This commit is contained in:
Sourabrata Bose 2024-04-17 15:34:52 +05:30
parent facb8b56f8
commit df175f7c60

View file

@ -767,6 +767,15 @@ bool gpt_params_find_arg(int argc, char ** argv, const std::string & arg, gpt_pa
params.hf_file = argv[i]; params.hf_file = argv[i];
return true; return true;
} }
if (arg == "-hft" || arg == "--hf-token") {
params.hf_token = NULL;
if (++i >= argc) {
invalid_param = true;
return true;
}
params.hf_token = argv[i];
return true;
}
if (arg == "--lora") { if (arg == "--lora") {
if (++i >= argc) { if (++i >= argc) {
invalid_param = true; invalid_param = true;
@ -2089,6 +2098,12 @@ struct llama_model * llama_load_model_from_url(
return NULL; return NULL;
} }
if(params.hf_token!=NULL){
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Authorization: Bearer " + params.hf_token);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
}
if (!llama_download_file(curl, model_url, path_model)) { if (!llama_download_file(curl, model_url, path_model)) {
return NULL; return NULL;
} }