chat template again?

#2
by djuna - opened

{{ bos_token }}{% if messages | length > 0 %}{% if messages[0]['role'] == 'system' %}{{'user\n'}}{{ messages[0]['content'] | trim + '\n\n' }}{% if messages | length > 1 %}{{ messages[1]['content'] | trim }}{% elif messages | length > 1 %}{{ raise_exception('Error: Expected user role after system role.') }}{% endif %}{{'\n'}}{% for message in messages %}{% if loop.index > 2 %}{% if message['role'] == 'assistant' %}{{'model\n'}}{{ message['content'] | trim }}{{'\n'}}{% elif message['role'] == 'user' %}{{'user\n'}}{{ message['content'] | trim }}{{'\n'}}{% endif %}{% endif %}{% endfor %}{% else %}{% for message in messages %}{% if message['role'] == 'assistant' %}{{'model\n'}}{{ message['content'] | trim }}{{'\n'}}{% elif message['role'] == 'user' %}{{'user\n'}}{{ message['content'] | trim }}{{'\n'}}{% endif %}{% endfor %}{% endif %}{% endif %}{% if add_generation_prompt %}{{'model\n'}}{% endif %}

or this?
like ST mistal
{{ bos_token }}{% for message in messages %}{% if message['role'] == 'system' %}{{'user\n'+message['content'] | trim +'\nmodel\nUnderstood.\n'}}{% elif message['role'] == 'assistant' %}{{'model\n'+message['content'] | trim+'\n'}}{% elif message['role'] == 'user' %}{{'user\n'+message['content'] | trim+'\n'}}{% endif %}{% endfor %}{% if add_generation_prompt %}{{'model\n'}}{% endif %}

Sign up or log in to comment