🛠️ revert chat template to the original one

#1
Files changed (2) hide show
  1. README.md +1 -4
  2. chat_template.jinja +14 -47
README.md CHANGED
@@ -14,10 +14,7 @@ base_model: Qwen/Qwen3.6-35B-A3B
14
  >
15
  > Please use [deepsweet/Qwen3.6-35B-A3B-MLX-oQ8](https://huggingface.co/deepsweet/Qwen3.6-35B-A3B-MLX-oQ8) if you have M3+ Apple Silicon.
16
 
17
- This model was converted to MLX format from [Qwen/Qwen3.6-35B-A3B](https://huggingface.co/Qwen/Qwen3.6-35B-A3B) using:
18
-
19
- - [oMLX v0.36.0](https://github.com/jundot/omlx/releases/tag/v0.3.6)
20
- - fully [fixed](https://huggingface.co/froggeric/Qwen3.5-35B-A3B-Uncensored-FernflowerAI-MLX-8bit/blob/main/chat_template.README.md) `chat_template.jinja` by [@froggeric](https://huggingface.co/froggeric)
21
 
22
  Settings:
23
 
 
14
  >
15
  > Please use [deepsweet/Qwen3.6-35B-A3B-MLX-oQ8](https://huggingface.co/deepsweet/Qwen3.6-35B-A3B-MLX-oQ8) if you have M3+ Apple Silicon.
16
 
17
+ This model was converted to MLX format from [Qwen/Qwen3.6-35B-A3B](https://huggingface.co/Qwen/Qwen3.6-35B-A3B) using [oMLX v0.36.0].
 
 
 
18
 
19
  Settings:
20
 
chat_template.jinja CHANGED
@@ -12,7 +12,7 @@
12
  {%- if do_vision_count %}
13
  {%- set image_count.value = image_count.value + 1 %}
14
  {%- endif %}
15
- {%- if add_vision_id is defined and add_vision_id %}
16
  {{- 'Picture ' ~ image_count.value ~ ': ' }}
17
  {%- endif %}
18
  {{- '<|vision_start|><|image_pad|><|vision_end|>' }}
@@ -23,7 +23,7 @@
23
  {%- if do_vision_count %}
24
  {%- set video_count.value = video_count.value + 1 %}
25
  {%- endif %}
26
- {%- if add_vision_id is defined and add_vision_id %}
27
  {{- 'Video ' ~ video_count.value ~ ': ' }}
28
  {%- endif %}
29
  {{- '<|vision_start|><|video_pad|><|vision_end|>' }}
@@ -39,10 +39,6 @@
39
  {{- raise_exception('Unexpected content type.') }}
40
  {%- endif %}
41
  {%- endmacro %}
42
- {%- set ns_flags = namespace(enable_thinking=true) %}
43
- {%- if enable_thinking is defined %}
44
- {%- set ns_flags.enable_thinking = enable_thinking %}
45
- {%- endif %}
46
  {%- if not messages %}
47
  {{- raise_exception('No messages provided.') }}
48
  {%- endif %}
@@ -55,30 +51,16 @@
55
  {%- endfor %}
56
  {{- "\n</tools>" }}
57
  {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
58
- {%- if messages[0].role == 'system' or messages[0].role == 'developer' %}
59
  {%- set content = render_content(messages[0].content, false, true)|trim %}
60
- {%- if '<|think_off|>' in content %}
61
- {%- set ns_flags.enable_thinking = false %}
62
- {%- set content = content.replace('<|think_off|>', '').strip() %}
63
- {%- elif '<|think_on|>' in content %}
64
- {%- set ns_flags.enable_thinking = true %}
65
- {%- set content = content.replace('<|think_on|>', '').strip() %}
66
- {%- endif %}
67
  {%- if content %}
68
  {{- '\n\n' + content }}
69
  {%- endif %}
70
  {%- endif %}
71
  {{- '<|im_end|>\n' }}
72
  {%- else %}
73
- {%- if messages[0].role == 'system' or messages[0].role == 'developer' %}
74
  {%- set content = render_content(messages[0].content, false, true)|trim %}
75
- {%- if '<|think_off|>' in content %}
76
- {%- set ns_flags.enable_thinking = false %}
77
- {%- set content = content.replace('<|think_off|>', '').strip() %}
78
- {%- elif '<|think_on|>' in content %}
79
- {%- set ns_flags.enable_thinking = true %}
80
- {%- set content = content.replace('<|think_on|>', '').strip() %}
81
- {%- endif %}
82
  {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
83
  {%- endif %}
84
  {%- endif %}
@@ -98,14 +80,7 @@
98
  {%- endif %}
99
  {%- for message in messages %}
100
  {%- set content = render_content(message.content, true)|trim %}
101
- {%- if '<|think_off|>' in content %}
102
- {%- set ns_flags.enable_thinking = false %}
103
- {%- set content = content.replace('<|think_off|>', '').strip() %}
104
- {%- elif '<|think_on|>' in content %}
105
- {%- set ns_flags.enable_thinking = true %}
106
- {%- set content = content.replace('<|think_on|>', '').strip() %}
107
- {%- endif %}
108
- {%- if message.role == "system" or message.role == "developer" %}
109
  {%- if not loop.first %}
110
  {{- raise_exception('System message must be at the beginning.') }}
111
  {%- endif %}
@@ -122,7 +97,7 @@
122
  {%- endif %}
123
  {%- endif %}
124
  {%- set reasoning_content = reasoning_content|trim %}
125
- {%- if loop.index0 > ns.last_query_index and reasoning_content %}
126
  {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
127
  {%- else %}
128
  {{- '<|im_start|>' + message.role + '\n' + content }}
@@ -141,21 +116,13 @@
141
  {%- else %}
142
  {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
143
  {%- endif %}
144
- {%- if tool_call.arguments is defined and tool_call.arguments is mapping %}
145
- {%- if tool_call.arguments|length > 0 %}
146
- {%- for args_name in tool_call.arguments %}
147
- {%- set args_value = tool_call.arguments[args_name] %}
148
- {{- '<parameter=' + args_name + '>\n' }}
149
- {%- set args_value = args_value | tojson if args_value is mapping or (args_value is iterable and args_value is not string) else args_value | string %}
150
- {{- args_value }}
151
- {{- '\n</parameter>\n' }}
152
- {%- endfor %}
153
- {%- endif %}
154
- {%- elif tool_call.arguments is defined and tool_call.arguments is string %}
155
- {%- if tool_call.arguments|trim|length > 0 %}
156
- {{- tool_call.arguments }}
157
- {{- '\n' }}
158
- {%- endif %}
159
  {%- endif %}
160
  {{- '</function>\n</tool_call>' }}
161
  {%- endfor %}
@@ -179,7 +146,7 @@
179
  {%- endfor %}
180
  {%- if add_generation_prompt %}
181
  {{- '<|im_start|>assistant\n' }}
182
- {%- if ns_flags.enable_thinking is false %}
183
  {{- '<think>\n\n</think>\n\n' }}
184
  {%- else %}
185
  {{- '<think>\n' }}
 
12
  {%- if do_vision_count %}
13
  {%- set image_count.value = image_count.value + 1 %}
14
  {%- endif %}
15
+ {%- if add_vision_id %}
16
  {{- 'Picture ' ~ image_count.value ~ ': ' }}
17
  {%- endif %}
18
  {{- '<|vision_start|><|image_pad|><|vision_end|>' }}
 
23
  {%- if do_vision_count %}
24
  {%- set video_count.value = video_count.value + 1 %}
25
  {%- endif %}
26
+ {%- if add_vision_id %}
27
  {{- 'Video ' ~ video_count.value ~ ': ' }}
28
  {%- endif %}
29
  {{- '<|vision_start|><|video_pad|><|vision_end|>' }}
 
39
  {{- raise_exception('Unexpected content type.') }}
40
  {%- endif %}
41
  {%- endmacro %}
 
 
 
 
42
  {%- if not messages %}
43
  {{- raise_exception('No messages provided.') }}
44
  {%- endif %}
 
51
  {%- endfor %}
52
  {{- "\n</tools>" }}
53
  {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
54
+ {%- if messages[0].role == 'system' %}
55
  {%- set content = render_content(messages[0].content, false, true)|trim %}
 
 
 
 
 
 
 
56
  {%- if content %}
57
  {{- '\n\n' + content }}
58
  {%- endif %}
59
  {%- endif %}
60
  {{- '<|im_end|>\n' }}
61
  {%- else %}
62
+ {%- if messages[0].role == 'system' %}
63
  {%- set content = render_content(messages[0].content, false, true)|trim %}
 
 
 
 
 
 
 
64
  {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
65
  {%- endif %}
66
  {%- endif %}
 
80
  {%- endif %}
81
  {%- for message in messages %}
82
  {%- set content = render_content(message.content, true)|trim %}
83
+ {%- if message.role == "system" %}
 
 
 
 
 
 
 
84
  {%- if not loop.first %}
85
  {{- raise_exception('System message must be at the beginning.') }}
86
  {%- endif %}
 
97
  {%- endif %}
98
  {%- endif %}
99
  {%- set reasoning_content = reasoning_content|trim %}
100
+ {%- if (preserve_thinking is defined and preserve_thinking is true) or (loop.index0 > ns.last_query_index) %}
101
  {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
102
  {%- else %}
103
  {{- '<|im_start|>' + message.role + '\n' + content }}
 
116
  {%- else %}
117
  {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
118
  {%- endif %}
119
+ {%- if tool_call.arguments is defined %}
120
+ {%- for args_name, args_value in tool_call.arguments|items %}
121
+ {{- '<parameter=' + args_name + '>\n' }}
122
+ {%- set args_value = args_value | string if args_value is string else args_value | tojson | safe %}
123
+ {{- args_value }}
124
+ {{- '\n</parameter>\n' }}
125
+ {%- endfor %}
 
 
 
 
 
 
 
 
126
  {%- endif %}
127
  {{- '</function>\n</tool_call>' }}
128
  {%- endfor %}
 
146
  {%- endfor %}
147
  {%- if add_generation_prompt %}
148
  {{- '<|im_start|>assistant\n' }}
149
+ {%- if enable_thinking is defined and enable_thinking is false %}
150
  {{- '<think>\n\n</think>\n\n' }}
151
  {%- else %}
152
  {{- '<think>\n' }}