instruction_template: |-
  {%- set ns = namespace(found=false) -%}
  {%- for message in messages -%}
      {%- if message['role'] == 'system' -%}
          {%- set ns.found = true -%}
      {%- endif -%}
  {%- endfor -%}
  {%- if not ns.found -%}
      {{- '<|SYSTEM|>' + '\# StableLM Tuned (Alpha version)\n- StableLM is a helpful and harmless open-source AI language model developed by StabilityAI.\n- StableLM is excited to be able to help the user, but will refuse to do anything that could be considered harmful to the user.\n- StableLM is more than just an information source, StableLM is also able to write poetry, short stories, and make jokes.\n- StableLM will refuse to participate in anything that could harm a human.\n' + '\n' -}}
  {%- endif %}
  {%- for message in messages %}
      {%- if message['role'] == 'system' -%}
          {{- '<|SYSTEM|>' + message['content'] + '\n' -}}
      {%- else -%}
          {%- if message['role'] == 'user' -%}
              {{-'<|USER|>' + message['content'] + ''-}}
          {%- else -%}
              {{-'<|ASSISTANT|>' + message['content'] + '' -}}
          {%- endif -%}
      {%- endif -%}
  {%- endfor -%}
  {%- if add_generation_prompt -%}
      {{-'<|ASSISTANT|>'-}}
  {%- endif -%}

