{%- for message in messages %} {{- '<|im_start|>' + message['role'] + ' ' + message['content'] + '<|im_end|> ' }} {%- endfor %} {%- if add_generation_prompt %} {{- '<|im_start|>assistant ' }} {%- if enable_thinking is defined and enable_thinking is false %} {{- ' ' }} {%- endif %} {%- endif %}