Skip to content

Commit bff549d

Browse files
author
Olivier Chafik
committed
simplify hack to fix original template's backfill from minja
1 parent bbd45bf commit bff549d

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

common/chat.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -604,13 +604,10 @@ static common_chat_params common_chat_params_init_deepseek_r1(const common_chat_
604604
}
605605
}
606606
// Fix up tool call delta example added by Minja
607-
std::string marker = "<|tool▁call▁end|>\n";
608-
auto pos = prompt.rfind(marker);
609-
if (pos != std::string::npos) {
610-
prompt.insert(pos + marker.size() - 1, "<|tool▁calls▁end|>");
611-
} else {
612-
LOG_WRN("Failed to find expected broken tool call example marker in prompt\n");
613-
}
607+
prompt = std::regex_replace(
608+
prompt,
609+
std::regex("<|tool▁call▁end|>[\\s\\r\\n]*<|User|>"),
610+
"<|tool▁call▁end|><|tool▁calls▁end|><|User|>");
614611
}
615612
data.prompt = prompt;
616613
data.format = COMMON_CHAT_FORMAT_DEEPSEEK_R1;

0 commit comments

Comments
 (0)