m-i commited on
Commit
87c22fd
·
verified ·
1 Parent(s): 800bd37

Upload chat_template.jinja with huggingface_hub

Browse files
Files changed (1) hide show
  1. chat_template.jinja +55 -0
chat_template.jinja ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ {%- if tools %}
3
+ {{- '<|im_start|>system\n' }}
4
+ {%- if messages[0]['role'] == 'system' %}
5
+ {{- messages[0]['content'] }}
6
+ {%- else %}
7
+ {{- 'A conversation between User and Assistant. The User asks a question, and the Assistant solves it. The Assistant first thinks about the reasoning process in the mind and then provides the User with the answer. The reasoning process is enclosed within <reason> </reason> and answer is enclosed within <answer> </answer> tags, respectively, i.e., <reason> reasoning process here </reason> <answer> answer here </answer>.' }}
8
+ {%- endif %}
9
+ {{- "\n\n# Tools\n\nYou 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>" }}
10
+ {%- for tool in tools %}
11
+ {{- "\n" }}
12
+ {{- tool | tojson }}
13
+ {%- endfor %}
14
+ {{- "\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" }}
15
+ {%- else %}
16
+ {%- if messages[0]['role'] == 'system' %}
17
+ {{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
18
+ {%- else %}
19
+ {{- '<|im_start|>system\nA conversation between User and Assistant. The User asks a question, and the Assistant solves it. The Assistant first thinks about the reasoning process in the mind and then provides the User with the answer. The reasoning process is enclosed within <reason> </reason> and answer is enclosed within <answer> </answer> tags, respectively, i.e., <reason> reasoning process here </reason> <answer> answer here </answer>.<|im_end|>\n' }}
20
+ {%- endif %}
21
+ {%- endif %}
22
+ {%- for message in messages %}
23
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
24
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
25
+ {%- elif message.role == "assistant" %}
26
+ {{- '<|im_start|>' + message.role }}
27
+ {%- if message.content %}
28
+ {{- '\n' + message.content }}
29
+ {%- endif %}
30
+ {%- for tool_call in message.tool_calls %}
31
+ {%- if tool_call.function is defined %}
32
+ {%- set tool_call = tool_call.function %}
33
+ {%- endif %}
34
+ {{- '\n<tool_call>\n{"name": "' }}
35
+ {{- tool_call.name }}
36
+ {{- '", "arguments": ' }}
37
+ {{- tool_call.arguments | tojson }}
38
+ {{- '}\n</tool_call>' }}
39
+ {%- endfor %}
40
+ {{- '<|im_end|>\n' }}
41
+ {%- elif message.role == "tool" %}
42
+ {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
43
+ {{- '<|im_start|>user' }}
44
+ {%- endif %}
45
+ {{- '\n<tool_response>\n' }}
46
+ {{- message.content }}
47
+ {{- '\n</tool_response>' }}
48
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
49
+ {{- '<|im_end|>\n' }}
50
+ {%- endif %}
51
+ {%- endif %}
52
+ {%- endfor %}
53
+ {%- if add_generation_prompt %}
54
+ {{- '<|im_start|>assistant\n<reason>' }}
55
+ {%- endif %}