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