Skip to content

Commit c17bce7

Browse files
CISCjpohhhh
authored andcommitted
main : add -sysf / --system-prompt-file (#12249) (#12250)
* add system_prompt_file * add -sysf / --system-prompt-file * remove system_prompt_file
1 parent 04b913b commit c17bce7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

common/arg.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,20 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
853853
}
854854
}
855855
).set_excludes({LLAMA_EXAMPLE_SERVER}));
856+
add_opt(common_arg(
857+
{"-sysf", "--system-prompt-file"}, "FNAME",
858+
"a file containing the system prompt (default: none)",
859+
[](common_params & params, const std::string & value) {
860+
std::ifstream file(value);
861+
if (!file) {
862+
throw std::runtime_error(string_format("error: failed to open file '%s'\n", value.c_str()));
863+
}
864+
std::copy(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>(), back_inserter(params.system_prompt));
865+
if (!params.system_prompt.empty() && params.system_prompt.back() == '\n') {
866+
params.system_prompt.pop_back();
867+
}
868+
}
869+
).set_examples({LLAMA_EXAMPLE_MAIN}));
856870
add_opt(common_arg(
857871
{"--in-file"}, "FNAME",
858872
"an input file (repeat to specify multiple files)",

0 commit comments

Comments
 (0)