{% set messages = conversations[0] if conversations else [] -%}
{% if messages and messages[0]['role'] == 'system' -%}
    {% set loop_messages = messages[1:] -%}
{% else -%}
    {% set loop_messages = messages -%}
{% endif -%}
{% for message in loop_messages -%}
    {% if message['role'] == 'user' -%}
        <|im_kimia_user_msg_start|>{{ message['content'] }}<|im_msg_end|><|im_kimia_assistant_msg_start|>
    {%- elif message['role'] == 'assistant' -%}
        {{ message['content'] }}<|im_kimia_text_eos|>
    {%- endif -%}
{% endfor -%}
