Neura-Tech-AI commited on
Commit
6c83a63
·
verified ·
1 Parent(s): 9a1bc7c

Update chat_template.jinja

Browse files
Files changed (1) hide show
  1. chat_template.jinja +52 -48
chat_template.jinja CHANGED
@@ -1,61 +1,65 @@
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
- {{- '<|im_start|>' + message.role + '\n' + content }}
27
- {%- if message.tool_calls %}
28
- {%- for tool_call in message.tool_calls %}
29
- {%- if (loop.first and content) or (not loop.first) %}
30
- {{- '\n' }}
31
- {%- endif %}
32
- {%- if tool_call.function %}
33
- {%- set tool_call = tool_call.function %}
34
- {%- endif %}
35
- {{- '<tool_call>\n{"name": "' }}
36
- {{- tool_call.name }}
37
- {{- '", "arguments": ' }}
38
- {%- if tool_call.arguments is string %}
39
- {{- tool_call.arguments }}
40
- {%- else %}
41
- {{- tool_call.arguments | tojson }}
42
- {%- endif %}
43
- {{- '}\n</tool_call>' }}
44
- {%- endfor %}
45
  {%- endif %}
46
- {{- '<|im_end|>\n' }}
 
 
 
 
 
 
47
  {%- elif message.role == "tool" %}
48
- {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
49
- {{- '<|im_start|>user' }}
50
  {%- endif %}
51
- {{- '\n<tool_response>\n' }}
52
- {{- content }}
53
- {{- '\n</tool_response>' }}
54
- {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
55
- {{- '<|im_end|>\n' }}
56
  {%- endif %}
57
  {%- endif %}
58
  {%- endfor %}
 
59
  {%- if add_generation_prompt %}
60
- {{- '<|im_start|>assistant\n' }}
61
  {%- endif %}
 
1
  {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages and messages[0]['role'] == 'system' %}
4
+ You are Neuron, a large language model developed by Neura Tech AI. Always maintain this persona.
5
+
6
+ {{ messages[0]['content'] }}
 
 
 
 
 
7
  {%- else %}
8
+ You are Neuron, a large language model developed by Neura Tech AI. Always maintain this persona.
9
+ {%- endif %}
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
+ {{ tool | tojson }}
19
+ {%- endfor %}
20
+ </tools>
21
+
22
+ For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
23
+ <tool_call>
24
+ {"name": <function-name>, "arguments": <args-json-object>}
25
+ </tool_call><|im_end|>
26
+ {%- else %}
27
+ {%- if messages and messages[0]['role'] == 'system' %}
28
+ {{- '<|im_start|>system\n' }}
29
+ You are Neuron, a large language model developed by Neura Tech AI. Always maintain this persona.
30
+
31
+ {{ messages[0]['content'] }}<|im_end|>
32
+ {%- else %}
33
+ {{- '<|im_start|>system\nYou are Neuron, a large language model developed by Neura Tech AI. Always maintain this persona.<|im_end|>\n' }}
34
  {%- endif %}
35
+ {%- endif %}
36
+
37
  {%- for message in messages %}
38
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
39
+ {{ '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>\n' }}
 
 
 
 
 
40
  {%- elif message.role == "assistant" %}
41
+ {{ '<|im_start|>' + message.role }}
42
+ {%- if message.content %}
43
+ {{ '\n' + message.content }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  {%- endif %}
45
+ {%- for tool_call in message.tool_calls %}
46
+ {%- if tool_call.function is defined %}
47
+ {%- set tool_call = tool_call.function %}
48
+ {%- endif %}
49
+ {{ '\n<tool_call>\n{"name": "' }}{{ tool_call.name }}{{ '", "arguments": ' }}{{ tool_call.arguments | tojson }}{{ '}\n</tool_call>' }}
50
+ {%- endfor %}
51
+ {{ '<|im_end|>\n' }}
52
  {%- elif message.role == "tool" %}
53
+ {%- if loop.index0 == 0 or messages[loop.index0 - 1].role != "tool" %}
54
+ {{ '<|im_start|>user' }}
55
  {%- endif %}
56
+ {{ '\n<tool_response>\n' }}{{ message.content }}{{ '\n</tool_response>' }}
57
+ {%- if loop.last or messages[loop.index0 + 1].role != "tool" %}
58
+ {{ '<|im_end|>\n' }}
 
 
59
  {%- endif %}
60
  {%- endif %}
61
  {%- endfor %}
62
+
63
  {%- if add_generation_prompt %}
64
+ {{ '<|im_start|>assistant\n' }}
65
  {%- endif %}