]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
llama : add <|tool_call|> formatting to Granite template (#10177)
authorGabe Goodhart <redacted>
Tue, 5 Nov 2024 12:23:04 +0000 (05:23 -0700)
committerGitHub <redacted>
Tue, 5 Nov 2024 12:23:04 +0000 (14:23 +0200)
Branch: GraniteToolCallTemplate

Signed-off-by: Gabe Goodhart <redacted>
src/llama.cpp

index 3e563d811b77c4a637ed7d8f3e9411b8b0c48f00..0cdf0c073b19f5ae5f11d177c550e31dc059435e 100644 (file)
@@ -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";