LLM inference in C/C++
C++ ggml
app : enable self-update only when built with llama-install.sh (#24754)
Adrien Gallouët6ec59ddaeab5
diff --git a/app/llama.cpp b/app/llama.cppindex 30b09f9ef7..c4578ea53b 100644--- a/app/llama.cpp+++ b/app/llama.cpp@@ -20,16 +20,21 @@ int llama_fit_params(int argc, char ** argv);int llama_quantize(int argc, char ** argv);int llama_perplexity(int argc, char ** argv);-// hands the update over to the install script, which downloads and swaps the binary+// Self-update is only supported for binaries built with llama-install.shstatic int llama_update(int argc, char ** argv) {(void) argc;(void) argv;+#ifdef LLAMA_INSTALL_BUILD#if defined(_WIN32)return system("powershell -NoProfile -ExecutionPolicy Bypass -Command \"irm https://llama.app/install.ps1 | iex\"");#elsereturn system("curl -fsSL https://llama.app/install.sh | sh");#endif+#else+ printf("Updates are available only when installed from https://llama.app\n");+ return 1;+#endif}static const char * progname;@@ -46,21 +51,29 @@ struct command {int (*func)(int, char **);};+#ifdef LLAMA_INSTALL_BUILD+#define UPDATE_HIDDEN false+#else+#define UPDATE_HIDDEN true+#endif+static const command cmds[] = {- {"serve", "HTTP API server", {"server"}, false, llama_server },- {"cli", "Command-line interactive interface", {"client"}, false, llama_cli },- {"update", "Update llama to the latest release", {}, false, llama_update },- {"completion", "Text completion", {"complete"}, true, llama_completion },- {"bench", "Benchmark prompt processing and text generation", {}, true, llama_bench },- {"batched-bench", "Benchmark batched decoding performance", {}, true, llama_batched_bench},- {"fit-params", "Compute parameters to fit a model in device memory", {}, true, llama_fit_params },- {"quantize", "Quantize a model", {}, true, llama_quantize },- {"perplexity", "Compute model perplexity and KL divergence", {}, true, llama_perplexity },- {"version", "Show version", {}, false, version },- {"licenses", "Show third-party licenses", {"credits"}, false, licenses },- {"help", "Show available commands", {}, false, help },+ {"serve", "HTTP API server", {"server"}, false, llama_server },+ {"cli", "Command-line interactive interface", {"client"}, false, llama_cli },+ {"update", "Update llama to the latest release", {}, UPDATE_HIDDEN, llama_update },+ {"completion", "Text completion", {"complete"}, true, llama_completion },+ {"bench", "Benchmark prompt processing and text generation", {}, true, llama_bench },+ {"batched-bench", "Benchmark batched decoding performance", {}, true, llama_batched_bench},+ {"fit-params", "Compute parameters to fit a model in device memory", {}, true, llama_fit_params },+ {"quantize", "Quantize a model", {}, true, llama_quantize },+ {"perplexity", "Compute model perplexity and KL divergence", {}, true, llama_perplexity },+ {"version", "Show version", {}, false, version },+ {"licenses", "Show third-party licenses", {"credits"}, false, licenses },+ {"help", "Show available commands", {}, false, help },};+#undef UPDATE_HIDDEN+static int version(int argc, char ** argv) {printf("%s\n", llama_build_info());return 0;