@@ -175,6 +175,21 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
175
175
if (params.prompt .back () == ' \n ' ) {
176
176
params.prompt .pop_back ();
177
177
}
178
+ } else if (arg == " -sysf" || arg == " --system-file" ) {
179
+ if (++i >= argc) {
180
+ invalid_param = true ;
181
+ break ;
182
+ }
183
+ std::ifstream file (argv[i]);
184
+ if (!file) {
185
+ fprintf (stderr, " error: failed to open file '%s'\n " , argv[i]);
186
+ invalid_param = true ;
187
+ break ;
188
+ }
189
+ std::copy (std::istreambuf_iterator<char >(file), std::istreambuf_iterator<char >(), back_inserter (params.system_prompt ));
190
+ if (params.system_prompt .back () == ' \n ' ) {
191
+ params.system_prompt .pop_back ();
192
+ }
178
193
} else if (arg == " -n" || arg == " --n-predict" ) {
179
194
if (++i >= argc) {
180
195
invalid_param = true ;
@@ -516,10 +531,11 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
516
531
}
517
532
if (escape_prompt) {
518
533
process_escapes (params.prompt );
534
+ process_escapes (params.system_prompt );
519
535
}
520
536
521
537
522
- bool all_zero = true ;
538
+ bool all_zero = true ;
523
539
for (size_t i = 0 ; i < LLAMA_MAX_DEVICES; ++i) {
524
540
if (params.tensor_split [i] != 0 .0f ) {
525
541
all_zero = false ;
@@ -565,7 +581,7 @@ void gpt_print_usage(int /*argc*/, char ** argv, const gpt_params & params) {
565
581
fprintf (stderr, " -S, --stopwords \" ,,,\" Add stopwords in addition to the usual end-of-sequence\n " );
566
582
fprintf (stderr, " comma separated list: -S \"\\ n,Hello World,stopword\" - overwrites defaults except eos\n " );
567
583
fprintf (stderr, " Important: 'is' and ' is' are unique tokens in a stopword. Just as 'Hello' and ' Hello' are distinct\n " );
568
- fprintf (stderr, " -e process prompt escapes sequences (\\ n, \\ r, \\ t, \\ ', \\\" , \\\\ )\n " );
584
+ fprintf (stderr, " -e process escapes sequences in prompt and system message (\\ n, \\ r, \\ t, \\ ', \\\" , \\\\ )\n " );
569
585
fprintf (stderr, " --prompt-cache FNAME file to cache prompt state for faster startup (default: none)\n " );
570
586
fprintf (stderr, " --prompt-cache-all if specified, saves user input and generations to cache as well.\n " );
571
587
fprintf (stderr, " not supported with --interactive or other interactive options\n " );
@@ -575,6 +591,8 @@ void gpt_print_usage(int /*argc*/, char ** argv, const gpt_params & params) {
575
591
fprintf (stderr, " --in-suffix STRING string to suffix after user inputs with (default: empty)\n " );
576
592
fprintf (stderr, " -f FNAME, --file FNAME\n " );
577
593
fprintf (stderr, " read prompt from a file, optionally -p prompt is prefixed\n " );
594
+ fprintf (stderr, " -sysf FNAME, --system-file FNAME\n " );
595
+ fprintf (stderr, " read system prompt from a file\n " );
578
596
fprintf (stderr, " -n N, --n-predict N number of tokens to predict (default: %d, -1 = infinity)\n " , params.n_predict );
579
597
fprintf (stderr, " --top-k N top-k sampling (default: %d, 0 = disabled)\n " , params.top_k );
580
598
fprintf (stderr, " --top-p N top-p sampling (default: %.1f, 1.0 = disabled)\n " , (double )params.top_p );
0 commit comments