File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -1090,22 +1090,21 @@ struct server_context {
1090
1090
size_t pos = std::min (slot.n_sent_text , slot.generated_text .size ());
1091
1091
1092
1092
const std::string str_test = slot.generated_text .substr (pos);
1093
- bool is_stop_full = false ;
1093
+ bool send_text = true ;
1094
1094
1095
1095
size_t stop_pos = slot.find_stopping_strings (str_test, token_str.size (), STOP_TYPE_FULL);
1096
1096
if (stop_pos != std::string::npos) {
1097
- is_stop_full = true ;
1098
1097
slot.generated_text .erase (
1099
1098
slot.generated_text .begin () + pos + stop_pos,
1100
1099
slot.generated_text .end ());
1101
1100
pos = std::min (slot.n_sent_text , slot.generated_text .size ());
1102
- } else {
1103
- is_stop_full = false ;
1101
+ } else if (slot.has_next_token ) {
1104
1102
stop_pos = slot.find_stopping_strings (str_test, token_str.size (), STOP_TYPE_PARTIAL);
1103
+ send_text = stop_pos == std::string::npos;
1105
1104
}
1106
1105
1107
1106
// check if there is any token to predict
1108
- if (stop_pos == std::string::npos || (!slot. has_next_token && !is_stop_full && stop_pos > 0 ) ) {
1107
+ if (send_text ) {
1109
1108
// no send the stop word in the response
1110
1109
result.text_to_send = slot.generated_text .substr (pos, std::string::npos);
1111
1110
slot.n_sent_text += result.text_to_send .size ();
You can’t perform that action at this time.
0 commit comments