Update chat_template.jinja
Browse files- chat_template.jinja +9 -8
chat_template.jinja
CHANGED
@@ -23,14 +23,14 @@
|
|
23 |
{%- set custom_instructions = system_message.replace("/no_think", "").replace("/think", "").rstrip() -%}
|
24 |
{%- endif -%}
|
25 |
|
26 |
-
{%- if "/system_override" in system_message -%}
|
27 |
{{- custom_instructions.replace("/system_override", "").rstrip() -}}
|
28 |
{{- "<|im_end|>\n" -}}
|
29 |
{%- else -%}
|
30 |
{{- "## Metadata\n\n" -}}
|
31 |
{{- "Knowledge Cutoff Date: June 2025\n" -}}
|
32 |
{%- set today = strftime_now("%d %B %Y") -%}
|
33 |
-
{{- "Today Date: "
|
34 |
{{- "Reasoning Mode: " + reasoning_mode + "\n\n" -}}
|
35 |
|
36 |
{{- "## Custom Instructions\n\n" -}}
|
@@ -42,12 +42,15 @@
|
|
42 |
{{- "You are a helpful AI assistant named SmolLM, trained by Hugging Face.\n\n" -}}
|
43 |
{%- endif -%}
|
44 |
|
45 |
-
{%- if xml_tools or python_tools -%}
|
46 |
{{- "### Tools\n\n" -}}
|
47 |
-
{%- if xml_tools -%}
|
|
|
|
|
|
|
48 |
{%- set ns = namespace(xml_tool_string="You may call one or more functions to assist with the user query.\nYou are provided with function signatures within <tools></tools> XML tags:\n\n<tools>\n") -%}
|
49 |
{%- for tool in xml_tools[:] -%} {# The slicing makes sure that xml_tools is a list #}
|
50 |
-
{%- set ns.xml_tool_string = ns.xml_tool_string
|
51 |
{%- endfor -%}
|
52 |
{%- set xml_tool_string = ns.xml_tool_string + "</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call>" -%}
|
53 |
{{- xml_tool_string -}}
|
@@ -55,7 +58,7 @@
|
|
55 |
{%- if python_tools -%}
|
56 |
{%- set ns = namespace(python_tool_string="When you send a message containing Python code between '<code>' and '</code>' tags, it will be executed in a stateful Jupyter notebook environment, and you will then be given the output to continued reasoning in an agentic loop.\n\nYou can use the following tools in your python code like regular functions:\n<tools>\n") -%}
|
57 |
{%- for tool in python_tools[:] -%} {# The slicing makes sure that python_tools is a list #}
|
58 |
-
{%- set ns.python_tool_string = ns.python_tool_string
|
59 |
{%- endfor -%}
|
60 |
{%- set python_tool_string = ns.python_tool_string + "</tools>\n\nThe state persists between code executions: so variables that you define in one step are still available thereafter." -%}
|
61 |
{{- python_tool_string -}}
|
@@ -70,13 +73,11 @@
|
|
70 |
{%- if message.role == "user" -%}
|
71 |
{{ "<|im_start|>" + message.role + "\n" + content + "<|im_end|>\n" }}
|
72 |
{%- elif message.role == "assistant" -%}
|
73 |
-
{% generation %}
|
74 |
{%- if reasoning_mode == "/think" -%}
|
75 |
{{ "<|im_start|>assistant\n" + content.lstrip("\n") + "<|im_end|>\n" }}
|
76 |
{%- else -%}
|
77 |
{{ "<|im_start|>assistant\n" + "<think>\n\n</think>\n" + content.lstrip("\n") + "<|im_end|>\n" }}
|
78 |
{%- endif -%}
|
79 |
-
{% endgeneration %}
|
80 |
{%- elif message.role == "tool" -%}
|
81 |
{{ "<|im_start|>" + "user\n" + content + "<|im_end|>\n" }}
|
82 |
{%- endif -%}
|
|
|
23 |
{%- set custom_instructions = system_message.replace("/no_think", "").replace("/think", "").rstrip() -%}
|
24 |
{%- endif -%}
|
25 |
|
26 |
+
{%- if system_message is defined and "/system_override" in system_message -%}
|
27 |
{{- custom_instructions.replace("/system_override", "").rstrip() -}}
|
28 |
{{- "<|im_end|>\n" -}}
|
29 |
{%- else -%}
|
30 |
{{- "## Metadata\n\n" -}}
|
31 |
{{- "Knowledge Cutoff Date: June 2025\n" -}}
|
32 |
{%- set today = strftime_now("%d %B %Y") -%}
|
33 |
+
{{- "Today Date: " + today + "\n" -}}
|
34 |
{{- "Reasoning Mode: " + reasoning_mode + "\n\n" -}}
|
35 |
|
36 |
{{- "## Custom Instructions\n\n" -}}
|
|
|
42 |
{{- "You are a helpful AI assistant named SmolLM, trained by Hugging Face.\n\n" -}}
|
43 |
{%- endif -%}
|
44 |
|
45 |
+
{%- if xml_tools or python_tools or tools -%}
|
46 |
{{- "### Tools\n\n" -}}
|
47 |
+
{%- if xml_tools or tools -%}
|
48 |
+
{%- if tools -%}
|
49 |
+
{%- set xml_tools = tools -%}
|
50 |
+
{%- endif -%}
|
51 |
{%- set ns = namespace(xml_tool_string="You may call one or more functions to assist with the user query.\nYou are provided with function signatures within <tools></tools> XML tags:\n\n<tools>\n") -%}
|
52 |
{%- for tool in xml_tools[:] -%} {# The slicing makes sure that xml_tools is a list #}
|
53 |
+
{%- set ns.xml_tool_string = ns.xml_tool_string + (tool | tojson) + "\n" -%}
|
54 |
{%- endfor -%}
|
55 |
{%- set xml_tool_string = ns.xml_tool_string + "</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call>" -%}
|
56 |
{{- xml_tool_string -}}
|
|
|
58 |
{%- if python_tools -%}
|
59 |
{%- set ns = namespace(python_tool_string="When you send a message containing Python code between '<code>' and '</code>' tags, it will be executed in a stateful Jupyter notebook environment, and you will then be given the output to continued reasoning in an agentic loop.\n\nYou can use the following tools in your python code like regular functions:\n<tools>\n") -%}
|
60 |
{%- for tool in python_tools[:] -%} {# The slicing makes sure that python_tools is a list #}
|
61 |
+
{%- set ns.python_tool_string = ns.python_tool_string + (tool | tojson) + "\n" -%}
|
62 |
{%- endfor -%}
|
63 |
{%- set python_tool_string = ns.python_tool_string + "</tools>\n\nThe state persists between code executions: so variables that you define in one step are still available thereafter." -%}
|
64 |
{{- python_tool_string -}}
|
|
|
73 |
{%- if message.role == "user" -%}
|
74 |
{{ "<|im_start|>" + message.role + "\n" + content + "<|im_end|>\n" }}
|
75 |
{%- elif message.role == "assistant" -%}
|
|
|
76 |
{%- if reasoning_mode == "/think" -%}
|
77 |
{{ "<|im_start|>assistant\n" + content.lstrip("\n") + "<|im_end|>\n" }}
|
78 |
{%- else -%}
|
79 |
{{ "<|im_start|>assistant\n" + "<think>\n\n</think>\n" + content.lstrip("\n") + "<|im_end|>\n" }}
|
80 |
{%- endif -%}
|
|
|
81 |
{%- elif message.role == "tool" -%}
|
82 |
{{ "<|im_start|>" + "user\n" + content + "<|im_end|>\n" }}
|
83 |
{%- endif -%}
|