pygchat.jinja 381 B

12345678910111213
  1. {# Fetch character name. This gets a bit ugly, but so be it. #}
  2. {% set char_name = (messages|selectattr('role', 'equalto', 'assistant')|list|last|split(":"))[0]|trim - %}
  3. {% for message in messages %}
  4. {{ message['content']|trim -}}
  5. {% if not loop.last %}
  6. {% endif %}
  7. {% endfor %}
  8. {% if add_generation_prompt and messages[-1]['role'] != 'assistant' %}
  9. {{char_name}}:
  10. {% endif %}