From: Gabe Goodhart Date: Tue, 5 Nov 2024 12:23:04 +0000 (-0700) Subject: llama : add <|tool_call|> formatting to Granite template (#10177) X-Git-Tag: upstream/0.0.4488~453 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=b8deef0ec0af5febac1d2cfd9119ff330ed0b762;p=pkg%2Fggml%2Fsources%2Fllama.cpp llama : add <|tool_call|> formatting to Granite template (#10177) Branch: GraniteToolCallTemplate Signed-off-by: Gabe Goodhart --- diff --git a/src/llama.cpp b/src/llama.cpp index 3e563d81..0cdf0c07 100644 --- a/src/llama.cpp +++ b/src/llama.cpp @@ -21799,8 +21799,11 @@ static int32_t llama_chat_apply_template_internal( // IBM Granite template for (const auto & message : chat) { std::string role(message->role); - ss << "<|start_of_role|>" << role << "<|end_of_role|>" - << message->content << "<|end_of_text|>\n"; + ss << "<|start_of_role|>" << role << "<|end_of_role|>"; + if (role == "assistant_tool_call") { + ss << "<|tool_call|>"; + } + ss << message->content << "<|end_of_text|>\n"; } if (add_ass) { ss << "<|start_of_role|>assistant<|end_of_role|>\n";