Upload chat_template.jinja with huggingface_hub
Browse files- chat_template.jinja +86 -0
chat_template.jinja
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{%- if tools %}
|
2 |
+
{{- '<|im_start|>system
|
3 |
+
' }}
|
4 |
+
{%- if messages[0]['role'] == 'system' %}
|
5 |
+
{{- messages[0]['content'] }}
|
6 |
+
{%- else %}
|
7 |
+
{{- 'You are a specialized DevOps assistant. You ONLY help with DevOps-related topics like Kubernetes, Docker, CI/CD, infrastructure automation, monitoring, and cloud operations. If asked about non-DevOps topics (movies, weather, cooking, sports, music, travel, health, education, politics, religion, philosophy, entertainment, gaming, fashion, or any other non-DevOps topics), you MUST politely refuse and redirect to DevOps topics. You are NOT a general assistant.' }}
|
8 |
+
{%- endif %}
|
9 |
+
{{- "
|
10 |
+
|
11 |
+
# Tools
|
12 |
+
|
13 |
+
You may call one or more functions to assist with the user query.
|
14 |
+
|
15 |
+
You are provided with function signatures within <tools></tools> XML tags:
|
16 |
+
<tools>" }}
|
17 |
+
{%- for tool in tools %}
|
18 |
+
{{- "
|
19 |
+
" }}
|
20 |
+
{{- tool | tojson }}
|
21 |
+
{%- endfor %}
|
22 |
+
{{- "
|
23 |
+
</tools>
|
24 |
+
|
25 |
+
For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
|
26 |
+
<tool_call>
|
27 |
+
{"name": <function-name>, "arguments": <args-json-object>}
|
28 |
+
</tool_call><|im_end|>
|
29 |
+
" }}
|
30 |
+
{%- else %}
|
31 |
+
{%- if messages[0]['role'] == 'system' %}
|
32 |
+
{{- '<|im_start|>system
|
33 |
+
' + messages[0]['content'] + '<|im_end|>
|
34 |
+
' }}
|
35 |
+
{%- else %}
|
36 |
+
{{- '<|im_start|>system
|
37 |
+
You are a specialized DevOps assistant. You ONLY help with DevOps-related topics like Kubernetes, Docker, CI/CD, infrastructure automation, monitoring, and cloud operations. If asked about non-DevOps topics (movies, weather, cooking, sports, music, travel, health, education, politics, religion, philosophy, entertainment, gaming, fashion, or any other non-DevOps topics), you MUST politely refuse and redirect to DevOps topics. You are NOT a general assistant.<|im_end|>
|
38 |
+
' }}
|
39 |
+
{%- endif %}
|
40 |
+
{%- endif %}
|
41 |
+
{%- for message in messages %}
|
42 |
+
{%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
|
43 |
+
{{- '<|im_start|>' + message.role + '
|
44 |
+
' + message.content + '<|im_end|>' + '
|
45 |
+
' }}
|
46 |
+
{%- elif message.role == "assistant" %}
|
47 |
+
{{- '<|im_start|>' + message.role }}
|
48 |
+
{%- if message.content %}
|
49 |
+
{{- '
|
50 |
+
' + message.content }}
|
51 |
+
{%- endif %}
|
52 |
+
{%- for tool_call in message.tool_calls %}
|
53 |
+
{%- if tool_call.function is defined %}
|
54 |
+
{%- set tool_call = tool_call.function %}
|
55 |
+
{%- endif %}
|
56 |
+
{{- '
|
57 |
+
<tool_call>
|
58 |
+
{"name": "' }}
|
59 |
+
{{- tool_call.name }}
|
60 |
+
{{- '", "arguments": ' }}
|
61 |
+
{{- tool_call.arguments | tojson }}
|
62 |
+
{{- '}
|
63 |
+
</tool_call>' }}
|
64 |
+
{%- endfor %}
|
65 |
+
{{- '<|im_end|>
|
66 |
+
' }}
|
67 |
+
{%- elif message.role == "tool" %}
|
68 |
+
{%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
|
69 |
+
{{- '<|im_start|>user' }}
|
70 |
+
{%- endif %}
|
71 |
+
{{- '
|
72 |
+
<tool_response>
|
73 |
+
' }}
|
74 |
+
{{- message.content }}
|
75 |
+
{{- '
|
76 |
+
</tool_response>' }}
|
77 |
+
{%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
|
78 |
+
{{- '<|im_end|>
|
79 |
+
' }}
|
80 |
+
{%- endif %}
|
81 |
+
{%- endif %}
|
82 |
+
{%- endfor %}
|
83 |
+
{%- if add_generation_prompt %}
|
84 |
+
{{- '<|im_start|>assistant
|
85 |
+
' }}
|
86 |
+
{%- endif %}
|