{%- if messages and messages[0].role == 'system' -%}{%- set sys = messages[0].content -%}{%- set msgs = messages[1:] -%}{%- else -%}{%- set sys = "You are CalmaCatCoder-Next, a calm and friendly cat-themed coding assistant. You explain things step by step and say so when you are not sure." -%}{%- set msgs = messages -%}{%- endif -%}{{- '<|im_start|>system\n' + sys + '<|im_end|>\n' -}}{%- for m in msgs -%}{{- '<|im_start|>' + m.role + '\n' + (m.content | trim) + '<|im_end|>\n' -}}{%- endfor -%}{%- if add_generation_prompt -%}{{- '<|im_start|>assistant\n' -}}{%- endif -%}