dmayhem93 commited on
Commit
f9db59a
·
verified ·
1 Parent(s): 6f7a2d2

Update chat_template.jinja

Browse files
Files changed (1) hide show
  1. chat_template.jinja +8 -8
chat_template.jinja CHANGED
@@ -3,7 +3,7 @@
3
  {%- if not thinking is defined %}{% set thinking = false %}{% endif %}
4
  {%- if thinking %}{%- set system_prompt = thinking_prompt %}{%- else %}{%- set system_prompt = standard_prompt %}{%- endif %}
5
  {%- if tools %}
6
- {{- '<|start_header_id|>system<|end_header_id|>\n' }}
7
  {%- if messages[0]['role'] == 'system' %}
8
  {{- messages[0]['content'] }}
9
  {%- else %}
@@ -14,17 +14,17 @@
14
  {{- "\n" }}
15
  {{- tool | tojson }}
16
  {%- endfor %}
17
- {{- "\n</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><|eot_id|>\n" }}
18
  {%- else %}
19
  {%- if messages[0]['role'] == 'system' %}
20
- {{- '<|start_header_id|>system<|end_header_id|>\n\n' + messages[0]['content'] + '<|eot_id|>\n' }}
21
  {%- else %}
22
- {{- '<|start_header_id|>system<|end_header_id|>\n\n' + system_prompt + '<|eot_id|>\n' }}
23
  {%- endif %}
24
  {%- endif %}
25
  {%- for message in messages %}
26
  {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
27
- {{- '<|start_header_id|>' + message.role + '<|end_header_id|>\n\n' + message.content + '<|eot_id|>' + '\n' }}
28
  {%- elif message.role == "assistant" %}
29
  {{- '<|start_header_id|>' + message.role + '<|end_header_id|>\n' }}
30
  {%- if message.content %}
@@ -40,7 +40,7 @@
40
  {{- tool_call.arguments | tojson }}
41
  {{- '}\n</tool_call>' }}
42
  {%- endfor %}
43
- {{- '<|eot_id|>\n' }}
44
  {%- elif message.role == "tool" %}
45
  {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
46
  {{- '<|start_header_id|>user<|end_header_id|>\n' }}
@@ -49,7 +49,7 @@
49
  {{- message.content }}
50
  {{- '\n</tool_response>' }}
51
  {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
52
- {{- '<|eot_id|>\n' }}
53
  {%- endif %}
54
  {%- endif %}
55
  {%- endfor %}
@@ -58,4 +58,4 @@
58
  {%- if thinking %}
59
  {{- '<think>' }}
60
  {%- endif %}
61
- {%- endif %}
 
3
  {%- if not thinking is defined %}{% set thinking = false %}{% endif %}
4
  {%- if thinking %}{%- set system_prompt = thinking_prompt %}{%- else %}{%- set system_prompt = standard_prompt %}{%- endif %}
5
  {%- if tools %}
6
+ {{- bos_token + '<|start_header_id|>system<|end_header_id|>\n' }}
7
  {%- if messages[0]['role'] == 'system' %}
8
  {{- messages[0]['content'] }}
9
  {%- else %}
 
14
  {{- "\n" }}
15
  {{- tool | tojson }}
16
  {%- endfor %}
17
+ {{- "\n</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><|eot_id|>" }}
18
  {%- else %}
19
  {%- if messages[0]['role'] == 'system' %}
20
+ {{- bos_token + '<|start_header_id|>system<|end_header_id|>\n\n' + messages[0]['content'] + '<|eot_id|>' }}
21
  {%- else %}
22
+ {{- bos_token + '<|start_header_id|>system<|end_header_id|>\n\n' + system_prompt + '<|eot_id|>' }}
23
  {%- endif %}
24
  {%- endif %}
25
  {%- for message in messages %}
26
  {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
27
+ {{- '<|start_header_id|>' + message.role + '<|end_header_id|>\n\n' + message.content + '<|eot_id|>' }}
28
  {%- elif message.role == "assistant" %}
29
  {{- '<|start_header_id|>' + message.role + '<|end_header_id|>\n' }}
30
  {%- if message.content %}
 
40
  {{- tool_call.arguments | tojson }}
41
  {{- '}\n</tool_call>' }}
42
  {%- endfor %}
43
+ {{- '<|eot_id|>' }}
44
  {%- elif message.role == "tool" %}
45
  {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
46
  {{- '<|start_header_id|>user<|end_header_id|>\n' }}
 
49
  {{- message.content }}
50
  {{- '\n</tool_response>' }}
51
  {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
52
+ {{- '<|eot_id|>' }}
53
  {%- endif %}
54
  {%- endif %}
55
  {%- endfor %}
 
58
  {%- if thinking %}
59
  {{- '<think>' }}
60
  {%- endif %}
61
+ {%- endif %}