Update chat_template.jinja
Browse files- chat_template.jinja +11 -9
chat_template.jinja
CHANGED
|
@@ -43,8 +43,7 @@ For each function call, output the function name and arguments within the follow
|
|
| 43 |
{%- endfor %}
|
| 44 |
{% for m in messages %}
|
| 45 |
{%- if m.role == 'user' -%}<|user|>
|
| 46 |
-
{%- set content = visible_text(m.content)|string %}
|
| 47 |
-
{{ content }}
|
| 48 |
{{- '/nothink' if (enable_thinking is defined and not enable_thinking and not content.endswith("/nothink")) else '' -}}
|
| 49 |
{%- elif m.role == 'assistant' -%}
|
| 50 |
<|assistant|>
|
|
@@ -53,13 +52,16 @@ For each function call, output the function name and arguments within the follow
|
|
| 53 |
{%- if m.reasoning_content is defined and m.reasoning_content is string %}
|
| 54 |
{%- set reasoning_content = m.reasoning_content %}
|
| 55 |
{%- else %}
|
| 56 |
-
{
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
{%-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
| 63 |
{%- endif %}
|
| 64 |
{%- if loop.index0 > ns.last_user_index and reasoning_content -%}
|
| 65 |
{{ '\n<think>' + reasoning_content.strip() + '</think>'}}
|
|
|
|
| 43 |
{%- endfor %}
|
| 44 |
{% for m in messages %}
|
| 45 |
{%- if m.role == 'user' -%}<|user|>
|
| 46 |
+
{%- set content = visible_text(m.content)|string %}{{ content }}
|
|
|
|
| 47 |
{{- '/nothink' if (enable_thinking is defined and not enable_thinking and not content.endswith("/nothink")) else '' -}}
|
| 48 |
{%- elif m.role == 'assistant' -%}
|
| 49 |
<|assistant|>
|
|
|
|
| 52 |
{%- if m.reasoning_content is defined and m.reasoning_content is string %}
|
| 53 |
{%- set reasoning_content = m.reasoning_content %}
|
| 54 |
{%- else %}
|
| 55 |
+
{# Unsloth template fixes - must change to for loop since llama.cpp will error out if not #}
|
| 56 |
+
{%- set parts = content.split('</think>') %}
|
| 57 |
+
{% for part in parts %}
|
| 58 |
+
{%- if loop.index0 == 0 -%}
|
| 59 |
+
{%- set reasoning_content = part.split("<think>")[-1] %}
|
| 60 |
+
{%- set reasoning_content = reasoning_content.lstrip('\n').rstrip('\n') -%}
|
| 61 |
+
{%- else -%}
|
| 62 |
+
{%- set content = part.lstrip('\n') %}
|
| 63 |
+
{%- endif %}
|
| 64 |
+
{%- endfor %}
|
| 65 |
{%- endif %}
|
| 66 |
{%- if loop.index0 > ns.last_user_index and reasoning_content -%}
|
| 67 |
{{ '\n<think>' + reasoning_content.strip() + '</think>'}}
|