aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgi Gerganov <ggerganov@gmail.com>2023-03-19 19:04:44 +0200
committerGeorgi Gerganov <ggerganov@gmail.com>2023-03-19 19:05:04 +0200
commit70f01cb8632f73b5cf70428608b89cd3c0775d23 (patch)
tree11fa4bdd3135b82174b5e5c17e4f1913a677cdf3
parenta4e63b73dfa1894387926cc8072b5f36deebf0a5 (diff)
Drop trailing new line from file prompts (#80)
-rw-r--r--main.cpp1
-rw-r--r--utils.cpp3
2 files changed, 3 insertions, 1 deletions
diff --git a/main.cpp b/main.cpp
index a95e2e7..2a07bbb 100644
--- a/main.cpp
+++ b/main.cpp
@@ -850,7 +850,6 @@ int main(int argc, char ** argv) {
// in instruct mode, we inject a prefix and a suffix to each input by the user
if (params.instruct) {
- fprintf(stderr, "== Instruction mode enabled ==\n");
params.interactive = true;
params.antiprompt = "### Instruction:\n\n";
}
diff --git a/utils.cpp b/utils.cpp
index be81c6c..320d7c3 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -40,6 +40,9 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
} else if (arg == "-f" || arg == "--file") {
std::ifstream file(argv[++i]);
std::copy(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>(), back_inserter(params.prompt));
+ if (params.prompt.back() == '\n') {
+ params.prompt.pop_back();
+ }
} else if (arg == "-n" || arg == "--n_predict") {
params.n_predict = std::stoi(argv[++i]);
} else if (arg == "--top_k") {