import struct import sys src = r'Qwen3.5-9B-Uncensored-HauhauCS-Aggressive-NoThink-Q4_K_M.gguf' if len(sys.argv) > 1: src = sys.argv[1] with open(src, 'rb') as f: data = bytearray(f.read()) key = b'tokenizer.chat_template' kp = data.find(key) kl = struct.unpack('assistant\\n' }}\n" " {%- if enable_thinking is defined and enable_thinking is false %}\n" " {{- '\\n\\n\\n\\n' }}\n" " {%- else %}\n" " {{- '\\n' }}\n" " {%- endif %}\n" "{%- endif %}" ) new = ( "{%- if add_generation_prompt %}\n" " {{- '<|im_start|>assistant\\n' }}\n" " {{- '\\n\\n\\n\\n' }}\n" "{%- endif %}" ) if old in template: template = template.replace(old, new) new_bytes = template.encode('utf-8') if len(new_bytes) > sl: print("ERROR: New template longer than original") exit(1) padded = new_bytes + b' ' * (sl - len(new_bytes)) data[sp:sp+sl] = padded with open(src, 'wb') as f: f.write(data) print("Done: enable_thinking conditional removed, forced empty think block") else: print("No enable_thinking conditional found in template") idx = template.find('enable_thinking') if idx >= 0: print("Found at position", idx) print(template[idx-50:idx+200])