likejazz commited on
Commit
df96d7b
·
verified ·
1 Parent(s): 26d3d1c

Update chat_template.jinja

Browse files
Files changed (1) hide show
  1. chat_template.jinja +11 -10
chat_template.jinja CHANGED
@@ -30,9 +30,8 @@
30
  {%- endif %}
31
  {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
32
  {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
33
- {%- elif message.role == "assistant" -%}
34
- {% generation %}
35
- {%- set reasoning_content = '' -%}
36
  {%- if message.reasoning_content is string %}
37
  {%- set reasoning_content = message.reasoning_content %}
38
  {%- else %}
@@ -41,16 +40,17 @@
41
  {%- set content = content.split('</think>')[-1].lstrip('\n') %}
42
  {%- endif %}
43
  {%- endif %}
 
 
44
  {%- if loop.index0 > ns.last_query_index %}
45
  {%- if loop.last or (not loop.last and reasoning_content) %}
46
- {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
47
  {%- else %}
48
- {{- '<|im_start|>' + message.role + '\n' + content }}
49
  {%- endif %}
50
  {%- else %}
51
- {{- '<|im_start|>' + message.role + '\n' + content }}
52
- {%- endif -%}
53
- {% endgeneration %}
54
  {%- if message.tool_calls %}
55
  {%- for tool_call in message.tool_calls %}
56
  {%- if (loop.first and content) or (not loop.first) %}
@@ -70,7 +70,8 @@
70
  {{- '}\n</tool_call>' }}
71
  {%- endfor %}
72
  {%- endif %}
73
- {{- '<|im_end|>\n' }}
 
74
  {%- elif message.role == "tool" %}
75
  {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
76
  {{- '<|im_start|>user' }}
@@ -88,4 +89,4 @@
88
  {%- if enable_thinking is defined and enable_thinking is false %}
89
  {{- '<think>\n\n</think>\n\n' }}
90
  {%- endif %}
91
- {%- endif %}
 
30
  {%- endif %}
31
  {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
32
  {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
33
+ {%- elif message.role == "assistant" %}
34
+ {%- set reasoning_content = '' %}
 
35
  {%- if message.reasoning_content is string %}
36
  {%- set reasoning_content = message.reasoning_content %}
37
  {%- else %}
 
40
  {%- set content = content.split('</think>')[-1].lstrip('\n') %}
41
  {%- endif %}
42
  {%- endif %}
43
+ {{- '<|im_start|>' + message.role }}
44
+ {% generation %}
45
  {%- if loop.index0 > ns.last_query_index %}
46
  {%- if loop.last or (not loop.last and reasoning_content) %}
47
+ {{- '<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
48
  {%- else %}
49
+ {{- content }}
50
  {%- endif %}
51
  {%- else %}
52
+ {{- content }}
53
+ {%- endif %}
 
54
  {%- if message.tool_calls %}
55
  {%- for tool_call in message.tool_calls %}
56
  {%- if (loop.first and content) or (not loop.first) %}
 
70
  {{- '}\n</tool_call>' }}
71
  {%- endfor %}
72
  {%- endif %}
73
+ {{- '<|im_end|>' }}
74
+ {% endgeneration %}
75
  {%- elif message.role == "tool" %}
76
  {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
77
  {{- '<|im_start|>user' }}
 
89
  {%- if enable_thinking is defined and enable_thinking is false %}
90
  {{- '<think>\n\n</think>\n\n' }}
91
  {%- endif %}
92
+ {%- endif %}