Update chat_template.jinja
Browse files- chat_template.jinja +37 -4
chat_template.jinja
CHANGED
|
@@ -1,4 +1,37 @@
|
|
| 1 |
-
{{bos_token}}
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{- bos_token -}}
|
| 2 |
+
{%- set system_prompt = "" -%}
|
| 3 |
+
{%- set ns = namespace(system_prompt="") -%}
|
| 4 |
+
{%- if messages[0]["role"] == "system" -%}
|
| 5 |
+
{%- set ns.system_prompt = messages[0]["content"] -%}
|
| 6 |
+
{%- set messages = messages[1:] -%}
|
| 7 |
+
{%- endif -%}
|
| 8 |
+
{%- if tools -%}
|
| 9 |
+
{%- set ns.system_prompt = ns.system_prompt + ("\n" if ns.system_prompt else "") + "List of tools: <|tool_list_start|>[" -%}
|
| 10 |
+
{%- for tool in tools -%}
|
| 11 |
+
{%- if tool is not string -%}
|
| 12 |
+
{%- set tool = tool | tojson -%}
|
| 13 |
+
{%- endif -%}
|
| 14 |
+
{%- set ns.system_prompt = ns.system_prompt + tool -%}
|
| 15 |
+
{%- if not loop.last -%}
|
| 16 |
+
{%- set ns.system_prompt = ns.system_prompt + ", " -%}
|
| 17 |
+
{%- endif -%}
|
| 18 |
+
{%- endfor -%}
|
| 19 |
+
{%- set ns.system_prompt = ns.system_prompt + "]<|tool_list_end|>" -%}
|
| 20 |
+
{%- endif -%}
|
| 21 |
+
{%- if ns.system_prompt -%}
|
| 22 |
+
{{- "<|im_start|>system\n" + ns.system_prompt + "<|im_end|>\n" -}}
|
| 23 |
+
{%- endif -%}
|
| 24 |
+
{%- for message in messages -%}
|
| 25 |
+
{{- "<|im_start|>" + message["role"] + "\n" -}}
|
| 26 |
+
{%- set content = message["content"] -%}
|
| 27 |
+
{%- if content is not string -%}
|
| 28 |
+
{%- set content = content | tojson -%}
|
| 29 |
+
{%- endif -%}
|
| 30 |
+
{%- if message["role"] == "tool" -%}
|
| 31 |
+
{%- set content = "<|tool_response_start|>" + content + "<|tool_response_end|>" -%}
|
| 32 |
+
{%- endif -%}
|
| 33 |
+
{{- content + "<|im_end|>\n" -}}
|
| 34 |
+
{%- endfor -%}
|
| 35 |
+
{%- if add_generation_prompt -%}
|
| 36 |
+
{{- "<|im_start|>assistant\n" -}}
|
| 37 |
+
{%- endif -%}
|