summaryrefslogtreecommitdiff
path: root/common/common.cpp
diff options
context:
space:
mode:
authorKerfuffle <44031344+KerfuffleV2@users.noreply.github.com>2023-10-07 15:31:41 -0600
committerGitHub <noreply@github.com>2023-10-07 15:31:41 -0600
commita16e89cec83b4bd5f6af8f1ce1400f94c12356f9 (patch)
tree2a305318f3f6115b9c1d4c87e71bccdbfe18b163 /common/common.cpp
parent4d0383321184aadf91968d9e3c6a45286ed2473b (diff)
Fix trying to strip newline from empty prompt and cfg prompt file content (#3534)
Diffstat (limited to 'common/common.cpp')
-rw-r--r--common/common.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/common/common.cpp b/common/common.cpp
index 60b00b5f..0f55c33a 100644
--- a/common/common.cpp
+++ b/common/common.cpp
@@ -170,7 +170,7 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
// store the external file name in params
params.prompt_file = argv[i];
std::copy(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>(), back_inserter(params.prompt));
- if (params.prompt.back() == '\n') {
+ if (!params.prompt.empty() && params.prompt.back() == '\n') {
params.prompt.pop_back();
}
} else if (arg == "-n" || arg == "--n-predict") {
@@ -295,7 +295,7 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
break;
}
std::copy(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>(), back_inserter(params.cfg_negative_prompt));
- if (params.cfg_negative_prompt.back() == '\n') {
+ if (!params.cfg_negative_prompt.empty() && params.cfg_negative_prompt.back() == '\n') {
params.cfg_negative_prompt.pop_back();
}
} else if (arg == "--cfg-scale") {