{% for message in messages %}
{% if message['role'] == 'system' %}
<|im_start|>system
{{ message['content'] }}<|im_end|>

{% elif message['role'] in ['human', 'user'] %}
<|im_start|>user
{{ message['content'] }}<|im_end|>

{% elif message['role'] == 'function-call' %}
<|im_start|>call
{{ message['content'] }}<|im_end|>

{% elif message['role'] in ['function-response', 'tool'] %}
<|im_start|>function
{{ message['content'] }}<|im_end|>

{% elif message['role'] in ['gpt', 'assistant'] %}
<|im_start|>assistant
{{ message['content'] }}<|im_end|>

{% endif %}
{% endfor %}
{% if add_generation_prompt %}
<|im_start|>assistant
{% endif %}