Files
PaddleOCR-VL/chat_template.jinja
TingquanGao 15dd523c0f update
2025-10-29 14:12:36 +00:00

47 lines
1.6 KiB
Django/Jinja

{%- if not add_generation_prompt is defined -%}
{%- set add_generation_prompt = true -%}
{%- endif -%}
{%- if not cls_token is defined -%}
{%- set cls_token = "<|begin_of_sentence|>" -%}
{%- endif -%}
{%- if not sep_token is defined -%}
{%- set sep_token = "<|end_of_sentence|>" -%}
{%- endif -%}
{%- if not image_token is defined -%}
{%- set image_token = "<|IMAGE_START|><|IMAGE_PLACEHOLDER|><|IMAGE_END|>" -%}
{%- endif -%}
{{- cls_token -}}
{%- for message in messages -%}
{%- if message["role"] == "user" -%}
{{- "User: " -}}
{%- for content in message["content"] -%}
{%- if content["type"] == "image" -%}
{{ image_token }}
{%- endif -%}
{%- endfor -%}
{%- for content in message["content"] -%}
{%- if content["type"] == "text" -%}
{{ content["text"] }}
{%- endif -%}
{%- endfor -%}
{{ "\n" -}}
{%- elif message["role"] == "assistant" -%}
{{- "Assistant: " -}}
{%- for content in message["content"] -%}
{%- if content["type"] == "text" -%}
{{ content["text"] + "\n" }}
{%- endif -%}
{%- endfor -%}
{{ sep_token -}}
{%- elif message["role"] == "system" -%}
{%- for content in message["content"] -%}
{%- if content["type"] == "text" -%}
{{ content["text"] + "\n" }}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endfor -%}
{%- if add_generation_prompt -%}
{{- "Assistant: " -}}
{%- endif -%}