mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2025-02-04 23:52:32 +01:00
Handle missing model in CLI parameters for llama-run
The HTTP client in llama-run only prints an error in case the download of a resource failed. If the model name in the CLI parameter list is missing, this causes the application to crash. In order to prevent this, a check for the required model parameter has been added and errors for resource downloads get propagated to the caller. Signed-off-by: Michael Engel <mengel@redhat.com>
This commit is contained in:
parent
a07c2c8a52
commit
c1973cf687
@ -181,6 +181,10 @@ class Opt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (model_.empty()){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,7 +350,11 @@ class HttpClient {
|
|||||||
data.file_size = set_resume_point(output_file_partial);
|
data.file_size = set_resume_point(output_file_partial);
|
||||||
set_progress_options(progress, data);
|
set_progress_options(progress, data);
|
||||||
set_headers(headers);
|
set_headers(headers);
|
||||||
perform(url);
|
CURLcode res = perform(url);
|
||||||
|
if (res != CURLE_OK){
|
||||||
|
printe("Fetching resource '%s' failed: %s\n", url.c_str(), curl_easy_strerror(res));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
if (!output_file.empty()) {
|
if (!output_file.empty()) {
|
||||||
std::filesystem::rename(output_file_partial, output_file);
|
std::filesystem::rename(output_file_partial, output_file);
|
||||||
}
|
}
|
||||||
@ -411,16 +419,12 @@ class HttpClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void perform(const std::string & url) {
|
CURLcode perform(const std::string & url) {
|
||||||
CURLcode res;
|
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
||||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
||||||
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
|
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
|
||||||
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
|
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
|
||||||
res = curl_easy_perform(curl);
|
return curl_easy_perform(curl);
|
||||||
if (res != CURLE_OK) {
|
|
||||||
printe("curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string human_readable_time(double seconds) {
|
static std::string human_readable_time(double seconds) {
|
||||||
|
Loading…
Reference in New Issue
Block a user