File size: 3,167 Bytes
6691920
 
 
1
2
3
4
{
  "chat_template": "\n{%- set identifier = 'im' %}\n{% for message in messages %}\n    {% if message['role'] == 'stream' %}\n        {% set identifier = 'stream' %}\n    {% else %}\n        {% set identifier = 'im' %}\n    {% endif %}\n    {% if message['role'] is not none %}\n        {{- '<|' + identifier + '_start|>' + message['role'] + '\n' -}}\n    {% endif %}\n    {% if message['content'] is string %}\n        {{- message['content'] + '<|' + identifier + '_end|>\n' -}}\n    {% else %}\n        {% for content in message['content'] %}\n            {% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}\n                {% if 'time' in content %}\n                    {{- 'Time ' + content['time'] | round(1) | string + 's: ' -}}\n                {% endif %}\n                {{- image_token + '\n' -}}\n            {% elif content['type'] == 'video' or 'video' in content or 'video_url' in content %}\n                {% for i in range(content['num_frames']) %}\n                    {% if 'timestamps' in content %}\n                        {{- 'Time ' + content['timestamps'][i] | round(1) | string + 's:' -}}\n                    {% endif %}\n                    {% if i < content['num_frames'] - 1 %}\n                        {{- image_token + ',' -}}\n                        {% if 'audio_split' in content and content['audio_split'][i] > 0 %}\n                            {{- '<|audio_start|>' + audio_token * content['audio_split'][i] + '<|audio_end|>,' -}}\n                        {% endif %}\n                    {% else %}\n                        {{- image_token -}}\n                        {% if 'audio_split' in content and content['audio_split'][i] > 0 %}\n                            {{- ',<|audio_start|>' + audio_token * content['audio_split'][i] + '<|audio_end|>\n' -}}\n                        {% else %}\n                            {{- '\n' -}}\n                        {% endif %}\n                    {% endif %}\n                {% endfor %}\n            {% elif content['type'] == 'audio' or 'audio' in content or 'audio_url' in content %}\n                {% for i in range(content['num_frames']) %}\n                    {% if 'timestamps' in content %}\n                        {{- 'Time ' + content['timestamps'][i] | round(1) | string + 's:' -}}\n                    {% endif %}\n                    {% if i < content['num_frames'] - 1 %}\n                        {{- '<|audio_start|>' + audio_token + '<|audio_end|>,' -}}\n                    {% else %}\n                        {{- '<|audio_start|>' + audio_token + '<|audio_end|>\n' -}}\n                    {% endif %}\n                {% endfor %}\n            {% elif content['type'] == 'text' or 'text' in content %}\n                {{- content['text'] -}}\n            {% endif %}\n        {% endfor %}\n        {% if message['role'] is not none %}\n            {{- '<|' + identifier + '_end|>\n' -}}\n        {% endif %}\n    {% endif %}\n{% endfor %}\n{% if add_generation_prompt %}\n    {{- '<|im_start|>assistant\n' -}}\n    {% if not add_think_prompt %}\n        {{- '<think>\n\n</think>\n\n' -}}\n    {% endif %}\n{% endif %}\n"
}