Update chat_template.jinja
Browse files- chat_template.jinja +9 -9
chat_template.jinja
CHANGED
|
@@ -23,18 +23,18 @@
|
|
| 23 |
{%- set ns.interval = budget_values_v05[i] -%}
|
| 24 |
{%- endif -%}
|
| 25 |
{%- endfor -%}
|
| 26 |
-
{#
|
| 27 |
{%- if ns.interval is none -%}
|
| 28 |
{%- set ns.interval = budget_values_v05[-1] -%}
|
| 29 |
{%- endif -%}
|
| 30 |
-
{# ----------
|
| 31 |
{%- if messages[0]["role"] == "system" %}
|
| 32 |
{%- set system_message = messages[0]["content"] %}
|
| 33 |
{%- set loop_messages = messages[1:] %}
|
| 34 |
{%- else %}
|
| 35 |
{%- set loop_messages = messages %}
|
| 36 |
{%- endif %}
|
| 37 |
-
{# ----------
|
| 38 |
{%- if not tools is defined or tools is none %}
|
| 39 |
{%- set tools = [] %}
|
| 40 |
{%- endif %}
|
|
@@ -46,7 +46,7 @@
|
|
| 46 |
{%- elif t == "array" -%}list
|
| 47 |
{%- else -%}Any{%- endif -%}
|
| 48 |
{%- endmacro -%}
|
| 49 |
-
{# ----------
|
| 50 |
{%- if system_message is defined %}
|
| 51 |
{{ bos_token + "system\n" + system_message }}
|
| 52 |
{%- else %}
|
|
@@ -100,7 +100,7 @@ def {{ item.function.name }}(
|
|
| 100 |
|
| 101 |
{{"工具调用请遵循如下格式:\n<seed:tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>value_1</parameter>\n<parameter=example_parameter_2>This is the value for the second parameter\nthat can span\nmultiple lines</parameter>\n</function>\n</seed:tool_call>\n"}}
|
| 102 |
{%- endif %}
|
| 103 |
-
{#
|
| 104 |
{%- if system_message is defined or tools is iterable and tools | length > 0 %}
|
| 105 |
{{ eos_token }}
|
| 106 |
{%- endif %}
|
|
@@ -116,7 +116,7 @@ def {{ item.function.name }}(
|
|
| 116 |
{{ eos_token }}
|
| 117 |
{%- endif %}
|
| 118 |
{%- endif %}
|
| 119 |
-
{# ----------
|
| 120 |
{%- for message in loop_messages %}
|
| 121 |
{%- if message.role == "assistant"
|
| 122 |
and message.tool_calls is defined
|
|
@@ -152,15 +152,15 @@ def {{ item.function.name }}(
|
|
| 152 |
{%- if message.content is defined and message.content is string and message.content | trim | length > 0 %}
|
| 153 |
{{ "\n" + message.content | trim + eos_token }}
|
| 154 |
{%- endif %}
|
| 155 |
-
{#
|
| 156 |
{%- else %}
|
| 157 |
{{ bos_token + message.role + "\n" + message.content + eos_token }}
|
| 158 |
{%- endif %}
|
| 159 |
{%- endfor %}
|
| 160 |
-
{# ----------
|
| 161 |
{%- if add_generation_prompt %}
|
| 162 |
{{ bos_token+"assistant\n" }}
|
| 163 |
{%- if thinking_budget == 0 %}
|
| 164 |
-
{{ think_begin_token+budget_begin_token }}
|
| 165 |
{%- endif %}
|
| 166 |
{%- endif %}
|
|
|
|
| 23 |
{%- set ns.interval = budget_values_v05[i] -%}
|
| 24 |
{%- endif -%}
|
| 25 |
{%- endfor -%}
|
| 26 |
+
{# Find the first gear that is greater than or equal to the thinking_budget. #}
|
| 27 |
{%- if ns.interval is none -%}
|
| 28 |
{%- set ns.interval = budget_values_v05[-1] -%}
|
| 29 |
{%- endif -%}
|
| 30 |
+
{# ---------- Preprocess the system message ---------- #}
|
| 31 |
{%- if messages[0]["role"] == "system" %}
|
| 32 |
{%- set system_message = messages[0]["content"] %}
|
| 33 |
{%- set loop_messages = messages[1:] %}
|
| 34 |
{%- else %}
|
| 35 |
{%- set loop_messages = messages %}
|
| 36 |
{%- endif %}
|
| 37 |
+
{# ---------- Ensure tools exist ---------- #}
|
| 38 |
{%- if not tools is defined or tools is none %}
|
| 39 |
{%- set tools = [] %}
|
| 40 |
{%- endif %}
|
|
|
|
| 46 |
{%- elif t == "array" -%}list
|
| 47 |
{%- else -%}Any{%- endif -%}
|
| 48 |
{%- endmacro -%}
|
| 49 |
+
{# ---------- Output the system block ---------- #}
|
| 50 |
{%- if system_message is defined %}
|
| 51 |
{{ bos_token + "system\n" + system_message }}
|
| 52 |
{%- else %}
|
|
|
|
| 100 |
|
| 101 |
{{"工具调用请遵循如下格式:\n<seed:tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>value_1</parameter>\n<parameter=example_parameter_2>This is the value for the second parameter\nthat can span\nmultiple lines</parameter>\n</function>\n</seed:tool_call>\n"}}
|
| 102 |
{%- endif %}
|
| 103 |
+
{# End the system block line #}
|
| 104 |
{%- if system_message is defined or tools is iterable and tools | length > 0 %}
|
| 105 |
{{ eos_token }}
|
| 106 |
{%- endif %}
|
|
|
|
| 116 |
{{ eos_token }}
|
| 117 |
{%- endif %}
|
| 118 |
{%- endif %}
|
| 119 |
+
{# ---------- List the historical messages one by one ---------- #}
|
| 120 |
{%- for message in loop_messages %}
|
| 121 |
{%- if message.role == "assistant"
|
| 122 |
and message.tool_calls is defined
|
|
|
|
| 152 |
{%- if message.content is defined and message.content is string and message.content | trim | length > 0 %}
|
| 153 |
{{ "\n" + message.content | trim + eos_token }}
|
| 154 |
{%- endif %}
|
| 155 |
+
{# Include the tool role #}
|
| 156 |
{%- else %}
|
| 157 |
{{ bos_token + message.role + "\n" + message.content + eos_token }}
|
| 158 |
{%- endif %}
|
| 159 |
{%- endfor %}
|
| 160 |
+
{# ---------- Control the model to start continuation ---------- #}
|
| 161 |
{%- if add_generation_prompt %}
|
| 162 |
{{ bos_token+"assistant\n" }}
|
| 163 |
{%- if thinking_budget == 0 %}
|
| 164 |
+
{{ think_begin_token + "\n" + budget_begin_token + "The current thinking budget is 0, so I will directly start answering the question." + budget_end_token + "\n" + think_end_token }}
|
| 165 |
{%- endif %}
|
| 166 |
{%- endif %}
|