fix interleaved reasoning
Browse files- chat_template.jinja +8 -4
chat_template.jinja
CHANGED
|
@@ -125,7 +125,11 @@ 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
{{ msg.thinking }}
|
| 130 |
{%- elif msg.content and msg.content[0].thinking -%}
|
| 131 |
{{ msg.content[0].thinking }}
|
|
@@ -224,7 +228,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 +240,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|>
|
|
@@ -256,4 +260,4 @@ Your output should adhere to the following json schema:
|
|
| 256 |
|
| 257 |
]<|END_TOOL_RESULT|><|END_OF_TURN_TOKEN|>
|
| 258 |
{%- endif %}
|
| 259 |
-
{%- endfor %}{%- if add_generation_prompt -%}<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>{% if reasoning %}<|START_THINKING|>{% else %}<|START_THINKING|><|END_THINKING|>{% endif %}{%- endif %}
|
|
|
|
| 125 |
{%- endif %}
|
| 126 |
{%- endmacro %}
|
| 127 |
{%- macro print_thinking(msg) %}
|
| 128 |
+
{%- if msg.reasoning -%}
|
| 129 |
+
{{ msg.reasoning }}
|
| 130 |
+
{%- elif msg.reasoning_content -%}
|
| 131 |
+
{{ msg.reasoning_content }}
|
| 132 |
+
{%- elif msg.thinking -%}
|
| 133 |
{{ msg.thinking }}
|
| 134 |
{%- elif msg.content and msg.content[0].thinking -%}
|
| 135 |
{{ msg.content[0].thinking }}
|
|
|
|
| 228 |
{% if not skip_thinking %}
|
| 229 |
{% if message.tool_plan -%}
|
| 230 |
<|START_THINKING|>{{ message.tool_plan }}<|END_THINKING|>
|
| 231 |
+
{%- elif message.reasoning or message.reasoning_content or message.thinking or (message.content and message.content[0].type == "thinking") -%}
|
| 232 |
<|START_THINKING|>{{ print_thinking(message) }}<|END_THINKING|>
|
| 233 |
{%- endif %}
|
| 234 |
{%- endif %}<|START_ACTION|>[
|
|
|
|
| 240 |
|
| 241 |
]<|END_ACTION|><|END_OF_TURN_TOKEN|>
|
| 242 |
{%- else -%}
|
| 243 |
+
{% if (message.reasoning or message.reasoning_content or message.thinking or (message.content and message.content[0].type == "thinking")) and not skip_thinking -%}
|
| 244 |
<|START_THINKING|>{{ print_thinking(message) }}<|END_THINKING|>
|
| 245 |
{%- endif -%}
|
| 246 |
{{ print_msg(message) }}<|END_OF_TURN_TOKEN|>
|
|
|
|
| 260 |
|
| 261 |
]<|END_TOOL_RESULT|><|END_OF_TURN_TOKEN|>
|
| 262 |
{%- endif %}
|
| 263 |
+
{%- endfor %}{%- if add_generation_prompt -%}<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>{% if reasoning %}<|START_THINKING|>{% else %}<|START_THINKING|><|END_THINKING|>{% endif %}{%- endif %}
|