Skip to content

Commit 6441ad4

Browse files
author
CNE FICHEPOIL Pierre
committed
updated qwen3 0.6B chat template with official one
1 parent 73010a1 commit 6441ad4

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

models/templates/Qwen-Qwen3-0.6B.jinja

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,27 @@
1717
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
1818
{%- for message in messages[::-1] %}
1919
{%- set index = (messages|length - 1) - loop.index0 %}
20-
{%- if ns.multi_step_tool and message.role == "user" and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
20+
{%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
2121
{%- set ns.multi_step_tool = false %}
2222
{%- set ns.last_query_index = index %}
2323
{%- endif %}
2424
{%- endfor %}
2525
{%- for message in messages %}
26+
{%- if message.content is string %}
27+
{%- set content = message.content %}
28+
{%- else %}
29+
{%- set content = '' %}
30+
{%- endif %}
2631
{%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
27-
{{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
32+
{{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
2833
{%- elif message.role == "assistant" %}
29-
{%- set content = message.content %}
3034
{%- set reasoning_content = '' %}
31-
{%- if message.reasoning_content is defined and message.reasoning_content is not none %}
35+
{%- if message.reasoning_content is string %}
3236
{%- set reasoning_content = message.reasoning_content %}
3337
{%- else %}
34-
{%- if '</think>' in message.content %}
35-
{%- set content = message.content.split('</think>')[-1].lstrip('\n') %}
36-
{%- set reasoning_content = message.content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
38+
{%- if '</think>' in content %}
39+
{%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
40+
{%- set content = content.split('</think>')[-1].lstrip('\n') %}
3741
{%- endif %}
3842
{%- endif %}
3943
{%- if loop.index0 > ns.last_query_index %}
@@ -70,7 +74,7 @@
7074
{{- '<|im_start|>user' }}
7175
{%- endif %}
7276
{{- '\n<tool_response>\n' }}
73-
{{- message.content }}
77+
{{- content }}
7478
{{- '\n</tool_response>' }}
7579
{%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
7680
{{- '<|im_end|>\n' }}

0 commit comments

Comments
 (0)