Create chat_template.jinja
Browse files- chat_template.jinja +61 -0
chat_template.jinja
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- set thinking_prompt = 'You are a deep thinking AI, you may use extremely long chains of thought to deeply consider the problem and deliberate with yourself via systematic reasoning processes to help come to a correct solution prior to answering. You should enclose your thoughts and internal monologue inside <think> </think> tags, and then provide your solution or response to the problem.' %}
|
| 2 |
+
{%- set standard_prompt = 'You are Hermes, created by Nous Research.' %}
|
| 3 |
+
{%- if not thinking is defined %}{% set thinking = false %}{% endif %}
|
| 4 |
+
{%- if thinking %}{%- set system_prompt = thinking_prompt %}{%- else %}{%- set system_prompt = standard_prompt %}{%- endif %}
|
| 5 |
+
{%- if tools %}
|
| 6 |
+
{{- bos_token + '<|start_header_id|>system<|end_header_id|>\n' }}
|
| 7 |
+
{%- if messages[0]['role'] == 'system' %}
|
| 8 |
+
{{- messages[0]['content'] }}
|
| 9 |
+
{%- else %}
|
| 10 |
+
{{- system_prompt }}
|
| 11 |
+
{%- endif %}
|
| 12 |
+
{{- "\n\n# Tools\n\nYou are a function calling AI model. You may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
|
| 13 |
+
{%- for tool in tools %}
|
| 14 |
+
{{- "\n" }}
|
| 15 |
+
{{- tool | tojson }}
|
| 16 |
+
{%- endfor %}
|
| 17 |
+
{{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": \"<function-name>\", \"arguments\": <args-json-object>}\n</tool_call><|eot_id|>" }}
|
| 18 |
+
{%- else %}
|
| 19 |
+
{%- if messages[0]['role'] == 'system' %}
|
| 20 |
+
{{- bos_token + '<|start_header_id|>system<|end_header_id|>\n\n' + messages[0]['content'] + '<|eot_id|>' }}
|
| 21 |
+
{%- else %}
|
| 22 |
+
{{- bos_token + '<|start_header_id|>system<|end_header_id|>\n\n' + system_prompt + '<|eot_id|>' }}
|
| 23 |
+
{%- endif %}
|
| 24 |
+
{%- endif %}
|
| 25 |
+
{%- for message in messages %}
|
| 26 |
+
{%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
|
| 27 |
+
{{- '<|start_header_id|>' + message.role + '<|end_header_id|>\n\n' + message.content + '<|eot_id|>' }}
|
| 28 |
+
{%- elif message.role == "assistant" %}
|
| 29 |
+
{{- '<|start_header_id|>' + message.role + '<|end_header_id|>\n' }}
|
| 30 |
+
{%- if message.content %}
|
| 31 |
+
{{- '\n' + message.content }}
|
| 32 |
+
{%- endif %}
|
| 33 |
+
{%- for tool_call in message.tool_calls %}
|
| 34 |
+
{%- if tool_call.function is defined %}
|
| 35 |
+
{%- set tool_call = tool_call.function %}
|
| 36 |
+
{%- endif %}
|
| 37 |
+
{{- '\n<tool_call>\n{"name": "' }}
|
| 38 |
+
{{- tool_call.name }}
|
| 39 |
+
{{- '", "arguments": ' }}
|
| 40 |
+
{{- tool_call.arguments | tojson }}
|
| 41 |
+
{{- '}\n</tool_call>' }}
|
| 42 |
+
{%- endfor %}
|
| 43 |
+
{{- '<|eot_id|>' }}
|
| 44 |
+
{%- elif message.role == "tool" %}
|
| 45 |
+
{%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
|
| 46 |
+
{{- '<|start_header_id|>user<|end_header_id|>\n' }}
|
| 47 |
+
{%- endif %}
|
| 48 |
+
{{- '\n<tool_response>\n' }}
|
| 49 |
+
{{- message.content }}
|
| 50 |
+
{{- '\n</tool_response>' }}
|
| 51 |
+
{%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
|
| 52 |
+
{{- '<|eot_id|>' }}
|
| 53 |
+
{%- endif %}
|
| 54 |
+
{%- endif %}
|
| 55 |
+
{%- endfor %}
|
| 56 |
+
{%- if add_generation_prompt %}
|
| 57 |
+
{{- '<|start_header_id|>assistant<|end_header_id|>\n\n' }}
|
| 58 |
+
{%- if thinking %}
|
| 59 |
+
{{- '<think>' }}
|
| 60 |
+
{%- endif %}
|
| 61 |
+
{%- endif %}
|