Update chat_template.jinja
Browse files- chat_template.jinja +18 -33
chat_template.jinja
CHANGED
@@ -4,8 +4,7 @@
|
|
4 |
- "builtin_tools": A list, can contain "browser" and/or "python".
|
5 |
- "model_identity": A string that optionally describes the model identity.
|
6 |
- "reasoning_effort": A string that describes the reasoning effort, defaults to "medium".
|
7 |
-
|
8 |
-
|
9 |
{#- Tool Definition Rendering ============================================== #}
|
10 |
{%- macro render_typescript_type(param_spec, required_params, is_nullable=false) -%}
|
11 |
{%- if param_spec.type == "array" -%}
|
@@ -55,15 +54,15 @@
|
|
55 |
{%- else -%}
|
56 |
{%- for variant in param_spec.oneOf -%}
|
57 |
{{- render_typescript_type(variant, required_params) -}}
|
58 |
-
{%- if variant.description
|
59 |
{{- "// " + variant.description }}
|
60 |
{%- endif -%}
|
61 |
-
{%- if variant.default is defined
|
62 |
-
{{ "// default: " + variant.default|tojson }}
|
63 |
{%- endif -%}
|
64 |
-
{%- if not loop.last
|
65 |
{{- " | " }}
|
66 |
-
{
|
67 |
{%- endfor -%}
|
68 |
{%- endif -%}
|
69 |
{%- elif param_spec.type == "string" -%}
|
@@ -81,7 +80,6 @@
|
|
81 |
{{- "number" }}
|
82 |
{%- elif param_spec.type == "boolean" -%}
|
83 |
{{- "boolean" }}
|
84 |
-
|
85 |
{%- elif param_spec.type == "object" -%}
|
86 |
{%- if param_spec.properties -%}
|
87 |
{{- "{\n" }}
|
@@ -91,9 +89,9 @@
|
|
91 |
{{- "?" }}
|
92 |
{%- endif -%}
|
93 |
{{- ": " }}
|
94 |
-
{{ render_typescript_type(prop_spec, param_spec.required or []) }}
|
95 |
{%- if not loop.last -%}
|
96 |
-
{{-", " }}
|
97 |
{%- endif -%}
|
98 |
{%- endfor -%}
|
99 |
{{- "}" }}
|
@@ -104,7 +102,6 @@
|
|
104 |
{{- "any" }}
|
105 |
{%- endif -%}
|
106 |
{%- endmacro -%}
|
107 |
-
|
108 |
{%- macro render_tool_namespace(namespace_name, tools) -%}
|
109 |
{{- "## " + namespace_name + "\n\n" }}
|
110 |
{{- "namespace " + namespace_name + " {\n\n" }}
|
@@ -146,7 +143,6 @@
|
|
146 |
{%- endfor %}
|
147 |
{{- "} // namespace " + namespace_name }}
|
148 |
{%- endmacro -%}
|
149 |
-
|
150 |
{%- macro render_builtin_tools(browser_tool, python_tool) -%}
|
151 |
{%- if browser_tool %}
|
152 |
{{- "## browser\n\n" }}
|
@@ -184,14 +180,12 @@
|
|
184 |
{{- "}) => any;\n\n" }}
|
185 |
{{- "} // namespace browser\n\n" }}
|
186 |
{%- endif -%}
|
187 |
-
|
188 |
{%- if python_tool %}
|
189 |
{{- "## python\n\n" }}
|
190 |
{{- "Use this tool to execute Python code in your chain of thought. The code will not be shown to the user. This tool should be used for internal reasoning, but not for code that is intended to be visible to the user (e.g. when creating plots, tables, or files).\n\n" }}
|
191 |
{{- "When you send a message containing Python code to python, it will be executed in a stateful Jupyter notebook environment. python will respond with the output of the execution or time out after 120.0 seconds. The drive at '/mnt/data' can be used to save and persist user files. Internet access for this session is UNKNOWN. Depends on the cluster.\n\n" }}
|
192 |
{%- endif -%}
|
193 |
{%- endmacro -%}
|
194 |
-
|
195 |
{#- System Message Construction ============================================ #}
|
196 |
{%- macro build_system_message() -%}
|
197 |
{%- if model_identity is not defined %}
|
@@ -204,18 +198,16 @@
|
|
204 |
{%- set reasoning_effort = "medium" %}
|
205 |
{%- endif %}
|
206 |
{{- "Reasoning: " + reasoning_effort + "\n\n" }}
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
-
|
215 |
-
- If the
|
216 |
-
-
|
217 |
-
- Do not include any explanation or text outside the code block unless **explicitly** requested.
|
218 |
-
|
219 |
{%- if builtin_tools %}
|
220 |
{{- "# Tools\n\n" }}
|
221 |
{%- set available_builtin_tools = namespace(browser=false, python=false) %}
|
@@ -233,16 +225,12 @@
|
|
233 |
{{- "\nCalls to these tools must go to the commentary channel: 'functions'." }}
|
234 |
{%- endif -%}
|
235 |
{%- endmacro -%}
|
236 |
-
|
237 |
-
|
238 |
{#- Main Template Logic ================================================= #}
|
239 |
{#- Set defaults #}
|
240 |
-
|
241 |
{#- Render system message #}
|
242 |
{{- "<|start|>system<|message|>" }}
|
243 |
{{- build_system_message() }}
|
244 |
{{- "<|end|>" }}
|
245 |
-
|
246 |
{#- Extract developer message #}
|
247 |
{%- if messages[0].role == "developer" or messages[0].role == "system" %}
|
248 |
{%- set developer_message = messages[0].content %}
|
@@ -251,7 +239,6 @@
|
|
251 |
{%- set developer_message = "" %}
|
252 |
{%- set loop_messages = messages %}
|
253 |
{%- endif %}
|
254 |
-
|
255 |
{#- Render developer message #}
|
256 |
{%- if developer_message or tools %}
|
257 |
{{- "<|start|>developer<|message|>" }}
|
@@ -266,7 +253,6 @@
|
|
266 |
{%- endif -%}
|
267 |
{{- "<|end|>" }}
|
268 |
{%- endif %}
|
269 |
-
|
270 |
{#- Render messages #}
|
271 |
{%- set last_tool_call = namespace(name=none) %}
|
272 |
{%- for message in loop_messages -%}
|
@@ -337,7 +323,6 @@
|
|
337 |
{{- "<|start|>user<|message|>" + message.content + "<|end|>" }}
|
338 |
{%- endif -%}
|
339 |
{%- endfor -%}
|
340 |
-
|
341 |
{#- Generation prompt #}
|
342 |
{%- if add_generation_prompt -%}
|
343 |
<|start|>assistant
|
|
|
4 |
- "builtin_tools": A list, can contain "browser" and/or "python".
|
5 |
- "model_identity": A string that optionally describes the model identity.
|
6 |
- "reasoning_effort": A string that describes the reasoning effort, defaults to "medium".
|
7 |
+
#}
|
|
|
8 |
{#- Tool Definition Rendering ============================================== #}
|
9 |
{%- macro render_typescript_type(param_spec, required_params, is_nullable=false) -%}
|
10 |
{%- if param_spec.type == "array" -%}
|
|
|
54 |
{%- else -%}
|
55 |
{%- for variant in param_spec.oneOf -%}
|
56 |
{{- render_typescript_type(variant, required_params) -}}
|
57 |
+
{%- if variant.description -%}
|
58 |
{{- "// " + variant.description }}
|
59 |
{%- endif -%}
|
60 |
+
{%- if variant.default is defined -%}
|
61 |
+
{{- "// default: " + variant.default|tojson }}
|
62 |
{%- endif -%}
|
63 |
+
{%- if not loop.last -%}
|
64 |
{{- " | " }}
|
65 |
+
{%- endif -%}
|
66 |
{%- endfor -%}
|
67 |
{%- endif -%}
|
68 |
{%- elif param_spec.type == "string" -%}
|
|
|
80 |
{{- "number" }}
|
81 |
{%- elif param_spec.type == "boolean" -%}
|
82 |
{{- "boolean" }}
|
|
|
83 |
{%- elif param_spec.type == "object" -%}
|
84 |
{%- if param_spec.properties -%}
|
85 |
{{- "{\n" }}
|
|
|
89 |
{{- "?" }}
|
90 |
{%- endif -%}
|
91 |
{{- ": " }}
|
92 |
+
{{- render_typescript_type(prop_spec, param_spec.required or []) }}
|
93 |
{%- if not loop.last -%}
|
94 |
+
{{- ", " }}
|
95 |
{%- endif -%}
|
96 |
{%- endfor -%}
|
97 |
{{- "}" }}
|
|
|
102 |
{{- "any" }}
|
103 |
{%- endif -%}
|
104 |
{%- endmacro -%}
|
|
|
105 |
{%- macro render_tool_namespace(namespace_name, tools) -%}
|
106 |
{{- "## " + namespace_name + "\n\n" }}
|
107 |
{{- "namespace " + namespace_name + " {\n\n" }}
|
|
|
143 |
{%- endfor %}
|
144 |
{{- "} // namespace " + namespace_name }}
|
145 |
{%- endmacro -%}
|
|
|
146 |
{%- macro render_builtin_tools(browser_tool, python_tool) -%}
|
147 |
{%- if browser_tool %}
|
148 |
{{- "## browser\n\n" }}
|
|
|
180 |
{{- "}) => any;\n\n" }}
|
181 |
{{- "} // namespace browser\n\n" }}
|
182 |
{%- endif -%}
|
|
|
183 |
{%- if python_tool %}
|
184 |
{{- "## python\n\n" }}
|
185 |
{{- "Use this tool to execute Python code in your chain of thought. The code will not be shown to the user. This tool should be used for internal reasoning, but not for code that is intended to be visible to the user (e.g. when creating plots, tables, or files).\n\n" }}
|
186 |
{{- "When you send a message containing Python code to python, it will be executed in a stateful Jupyter notebook environment. python will respond with the output of the execution or time out after 120.0 seconds. The drive at '/mnt/data' can be used to save and persist user files. Internet access for this session is UNKNOWN. Depends on the cluster.\n\n" }}
|
187 |
{%- endif -%}
|
188 |
{%- endmacro -%}
|
|
|
189 |
{#- System Message Construction ============================================ #}
|
190 |
{%- macro build_system_message() -%}
|
191 |
{%- if model_identity is not defined %}
|
|
|
198 |
{%- set reasoning_effort = "medium" %}
|
199 |
{%- endif %}
|
200 |
{{- "Reasoning: " + reasoning_effort + "\n\n" }}
|
201 |
+
{{- "# Code Formatting Policy\n\n" }}
|
202 |
+
{{- "All code outputs MUST be wrapped in triple backticks and specify the language.\n" }}
|
203 |
+
{{- "For Python code, always use:\n" }}
|
204 |
+
{{- "```python\n" }}
|
205 |
+
{{- "# your code here\n" }}
|
206 |
+
{{- "```\n\n" }}
|
207 |
+
{{- "- Never output code without the code block formatting.\n" }}
|
208 |
+
{{- "- If the task is to generate code, always start your response with the code block.\n" }}
|
209 |
+
{{- "- If the code is split across multiple blocks, each block must be properly wrapped.\n" }}
|
210 |
+
{{- "- Do not include any explanation or text outside the code block unless **explicitly** requested.\n\n" }}
|
|
|
|
|
211 |
{%- if builtin_tools %}
|
212 |
{{- "# Tools\n\n" }}
|
213 |
{%- set available_builtin_tools = namespace(browser=false, python=false) %}
|
|
|
225 |
{{- "\nCalls to these tools must go to the commentary channel: 'functions'." }}
|
226 |
{%- endif -%}
|
227 |
{%- endmacro -%}
|
|
|
|
|
228 |
{#- Main Template Logic ================================================= #}
|
229 |
{#- Set defaults #}
|
|
|
230 |
{#- Render system message #}
|
231 |
{{- "<|start|>system<|message|>" }}
|
232 |
{{- build_system_message() }}
|
233 |
{{- "<|end|>" }}
|
|
|
234 |
{#- Extract developer message #}
|
235 |
{%- if messages[0].role == "developer" or messages[0].role == "system" %}
|
236 |
{%- set developer_message = messages[0].content %}
|
|
|
239 |
{%- set developer_message = "" %}
|
240 |
{%- set loop_messages = messages %}
|
241 |
{%- endif %}
|
|
|
242 |
{#- Render developer message #}
|
243 |
{%- if developer_message or tools %}
|
244 |
{{- "<|start|>developer<|message|>" }}
|
|
|
253 |
{%- endif -%}
|
254 |
{{- "<|end|>" }}
|
255 |
{%- endif %}
|
|
|
256 |
{#- Render messages #}
|
257 |
{%- set last_tool_call = namespace(name=none) %}
|
258 |
{%- for message in loop_messages -%}
|
|
|
323 |
{{- "<|start|>user<|message|>" + message.content + "<|end|>" }}
|
324 |
{%- endif -%}
|
325 |
{%- endfor -%}
|
|
|
326 |
{#- Generation prompt #}
|
327 |
{%- if add_generation_prompt -%}
|
328 |
<|start|>assistant
|