safounaldo commited on
Commit
8ba126b
·
verified ·
1 Parent(s): eebf3fe

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. 0 +91 -0
  2. chat_template.jinja +1 -0
0 ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set enable_thinking = true %}
2
+ {{- '<|im_start|>system\nCRITICAL INSTRUCTION: You must think step-by-step inside <think>...</think> tags. Your final answer MUST be wrapped exactly in \\boxed{}. The content of the \\boxed{} MUST be a single capital letter corresponding to the correct option (e.g., \\boxed{A}, \\boxed{B}). Do NOT output words like Yes, No, or Safe inside the box under any circumstances.<|im_end|>\n' }}
3
+ {%- if tools %}
4
+ {{- '<|im_start|>system\n' }}
5
+ {%- if messages[0].role == 'system' %}
6
+ {{- messages[0].content + '\n\n' }}
7
+ {%- endif %}
8
+ {{- "# 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>" }}
9
+ {%- for tool in tools %}
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><|im_end|>\n" }}
14
+ {%- else %}
15
+ {%- if messages[0].role == 'system' %}
16
+ {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
17
+ {%- endif %}
18
+ {%- endif %}
19
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
20
+ {%- for message in messages[::-1] %}
21
+ {%- set index = (messages|length - 1) - loop.index0 %}
22
+ {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
23
+ {%- set ns.multi_step_tool = false %}
24
+ {%- set ns.last_query_index = index %}
25
+ {%- endif %}
26
+ {%- endfor %}
27
+ {%- for message in messages %}
28
+ {%- if message.content is string %}
29
+ {%- set content = message.content %}
30
+ {%- else %}
31
+ {%- set content = '' %}
32
+ {%- endif %}
33
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
34
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
35
+ {%- elif message.role == "assistant" %}
36
+ {%- set reasoning_content = '' %}
37
+ {%- if message.reasoning_content is string %}
38
+ {%- set reasoning_content = message.reasoning_content %}
39
+ {%- else %}
40
+ {%- if '</think>' in content %}
41
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
42
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
43
+ {%- endif %}
44
+ {%- endif %}
45
+ {%- if loop.index0 > ns.last_query_index %}
46
+ {%- if loop.last or (not loop.last and reasoning_content) %}
47
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
48
+ {%- else %}
49
+ {{- '<|im_start|>' + message.role + '\n' + content }}
50
+ {%- endif %}
51
+ {%- else %}
52
+ {{- '<|im_start|>' + message.role + '\n' + content }}
53
+ {%- endif %}
54
+ {%- if message.tool_calls %}
55
+ {%- for tool_call in message.tool_calls %}
56
+ {%- if (loop.first and content) or (not loop.first) %}
57
+ {{- '\n' }}
58
+ {%- endif %}
59
+ {%- if tool_call.function %}
60
+ {%- set tool_call = tool_call.function %}
61
+ {%- endif %}
62
+ {{- '<tool_call>\n{"name": "' }}
63
+ {{- tool_call.name }}
64
+ {{- '", "arguments": ' }}
65
+ {%- if tool_call.arguments is string %}
66
+ {{- tool_call.arguments }}
67
+ {%- else %}
68
+ {{- tool_call.arguments | tojson }}
69
+ {%- endif %}
70
+ {{- '}\n</tool_call>' }}
71
+ {%- endfor %}
72
+ {%- endif %}
73
+ {{- '<|im_end|>\n' }}
74
+ {%- elif message.role == "tool" %}
75
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
76
+ {{- '<|im_start|>user' }}
77
+ {%- endif %}
78
+ {{- '\n<tool_response>\n' }}
79
+ {{- content }}
80
+ {{- '\n</tool_response>' }}
81
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
82
+ {{- '<|im_end|>\n' }}
83
+ {%- endif %}
84
+ {%- endif %}
85
+ {%- endfor %}
86
+ {%- if add_generation_prompt %}
87
+ {{- '<|im_start|>assistant\n' }}
88
+ {%- if enable_thinking is defined and enable_thinking is false %}
89
+ {{- '<think>\n\n</think>\n\n' }}
90
+ {%- endif %}
91
+ {%- endif %}
chat_template.jinja CHANGED
@@ -1,4 +1,5 @@
1
  {%- set enable_thinking = true %}
 
2
  {%- if tools %}
3
  {{- '<|im_start|>system\n' }}
4
  {%- if messages[0].role == 'system' %}
 
1
  {%- set enable_thinking = true %}
2
+ {{- '<|im_start|>system\nCRITICAL INSTRUCTION: You must think step-by-step inside <think>...</think> tags. Your final answer MUST be wrapped exactly in \\boxed{}. The content of the \\boxed{} MUST be a single capital letter corresponding to the correct option (e.g., \\boxed{A}, \\boxed{B}). Do NOT output words like Yes, No, or Safe inside the box under any circumstances.<|im_end|>\n' }}
3
  {%- if tools %}
4
  {{- '<|im_start|>system\n' }}
5
  {%- if messages[0].role == 'system' %}