Skip to content

Commit e8f6e33

Browse files
author
ochafik
committed
more forgiving message diffs: partial stop words aren't erased, full stops are
1 parent d785f9c commit e8f6e33

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

common/chat.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ static std::string string_diff(const std::string & last, const std::string & cur
3131
return current;
3232
}
3333
if (!string_starts_with(current, last)) {
34+
if (string_starts_with(last, current)) {
35+
// This happens if the last generation ended on a partial stop word (not erased),
36+
// and the current ended on a stop word (erased).
37+
return "";
38+
}
3439
throw std::runtime_error("Invalid diff: '" + last + "' not found at start of '" + current + "'");
3540
}
3641
return current.substr(last.size());

0 commit comments

Comments
 (0)