danielhanchen commited on
Commit
bb807f2
·
verified ·
1 Parent(s): 5c2acb7

Update chat_template.jinja

Browse files
Files changed (1) hide show
  1. chat_template.jinja +16 -10
chat_template.jinja CHANGED
@@ -111,9 +111,9 @@
111
  {%- for tool in tools %}
112
  {%- set tool = tool.function %}
113
  {{- "// " + tool.description + "\n" }}
114
- {{- "type "+ tool.name + " = (" }}
115
  {%- if tool.parameters and tool.parameters.properties -%}
116
- {{- "_: " }}
117
  {{- "{\n" }}
118
  {%- for param_name, param_spec in tool.parameters.properties.items() %}
119
  {{- "// " + param_spec.description + "\n" }}
@@ -124,7 +124,9 @@
124
  {{- ": " }}
125
  {{- render_typescript_type(param_spec, tool.parameters.required or []) }}
126
  {%- if param_spec.default is defined -%}
127
- {%- if param_spec.oneOf %}
 
 
128
  {{- "// default: " + param_spec.default }}
129
  {%- else %}
130
  {{- ", // default: " + param_spec.default|tojson }}
@@ -132,14 +134,16 @@
132
  {%- endif -%}
133
  {%- if not loop.last %}
134
  {{- ",\n" }}
 
 
135
  {%- endif -%}
136
  {%- endfor %}
137
- {{- ",\n}) => any;\n" }}
138
  {%- else -%}
139
- {{- "\n}) => any;\n" }}
140
  {%- endif -%}
141
  {%- endfor %}
142
- {{- "\n} // namespace " + namespace_name }}
143
  {%- endmacro -%}
144
 
145
  {%- macro render_builtin_tools(browser_tool, python_tool) -%}
@@ -212,8 +216,10 @@
212
  {%- endfor %}
213
  {{- render_builtin_tools(available_builtin_tools.browser, available_builtin_tools.python) }}
214
  {%- endif -%}
215
- {{- "# Valid channels: analysis, commentary, final. Channel must be included for every message.\n" }}
216
- {{- "Calls to these tools must go to the commentary channel: 'functions'." }}
 
 
217
  {%- endmacro -%}
218
 
219
  {#- Main Template Logic ================================================= #}
@@ -266,7 +272,7 @@
266
  {{- "<|start|>assistant to=" }}
267
  {{- "functions." + tool_call.name + "<|channel|>commentary json<|message|>" }}
268
  {{- tool_call.arguments|tojson }}
269
- {{- "<|end|>" }}
270
  {%- set last_tool_call.name = tool_call.name %}
271
  {%- elif "thinking" in message and loop.last and not add_generation_prompt %}
272
  {#- Only render the CoT if the final turn is an assistant turn and add_generation_prompt is false #}
@@ -304,4 +310,4 @@
304
  {#- Generation prompt #}
305
  {%- if add_generation_prompt -%}
306
  <|start|>assistant
307
- {%- endif -%}
 
111
  {%- for tool in tools %}
112
  {%- set tool = tool.function %}
113
  {{- "// " + tool.description + "\n" }}
114
+ {{- "type "+ tool.name + " = " }}
115
  {%- if tool.parameters and tool.parameters.properties -%}
116
+ {{- "(_: " }}
117
  {{- "{\n" }}
118
  {%- for param_name, param_spec in tool.parameters.properties.items() %}
119
  {{- "// " + param_spec.description + "\n" }}
 
124
  {{- ": " }}
125
  {{- render_typescript_type(param_spec, tool.parameters.required or []) }}
126
  {%- if param_spec.default is defined -%}
127
+ {%- if param_spec.enum %}
128
+ {{- ", // default: " + param_spec.default }}
129
+ {%- elif param_spec.oneOf %}
130
  {{- "// default: " + param_spec.default }}
131
  {%- else %}
132
  {{- ", // default: " + param_spec.default|tojson }}
 
134
  {%- endif -%}
135
  {%- if not loop.last %}
136
  {{- ",\n" }}
137
+ {%- else %}
138
+ {{- "\n" }}
139
  {%- endif -%}
140
  {%- endfor %}
141
+ {{- "}) => any;\n\n" }}
142
  {%- else -%}
143
+ {{- "() => any;\n\n" }}
144
  {%- endif -%}
145
  {%- endfor %}
146
+ {{- "} // namespace " + namespace_name }}
147
  {%- endmacro -%}
148
 
149
  {%- macro render_builtin_tools(browser_tool, python_tool) -%}
 
216
  {%- endfor %}
217
  {{- render_builtin_tools(available_builtin_tools.browser, available_builtin_tools.python) }}
218
  {%- endif -%}
219
+ {{- "# Valid channels: analysis, commentary, final. Channel must be included for every message." }}
220
+ {%- if tools is defined -%}
221
+ {{- "\nCalls to these tools must go to the commentary channel: 'functions'." }}
222
+ {%- endif -%}
223
  {%- endmacro -%}
224
 
225
  {#- Main Template Logic ================================================= #}
 
272
  {{- "<|start|>assistant to=" }}
273
  {{- "functions." + tool_call.name + "<|channel|>commentary json<|message|>" }}
274
  {{- tool_call.arguments|tojson }}
275
+ {{- "<|call|>" }}
276
  {%- set last_tool_call.name = tool_call.name %}
277
  {%- elif "thinking" in message and loop.last and not add_generation_prompt %}
278
  {#- Only render the CoT if the final turn is an assistant turn and add_generation_prompt is false #}
 
310
  {#- Generation prompt #}
311
  {%- if add_generation_prompt -%}
312
  <|start|>assistant
313
+ {%- endif -%}