main
jinja 29 lines 667 Bytes
Raw
1 {{ (messages|selectattr('role', 'equalto', 'system')|list|last).content|trim if (messages|selectattr('role', 'equalto', 'system')|list) else '' }}
2
3 {% for message in messages %}
4 {% if message['role'] == 'user' %}
5 ### Instruction:
6 {{ message['content']|trim -}}
7 {% if not loop.last %}
8
9
10 {% endif %}
11 {% elif message['role'] == 'assistant' %}
12 ### Response:
13 {{ message['content']|trim -}}
14 {% if not loop.last %}
15
16
17 {% endif %}
18 {% elif message['role'] == 'user_context' %}
19 ### Input:
20 {{ message['content']|trim -}}
21 {% if not loop.last %}
22
23
24 {% endif %}
25 {% endif %}
26 {% endfor %}
27 {% if add_generation_prompt and messages[-1]['role'] != 'assistant' %}
28 ### Response:
29 {% endif %}