This commit is contained in:
htxsrl 2026-02-01 15:20:41 -08:00 committed by GitHub
commit aa8f7ee40d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 1 deletions

View File

@ -1882,9 +1882,22 @@ static common_chat_params common_chat_params_init_kimi_k2(const common_chat_temp
common_chat_params data;
data.grammar_lazy = params.tools.is_array() && !params.tools.empty() && params.tool_choice != COMMON_CHAT_TOOL_CHOICE_REQUIRED;
data.prompt = apply(tmpl, params);
json additional_context = {
{"thinking", params.enable_thinking},
};
data.prompt = apply(tmpl, params, /* messages_override= */ std::nullopt, /* tools_override= */ std::nullopt, additional_context);
data.format = COMMON_CHAT_FORMAT_KIMI_K2;
// Handle thinking tags based on prompt ending
if (string_ends_with(data.prompt, "<think>\n") || string_ends_with(data.prompt, "<think>")) {
if (!params.enable_thinking) {
data.prompt += "</think>";
} else {
data.thinking_forced_open = true;
}
}
data.preserved_tokens = {
"<think>",
"</think>",