File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -1968,7 +1968,9 @@ struct server_context {
19681968 slot.generated_text .erase (
19691969 slot.generated_text .begin () + pos + stop_pos,
19701970 slot.generated_text .end ());
1971- pos = std::min (slot.n_sent_text , slot.generated_text .size ());
1971+ // Update n_sent_text to not exceed the new generated_text size
1972+ slot.n_sent_text = std::min (slot.n_sent_text , slot.generated_text .size ());
1973+ pos = slot.n_sent_text ;
19721974 } else {
19731975 is_stop_full = false ;
19741976 stop_pos = slot.find_stopping_strings (str_test, token_str.size (), false );
@@ -1980,6 +1982,9 @@ struct server_context {
19801982 result.text_to_send = slot.generated_text .substr (pos, std::string::npos);
19811983 slot.n_sent_text += result.text_to_send .size ();
19821984 // add the token to slot queue and cache
1985+ } else if (stop_pos != std::string::npos) {
1986+ // Handle partial stop - update n_sent_text to the end of the current text
1987+ slot.n_sent_text = slot.generated_text .size ();
19831988 }
19841989
19851990 slot.add_token_string (result);
You can’t perform that action at this time.
0 commit comments