{% set system_message = 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' %}{% if messages[0]['role'] == 'system' %}{% set loop_messages = messages[1:] %}{% set system_message = messages[0]['content'] %}{% else %}{% set loop_messages = messages %}{% endif %}{% if system_message is defined %}{{ '<|im_start|>system
' + system_message + '<|im_end|>
' }}{% endif %}{% for message in loop_messages %}{% set content = message['content'] %}{% if message['role'] == 'user' %}{{ '<|im_start|>user
' + content + '<|im_end|>
<|im_start|>assistant
' }}{% elif message['role'] == 'assistant' %}{{ content + '<|im_end|>
' }}{% endif %}{% endfor %}