Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions models/templates/llama-cpp-deepseek-r1.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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'] -%}
Expand All @@ -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 -%}
Expand All @@ -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 -%}
{%- endif -%}
8 changes: 5 additions & 3 deletions tests/test-chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -906,7 +906,8 @@ static void test_template_output_parsers() {
" },\n"
" \"id\": \"123456789\"\n"
" }\n"
" ]\n"
" ],\n"
" \"content\": \"\"\n"
"}");
}
{
Expand Down Expand Up @@ -1713,7 +1714,8 @@ static void test_template_output_parsers() {
" },\n"
" \"id\": \"123456789\"\n"
" }\n"
" ]\n"
" ],\n"
" \"content\": \"\"\n"
"}",
/* expect_grammar_triggered= */ false
);
Expand Down
Loading