Skip to content

Commit 70f01cb

Browse files
committed
Drop trailing new line from file prompts (#80)
1 parent a4e63b7 commit 70f01cb

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,6 @@ int main(int argc, char ** argv) {
850850

851851
// in instruct mode, we inject a prefix and a suffix to each input by the user
852852
if (params.instruct) {
853-
fprintf(stderr, "== Instruction mode enabled ==\n");
854853
params.interactive = true;
855854
params.antiprompt = "### Instruction:\n\n";
856855
}

utils.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
4040
} else if (arg == "-f" || arg == "--file") {
4141
std::ifstream file(argv[++i]);
4242
std::copy(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>(), back_inserter(params.prompt));
43+
if (params.prompt.back() == '\n') {
44+
params.prompt.pop_back();
45+
}
4346
} else if (arg == "-n" || arg == "--n_predict") {
4447
params.n_predict = std::stoi(argv[++i]);
4548
} else if (arg == "--top_k") {

0 commit comments

Comments
 (0)