Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit a3acd59

Browse files
committed
strimming all the trailing space
1 parent 554b1c3 commit a3acd59

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

controllers/llamaCPP.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,16 +200,16 @@ void llamaCPP::chatCompletion(
200200
stopWords.push_back(stop_word.asString());
201201
}
202202
// specify default stop words
203-
stopWords.push_back(user_prompt);
203+
stopWords.push_back(nitro_utils::rtrim(user_prompt));
204204
data["stop"] = stopWords;
205205
}
206206

207207
bool is_streamed = data["stream"];
208-
// Enable full message debugging
209-
#ifdef DEBUG
208+
// Enable full message debugging
209+
#ifdef DEBUG
210210
LOG_INFO << "Current completion text";
211-
LOG_INFO << formatted_output ;
212-
#endif
211+
LOG_INFO << formatted_output;
212+
#endif
213213
const int task_id = llama.request_completion(data, false, false);
214214
LOG_INFO << "Resolved request for task_id:" << task_id;
215215

utils/nitro_utils.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
#include <ostream>
99

1010
namespace nitro_utils {
11+
12+
inline std::string rtrim(const std::string &str) {
13+
size_t end = str.find_last_not_of("\n\t ");
14+
return (end == std::string::npos) ? "" : str.substr(0, end + 1);
15+
}
16+
1117
inline std::string generate_random_string(std::size_t length) {
1218
const std::string characters =
1319
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

0 commit comments

Comments
 (0)