chat_template error when using apply_chat_template

#1
by RoacherM - opened

UndefinedError: 'system_message' is undefined. Use this instead.

{
  "chat_template": "{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% if messages[0]['role'] == 'system' %}{% set system_message = messages[0]['content'] %}{% else %}{% set system_message = '' %}{% endif %}{{ '<s>' + system_message }}{% for message in messages %}{% set content = message['content'] %}{% if message['role'] == 'user' %}{{ '[INST] ' + content + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ content + '</s>' }}{% elif message['role'] == 'function' %}{{ '<<functions>>' + content + '</s>' }}{% elif message['role'] == 'observation' %}{{ '[INST] <<observation>>' + content + ' [/INST]' }}{% endif %}{% endfor %}"
}

Sign up or log in to comment