11#include " arg.h"
22
3+ #include " log.h"
34#include " sampling.h"
45
56#include < algorithm>
6- #include < string>
7- #include < vector>
8- #include < set>
7+ #include < climits>
8+ #include < cstdarg>
99#include < fstream>
1010#include < regex>
11- #include < cstdarg>
12- #include < climits>
11+ #include < set>
12+ #include < string>
13+ #include < thread>
14+ #include < vector>
1315
1416#include " json-schema-to-grammar.h"
1517
@@ -383,20 +385,6 @@ gpt_params_context gpt_params_parser_init(gpt_params & params, llama_example ex,
383385 exit (0 );
384386 }
385387 ));
386- add_opt (llama_arg (
387- {" -v" , " --verbose" },
388- " print verbose information" ,
389- [](gpt_params & params) {
390- params.verbosity = 1 ;
391- }
392- ));
393- add_opt (llama_arg (
394- {" --verbosity" }, " N" ,
395- format (" set specific verbosity level (default: %d)" , params.verbosity ),
396- [](gpt_params & params, int value) {
397- params.verbosity = value;
398- }
399- ));
400388 add_opt (llama_arg (
401389 {" --verbose-prompt" },
402390 format (" print a verbose prompt before generation (default: %s)" , params.verbose_prompt ? " true" : " false" ),
@@ -417,7 +405,7 @@ gpt_params_context gpt_params_parser_init(gpt_params & params, llama_example ex,
417405 [](gpt_params & params) {
418406 params.use_color = true ;
419407 }
420- ).set_examples ({LLAMA_EXAMPLE_MAIN, LLAMA_EXAMPLE_INFILL}));
408+ ).set_examples ({LLAMA_EXAMPLE_MAIN, LLAMA_EXAMPLE_INFILL, LLAMA_EXAMPLE_SPECULATIVE, LLAMA_EXAMPLE_LOOKUP }));
421409 add_opt (llama_arg (
422410 {" -t" , " --threads" }, " N" ,
423411 format (" number of threads to use during generation (default: %d)" , params.cpuparams .n_threads ),
@@ -876,15 +864,15 @@ gpt_params_context gpt_params_parser_init(gpt_params & params, llama_example ex,
876864 params.input_prefix = value;
877865 params.enable_chat_template = false ;
878866 }
879- ).set_examples ({LLAMA_EXAMPLE_MAIN}));
867+ ).set_examples ({LLAMA_EXAMPLE_MAIN, LLAMA_EXAMPLE_INFILL }));
880868 add_opt (llama_arg (
881869 {" --in-suffix" }, " STRING" ,
882870 " string to suffix after user inputs with (default: empty)" ,
883871 [](gpt_params & params, const std::string & value) {
884872 params.input_suffix = value;
885873 params.enable_chat_template = false ;
886874 }
887- ).set_examples ({LLAMA_EXAMPLE_MAIN}));
875+ ).set_examples ({LLAMA_EXAMPLE_MAIN, LLAMA_EXAMPLE_INFILL }));
888876 add_opt (llama_arg (
889877 {" --no-warmup" },
890878 " skip warming up the model with an empty run" ,
@@ -1824,19 +1812,6 @@ gpt_params_context gpt_params_parser_init(gpt_params & params, llama_example ex,
18241812 params.system_prompt = system_prompt;
18251813 }
18261814 ).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}));
18401815 add_opt (llama_arg (
18411816 {" --metrics" },
18421817 format (" enable prometheus compatible metrics endpoint (default: %s)" , params.endpoint_metrics ? " enabled" : " disabled" ),
@@ -1956,39 +1931,57 @@ gpt_params_context gpt_params_parser_init(gpt_params & params, llama_example ex,
19561931 else { std::invalid_argument (" invalid value" ); }
19571932 }
19581933 ).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- ));
19661934 add_opt (llama_arg (
19671935 {" --log-disable" },
19681936 " Log disable" ,
1969- [](gpt_params &) { log_param_single_parse (" --log-disable" ); }
1937+ [](gpt_params &) {
1938+ gpt_log_pause (gpt_log_main ());
1939+ }
19701940 ));
19711941 add_opt (llama_arg (
1972- {" --log-enable" },
1973- " Log enable" ,
1974- [](gpt_params &) { log_param_single_parse (" --log-enable" ); }
1942+ {" --log-file" }, " FNAME" ,
1943+ " Log to file" ,
1944+ [](gpt_params &, const std::string & value) {
1945+ gpt_log_set_file (gpt_log_main (), value.c_str ());
1946+ }
19751947 ));
19761948 add_opt (llama_arg (
1977- {" --log-new" },
1978- " Log new" ,
1979- [](gpt_params &) { log_param_single_parse (" --log-new" ); }
1980- ));
1949+ {" --log-colors" },
1950+ " Enable colored logging" ,
1951+ [](gpt_params &) {
1952+ gpt_log_set_colors (gpt_log_main (), true );
1953+ }
1954+ ).set_env (" LLAMA_LOG_COLORS" ));
19811955 add_opt (llama_arg (
1982- {" --log-append" },
1983- " Log append" ,
1984- [](gpt_params &) { log_param_single_parse (" --log-append" ); }
1956+ {" -v" , " --verbose" , " --log-verbose" },
1957+ " Set verbosity level to infinity (i.e. log all messages, useful for debugging)" ,
1958+ [](gpt_params & params) {
1959+ params.verbosity = INT_MAX;
1960+ gpt_log_set_verbosity_thold (INT_MAX);
1961+ }
19851962 ));
19861963 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
1964+ {" -lv" , " --verbosity" , " --log-verbosity" }, " N" ,
1965+ " Set the verbosity threshold. Messages with a higher verbosity will be ignored." ,
1966+ [](gpt_params & params, int value) {
1967+ params.verbosity = value;
1968+ gpt_log_set_verbosity_thold (value);
1969+ }
1970+ ).set_env (" LLAMA_LOG_VERBOSITY" ));
1971+ add_opt (llama_arg (
1972+ {" --log-prefix" },
1973+ " Enable prefx in log messages" ,
1974+ [](gpt_params &) {
1975+ gpt_log_set_prefix (gpt_log_main (), true );
1976+ }
1977+ ).set_env (" LLAMA_LOG_PREFIX" ));
1978+ add_opt (llama_arg (
1979+ {" --log-timestamps" },
1980+ " Enable timestamps in log messages" ,
1981+ [](gpt_params &) {
1982+ gpt_log_set_timestamps (gpt_log_main (), true );
1983+ }
1984+ ).set_env (" LLAMA_LOG_TIMESTAMPS" ));
19921985
19931986 return ctx_arg;
19941987}
0 commit comments