Fix crasher with an empty string for prompt template.

This commit is contained in:
Adam Treat 2023-10-06 12:44:31 -04:00
parent 5fe685427a
commit b2cd3bdb3f

View File

@ -423,6 +423,9 @@ std::string trim_whitespace(const std::string& input) {
return !std::isspace(c); return !std::isspace(c);
}); });
if (first_non_whitespace == input.end())
return std::string();
auto last_non_whitespace = std::find_if(input.rbegin(), input.rend(), [](unsigned char c) { auto last_non_whitespace = std::find_if(input.rbegin(), input.rend(), [](unsigned char c) {
return !std::isspace(c); return !std::isspace(c);
}).base(); }).base();