jerryzh168 commited on
Commit
57d47ee
·
verified ·
1 Parent(s): 0630155

Upload tokenizer

Browse files
Files changed (1) hide show
  1. chat_template.jinja +12 -8
chat_template.jinja CHANGED
@@ -17,23 +17,27 @@
17
  {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
18
  {%- for message in messages[::-1] %}
19
  {%- set index = (messages|length - 1) - loop.index0 %}
20
- {%- if ns.multi_step_tool and message.role == "user" and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
21
  {%- set ns.multi_step_tool = false %}
22
  {%- set ns.last_query_index = index %}
23
  {%- endif %}
24
  {%- endfor %}
25
  {%- for message in messages %}
 
 
 
 
 
26
  {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
27
- {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
28
  {%- elif message.role == "assistant" %}
29
- {%- set content = message.content %}
30
  {%- set reasoning_content = '' %}
31
- {%- if message.reasoning_content is defined and message.reasoning_content is not none %}
32
  {%- set reasoning_content = message.reasoning_content %}
33
  {%- else %}
34
- {%- if '</think>' in message.content %}
35
- {%- set content = message.content.split('</think>')[-1].lstrip('\n') %}
36
- {%- set reasoning_content = message.content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
37
  {%- endif %}
38
  {%- endif %}
39
  {%- if loop.index0 > ns.last_query_index %}
@@ -70,7 +74,7 @@
70
  {{- '<|im_start|>user' }}
71
  {%- endif %}
72
  {{- '\n<tool_response>\n' }}
73
- {{- message.content }}
74
  {{- '\n</tool_response>' }}
75
  {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
76
  {{- '<|im_end|>\n' }}
 
17
  {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
18
  {%- for message in messages[::-1] %}
19
  {%- set index = (messages|length - 1) - loop.index0 %}
20
+ {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
21
  {%- set ns.multi_step_tool = false %}
22
  {%- set ns.last_query_index = index %}
23
  {%- endif %}
24
  {%- endfor %}
25
  {%- for message in messages %}
26
+ {%- if message.content is string %}
27
+ {%- set content = message.content %}
28
+ {%- else %}
29
+ {%- set content = '' %}
30
+ {%- endif %}
31
  {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
32
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
33
  {%- elif message.role == "assistant" %}
 
34
  {%- set reasoning_content = '' %}
35
+ {%- if message.reasoning_content is string %}
36
  {%- set reasoning_content = message.reasoning_content %}
37
  {%- else %}
38
+ {%- if '</think>' in content %}
39
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
40
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
41
  {%- endif %}
42
  {%- endif %}
43
  {%- if loop.index0 > ns.last_query_index %}
 
74
  {{- '<|im_start|>user' }}
75
  {%- endif %}
76
  {{- '\n<tool_response>\n' }}
77
+ {{- content }}
78
  {{- '\n</tool_response>' }}
79
  {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
80
  {{- '<|im_end|>\n' }}