]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
common : default content to an empty string (#18485)
authorAldehir Rojas <redacted>
Tue, 30 Dec 2025 18:00:57 +0000 (12:00 -0600)
committerGitHub <redacted>
Tue, 30 Dec 2025 18:00:57 +0000 (12:00 -0600)
* common : default content to an empty string

* common : fix tests that break when content != null

common/chat.cpp
models/templates/llama-cpp-deepseek-r1.jinja
tests/test-chat.cpp

index 0a426f447868be477f302e639f314cc151e2a57d..be44c8abb0b908a9a981e5b6358a3bf0b7e617bc 100644 (file)
@@ -319,7 +319,7 @@ json common_chat_msgs_to_json_oaicompat(const std::vector<common_chat_msg> & msg
                 }
             }
         } else {
-            jmsg["content"] = json(); // null
+            jmsg["content"] = "";
         }
         if (!msg.reasoning_content.empty()) {
             jmsg["reasoning_content"] = msg.reasoning_content;
index fcb1732eb8fe713cfc77e5f86dc58489f9eca3bc..0d18870870e5f1f212a163d5db900cfb037ae071 100644 (file)
@@ -38,7 +38,7 @@ Example function tool call syntax:
     {%- if message['role'] == 'user' -%}
         {{- '<|User|>' + message['content'] + '<|end▁of▁sentence|>' -}}
     {%- endif -%}
-    {%- if message['role'] == 'assistant' and message['content'] is none -%}
+    {%- if message['role'] == 'assistant' and not message['content'] -%}
         {{- '<|Assistant|><|tool▁calls▁begin|>' -}}
         {%- set ns.is_first = true -%}
         {%- for tc in message['tool_calls'] -%}
@@ -53,7 +53,7 @@ Example function tool call syntax:
         {%- endfor -%}
         {{- '<|tool▁calls▁end|><|end▁of▁sentence|>' -}}
     {%- endif -%}
-    {%- if message['role'] == 'assistant' and message['content'] is  not none -%}
+    {%- if message['role'] == 'assistant' and message['content'] -%}
         {{- flush_tool_outputs() -}}
         {%- set content = message['content'] -%}
         {%- if '</think>' in content -%}
@@ -73,4 +73,4 @@ Example function tool call syntax:
 {{- flush_tool_outputs() -}}
 {%- if add_generation_prompt and not ns.is_tool_outputs -%}
     {{- '<|Assistant|><think>\n' -}}
-{%- endif -%}
\ No newline at end of file
+{%- endif -%}
index 02af5251cc6de8eb75af43971ff8de39684c3692..a78627604e79881b7a86e5f6d34d4d11b9ea2f3d 100644 (file)
@@ -650,7 +650,7 @@ static void test_msgs_oaicompat_json_conversion() {
             "[\n"
             "  {\n"
             "    \"role\": \"assistant\",\n"
-            "    \"content\": null,\n"
+            "    \"content\": \"\",\n"
             "    \"tool_calls\": [\n"
             "      {\n"
             "        \"type\": \"function\",\n"
@@ -906,7 +906,8 @@ static void test_template_output_parsers() {
                       "      },\n"
                       "      \"id\": \"123456789\"\n"
                       "    }\n"
-                      "  ]\n"
+                      "  ],\n"
+                      "  \"content\": \"\"\n"
                       "}");
     }
     {
@@ -1713,7 +1714,8 @@ static void test_template_output_parsers() {
                       "      },\n"
                       "      \"id\": \"123456789\"\n"
                       "    }\n"
-                      "  ]\n"
+                      "  ],\n"
+                      "  \"content\": \"\"\n"
                       "}",
                       /* expect_grammar_triggered= */ false
         );