|
1 | 1 | #include "arg.h"
|
2 | 2 |
|
| 3 | +#include "log.h" |
3 | 4 | #include "sampling.h"
|
4 | 5 |
|
5 | 6 | #include <algorithm>
|
6 |
| -#include <string> |
7 |
| -#include <vector> |
8 |
| -#include <set> |
| 7 | +#include <climits> |
| 8 | +#include <cstdarg> |
9 | 9 | #include <fstream>
|
10 | 10 | #include <regex>
|
11 |
| -#include <cstdarg> |
12 |
| -#include <climits> |
| 11 | +#include <set> |
| 12 | +#include <string> |
| 13 | +#include <thread> |
| 14 | +#include <vector> |
13 | 15 |
|
14 | 16 | #include "json-schema-to-grammar.h"
|
15 | 17 |
|
@@ -417,7 +419,7 @@ gpt_params_context gpt_params_parser_init(gpt_params & params, llama_example ex,
|
417 | 419 | [](gpt_params & params) {
|
418 | 420 | params.use_color = true;
|
419 | 421 | }
|
420 |
| - ).set_examples({LLAMA_EXAMPLE_MAIN, LLAMA_EXAMPLE_INFILL})); |
| 422 | + ).set_examples({LLAMA_EXAMPLE_MAIN, LLAMA_EXAMPLE_INFILL, LLAMA_EXAMPLE_SPECULATIVE, LLAMA_EXAMPLE_LOOKUP})); |
421 | 423 | add_opt(llama_arg(
|
422 | 424 | {"-t", "--threads"}, "N",
|
423 | 425 | format("number of threads to use during generation (default: %d)", params.cpuparams.n_threads),
|
@@ -876,15 +878,15 @@ gpt_params_context gpt_params_parser_init(gpt_params & params, llama_example ex,
|
876 | 878 | params.input_prefix = value;
|
877 | 879 | params.enable_chat_template = false;
|
878 | 880 | }
|
879 |
| - ).set_examples({LLAMA_EXAMPLE_MAIN})); |
| 881 | + ).set_examples({LLAMA_EXAMPLE_MAIN, LLAMA_EXAMPLE_INFILL})); |
880 | 882 | add_opt(llama_arg(
|
881 | 883 | {"--in-suffix"}, "STRING",
|
882 | 884 | "string to suffix after user inputs with (default: empty)",
|
883 | 885 | [](gpt_params & params, const std::string & value) {
|
884 | 886 | params.input_suffix = value;
|
885 | 887 | params.enable_chat_template = false;
|
886 | 888 | }
|
887 |
| - ).set_examples({LLAMA_EXAMPLE_MAIN})); |
| 889 | + ).set_examples({LLAMA_EXAMPLE_MAIN, LLAMA_EXAMPLE_INFILL})); |
888 | 890 | add_opt(llama_arg(
|
889 | 891 | {"--no-warmup"},
|
890 | 892 | "skip warming up the model with an empty run",
|
@@ -1824,19 +1826,6 @@ gpt_params_context gpt_params_parser_init(gpt_params & params, llama_example ex,
|
1824 | 1826 | params.system_prompt = system_prompt;
|
1825 | 1827 | }
|
1826 | 1828 | ).set_examples({LLAMA_EXAMPLE_SERVER}));
|
1827 |
| - add_opt(llama_arg( |
1828 |
| - {"--log-format"}, "{text, json}", |
1829 |
| - "log output format: json or text (default: json)", |
1830 |
| - [](gpt_params & params, const std::string & value) { |
1831 |
| - if (value == "json") { |
1832 |
| - params.log_json = true; |
1833 |
| - } else if (value == "text") { |
1834 |
| - params.log_json = false; |
1835 |
| - } else { |
1836 |
| - throw std::invalid_argument("invalid value"); |
1837 |
| - } |
1838 |
| - } |
1839 |
| - ).set_examples({LLAMA_EXAMPLE_SERVER})); |
1840 | 1829 | add_opt(llama_arg(
|
1841 | 1830 | {"--metrics"},
|
1842 | 1831 | format("enable prometheus compatible metrics endpoint (default: %s)", params.endpoint_metrics ? "enabled" : "disabled"),
|
@@ -1956,39 +1945,48 @@ gpt_params_context gpt_params_parser_init(gpt_params & params, llama_example ex,
|
1956 | 1945 | else { std::invalid_argument("invalid value"); }
|
1957 | 1946 | }
|
1958 | 1947 | ).set_examples({LLAMA_EXAMPLE_BENCH}));
|
1959 |
| -#ifndef LOG_DISABLE_LOGS |
1960 |
| - // TODO: make this looks less weird |
1961 |
| - add_opt(llama_arg( |
1962 |
| - {"--log-test"}, |
1963 |
| - "Log test", |
1964 |
| - [](gpt_params &) { log_param_single_parse("--log-test"); } |
1965 |
| - )); |
1966 | 1948 | add_opt(llama_arg(
|
1967 | 1949 | {"--log-disable"},
|
1968 | 1950 | "Log disable",
|
1969 |
| - [](gpt_params &) { log_param_single_parse("--log-disable"); } |
| 1951 | + [](gpt_params &) { |
| 1952 | + gpt_log_pause(gpt_log_main()); |
| 1953 | + } |
1970 | 1954 | ));
|
1971 | 1955 | add_opt(llama_arg(
|
1972 |
| - {"--log-enable"}, |
1973 |
| - "Log enable", |
1974 |
| - [](gpt_params &) { log_param_single_parse("--log-enable"); } |
| 1956 | + {"--log-file"}, "FNAME", |
| 1957 | + "Log to file", |
| 1958 | + [](gpt_params &, const std::string & value) { |
| 1959 | + gpt_log_set_file(gpt_log_main(), value.c_str()); |
| 1960 | + } |
1975 | 1961 | ));
|
1976 | 1962 | add_opt(llama_arg(
|
1977 |
| - {"--log-new"}, |
1978 |
| - "Log new", |
1979 |
| - [](gpt_params &) { log_param_single_parse("--log-new"); } |
1980 |
| - )); |
| 1963 | + {"--log-colors"}, |
| 1964 | + "Enable colored logging", |
| 1965 | + [](gpt_params &) { |
| 1966 | + gpt_log_set_colors(gpt_log_main(), true); |
| 1967 | + } |
| 1968 | + ).set_env("LLAMA_LOG_COLORS")); |
1981 | 1969 | add_opt(llama_arg(
|
1982 |
| - {"--log-append"}, |
1983 |
| - "Log append", |
1984 |
| - [](gpt_params &) { log_param_single_parse("--log-append"); } |
| 1970 | + {"-lv", "--log-verbose"}, |
| 1971 | + "Set verbosity level to infinity (i.e. log all messages, useful for debugging)", |
| 1972 | + [](gpt_params &) { |
| 1973 | + gpt_log_set_verbosity_thold(INT_MAX); |
| 1974 | + } |
1985 | 1975 | ));
|
1986 | 1976 | add_opt(llama_arg(
|
1987 |
| - {"--log-file"}, "FNAME", |
1988 |
| - "Log file", |
1989 |
| - [](gpt_params &, const std::string & value) { log_param_pair_parse(false, "--log-file", value); } |
1990 |
| - )); |
1991 |
| -#endif // LOG_DISABLE_LOGS |
| 1977 | + {"--log-verbosity"}, "THOLD", |
| 1978 | + "Set the verbosity threshold. Messages with a higher verbosity will be ignored.", |
| 1979 | + [](gpt_params &, int value) { |
| 1980 | + gpt_log_set_verbosity_thold(value); |
| 1981 | + } |
| 1982 | + ).set_env("LLAMA_LOG_VERBOSITY")); |
| 1983 | + add_opt(llama_arg( |
| 1984 | + {"--log-timestamps"}, |
| 1985 | + "Enable timestamps in log messages", |
| 1986 | + [](gpt_params &) { |
| 1987 | + gpt_log_set_timestamps(gpt_log_main(), true); |
| 1988 | + } |
| 1989 | + ).set_env("LLAMA_LOG_TIMESTAMPS")); |
1992 | 1990 |
|
1993 | 1991 | return ctx_arg;
|
1994 | 1992 | }
|
|
0 commit comments