Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1#include "build-info.h"2 3#include <cstdio>4#include <cstdlib>5#include <string>6#include <vector>7 8// embedded data generated by cmake9extern const char * LICENSES[];10 11// visible12int llama_server(int argc, char ** argv);13int llama_cli(int argc, char ** argv);14 15// hidden16int llama_completion(int argc, char ** argv);17int llama_bench(int argc, char ** argv);18int llama_batched_bench(int argc, char ** argv);19int llama_fit_params(int argc, char ** argv);20int llama_quantize(int argc, char ** argv);21int llama_perplexity(int argc, char ** argv);22int llama_download(int argc, char ** argv);23 24// Self-update is disabled to protect the custom fork from being overwritten25static int llama_update(int argc, char ** argv) {26 (void) argc;27 (void) argv;28 29 printf("Custom fork build: self-update is disabled to prevent overwriting modifications.\n");30 return 0;31}32 33static const char * progname;34 35static int help(int argc, char ** argv);36static int version(int argc, char ** argv);37static int licenses(int argc, char ** argv);38 39struct command {40 const char * name;41 const char * desc;42 std::vector<std::string> aliases;43 bool hidden;44 int (*func)(int, char **);45 bool flags = false; // allow --name46};47 48#ifdef LLAMA_INSTALL_BUILD49#define UPDATE_HIDDEN false50#else51#define UPDATE_HIDDEN true52#endif53 54static const command cmds[] = {55 {"serve", "HTTP API server", {"server"}, false, llama_server },56 {"cli", "Command-line interactive interface", {"client"}, false, llama_cli },57 {"update", "Update llama to the latest release", {}, UPDATE_HIDDEN, llama_update },58 {"download", "Download a model", {"get"}, false, llama_download },59 {"completion", "Text completion", {"complete"}, true, llama_completion },60 {"bench", "Benchmark prompt processing and text generation", {}, true, llama_bench },61 {"batched-bench", "Benchmark batched decoding performance", {}, true, llama_batched_bench},62 {"fit-params", "Compute parameters to fit a model in device memory", {}, true, llama_fit_params },63 {"quantize", "Quantize a model", {}, true, llama_quantize },64 {"perplexity", "Compute model perplexity and KL divergence", {}, true, llama_perplexity },65 {"version", "Show version", {}, false, version, true },66 {"licenses", "Show third-party licenses", {"credits"}, false, licenses, true },67 {"help", "Show available commands", {}, false, help, true },68};69 70#undef UPDATE_HIDDEN71 72static int version(int argc, char ** argv) {73 printf("%s\n", llama_build_info());74 return 0;75}76 77static int licenses(int argc, char ** argv) {78 for (int i = 0; LICENSES[i]; ++i) {79 printf("%s\n", LICENSES[i]);80 }81 return 0;82}83 84static int help(int argc, char ** argv) {85 const bool show_all = argc >= 2 && std::string(argv[1]) == "all";86 87 printf("Usage: %s <command> [options]\n\nAvailable commands:\n", progname);88 89 for (const auto & cmd : cmds) {90 if (show_all || !cmd.hidden) {91 printf(" %-15s %s\n", cmd.name, cmd.desc);92 }93 }94 printf("\n");95 96 if (!show_all) {97 printf("Run '%s help all' to show additional commands.\n", progname);98 }99 printf("Run '%s <command> --help' for command-specific usage.\n", progname);100 101 return 0;102}103 104static bool matches(std::string arg, const command & cmd) {105 if (cmd.flags && arg.size() > 2 && arg[0] == '-' && arg[1] == '-') {106 arg.erase(0, 2);107 }108 if (arg == cmd.name) {109 return true;110 }111 for (const auto & alias : cmd.aliases) {112 if (arg == alias) {113 return true;114 }115 }116 return false;117}118 119int main(int argc, char ** argv) {120 progname = argv[0];121 122 const std::string arg = argc >= 2 ? argv[1] : "help";123 124 for (const auto & cmd : cmds) {125 if (matches(arg, cmd)) {126 // keep cmd.name so the router's child processes re-invoke correctly127#ifdef _WIN32128 _putenv_s("LLAMA_APP_CMD", cmd.name);129#else130 setenv("LLAMA_APP_CMD", cmd.name, 1);131#endif132 return cmd.func(argc - 1, argv + 1);133 }134 }135 136 fprintf(stderr, "error: unknown command '%s'\n", arg.c_str());137 return 1;138}139 