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 @@ -1068,22 +1068,21 @@ struct server_context {
10681068 size_t pos = std::min (slot.n_sent_text , slot.generated_text .size ());
10691069
10701070 const std::string str_test = slot.generated_text .substr (pos);
1071- bool is_stop_full = false ;
1071+ bool send_text = true ;
10721072
10731073 size_t stop_pos = slot.find_stopping_strings (str_test, token_str.size (), STOP_TYPE_FULL);
10741074 if (stop_pos != std::string::npos) {
1075- is_stop_full = true ;
10761075 slot.generated_text .erase (
10771076 slot.generated_text .begin () + pos + stop_pos,
10781077 slot.generated_text .end ());
10791078 pos = std::min (slot.n_sent_text , slot.generated_text .size ());
1080- } else {
1081- is_stop_full = false ;
1079+ } else if (slot.has_next_token ) {
10821080 stop_pos = slot.find_stopping_strings (str_test, token_str.size (), STOP_TYPE_PARTIAL);
1081+ send_text = stop_pos == std::string::npos;
10831082 }
10841083
10851084 // check if there is any token to predict
1086- if (stop_pos == std::string::npos || is_stop_full || (!slot. has_next_token && !is_stop_full && stop_pos > 0 ) ) {
1085+ if (send_text ) {
10871086 // no send the stop word in the response
10881087 result.text_to_send = slot.generated_text .substr (pos, std::string::npos);
10891088 slot.n_sent_text += result.text_to_send .size ();
You can’t perform that action at this time.
0 commit comments