jina-vlm / chat_template.jinja
gmastrapas's picture
Model update
c6ce1be verified
raw
history blame contribute delete
866 Bytes
{%- for message in messages %}
{%- if (loop.index % 2 == 1 and message['role'].lower() != 'user') or (loop.index % 2 == 0 and message['role'].lower() != 'assistant') %}
{{ raise_exception('Conversation roles must alternate between user and assistant ...') }}
{%- endif %}
{%- if not loop.first or always_start_with_space %}
{{- ' ' }}
{%- endif %}
{{- message['role'].capitalize() + ': ' }}
{%- for content in message['content'] %}
{%- if content['type'] == 'text' %}
{{- content['text'] + ' ' }}
{%- elif content['type'] == 'image' %}
{{- image_prompt_token }}
{%- else %}
{{ raise_exception('Unsupported content type: ' + content['type']) }}
{%- endif %}
{%- endfor %}
{%- endfor %}
{%- if add_generation_prompt %}
{{- 'Assistant:' }}
{%- endif %}