server: fix the disappearance of the end of the text when streaming with stop strings

This commit is contained in:
ZXED 2024-10-12 18:31:43 +03:00
parent edc265661c
commit ae996a2fc8
No known key found for this signature in database
GPG key ID: 637FB44813DCFD66

View file

@ -1083,7 +1083,7 @@ struct server_context {
} }
// check if there is any token to predict // check if there is any token to predict
if (stop_pos == std::string::npos || (!slot.has_next_token && !is_stop_full && stop_pos > 0)) { if (stop_pos == std::string::npos || is_stop_full || (!slot.has_next_token && !is_stop_full && stop_pos > 0)) {
// no send the stop word in the response // no send the stop word in the response
result.text_to_send = slot.generated_text.substr(pos, std::string::npos); result.text_to_send = slot.generated_text.substr(pos, std::string::npos);
slot.n_sent_text += result.text_to_send.size(); slot.n_sent_text += result.text_to_send.size();