44 lines
1.4 KiB
Plaintext
44 lines
1.4 KiB
Plaintext
|
|
{%- 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 eos_token is defined -%}
|
||
|
|
{%- set eos_token = "</s>" -%}
|
||
|
|
{%- endif -%}
|
||
|
|
{{- cls_token -}}
|
||
|
|
{%- for message in messages -%}
|
||
|
|
{%- if message["role"] == "user" -%}
|
||
|
|
{{- "User: " -}}
|
||
|
|
{%- for content in message["content"] -%}
|
||
|
|
{%- if content["type"] == "image" -%}
|
||
|
|
{{ "<|IMAGE_START|><|IMAGE_PLACEHOLDER|><|IMAGE_END|>" }}
|
||
|
|
{%- endif -%}
|
||
|
|
{%- endfor -%}
|
||
|
|
{%- for content in message["content"] -%}
|
||
|
|
{%- if content["type"] == "text" -%}
|
||
|
|
{{ content["text"] }}
|
||
|
|
{%- endif -%}
|
||
|
|
{%- endfor -%}
|
||
|
|
{{ "\n" -}}
|
||
|
|
{%- elif message["role"] == "assistant" -%}
|
||
|
|
{{- "Assistant:\n" -}}
|
||
|
|
{%- for content in message["content"] -%}
|
||
|
|
{%- if content["type"] == "text" -%}
|
||
|
|
{{ content["text"] }}
|
||
|
|
{%- endif -%}
|
||
|
|
{%- endfor -%}
|
||
|
|
{{ eos_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:\n" -}}
|
||
|
|
{%- endif -%}
|