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 ),
@@ -697,6 +685,13 @@ gpt_params_context gpt_params_parser_init(gpt_params & params, llama_example ex,
697685 params.n_keep = value;
698686 }
699687 ));
688+ add_opt (llama_arg (
689+ {" --no-context-shift" },
690+ format (" disables context shift on inifinite text generation (default: %s)" , params.ctx_shift ? " disabled" : " enabled" ),
691+ [](gpt_params & params) {
692+ params.ctx_shift = false ;
693+ }
694+ ).set_examples ({LLAMA_EXAMPLE_MAIN}));
700695 add_opt (llama_arg (
701696 {" --chunks" }, " N" ,
702697 format (" max number of chunks to process (default: %d, -1 = all)" , params.n_chunks ),
@@ -876,15 +871,15 @@ gpt_params_context gpt_params_parser_init(gpt_params & params, llama_example ex,
876871 params.input_prefix = value;
877872 params.enable_chat_template = false ;
878873 }
879- ).set_examples ({LLAMA_EXAMPLE_MAIN}));
874+ ).set_examples ({LLAMA_EXAMPLE_MAIN, LLAMA_EXAMPLE_INFILL }));
880875 add_opt (llama_arg (
881876 {" --in-suffix" }, " STRING" ,
882877 " string to suffix after user inputs with (default: empty)" ,
883878 [](gpt_params & params, const std::string & value) {
884879 params.input_suffix = value;
885880 params.enable_chat_template = false ;
886881 }
887- ).set_examples ({LLAMA_EXAMPLE_MAIN}));
882+ ).set_examples ({LLAMA_EXAMPLE_MAIN, LLAMA_EXAMPLE_INFILL }));
888883 add_opt (llama_arg (
889884 {" --no-warmup" },
890885 " skip warming up the model with an empty run" ,
@@ -1824,19 +1819,6 @@ gpt_params_context gpt_params_parser_init(gpt_params & params, llama_example ex,
18241819 params.system_prompt = system_prompt;
18251820 }
18261821 ).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}));
18401822 add_opt (llama_arg (
18411823 {" --metrics" },
18421824 format (" enable prometheus compatible metrics endpoint (default: %s)" , params.endpoint_metrics ? " enabled" : " disabled" ),
@@ -1956,40 +1938,57 @@ gpt_params_context gpt_params_parser_init(gpt_params & params, llama_example ex,
19561938 else { std::invalid_argument (" invalid value" ); }
19571939 }
19581940 ).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- ));
19661941 add_opt (llama_arg (
19671942 {" --log-disable" },
19681943 " Log disable" ,
1969- [](gpt_params &) { log_param_single_parse (" --log-disable" ); }
1944+ [](gpt_params &) {
1945+ gpt_log_pause (gpt_log_main ());
1946+ }
19701947 ));
19711948 add_opt (llama_arg (
1972- {" --log-enable" },
1973- " Log enable" ,
1974- [](gpt_params &) { log_param_single_parse (" --log-enable" ); }
1949+ {" --log-file" }, " FNAME" ,
1950+ " Log to file" ,
1951+ [](gpt_params &, const std::string & value) {
1952+ gpt_log_set_file (gpt_log_main (), value.c_str ());
1953+ }
19751954 ));
19761955 add_opt (llama_arg (
1977- {" --log-new" },
1978- " Log new" ,
1979- [](gpt_params &) { log_param_single_parse (" --log-new" ); }
1980- ));
1956+ {" --log-colors" },
1957+ " Enable colored logging" ,
1958+ [](gpt_params &) {
1959+ gpt_log_set_colors (gpt_log_main (), true );
1960+ }
1961+ ).set_env (" LLAMA_LOG_COLORS" ));
19811962 add_opt (llama_arg (
1982- {" --log-append" },
1983- " Log append" ,
1984- [](gpt_params &) { log_param_single_parse (" --log-append" ); }
1963+ {" -v" , " --verbose" , " --log-verbose" },
1964+ " Set verbosity level to infinity (i.e. log all messages, useful for debugging)" ,
1965+ [](gpt_params & params) {
1966+ params.verbosity = INT_MAX;
1967+ gpt_log_set_verbosity_thold (INT_MAX);
1968+ }
19851969 ));
19861970 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
1971+ {" -lv" , " --verbosity" , " --log-verbosity" }, " N" ,
1972+ " Set the verbosity threshold. Messages with a higher verbosity will be ignored." ,
1973+ [](gpt_params & params, int value) {
1974+ params.verbosity = value;
1975+ gpt_log_set_verbosity_thold (value);
1976+ }
1977+ ).set_env (" LLAMA_LOG_VERBOSITY" ));
1978+ add_opt (llama_arg (
1979+ {" --log-prefix" },
1980+ " Enable prefx in log messages" ,
1981+ [](gpt_params &) {
1982+ gpt_log_set_prefix (gpt_log_main (), true );
1983+ }
1984+ ).set_env (" LLAMA_LOG_PREFIX" ));
1985+ add_opt (llama_arg (
1986+ {" --log-timestamps" },
1987+ " Enable timestamps in log messages" ,
1988+ [](gpt_params &) {
1989+ gpt_log_set_timestamps (gpt_log_main (), true );
1990+ }
1991+ ).set_env (" LLAMA_LOG_TIMESTAMPS" ));
19921992
19931993 return ctx_arg;
19941994}
1995-
0 commit comments