File size: 520 Bytes
1490cc9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
{%- for message in messages -%}
{%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) -%}
{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}
{%- endif -%}
{%- if message['role'] == 'user' -%}
{{ '<问>:' + message['content'] + '\n' }}
{%- elif message['role'] == 'assistant' -%}
{{ '<答>:' + message['content'] + '\n' }}
{%- endif -%}
{%- endfor -%}
{%- if add_generation_prompt -%}
{{- '<答>:' -}}
{% endif %} |