CerovazS commited on
Commit
bc86a12
·
1 Parent(s): e47321c

Enforce canonical math system and text-only chat

Browse files
Files changed (1) hide show
  1. chat_template.jinja +16 -46
chat_template.jinja CHANGED
@@ -1,53 +1,23 @@
1
- {{- '<|endoftext|>' }}
2
  {%- if tools %}
3
- {{- '<|im_start|>system\n' }}
4
- {%- if messages[0]['role'] == 'system' %}
5
- {{- messages[0]['content'] }}
6
- {%- else %}
7
- {{- '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 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) 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 %}
 
1
+ {%- set system_prompt = 'You are a helpful assistant.\nPlease reason step by step, and put your final answer within \\boxed{}.' %}
2
  {%- if tools %}
3
+ {{- raise_exception('Limite Violetto supports text-only chat; tools are not supported.') }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  {%- endif %}
5
+ {{- '<|endoftext|><|im_start|>system\n' + system_prompt + '<|im_end|>\n' }}
6
  {%- for message in messages %}
7
+ {%- if (message.tool_calls is defined and message.tool_calls is not none) or (message.function_call is defined and message.function_call is not none) %}
8
+ {{- raise_exception('Limite Violetto supports text-only chat; tool calls are not supported.') }}
9
+ {%- endif %}
10
+ {%- if message.content is not string %}
11
+ {{- raise_exception('Limite Violetto supports text-only chat; message content must be a string.') }}
12
+ {%- endif %}
13
+ {%- if message.role == 'system' %}
14
+ {%- if message.content != system_prompt %}
15
+ {{- raise_exception('Limite Violetto requires its fixed mathematical system prompt; custom system messages are not supported.') }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  {%- endif %}
17
+ {%- elif message.role == 'user' or message.role == 'assistant' %}
18
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>\n' }}
19
+ {%- else %}
20
+ {{- raise_exception('Limite Violetto supports only user, assistant, and the exact canonical system message; other roles are not supported.') }}
21
  {%- endif %}
22
  {%- endfor %}
23
  {%- if add_generation_prompt %}