mrtoots commited on
Commit
a70371c
·
verified ·
1 Parent(s): 1df9d38

Upload chat_template.jinja with huggingface_hub

Browse files
Files changed (1) hide show
  1. chat_template.jinja +7 -5
chat_template.jinja CHANGED
@@ -1,3 +1,4 @@
 
1
  [gMASK]<sop>
2
  {%- if tools -%}
3
  <|system|>
@@ -8,7 +9,7 @@ You may call one or more functions to assist with the user query.
8
  You are provided with function signatures within <tools></tools> XML tags:
9
  <tools>
10
  {% for tool in tools %}
11
- {{ tool | tojson(ensure_ascii=False) }}
12
  {% endfor %}
13
  </tools>
14
 
@@ -45,8 +46,8 @@ For each function call, output the function name and arguments within the follow
45
  {%- set reasoning_content = m.reasoning_content %}
46
  {%- else %}
47
  {%- if '</think>' in content %}
48
- {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
49
- {%- set content = content.split('</think>')[-1].lstrip('\n') %}
50
  {%- endif %}
51
  {%- endif %}
52
  {%- if ((clear_thinking is defined and not clear_thinking) or loop.index0 > ns.last_user_index) and reasoning_content -%}
@@ -63,7 +64,7 @@ For each function call, output the function name and arguments within the follow
63
  {%- set tc = tc.function %}
64
  {%- endif %}
65
  {{- '<tool_call>' + tc.name -}}
66
- {% set _args = tc.arguments %}{% for k, v in _args.items() %}<arg_key>{{ k }}</arg_key><arg_value>{{ v | tojson(ensure_ascii=False) if v is not string else v }}</arg_value>{% endfor %}</tool_call>{% endfor %}
67
  {% endif %}
68
  {%- elif m.role == 'tool' -%}
69
  {%- if m.content is string -%}
@@ -83,4 +84,5 @@ For each function call, output the function name and arguments within the follow
83
  {%- endfor -%}
84
  {%- if add_generation_prompt -%}
85
  <|assistant|>{{- '</think>' if (enable_thinking is defined and not enable_thinking) else '<think>' -}}
86
- {%- endif -%}
 
 
1
+ {# Unsloth template fixes #}
2
  [gMASK]<sop>
3
  {%- if tools -%}
4
  <|system|>
 
9
  You are provided with function signatures within <tools></tools> XML tags:
10
  <tools>
11
  {% for tool in tools %}
12
+ {{ tool | tojson|string }}
13
  {% endfor %}
14
  </tools>
15
 
 
46
  {%- set reasoning_content = m.reasoning_content %}
47
  {%- else %}
48
  {%- if '</think>' in content %}
49
+ {%- set reasoning_content = ((content.split('</think>')|first).rstrip('\n').split('<think>')|last).lstrip('\n') %}
50
+ {%- set content = (content.split('</think>')|last).lstrip('\n') %}
51
  {%- endif %}
52
  {%- endif %}
53
  {%- if ((clear_thinking is defined and not clear_thinking) or loop.index0 > ns.last_user_index) and reasoning_content -%}
 
64
  {%- set tc = tc.function %}
65
  {%- endif %}
66
  {{- '<tool_call>' + tc.name -}}
67
+ {% set _args = tc.arguments %}{%- if _args is mapping %}{% for k, v in _args|items %}<arg_key>{{ k }}</arg_key><arg_value>{{ v | tojson|string if v is not string else v }}</arg_value>{% endfor %}{%- endif %}</tool_call>{% endfor %}
68
  {% endif %}
69
  {%- elif m.role == 'tool' -%}
70
  {%- if m.content is string -%}
 
84
  {%- endfor -%}
85
  {%- if add_generation_prompt -%}
86
  <|assistant|>{{- '</think>' if (enable_thinking is defined and not enable_thinking) else '<think>' -}}
87
+ {%- endif -%}
88
+ {# Copyright 2025-present Unsloth. Apache 2.0 License. #}