ineso22 commited on
Commit
9d4cf8d
·
verified ·
1 Parent(s): 33ecd5f

Delete chat_template.jinja with huggingface_hub

Browse files
Files changed (1) hide show
  1. chat_template.jinja +0 -165
chat_template.jinja DELETED
@@ -1,165 +0,0 @@
1
- {# ----------‑‑‑ special token variables ‑‑‑---------- #}
2
- {%- set toolcall_begin_token = '<minimax:tool_call>' -%}
3
- {%- set toolcall_end_token = '</minimax:tool_call>' -%}
4
- {#- Tool Rendering Functions ============================================== -#}
5
- {%- macro render_tool_namespace(namespace_name, tool_list) -%}
6
- {%- for tool in tool_list -%}
7
- <tool>{{ tool.function | tojson(ensure_ascii=False) }}</tool>
8
- {% endfor -%}
9
- {%- endmacro -%}
10
- {%- macro visible_text(content) -%}
11
- {%- if content is string -%}
12
- {{ content }}
13
- {%- elif content is iterable and content is not mapping -%}
14
- {%- for item in content -%}
15
- {%- if item is mapping and item.type == 'text' -%}
16
- {{- item.text }}
17
- {%- elif item is string -%}
18
- {{- item }}
19
- {%- endif -%}
20
- {%- endfor -%}
21
- {%- elif content is none -%}
22
- {{- '' }}
23
- {%- else -%}
24
- {{- content }}
25
- {%- endif -%}
26
- {%- endmacro -%}
27
- {#- System Message Construction ============================================ -#}
28
- {%- macro build_system_message(system_message) -%}
29
- {%- if system_message and system_message.content -%}
30
- {{- visible_text(system_message.content) }}
31
- {%- else -%}
32
- {%- if model_identity is not defined -%}
33
- {%- set model_identity = "You are a helpful assistant. Your name is MiniMax-M2.1 and is built by MiniMax." -%}
34
- {%- endif -%}
35
- {{- model_identity }}
36
- {%- endif -%}
37
-
38
- {#- Handle current_date -#}
39
- {%- if system_message and system_message.current_date -%}
40
- {{- '\n' ~ 'Current date: ' + system_message.current_date }}
41
- {%- endif -%}
42
- {#- Handle current_location -#}
43
- {%- if system_message and system_message.current_location -%}
44
- {{- '\n' ~ 'Current location: ' + system_message.current_location }}
45
- {%- endif -%}
46
- {%- endmacro -%}
47
- {#- Main Template Logic ================================================= -#}
48
- {#- Extract system message (only first message if it's system) -#}
49
- {%- set system_message = none -%}
50
- {%- set conversation_messages = messages -%}
51
- {%- if messages and messages[0].role == "system" -%}
52
- {%- set system_message = messages[0] -%}
53
- {%- set conversation_messages = messages[1:] -%}
54
- {%- endif -%}
55
- {#- Get the last user message turn, for interleved thinking -#}
56
- {%- set ns = namespace(last_user_index=-1) %}
57
- {% for m in conversation_messages %}
58
- {%- if m.role == 'user' %}
59
- {% set ns.last_user_index = loop.index0 -%}
60
- {%- endif %}
61
- {%- endfor %}
62
- {#- Render system message -#}
63
- {{- ']~!b[' ~ ']~b]system' ~ '\n' }}
64
- {{- build_system_message(system_message) }}
65
- {#- Render tools if available -#}
66
- {%- if tools -%}
67
- {{- '\n\n' ~ '# Tools' ~ '\n' ~ 'You may call one or more tools to assist with the user query.\nHere are the tools available in JSONSchema format:' ~ '\n' }}
68
- {{- '\n' ~ '<tools>' ~ '\n' }}
69
- {{- render_tool_namespace("functions", tools) }}
70
- {{- '</tools>' ~ '\n\n' }}
71
- {{- 'When making tool calls, use XML format to invoke tools and pass parameters:' ~ '\n' }}
72
- {{- '\n' ~ toolcall_begin_token }}
73
- <invoke name="tool-name-1">
74
- <parameter name="param-key-1">param-value-1</parameter>
75
- <parameter name="param-key-2">param-value-2</parameter>
76
- ...
77
- </invoke>
78
- {{- '\n' ~ toolcall_end_token }}
79
- {%- endif -%}
80
- {{- '[e~[\n' }}
81
-
82
- {#- Render messages -#}
83
- {%- set last_tool_call = namespace(name=none) -%}
84
- {%- for message in conversation_messages -%}
85
- {%- if message.role == 'assistant' -%}
86
- {#- Only render reasoning_content if no user message follows -#}
87
- {{- ']~b]ai' ~ '\n' }}
88
-
89
- {%- set reasoning_content = '' %}
90
- {%- set content = visible_text(message.content) %}
91
- {%- if message.reasoning_content is string %}
92
- {%- set reasoning_content = message.reasoning_content %}
93
- {%- else %}
94
- {%- if '</think>' in content %}
95
- {%- set reasoning_content = content.split('</think>')[0].strip('\n').split('<think>')[-1].strip('\n') %}
96
- {%- set content = content.split('</think>')[-1].strip('\n') %}
97
- {%- endif %}
98
- {%- endif %}
99
- {%- if reasoning_content and loop.index0 > ns.last_user_index -%}
100
- {{- '<think>' ~ '\n' ~ reasoning_content ~ '\n' ~ '</think>' ~ '\n\n' }}
101
- {%- endif -%}
102
- {%- if content -%}
103
- {{- content }}
104
- {%- endif -%}
105
- {%- if message.tool_calls -%}
106
- {{- '\n' ~ toolcall_begin_token ~ '\n' }}
107
-
108
- {%- for tool_call in message.tool_calls -%}
109
- {%- if tool_call.function %}
110
- {%- set tool_call = tool_call.function %}
111
- {%- endif %}
112
- {{- '<invoke name="' + tool_call.name + '">' }}
113
- {% set _args = tool_call.arguments %}
114
- {%- for k, v in _args.items() %}
115
- {{- '<parameter name="' + k + '">' }}
116
- {{- v | tojson(ensure_ascii=False) if v is not string else v }}
117
- {{- '</parameter>' }}
118
- {% endfor %}
119
- {{- '</invoke>' ~ '\n' }}
120
- {%- endfor -%}
121
-
122
- {{- toolcall_end_token}}
123
- {%- if message.tool_calls[-1].function -%}
124
- {%- set last_tool_call.name = message.tool_calls[-1].function.name -%}
125
- {%- else -%}
126
- {%- set last_tool_call.name = message.tool_calls[-1].name -%}
127
- {%- endif -%}
128
- {%- else -%}
129
- {%- set last_tool_call.name = none -%}
130
- {%- endif -%}
131
- {{- '[e~[' ~ '\n' }}
132
-
133
- {%- elif message.role == 'tool' -%}
134
- {%- if last_tool_call.name is none -%}
135
- {{- raise_exception("Message has tool role, but there was no previous assistant message with a tool call!") }}
136
- {%- endif -%}
137
- {%- if loop.first or (conversation_messages[loop.index0 - 1].role != 'tool') -%}
138
- {{- ']~b]tool' }}
139
- {%- endif -%}
140
- {%- if message.content is string -%}
141
- {{- '\n<response>' }}
142
- {{- message.content }}
143
- {{- '</response>' }}
144
- {%- else -%}
145
- {%- for tr in message.content -%}
146
- {{- '\n<response>' }}
147
- {{- tr.output if tr.output is defined else (tr.text if tr.type == 'text' and tr.text is defined else tr) }}
148
- {{- '\n</response>' }}
149
- {%- endfor -%}
150
- {%- endif -%}
151
- {%- if loop.last or (conversation_messages[loop.index0 + 1].role != 'tool') -%}
152
- {{- '[e~[\n' -}}
153
- {%- endif -%}
154
-
155
- {%- elif message.role == 'user' -%}
156
- {{- ']~b]user' ~ '\n' }}
157
- {{- visible_text(message.content) }}
158
- {{- '[e~[' ~ '\n' }}
159
- {%- endif -%}
160
- {%- endfor -%}
161
-
162
- {#- Generation prompt -#}
163
- {%- if add_generation_prompt -%}
164
- {{- ']~b]ai' ~ '\n' ~ '<think>' ~ '\n' }}
165
- {%- endif -%}