Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/llm/ovms_text_streamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ ov::genai::StreamingStatus OVMSTextStreamer::write(int64_t token) {
// 2. Incomplete UTF-8: decoded length did not advance — last bytes are a
// partial multibyte sequence. Mark this slot as -1 so the delay check
// skips it (matching TextStreamer's own handling).
const size_t n = m_decoded_lengths.size();
if (n >= 2 && m_decoded_lengths[n - 1] == m_decoded_lengths[n - 2]) {
const size_t text_size = text.size();
char replacement[] = "\xef\xbf\xbd";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please create is_incomplete function just like in genai, it will be easier for us to debug later

if (text_size >= 3 && text.compare(text_size - 3, 3, replacement) == 0) {
m_decoded_lengths.back() = -1;
return ov::genai::StreamingStatus::RUNNING;
}

// 3. Delay buffer: need at least DELAY_N_TOKENS entries before flushing.
const size_t n = m_decoded_lengths.size();
if (n < DELAY_N_TOKENS) {
return ov::genai::StreamingStatus::RUNNING;
}
Expand Down