{% if 'role' in messages[0] %}{{- bos_token }}{% for message in messages %}{% if message['role'] == 'system' %}{{ '<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>' + message['content'] | trim + '<|END_OF_TURN_TOKEN|>' }}{% elif message['role'] == 'user' %}{{ '<|START_OF_TURN_TOKEN|><|USER_TOKEN|>' + message['content'] | trim + '<|END_OF_TURN_TOKEN|>' }}{% elif message['role'] == 'assistant' %}{{ '<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|><|START_RESPONSE|>' + message['content'] | trim + '<|END_RESPONSE|><|END_OF_TURN_TOKEN|>' }}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ '<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|><|START_RESPONSE|>' }}{% endif %}{% else %}{{- bos_token }}{% for message in messages %}{% if message['from'] == 'system' %}{{ '<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>' + message['value'] | trim + '<|END_OF_TURN_TOKEN|>' }}{% elif message['from'] == 'human' %}{{ '<|START_OF_TURN_TOKEN|><|USER_TOKEN|>' + message['value'] | trim + '<|END_OF_TURN_TOKEN|>' }}{% elif message['from'] == 'gpt' %}{{ '<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|><|START_RESPONSE|>' + message['value'] | trim + '<|END_RESPONSE|><|END_OF_TURN_TOKEN|>' }}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ '<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|><|START_RESPONSE|>' }}{% endif %}{% endif %}