File size: 1,317 Bytes
3b98499
 
 
1
2
3
4
{
    "chat_template": "{{- bos_token }}    \n{%- for message in messages %}    \n    {%- if message['role'] == 'user' %}    \n        {{- '[INST]' + ' ' }}    \n        {%- if message['content'] is not string %}    \n            {%- for chunk in message['content'] %}    \n                {%- if chunk['type'] == 'text' %}    \n                    {{- chunk['content'] }}    \n                {%- elif chunk['type'] == 'image' %}    \n                    {{- '[IMG]' }}    \n                {%- else %}    \n                    {{- raise_exception('Unrecognized content type!') }}    \n                {%- endif %}    \n            {%- endfor %}    \n                {%- else %}    \n                    {{- message['content'] }}    \n        {%- endif %}    \n            {{- '[\/INST]' }}    \n    {%- if not loop.last and messages[loop.index]['role'] == 'user' %}    \n        {{- eos_token }}    \n    {%- endif %}    \n    {%- elif message['role'] == 'system' %}    \n        {{- '[SYSTEM_PROMPT] ' + message['content'] + '[\/SYSTEM_PROMPT]' }}    \n    {%- elif message['role'] == 'assistant' %}    \n        {{- ' ' + message['content'] + eos_token }}    \n    {%- else %}    \n        {{- raise_exception('Only user, system and assistant roles are supported!') }}    \n    {%- endif %}    \n{%- endfor %}"
}