{# ============================================================ Ina-v11.1 Chat Template (Llama-3.1 header style) ============================================================ #} {{- '<|begin_of_text|>' }} {%- for message in messages %} {%- if message['role'] == 'system' %} {{- '<|start_header_id|>system<|end_header_id|>' + '\n' }} {{- message['content'] }} {{- '<|eot_id|>' }} {%- elif message['role'] == 'user' %} {{- '<|start_header_id|>user<|end_header_id|>' + '\n' }} {{- message['content'] }} {{- '<|eot_id|>' }} {%- elif message['role'] == 'assistant' %} {{- '<|start_header_id|>assistant<|end_header_id|>' + '\n' }} {{- message['content'] }} {{- '<|eot_id|>' }} {%- elif message['role'] == 'tool' %} {# Optional: format tool responses if you ever add tools #} {{- '<|start_header_id|>tool<|end_header_id|>' + '\n' }} {{- message['content'] }} {{- '<|eot_id|>' }} {%- endif %} {%- endfor %} {# ============================================================ Optional: add generation header if user requests it ============================================================ #} {%- if add_generation_prompt %} {{- '<|start_header_id|>assistant<|end_header_id|>' + '\n' }} {%- endif %}