Update chat_template.jinja (#13)
Browse files- Update chat_template.jinja (bef067fc89c029dc5429655ed48b830183177f04)
- Update chat_template.jinja (26bb21ffbfe2d9527e007758ddddb3700955d2af)
Co-authored-by: Joshua <Xenova@users.noreply.huggingface.co>
- chat_template.jinja +15 -4
chat_template.jinja
CHANGED
|
@@ -1,14 +1,25 @@
|
|
| 1 |
{{- bos_token -}}
|
| 2 |
{%- set system_prompt = "" -%}
|
|
|
|
| 3 |
{%- if messages[0]["role"] == "system" -%}
|
| 4 |
-
{%- set system_prompt = messages[0]["content"] -%}
|
| 5 |
{%- set messages = messages[1:] -%}
|
| 6 |
{%- endif -%}
|
| 7 |
{%- if tools -%}
|
| 8 |
-
{%- set system_prompt = system_prompt + ("\n" if system_prompt else "") + "List of tools: <|tool_list_start|>"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
{%- endif -%}
|
| 10 |
-
{%- if system_prompt -%}
|
| 11 |
-
{{- "<|im_start|>system\n" + system_prompt + "<|im_end|>\n" -}}
|
| 12 |
{%- endif -%}
|
| 13 |
{%- for message in messages -%}
|
| 14 |
{{- "<|im_start|>" + message["role"] + "\n" -}}
|
|
|
|
| 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" -}}
|