Upload chat_template.jinja with huggingface_hub
Browse files- chat_template.jinja +6 -20
chat_template.jinja
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
{{- bos_token }}
|
| 2 |
{%- if custom_tools is defined %}
|
| 3 |
{%- set tools = custom_tools %}
|
|
@@ -36,7 +39,7 @@
|
|
| 36 |
{{- 'Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}. ' }}
|
| 37 |
{{- "Do not use variables.\n\n" }}
|
| 38 |
{%- for t in tools %}
|
| 39 |
-
{{- t | tojson(indent=
|
| 40 |
{{- "\n\n" }}
|
| 41 |
{%- endfor %}
|
| 42 |
{%- endif %}
|
|
@@ -62,28 +65,14 @@
|
|
| 62 |
{{- 'Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}. ' }}
|
| 63 |
{{- "Do not use variables.\n\n" }}
|
| 64 |
{%- for t in tools %}
|
| 65 |
-
{{- t | tojson(indent=
|
| 66 |
{{- "\n\n" }}
|
| 67 |
{%- endfor %}
|
| 68 |
{{- first_user_message + "<|eot_id|>"}}
|
| 69 |
{%- endif %}
|
| 70 |
|
| 71 |
{%- for message in messages %}
|
| 72 |
-
{%- if message.role == '
|
| 73 |
-
{{- '<|start_header_id|>assistant<|end_header_id|>\n\n' }}
|
| 74 |
-
{%- generation %}
|
| 75 |
-
{%- if message['content'] is string %}
|
| 76 |
-
{{- message['content'] | trim}}
|
| 77 |
-
{%- else %}
|
| 78 |
-
{%- for content in message['content'] %}
|
| 79 |
-
{%- if content['type'] == 'text' %}
|
| 80 |
-
{{- content['text'] | trim }}
|
| 81 |
-
{%- endif %}
|
| 82 |
-
{%- endfor %}
|
| 83 |
-
{%- endif %}
|
| 84 |
-
{{- '<|eot_id|>' }}
|
| 85 |
-
{%- endgeneration %}
|
| 86 |
-
{%- elif not (message.role == 'ipython' or message.role == 'tool' or 'tool_calls' in message) %}
|
| 87 |
{{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n' }}
|
| 88 |
{%- if message['content'] is string %}
|
| 89 |
{{- message['content'] | trim}}
|
|
@@ -101,14 +90,11 @@
|
|
| 101 |
{%- endif %}
|
| 102 |
{%- set tool_call = message.tool_calls[0].function %}
|
| 103 |
{{- '<|start_header_id|>assistant<|end_header_id|>\n\n' -}}
|
| 104 |
-
{%- generation %}
|
| 105 |
{{- '{"name": "' + tool_call.name + '", ' }}
|
| 106 |
{{- '"parameters": ' }}
|
| 107 |
{{- tool_call.arguments | tojson }}
|
| 108 |
{{- "}" }}
|
| 109 |
{{- "<|eot_id|>" }}
|
| 110 |
-
{%- endgeneration %}
|
| 111 |
-
|
| 112 |
{%- elif message.role == "tool" or message.role == "ipython" %}
|
| 113 |
{{- "<|start_header_id|>ipython<|end_header_id|>\n\n" }}
|
| 114 |
{%- if message.content is string %}
|
|
|
|
| 1 |
+
{#- Llama 3 json tool calling chat template from https://github.com/vllm-project/vllm/blob/main/examples/tool_chat_template_llama3.1_json.jinja #}
|
| 2 |
+
{#- this is the “official” chat template for the Llama 3.1 models, but changed to have 2-space indents in the tools and a special header. Docs: https://docs.vllm.ai/en/stable/features/tool_calling.html #}
|
| 3 |
+
|
| 4 |
{{- bos_token }}
|
| 5 |
{%- if custom_tools is defined %}
|
| 6 |
{%- set tools = custom_tools %}
|
|
|
|
| 39 |
{{- 'Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}. ' }}
|
| 40 |
{{- "Do not use variables.\n\n" }}
|
| 41 |
{%- for t in tools %}
|
| 42 |
+
{{- t | tojson(indent=2) }}
|
| 43 |
{{- "\n\n" }}
|
| 44 |
{%- endfor %}
|
| 45 |
{%- endif %}
|
|
|
|
| 65 |
{{- 'Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}. ' }}
|
| 66 |
{{- "Do not use variables.\n\n" }}
|
| 67 |
{%- for t in tools %}
|
| 68 |
+
{{- t | tojson(indent=2) }}
|
| 69 |
{{- "\n\n" }}
|
| 70 |
{%- endfor %}
|
| 71 |
{{- first_user_message + "<|eot_id|>"}}
|
| 72 |
{%- endif %}
|
| 73 |
|
| 74 |
{%- for message in messages %}
|
| 75 |
+
{%- if not (message.role == 'ipython' or message.role == 'tool' or 'tool_calls' in message) %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
{{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n' }}
|
| 77 |
{%- if message['content'] is string %}
|
| 78 |
{{- message['content'] | trim}}
|
|
|
|
| 90 |
{%- endif %}
|
| 91 |
{%- set tool_call = message.tool_calls[0].function %}
|
| 92 |
{{- '<|start_header_id|>assistant<|end_header_id|>\n\n' -}}
|
|
|
|
| 93 |
{{- '{"name": "' + tool_call.name + '", ' }}
|
| 94 |
{{- '"parameters": ' }}
|
| 95 |
{{- tool_call.arguments | tojson }}
|
| 96 |
{{- "}" }}
|
| 97 |
{{- "<|eot_id|>" }}
|
|
|
|
|
|
|
| 98 |
{%- elif message.role == "tool" or message.role == "ipython" %}
|
| 99 |
{{- "<|start_header_id|>ipython<|end_header_id|>\n\n" }}
|
| 100 |
{%- if message.content is string %}
|