Skip to content

Commit c397bd1

Browse files
author
Olivier Chafik
committed
tweak delta logic
1 parent df3474e commit c397bd1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

common/chat-template.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ class chat_template {
203203
const json tools;
204204
auto prefix = apply(json::array({user_msg}), tools, /* add_generation_prompt= */ true);
205205
auto full = apply(json::array({user_msg, tool_call_msg}), tools, /* add_generation_prompt= */ false);
206+
if (full.find(prefix) != 0 && prefix.length() > 0 && prefix[prefix.length() - 1] == '\n') {
207+
prefix = prefix.substr(0, prefix.length() - 1);
208+
}
206209
if (full.find(prefix) != 0) {
207210
if (prefix.rfind(eos_token_) == prefix.size() - eos_token_.size()) {
208211
prefix = prefix.substr(0, prefix.size() - eos_token_.size());

0 commit comments

Comments
 (0)