Update chat_template.jinja
Browse files- chat_template.jinja +49 -16
chat_template.jinja
CHANGED
|
@@ -1,32 +1,65 @@
|
|
| 1 |
-
{%- set
|
| 2 |
{%- set knowledge_cutoff = "2024-06" %}
|
| 3 |
{%- set current_date = strftime_now("%Y-%m-%d") %}
|
| 4 |
{%- set reasoning = reasoning_effort if reasoning_effort is defined else "no" %}
|
| 5 |
|
| 6 |
<|start_of_role|>system<|end_of_role|><|start|>system<|message|>
|
| 7 |
-
{{
|
| 8 |
Knowledge cutoff: {{ knowledge_cutoff }}
|
| 9 |
Current date: {{ current_date }}
|
| 10 |
|
| 11 |
Reasoning: {{ reasoning }}<|end_of_text|>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
{%- for message in messages %}
|
| 13 |
-
{%- if message.
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
{%-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
{%-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
{%- endif %}
|
| 27 |
-
{{ '<|start_of_role|>' + message.role + '<|end_of_role|>' + content + '<|end_of_text|>\n' }}
|
| 28 |
{%- endif %}
|
| 29 |
{%- endfor %}
|
| 30 |
{%- if add_generation_prompt %}
|
| 31 |
<|start_of_role|>assistant<|end_of_role|>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
{%- endif %}
|
|
|
|
| 1 |
+
{%- set assistant_identity = "You are a helpful assistant created by Modotte." %}
|
| 2 |
{%- set knowledge_cutoff = "2024-06" %}
|
| 3 |
{%- set current_date = strftime_now("%Y-%m-%d") %}
|
| 4 |
{%- set reasoning = reasoning_effort if reasoning_effort is defined else "no" %}
|
| 5 |
|
| 6 |
<|start_of_role|>system<|end_of_role|><|start|>system<|message|>
|
| 7 |
+
{{ assistant_identity }}
|
| 8 |
Knowledge cutoff: {{ knowledge_cutoff }}
|
| 9 |
Current date: {{ current_date }}
|
| 10 |
|
| 11 |
Reasoning: {{ reasoning }}<|end_of_text|>
|
| 12 |
+
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
|
| 13 |
+
{%- for message in messages[::-1] %}
|
| 14 |
+
{%- set index = (messages|length - 1) - loop.index0 %}
|
| 15 |
+
{%- 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>')) %}
|
| 16 |
+
{%- set ns.multi_step_tool = false %}
|
| 17 |
+
{%- set ns.last_query_index = index %}
|
| 18 |
+
{%- endif %}
|
| 19 |
+
{%- endfor %}
|
| 20 |
{%- for message in messages %}
|
| 21 |
+
{%- set content = message.content if message.content is string else '' %}
|
| 22 |
+
{%- if message.role == "user" or (message.role == "system" and not loop.first) %}
|
| 23 |
+
<|start_of_role|>{{ message.role }}<|end_of_role|>{{ content }}<|end_of_text|>
|
| 24 |
+
{%- elif message.role == "assistant" %}
|
| 25 |
+
{%- set reasoning_content = '' %}
|
| 26 |
+
{%- if message.reasoning_content is string %}
|
| 27 |
+
{%- set reasoning_content = message.reasoning_content %}
|
| 28 |
+
{%- elif '</think>' in content %}
|
| 29 |
+
{%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
|
| 30 |
+
{%- set content = content.split('</think>')[-1].lstrip('\n') %}
|
| 31 |
+
{%- endif %}
|
| 32 |
+
{%- if loop.index0 > ns.last_query_index %}
|
| 33 |
+
{%- if loop.last or (not loop.last and reasoning_content) %}
|
| 34 |
+
<|start_of_role|>assistant<|end_of_role|><think>
|
| 35 |
+
{{ reasoning_content.strip('\n') }}
|
| 36 |
+
</think>
|
| 37 |
+
|
| 38 |
+
{{ content.lstrip('\n') }}<|end_of_text|>
|
| 39 |
+
{%- else %}
|
| 40 |
+
<|start_of_role|>assistant<|end_of_role|>{{ content }}<|end_of_text|>
|
| 41 |
+
{%- endif %}
|
| 42 |
+
{%- else %}
|
| 43 |
+
<|start_of_role|>assistant<|end_of_role|>{{ content }}<|end_of_text|>
|
| 44 |
+
{%- endif %}
|
| 45 |
+
{%- elif message.role == "tool" %}
|
| 46 |
+
{%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
|
| 47 |
+
<|start_of_role|>user<|end_of_role|>
|
| 48 |
+
{%- endif %}
|
| 49 |
+
<tool_response>
|
| 50 |
+
{{ content }}
|
| 51 |
+
</tool_response>
|
| 52 |
+
{%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
|
| 53 |
+
<|end_of_text|>
|
| 54 |
{%- endif %}
|
|
|
|
| 55 |
{%- endif %}
|
| 56 |
{%- endfor %}
|
| 57 |
{%- if add_generation_prompt %}
|
| 58 |
<|start_of_role|>assistant<|end_of_role|>
|
| 59 |
+
{%- if enable_thinking is defined and enable_thinking is false %}
|
| 60 |
+
<think>
|
| 61 |
+
|
| 62 |
+
</think>
|
| 63 |
+
|
| 64 |
+
{%- endif %}
|
| 65 |
{%- endif %}
|