warshanks commited on
Commit
37744af
·
verified ·
1 Parent(s): f3c4a37

Upload chat_template.jinja with huggingface_hub

Browse files
Files changed (1) hide show
  1. chat_template.jinja +77 -0
chat_template.jinja ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 not keep_cots is defined %}{% set keep_cots = false %}{% endif %}
5
+ {%- if thinking %}{%- set system_prompt = thinking_prompt %}{%- else %}{%- set system_prompt = standard_prompt %}{%- endif %}
6
+ {%- if tools %}
7
+ {{- '<|im_start|>system\n' }}
8
+ {%- if messages[0]['role'] == 'system' %}
9
+ {{- messages[0]['content'] }}
10
+ {%- else %}
11
+ {{- system_prompt }}
12
+ {%- endif %}
13
+ {{- "\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>" }}
14
+ {%- for tool in tools %}
15
+ {{- "\n" }}
16
+ {{- tool | tojson }}
17
+ {%- endfor %}
18
+ {{- "\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><|im_end|>\n" }}
19
+ {%- else %}
20
+ {%- if messages[0]['role'] == 'system' %}
21
+ {{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
22
+ {%- else %}
23
+ {{- '<|im_start|>system\n' + system_prompt + '<|im_end|>\n' }}
24
+ {%- endif %}
25
+ {%- endif %}
26
+ {%- for message in messages %}
27
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
28
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
29
+ {%- elif (message.role == "assistant" and not message.tool_calls) %}
30
+ {{- '<|im_start|>' + message.role }}
31
+ {%- if message.content %}
32
+ {%- set content = message['content'] -%}
33
+ {%- if thinking %}
34
+ {%- if not keep_cots %}
35
+ {%- set content = '<think> </think>' + content.split('</think>', 1)[1] -%}
36
+ {%- endif %}
37
+ {%- endif %}
38
+ {{- '\n' + content + '<|im_end|>' + '\n' }}
39
+ {%- endif %}
40
+ {%- elif message.role == "assistant" %}
41
+ {{- '<|im_start|>' + message.role }}
42
+ {%- if message.content %}
43
+ {%- set content = message['content'] -%}
44
+ {%- if thinking %}
45
+ {%- if not keep_cots %}
46
+ {%- set content = '<think> </think>' + content.split('</think>', 1)[1] -%}
47
+ {%- endif %}
48
+ {%- endif %}
49
+ {{- '\n' + content }}
50
+ {%- endif %}
51
+ {%- for tool_call in message.tool_calls %}
52
+ {%- if tool_call.function is defined %}
53
+ {%- set tool_call = tool_call.function %}
54
+ {%- endif %}
55
+ {{- '\n<tool_call>\n{"name": "' }}
56
+ {{- tool_call.name }}
57
+ {{- '", "arguments": ' }}
58
+ {{- tool_call.arguments | tojson }}
59
+ {{- '}\n</tool_call>' }}
60
+ {%- endfor %}
61
+ {{- '<|im_end|>\n' }}
62
+ {%- elif message.role == "tool" %}
63
+ {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
64
+ {{- '<|im_start|>user' }}
65
+ {%- endif %}
66
+ {{- '\n<tool_response>\n' }}
67
+ {{- message.content }}
68
+ {{- '\n</tool_response>' }}
69
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
70
+ {{- '<|im_end|>\n' }}
71
+ {%- endif %}
72
+ {%- endif %}
73
+ {%- endfor %}
74
+ {%- if add_generation_prompt %}
75
+ {{- '<|im_start|>assistant\n' }}
76
+ {%- endif %}
77
+