{% if not add_generation_prompt is defined %}
{% set add_generation_prompt = false %}
{% endif %}
{% for message in messages %}
{{ '\n<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' }}
{%- endfor %}
{%- if add_generation_prompt %}
{{ '\n<|im_start|>assistant\n' }}
{% endif %}