Upload complete model
Browse files- chat_template.jinja +43 -0
chat_template.jinja
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- if tools -%}
|
| 2 |
+
<|im_system|>tool_declare<|im_middle|>{{ tools | tojson }}<|im_end|>
|
| 3 |
+
{%- endif -%}
|
| 4 |
+
{%- for message in messages -%}
|
| 5 |
+
{%- if loop.first and messages[0]['role'] != 'system' -%}
|
| 6 |
+
<|im_system|>system<|im_middle|>You are Kimi, an AI assistant created by Moonshot AI.<|im_end|>
|
| 7 |
+
{%- endif -%}
|
| 8 |
+
{%- if message['role'] == 'system' -%}
|
| 9 |
+
<|im_system|>system<|im_middle|>
|
| 10 |
+
{%- elif message['role'] == 'user' -%}
|
| 11 |
+
<|im_user|>user<|im_middle|>
|
| 12 |
+
{%- elif message['role'] == 'assistant' -%}
|
| 13 |
+
<|im_assistant|>assistant<|im_middle|>
|
| 14 |
+
{%- elif message['role'] == 'tool' -%}
|
| 15 |
+
<|im_system|>tool<|im_middle|>
|
| 16 |
+
{%- endif -%}
|
| 17 |
+
{%- if message['role'] == 'assistant' and message.get('tool_calls') -%}
|
| 18 |
+
{%- if message['content'] -%}{{ message['content'] }}{%- endif -%}
|
| 19 |
+
<|tool_calls_section_begin|>
|
| 20 |
+
{%- for tool_call in message['tool_calls'] -%}
|
| 21 |
+
{%- set formatted_id = tool_call['id'] -%}
|
| 22 |
+
<|tool_call_begin|>{{ formatted_id }}<|tool_call_argument_begin|>{% if tool_call['function']['arguments'] is string %}{{ tool_call['function']['arguments'] }}{% else %}{{ tool_call['function']['arguments'] | tojson }}{% endif %}<|tool_call_end|>
|
| 23 |
+
{%- endfor -%}
|
| 24 |
+
<|tool_calls_section_end|>
|
| 25 |
+
{%- elif message['role'] == 'tool' -%}
|
| 26 |
+
## Return of {{ message.tool_call_id }}
|
| 27 |
+
{{ message['content'] }}
|
| 28 |
+
{%- elif message['content'] is string -%}
|
| 29 |
+
{{ message['content'] }}
|
| 30 |
+
{%- elif message['content'] is not none -%}
|
| 31 |
+
{% for content in message['content'] -%}
|
| 32 |
+
{% if content['type'] == 'image' or 'image' in content or 'image_url' in content -%}
|
| 33 |
+
<|media_start|>image<|media_content|><|media_pad|><|media_end|>
|
| 34 |
+
{% else -%}
|
| 35 |
+
{{ content['text'] }}
|
| 36 |
+
{%- endif -%}
|
| 37 |
+
{%- endfor -%}
|
| 38 |
+
{%- endif -%}
|
| 39 |
+
<|im_end|>
|
| 40 |
+
{%- endfor -%}
|
| 41 |
+
{%- if add_generation_prompt -%}
|
| 42 |
+
<|im_assistant|>assistant<|im_middle|>
|
| 43 |
+
{%- endif -%}
|