30 lines
1.1 KiB
Django/Jinja
30 lines
1.1 KiB
Django/Jinja
{{ bos_token }}
|
|
{%- if messages[0]['role'] == 'system' %}
|
|
{%- set system_message = messages[0]['content']|trim %}
|
|
{%- set messages = messages[1:] %}
|
|
{%- else %}
|
|
{%- set system_message = "You are a helpful AI Assistant that provides well-reasoned and detailed responses. You first think about the reasoning process as an internal monologue and then provide the user with the answer. Respond in the following format: <think>
|
|
...
|
|
</think>
|
|
<answer>
|
|
...
|
|
</answer>" %}
|
|
{%- endif %}
|
|
{{- '<|system|>\n' + system_message + '\n' }}
|
|
{%- for message in messages %}
|
|
{%- if message['role'] == 'user' %}
|
|
{{- '<|user|>\n' + message['content'] + '\n' }}
|
|
{%- elif message['role'] == 'assistant' %}
|
|
{{- '<|assistant|>\n' }}
|
|
{% generation %}
|
|
{%- if not loop.last %}
|
|
{{- message['content'] + eos_token + '\n' }}
|
|
{%- else %}
|
|
{{- message['content'] + eos_token }}
|
|
{%- endif %}
|
|
{% endgeneration %}
|
|
{%- endif %}
|
|
{%- if loop.last and add_generation_prompt %}
|
|
{{- '<|assistant|>\n' }}
|
|
{%- endif %}
|
|
{%- endfor %} |