WebScraper991923 commited on
Commit
113c5fe
·
verified ·
1 Parent(s): 67273c6

Upload chat_template.jinja with huggingface_hub

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