WonsukYangTL commited on
Commit
71807d5
·
verified ·
1 Parent(s): bd92dde

Upload chat_template.jinja

Browse files
Files changed (1) hide show
  1. chat_template.jinja +58 -0
chat_template.jinja ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}
2
+ {%- if tools %}
3
+ {{- '<|im_start|>system\n' }}
4
+ {%- if messages[0]['role'] == 'system' %}
5
+ {{- messages[0]['content'] }}
6
+ {%- else %}
7
+ {{- 'You are Trillion, created by TrillionLabs. You are a helpful assistant.' }}
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\nYou are Trillion, created by TrillionLabs. You are a helpful assistant.<|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) %}
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
+ {%- if message.tool_calls %}
31
+ {%- for tool_call in message.tool_calls %}
32
+ {%- if tool_call.function is defined %}
33
+ {%- set tool_call = tool_call.function %}
34
+ {%- endif %}
35
+ {{- '\n<tool_call>\n' }}
36
+ {{- '{"name": "' + tool_call.name + '", "arguments": ' + tool_call.arguments | tojson + '}' -}}
37
+ {{- '\n</tool_call>' }}
38
+ {%- endfor %}
39
+ {%- endif %}
40
+ {{- '<|im_end|>\n' }}
41
+ {%- elif message.role == "tool" %}
42
+ {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
43
+ {{- '<|im_start|>tool\n' }}
44
+ {%- endif %}
45
+ {% for tool_response in message.content %}
46
+ {{- tool_response | tojson }}
47
+ {%- if not loop.last %}
48
+ {{- '\n' }}
49
+ {%- endif %}
50
+ {%- endfor %}
51
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
52
+ {{- '<|im_end|>\n' }}
53
+ {%- endif %}
54
+ {%- endif %}
55
+ {%- endfor %}
56
+ {%- if add_generation_prompt %}
57
+ {{- '<|im_start|>assistant\n' }}
58
+ {%- endif %}