File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -216,6 +216,31 @@ def parse_assistant_response(
216
216
return output , None
217
217
218
218
219
+ class Qwen2Template (BaseTemplate ):
220
+
221
+ name = "qwen2"
222
+ system_prompt = ""
223
+ allow_models = ["qwen2" ]
224
+ stop = {
225
+ "strings" : ["<|endoftext|>" , "<|im_end|>" ],
226
+ }
227
+
228
+ @property
229
+ def template (self ) -> str :
230
+ """ This template formats inputs in the standard ChatML format. See
231
+ https://github.com/openai/openai-python/blob/main/chatml.md
232
+ """
233
+ return (
234
+ "{{ system_prompt }}"
235
+ "{% for message in messages %}"
236
+ "{{ '<|im_start|>' + message['role'] + '\\ n' + message['content'] + '<|im_end|>' + '\\ n' }}"
237
+ "{% endfor %}"
238
+ "{% if add_generation_prompt %}"
239
+ "{{ '<|im_start|>assistant\\ n' }}"
240
+ "{% endif %}"
241
+ )
242
+
243
+
219
244
class Llama2Template (BaseTemplate ):
220
245
221
246
name = "llama2"
@@ -1354,6 +1379,7 @@ def template(self) -> str:
1354
1379
register_prompt_adapter (PhoenixTemplate )
1355
1380
1356
1381
register_prompt_adapter (QwenTemplate )
1382
+ register_prompt_adapter (Qwen2Template )
1357
1383
1358
1384
register_prompt_adapter (StarChatTemplate )
1359
1385
register_prompt_adapter (SusChatTemplate )
You can’t perform that action at this time.
0 commit comments