roskosmos19 commited on
Commit
98b6c96
·
verified ·
1 Parent(s): 1906874

Update chat_template.jinja

Browse files
Files changed (1) hide show
  1. chat_template.jinja +15 -37
chat_template.jinja CHANGED
@@ -1,5 +1,5 @@
1
  {%- if tools %}
2
- {{- '||<|im_start|>system\n' }}
3
  {%- if messages[0].role == 'system' %}
4
  {{- messages[0].content + '\n\n' }}
5
  {%- else %}
@@ -10,12 +10,12 @@
10
  {{- "\n" }}
11
  {{- tool | tojson }}
12
  {%- endfor %}
13
- {{- "\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>||<|eos|>\n" }}
14
  {%- else %}
15
  {%- if messages[0].role == 'system' %}
16
- {{- '||<|im_start|>system\n' + messages[0].content + '||<|eos|>\n' }}
17
  {%- else %}
18
- {{- '||<|im_start|>system\nYou are Rhea-4B, a coding AI with multi-pass processing. Your process: 1) First implementation, 2) Self-review for bugs/edge cases/security/performance, 3) Final optimized version. Functionality remains identical, only structure and comments are improved.||<|eos|>\n' }}
19
  {%- endif %}
20
  {%- endif %}
21
 
@@ -36,48 +36,27 @@
36
  {%- endif %}
37
 
38
  {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
39
- {{- '||<|im_start|>' + message.role + '\n' + content + '||<|eos|>\n' }}
40
 
41
  {%- elif message.role == "assistant" %}
42
  {%- set reasoning_content = '' %}
43
  {%- if message.reasoning_content is string %}
44
  {%- set reasoning_content = message.reasoning_content %}
45
  {%- else %}
46
- {%- if '||<|thinking_end|>' in content %}
47
- {%- set reasoning_content = content.split('||<|thinking_end|>')[0].rstrip('\n').split('||<|thinking|>')[-1].lstrip('\n') %}
48
- {%- set content = content.split('||<|thinking_end|>')[-1].lstrip('\n') %}
49
  {%- endif %}
50
  {%- endif %}
51
 
52
  {%- if loop.index0 > ns.last_query_index %}
53
  {%- if loop.last or (not loop.last and reasoning_content) %}
54
- {{- '||<|im_start|>' + message.role + '\n' }}
55
-
56
- {{- '### PASS 1 - First Implementation:\n' }}
57
- {{- content.lstrip('\n') }}
58
-
59
- {{- '\n\n||<|think_start|>\n' }}
60
- {{- '### PASS 2 - Self-Review:\n' }}
61
- {{- '- Syntax errors? Check correct bracketing, semicolons, imports\n' }}
62
- {{- '- Edge cases? Empty inputs, null values, boundary cases\n' }}
63
- {{- '- Performance? Time complexity, memory leaks, loops\n' }}
64
- {{- '- Security? SQL injection, XSS, buffer overflow, input validation\n' }}
65
- {{- '- Type safety? Type hints, generics, null safety\n' }}
66
- {{- '||<|think_end|>\n' }}
67
-
68
- {{- '\n||<|review_start|>\n' }}
69
- {{- 'Review results: [Document found issues here]\n' }}
70
- {{- '||<|review_end|>\n' }}
71
-
72
- {{- '\n||<|final_start|>\n' }}
73
- {{- '### PASS 3 - Final Version:\n' }}
74
- {{- 'Based on review - identical functionality, optimized structure:\n\n' }}
75
-
76
  {%- else %}
77
- {{- '||<|im_start|>' + message.role + '\n' + content }}
78
  {%- endif %}
79
  {%- else %}
80
- {{- '||<|im_start|>' + message.role + '\n' + content }}
81
  {%- endif %}
82
 
83
  {%- if message.tool_calls %}
@@ -99,22 +78,21 @@
99
  {{- '}\n</tool_call>' }}
100
  {%- endfor %}
101
  {%- endif %}
102
- {{- '||<|eos|>\n' }}
103
 
104
  {%- elif message.role == "tool" %}
105
  {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
106
- {{- '||<|im_start|>user' }}
107
  {%- endif %}
108
  {{- '\n<<tool_response>\n' }}
109
  {{- content }}
110
  {{- '\n</tool_response>' }}
111
  {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
112
- {{- '||<|eos|>\n' }}
113
  {%- endif %}
114
  {%- endif %}
115
  {%- endfor %}
116
 
117
  {%- if add_generation_prompt %}
118
- {{- '||<|im_start|>assistant\n' }}
119
- {{- '### PASS 1 - First Implementation:\n' }}
120
  {%- endif %}
 
1
  {%- if tools %}
2
+ {{- '||<|<|im_start|>system\n' }}
3
  {%- if messages[0].role == 'system' %}
4
  {{- messages[0].content + '\n\n' }}
5
  {%- else %}
 
10
  {{- "\n" }}
11
  {{- tool | tojson }}
12
  {%- endfor %}
13
+ {{- "\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>||<|<|eos|>\n" }}
14
  {%- else %}
15
  {%- if messages[0].role == 'system' %}
16
+ {{- '||<|<|im_start|>system\n' + messages[0].content + '||<|<|eos|>\n' }}
17
  {%- else %}
18
+ {{- '||<|<|im_start|>system\nYou are Rhea-4B, a coding AI with multi-pass processing. Your process: 1) First implementation, 2) Self-review for bugs/edge cases/security/performance, 3) Final optimized version. Functionality remains identical, only structure and comments are improved.||<|<|eos|>\n' }}
19
  {%- endif %}
20
  {%- endif %}
21
 
 
36
  {%- endif %}
37
 
38
  {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
39
+ {{- '||<|<|im_start|>' + message.role + '\n' + content + '||<|<|eos|>\n' }}
40
 
41
  {%- elif message.role == "assistant" %}
42
  {%- set reasoning_content = '' %}
43
  {%- if message.reasoning_content is string %}
44
  {%- set reasoning_content = message.reasoning_content %}
45
  {%- else %}
46
+ {%- if '||<|<|thinking_end|>' in content %}
47
+ {%- set reasoning_content = content.split('||<|<|thinking_end|>')[0].rstrip('\n').split('||<|<|thinking|>')[-1].lstrip('\n') %}
48
+ {%- set content = content.split('||<|<|thinking_end|>')[-1].lstrip('\n') %}
49
  {%- endif %}
50
  {%- endif %}
51
 
52
  {%- if loop.index0 > ns.last_query_index %}
53
  {%- if loop.last or (not loop.last and reasoning_content) %}
54
+ {{- '||<|<|im_start|>' + message.role + '\n' + content }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  {%- else %}
56
+ {{- '||<|<|im_start|>' + message.role + '\n' + content }}
57
  {%- endif %}
58
  {%- else %}
59
+ {{- '||<|<|im_start|>' + message.role + '\n' + content }}
60
  {%- endif %}
61
 
62
  {%- if message.tool_calls %}
 
78
  {{- '}\n</tool_call>' }}
79
  {%- endfor %}
80
  {%- endif %}
81
+ {{- '||<|<|eos|>\n' }}
82
 
83
  {%- elif message.role == "tool" %}
84
  {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
85
+ {{- '||<|<|im_start|>user' }}
86
  {%- endif %}
87
  {{- '\n<<tool_response>\n' }}
88
  {{- content }}
89
  {{- '\n</tool_response>' }}
90
  {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
91
+ {{- '||<|<|eos|>\n' }}
92
  {%- endif %}
93
  {%- endif %}
94
  {%- endfor %}
95
 
96
  {%- if add_generation_prompt %}
97
+ {{- '||<|<|im_start|>assistant\n' }}
 
98
  {%- endif %}