{% for message in messages %} {% if message['role'] == 'user' %} {{ '<|start_header_id|>user<|end_header_id|> ' + message['content'] | trim + '<|eot_id|> ' }} {% elif message['role'] == 'system' %} {{ bos_token + ' <|start_header_id|>system<|end_header_id|> ' + message['content'] | trim + '<|eot_id|> ' }} {% elif message['role'] == 'assistant' %} {{ '<|start_header_id|>assistant<|end_header_id|> ' + message['content'] | trim + '<|eot_id|> ' }} {% endif %} {% if loop.last and add_generation_prompt %} {{ '<|start_header_id|>assistant<|end_header_id|> ' }} {% endif %} {% endfor %}