j2prompt-lint/jinja2-prompt-template-corpus huggingface dataset:
{{ bos_token }}{% if messages[0]['role'] == 'system' %}{% set loop_messages = messages[1:] %}{% set system_message = messages[0]['content'] %}{% elif true == true and not '
' in messages[0]['content'] %}{% set loop_messages = messages %}{% else %}{% set loop_messages = messages %}{% set system_message = false %}{% endif %}{% for message in loop_messages %}{% if loop.index0 == 0 and system_message != false %}{% set content = '
\n' + system_message + '\n
\n\n' + message['content'] %}{% else %}{% set content = message['content'] %}{% endif %}{% if message['role'] == 'user' %}{{ '
 ' + content.strip() + ' 
' }}{% elif message['role'] == 'system' %}{{ '
\n' + content.strip() + '\n
\n\n' }}{% elif message['role'] == 'assistant' %}{{ ' '  + content.strip() + ' ' + eos_token }}{% endif %}{% endfor %}
{%- for message in messages %}{{- '
' + message.role + '
'}}{%- if message.role == 'system' or message.role == 'user' %}{%- if message.content is string %}{{- message.content | replace('<image>', '') | replace('<video>', '') }}{%- else %}{%- for item in message.content %}{%- if item.type == 'text' and 'text' in item %}{{- item.text | replace('<image>', '') | replace('<video>', '') }}{%- elif item.type == 'image' %}{{- '<image>'}}{%- elif item.type == 'video' %}{{- '<video>'}}{%- else %}{{- raise_exception('Invalid content type. Supported types for system and user are text, image, video.')}}{%- endif %}{%- if not loop.last %}{{- '
'}}{%- endif %}{%- endfor %}{%- endif %}{%- elif message.role == 'assistant' %}{%- set content = '' %}{%- if message.content is string %}{%- set content = message.content | replace('<image>', '') | replace('<video>', '') %}{%- else %}{%- set ns = namespace(content='') -%}{%- for item in message.content %}{%- if item.type == 'text' and 'text' in item %}{%- set ns.content = ns.content ~ (item.text | replace('<image>', '') | replace('<video>', '')) %}{%- else %}{{- raise_exception('Invalid content type. Supported type for assistant is text.')}}{%- endif %}{%- endfor %}{%- set content = ns.content -%}{%- endif %}{%- set content = content.split('</think>')[-1].lstrip('
') %}{{- content }}{%- else %}{{- raise_exception('Invalid role. Supported roles are system, user, assistant.')}}{%- endif %}{{- '

'}}{%- endfor %}{%- if add_generation_prompt %}{{- '
assistant
' }}{%- if enable_thinking is defined and enable_thinking is false %}{{- '<think>

</think>

' }}{%- endif %}{%- endif %}