Chat Completion "reasoning" support

#2
by yzong-rh - opened
Files changed (1) hide show
  1. chat_template.jinja +5 -3
chat_template.jinja CHANGED
@@ -125,8 +125,10 @@ These instructions serve as your defaults, but they can be overridden in subsequ
125
  {%- endif %}
126
  {%- endmacro %}
127
  {%- macro print_thinking(msg) %}
128
- {%- if msg.thinking -%}
129
  {{ msg.thinking }}
 
 
130
  {%- elif msg.content and msg.content[0].thinking -%}
131
  {{ msg.content[0].thinking }}
132
  {%- endif %}
@@ -224,7 +226,7 @@ Your output should adhere to the following json schema:
224
  {% if not skip_thinking %}
225
  {% if message.tool_plan -%}
226
  <|START_THINKING|>{{ message.tool_plan }}<|END_THINKING|>
227
- {%- elif message.thinking or (message.content and message.content[0].type == "thinking") -%}
228
  <|START_THINKING|>{{ print_thinking(message) }}<|END_THINKING|>
229
  {%- endif %}
230
  {%- endif %}<|START_ACTION|>[
@@ -236,7 +238,7 @@ Your output should adhere to the following json schema:
236
 
237
  ]<|END_ACTION|><|END_OF_TURN_TOKEN|>
238
  {%- else -%}
239
- {% if (message.thinking or (message.content and message.content[0].type == "thinking")) and not skip_thinking -%}
240
  <|START_THINKING|>{{ print_thinking(message) }}<|END_THINKING|>
241
  {%- endif -%}
242
  {{ print_msg(message) }}<|END_OF_TURN_TOKEN|>
 
125
  {%- endif %}
126
  {%- endmacro %}
127
  {%- macro print_thinking(msg) %}
128
+ {%- if msg.thinking is defined and msg.thinking is not none -%}
129
  {{ msg.thinking }}
130
+ {%- elif msg.reasoning is defined and msg.reasoning is not none -%}
131
+ {{ msg.reasoning }}
132
  {%- elif msg.content and msg.content[0].thinking -%}
133
  {{ msg.content[0].thinking }}
134
  {%- endif %}
 
226
  {% if not skip_thinking %}
227
  {% if message.tool_plan -%}
228
  <|START_THINKING|>{{ message.tool_plan }}<|END_THINKING|>
229
+ {%- elif (message.thinking is defined and message.thinking is not none) or (message.reasoning is defined and message.reasoning is not none) or (message.content and message.content[0].type == "thinking") -%}
230
  <|START_THINKING|>{{ print_thinking(message) }}<|END_THINKING|>
231
  {%- endif %}
232
  {%- endif %}<|START_ACTION|>[
 
238
 
239
  ]<|END_ACTION|><|END_OF_TURN_TOKEN|>
240
  {%- else -%}
241
+ {% if ((message.thinking is defined and message.thinking is not none) or (message.reasoning is defined and message.reasoning is not none) or (message.content and message.content[0].type == "thinking")) and not skip_thinking -%}
242
  <|START_THINKING|>{{ print_thinking(message) }}<|END_THINKING|>
243
  {%- endif -%}
244
  {{ print_msg(message) }}<|END_OF_TURN_TOKEN|>