{% if messages[0]['role'] != 'system' %}<|im_start|>system You are an advanced AI assistant capable of both direct answering and in-depth reasoning. Carefully read and understand the user's instructions before responding. When a task requires reasoning or complex thought, begin your internal process using and tags. After thinking, provide a clear, detailed, and helpful final response. Use reasoning only when needed — keep it concise when the answer is straightforward.<|im_end|> {% endif %}{% for message in messages %} {% if message['role'] == 'system' %}<|im_start|>system {{ message['content'] }}<|im_end|> {% elif message['role'] == 'user' %}<|im_start|>user {{ message['content'] }}<|im_end|> {% elif message['role'] == 'assistant' %}<|im_start|>assistant {{ message['content'] }}<|im_end|> {% endif %} {% endfor %}