CrowdMind commited on
Commit
45aa955
·
verified ·
1 Parent(s): 531c466

Upload chat_template.jinja

Browse files
Files changed (1) hide show
  1. chat_template.jinja +17 -0
chat_template.jinja ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {#
2
+ Harness-neutral nanochat chat template.
3
+ Training adapters normalize tool turns into assistant content parts:
4
+ text, tool_call (JSON text), and tool_output (JSON text). The call JSON keeps
5
+ the source call ID, tool name, and arguments; the tool menu comes from `tools`.
6
+ <|bos|> is added by the tokenizer and must not be emitted here.
7
+ #}
8
+ {%- set system = messages[0]['content'] if messages and messages[0]['role'] == 'system' else '' -%}
9
+ {%- set ns = namespace(first_user=true) -%}
10
+ {%- for message in messages -%}
11
+ {%- if message['role'] == 'user' -%}
12
+ {{ '<|user_start|>' }}{%- if ns.first_user and tools %}<tool_schemas>{{ tools|tojson }}</tool_schemas>{{ '\n\n' }}{%- endif -%}{%- if ns.first_user and system %}{{ system + '\n\n' }}{%- endif -%}{{ message['content'] }}{{ '<|user_end|>' }}{%- set ns.first_user = false -%}
13
+ {%- elif message['role'] == 'assistant' -%}
14
+ {{ '<|assistant_start|>' }}{%- if message['content'] is string -%}{{ message['content'] }}{%- else -%}{%- for part in message['content'] -%}{%- if part['type'] == 'text' -%}{{ part['text'] }}{%- elif part['type'] == 'python' -%}{{ '<|python_start|>' + part['text'] + '<|python_end|>' }}{%- elif part['type'] == 'python_output' -%}{{ '<|output_start|>' + part['text'] + '<|output_end|>' }}{%- elif part['type'] == 'tool_call' -%}{{ '<tool_call>' + part['text'] + '</tool_call>' }}{%- elif part['type'] == 'tool_output' -%}{{ '<|output_start|>' + part['text'] + '<|output_end|>' }}{%- endif -%}{%- endfor -%}{%- endif -%}{{ '<|assistant_end|>' }}
15
+ {%- endif -%}
16
+ {%- endfor -%}
17
+ {%- if add_generation_prompt -%}{{ '<|assistant_start|>' }}{%- endif -%}