trim whitespace from the beginning and end of a string
| 17 | |
| 18 | // trim whitespace from the beginning and end of a string |
| 19 | static std::string trim(const std::string & str) { |
| 20 | size_t start = 0; |
| 21 | size_t end = str.size(); |
| 22 | |
| 23 | while (start < end && isspace(str[start])) { |
| 24 | start += 1; |
| 25 | } |
| 26 | |
| 27 | while (end > start && isspace(str[end - 1])) { |
| 28 | end -= 1; |
| 29 | } |
| 30 | |
| 31 | return str.substr(start, end - start); |
| 32 | } |
| 33 | |
| 34 | static std::string k_system = |
| 35 | R"(Transcript of a never ending dialog, where the User interacts with an Assistant. |