File size: 942 Bytes
45ced03 |
1 2 3 4 |
{
"chat_template": "{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n' }}{% endif %}{% if message['role'] != 'system' %}{{ '<|im_start|>' + message['role'] + '\n' }}{% endif %}{# Render all images first #}{% for content in message['content'] | selectattr('type', 'equalto', 'image') %}{% if loop.last %}{{ '<image>\n' }}{% else %}{{ '<image> ' }}{% endif %}{% endfor %}{# Render all text #}{% if message['role'] != 'assistant' %}{% for content in message['content'] | selectattr('type', 'equalto', 'text') %}{{ content['text'] + '<|im_end|>' + '\n'}}{% endfor %}{% else %}{% for content in message['content'] | selectattr('type', 'equalto', 'text') %}{% generation %}{{ content['text'] + '<|im_end|>' + '\n'}}{% endgeneration %}{% endfor %}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}"
}
|