6 lines
475 B
Django/Jinja
6 lines
475 B
Django/Jinja
{% for message in messages %}{{'<|im_start|>' + message['role'] + '
|
|
'}}{% if message['content'] is string %}{{ message['content'] }}{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' %}{{ '<image>
|
|
' }}{% elif content['type'] == 'video' %}{{ '<video>
|
|
' }}{% elif content['type'] == 'text' %}{{ content['text'] }}{% endif %}{% endfor %}{% endif %}{{'<|im_end|>
|
|
'}}{% endfor %}{% if add_generation_prompt %}{{'<|im_start|>assistant
|
|
' }}{% endif %} |