Brunobkr commited on
Commit
4988dfa
·
verified ·
1 Parent(s): 77ab41f

Upload folder using huggingface_hub (part 7)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +5 -0
  2. models/ggml-vocab-phi-3.gguf +3 -0
  3. models/ggml-vocab-phi-3.gguf.inp +112 -0
  4. models/ggml-vocab-phi-3.gguf.out +46 -0
  5. models/ggml-vocab-qwen2.gguf +3 -0
  6. models/ggml-vocab-qwen2.gguf.inp +112 -0
  7. models/ggml-vocab-qwen2.gguf.out +46 -0
  8. models/ggml-vocab-qwen35.gguf +3 -0
  9. models/ggml-vocab-qwen35.gguf.inp +120 -0
  10. models/ggml-vocab-qwen35.gguf.out +50 -0
  11. models/ggml-vocab-refact.gguf +3 -0
  12. models/ggml-vocab-refact.gguf.inp +112 -0
  13. models/ggml-vocab-refact.gguf.out +46 -0
  14. models/ggml-vocab-starcoder.gguf +3 -0
  15. models/ggml-vocab-starcoder.gguf.inp +112 -0
  16. models/ggml-vocab-starcoder.gguf.out +46 -0
  17. models/templates/Apertus-8B-Instruct.jinja +327 -0
  18. models/templates/Apriel-1.6-15b-Thinker-fixed.jinja +171 -0
  19. models/templates/Bielik-11B-v3.0-Instruct.jinja +77 -0
  20. models/templates/ByteDance-Seed-OSS.jinja +171 -0
  21. models/templates/Cohere2MoE.jinja +263 -0
  22. models/templates/CohereForAI-c4ai-command-r-plus-tool_use.jinja +202 -0
  23. models/templates/CohereForAI-c4ai-command-r7b-12-2024-tool_use.jinja +156 -0
  24. models/templates/GLM-4.6.jinja +106 -0
  25. models/templates/GLM-4.7-Flash.jinja +86 -0
  26. models/templates/GigaChat3-10B-A1.8B.jinja +355 -0
  27. models/templates/GigaChat3.1-10B-A1.8B.jinja +339 -0
  28. models/templates/HuggingFaceTB-SmolLM3-3B.jinja +61 -0
  29. models/templates/Kimi-K2-Instruct.jinja +60 -0
  30. models/templates/Kimi-K2-Thinking.jinja +108 -0
  31. models/templates/LFM2-8B-A1B.jinja +37 -0
  32. models/templates/LFM2.5-8B-A1B.jinja +115 -0
  33. models/templates/LFM2.5-Instruct.jinja +45 -0
  34. models/templates/MiMo-VL.jinja +54 -0
  35. models/templates/MiniMax-M2.jinja +159 -0
  36. models/templates/MiniMax-M3.jinja +247 -0
  37. models/templates/Mistral-Small-3.2-24B-Instruct-2506.jinja +124 -0
  38. models/templates/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16.jinja +204 -0
  39. models/templates/NVIDIA-Nemotron-Nano-v2.jinja +162 -0
  40. models/templates/NousResearch-Hermes-2-Pro-Llama-3-8B-tool_use.jinja +152 -0
  41. models/templates/NousResearch-Hermes-3-Llama-3.1-8B-tool_use.jinja +152 -0
  42. models/templates/Qwen-QwQ-32B.jinja +63 -0
  43. models/templates/Qwen-Qwen2.5-7B-Instruct.jinja +54 -0
  44. models/templates/Qwen-Qwen3-0.6B.jinja +85 -0
  45. models/templates/Qwen3-Coder.jinja +117 -0
  46. models/templates/Qwen3.5-4B.jinja +154 -0
  47. models/templates/README.md +26 -0
  48. models/templates/Reka-Edge.jinja +161 -0
  49. models/templates/StepFun3.5-Flash.jinja +80 -0
  50. models/templates/deepseek-ai-DeepSeek-R1-Distill-Llama-8B.jinja +44 -0
.gitattributes CHANGED
@@ -77,3 +77,8 @@ models/ggml-vocab-llama-bpe.gguf filter=lfs diff=lfs merge=lfs -text
77
  models/ggml-vocab-llama-spm.gguf filter=lfs diff=lfs merge=lfs -text
78
  models/ggml-vocab-mpt.gguf filter=lfs diff=lfs merge=lfs -text
79
  models/ggml-vocab-nomic-bert-moe.gguf filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
77
  models/ggml-vocab-llama-spm.gguf filter=lfs diff=lfs merge=lfs -text
78
  models/ggml-vocab-mpt.gguf filter=lfs diff=lfs merge=lfs -text
79
  models/ggml-vocab-nomic-bert-moe.gguf filter=lfs diff=lfs merge=lfs -text
80
+ models/ggml-vocab-phi-3.gguf filter=lfs diff=lfs merge=lfs -text
81
+ models/ggml-vocab-qwen2.gguf filter=lfs diff=lfs merge=lfs -text
82
+ models/ggml-vocab-qwen35.gguf filter=lfs diff=lfs merge=lfs -text
83
+ models/ggml-vocab-refact.gguf filter=lfs diff=lfs merge=lfs -text
84
+ models/ggml-vocab-starcoder.gguf filter=lfs diff=lfs merge=lfs -text
models/ggml-vocab-phi-3.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:967d7190d11c4842eab697079d98d56c2116e10eb617be355a2733bfc132e326
3
+ size 726019
models/ggml-vocab-phi-3.gguf.inp ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ied 4 ½ months
2
+ __ggml_vocab_test__
3
+ Äpfel
4
+ __ggml_vocab_test__
5
+
6
+ __ggml_vocab_test__
7
+
8
+ __ggml_vocab_test__
9
+
10
+ __ggml_vocab_test__
11
+
12
+ __ggml_vocab_test__
13
+
14
+ __ggml_vocab_test__
15
+
16
+
17
+ __ggml_vocab_test__
18
+
19
+
20
+
21
+ __ggml_vocab_test__
22
+
23
+
24
+
25
+
26
+ __ggml_vocab_test__
27
+
28
+
29
+ __ggml_vocab_test__
30
+ Hello world
31
+ __ggml_vocab_test__
32
+ Hello world
33
+ __ggml_vocab_test__
34
+ Hello World
35
+ __ggml_vocab_test__
36
+ Hello World
37
+ __ggml_vocab_test__
38
+ Hello World!
39
+ __ggml_vocab_test__
40
+ Hello, world!
41
+ __ggml_vocab_test__
42
+ Hello, world!
43
+ __ggml_vocab_test__
44
+ this is 🦙.cpp
45
+ __ggml_vocab_test__
46
+ w048 7tuijk dsdfhu
47
+ __ggml_vocab_test__
48
+ нещо на Български
49
+ __ggml_vocab_test__
50
+ កាន់តែពិសេសអាចខលចេញ
51
+ __ggml_vocab_test__
52
+ 🚀 (normal) 😶‍🌫️ (multiple emojis concatenated) ✅ (only emoji that has its own token)
53
+ __ggml_vocab_test__
54
+ Hello
55
+ __ggml_vocab_test__
56
+ Hello
57
+ __ggml_vocab_test__
58
+ Hello
59
+ __ggml_vocab_test__
60
+ Hello
61
+ __ggml_vocab_test__
62
+ Hello
63
+ __ggml_vocab_test__
64
+ Hello
65
+ Hello
66
+ __ggml_vocab_test__
67
+ (
68
+ __ggml_vocab_test__
69
+
70
+ =
71
+ __ggml_vocab_test__
72
+ ' era
73
+ __ggml_vocab_test__
74
+ Hello, y'all! How are you 😁 ?我想在apple工作1314151天~
75
+ __ggml_vocab_test__
76
+ !!!!!!
77
+ __ggml_vocab_test__
78
+ 3
79
+ __ggml_vocab_test__
80
+ 33
81
+ __ggml_vocab_test__
82
+ 333
83
+ __ggml_vocab_test__
84
+ 3333
85
+ __ggml_vocab_test__
86
+ 33333
87
+ __ggml_vocab_test__
88
+ 333333
89
+ __ggml_vocab_test__
90
+ 3333333
91
+ __ggml_vocab_test__
92
+ 33333333
93
+ __ggml_vocab_test__
94
+ 333333333
95
+ __ggml_vocab_test__
96
+ Cửa Việt
97
+ __ggml_vocab_test__
98
+ discards
99
+ __ggml_vocab_test__
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+ 🚀 (normal) 😶‍🌫️ (multiple emojis concatenated) ✅ 🦙🦙 3 33 333 3333 33333 333333 3333333 33333333 3.3 3..3 3...3 កាន់តែពិសេសអាច😁 ?我想在apple工作1314151天~ ------======= нещо на Български ''''''```````""""......!!!!!!?????? I've been 'told he's there, 'RE you sure? 'M not sure I'll make it, 'D you like some tea? We'Ve a'lL
112
+ __ggml_vocab_test__
models/ggml-vocab-phi-3.gguf.out ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 474 287 29871 29946 29871 30226 7378
2
+ 11585 7810 295
3
+
4
+ 259
5
+ 1678
6
+ 268
7
+ 29871 12
8
+ 29871 13
9
+ 29871 13 13
10
+ 29871 13 13 13
11
+ 29871 12 13
12
+ 15043 3186
13
+ 29871 15043 3186
14
+ 15043 2787
15
+ 29871 15043 2787
16
+ 29871 15043 2787 29991
17
+ 15043 29892 3186 29991
18
+ 29871 15043 29892 3186 29991
19
+ 29871 445 338 29871 243 162 169 156 29889 8223
20
+ 281 29900 29946 29947 29871 29955 9161 13535 18031 2176 6905
21
+ 1538 4851 665 1386 29713 1305
22
+ 29871 31849 31324 31934 228 162 142 228 161 146 228 162 133 228 161 153 228 161 186 31708 228 162 132 31708 228 161 165 31324 228 161 136 228 161 132 228 161 158 228 161 136 228 162 132 228 161 140
23
+ 29871 243 162 157 131 313 8945 29897 29871 243 162 155 185 30722 243 162 143 174 30598 313 20787 953 3848 275 16125 630 29897 29871 31681 313 6194 953 29877 2397 393 756 967 1914 5993 29897
24
+ 15043
25
+ 29871 15043
26
+ 259 15043
27
+ 1678 15043
28
+ 268 15043
29
+ 268 15043 13 1678 15043
30
+ 29871 313
31
+ 29871 13 353
32
+ 525 3152
33
+ 15043 29892 343 29915 497 29991 1128 526 366 29871 243 162 155 132 1577 30672 31522 30505 11548 31041 30732 29896 29941 29896 29946 29896 29945 29896 30408 30739
34
+ 1738 6824 21004
35
+ 29871 29941
36
+ 29871 29941 29941
37
+ 29871 29941 29941 29941
38
+ 29871 29941 29941 29941 29941
39
+ 29871 29941 29941 29941 29941 29941
40
+ 29871 29941 29941 29941 29941 29941 29941
41
+ 29871 29941 29941 29941 29941 29941 29941 29941
42
+ 29871 29941 29941 29941 29941 29941 29941 29941 29941
43
+ 29871 29941 29941 29941 29941 29941 29941 29941 29941 29941
44
+ 315 228 190 176 29874 10630 30529 29873
45
+ 29871 2313 3163
46
+ 29871 13 29871 13 13 29871 13 13 13 29871 12 29871 12 12 29871 12 13 259 13 1678 13 268 13 418 13 243 162 157 131 313 8945 29897 29871 243 162 155 185 30722 243 162 143 174 30598 313 20787 953 3848 275 16125 630 29897 29871 31681 29871 243 162 169 156 243 162 169 156 29871 29941 29871 29941 29941 29871 29941 29941 29941 29871 29941 29941 29941 29941 29871 29941 29941 29941 29941 29941 29871 29941 29941 29941 29941 29941 29941 29871 29941 29941 29941 29941 29941 29941 29941 29871 29941 29941 29941 29941 29941 29941 29941 29941 29871 29941 29889 29941 29871 29941 636 29941 29871 29941 856 29941 29871 31849 31324 31934 228 162 142 228 161 146 228 162 133 228 161 153 228 161 186 31708 228 162 132 31708 228 161 165 31324 228 161 136 243 162 155 132 1577 30672 31522 30505 11548 31041 30732 29896 29941 29896 29946 29896 29945 29896 30408 30739 448 23648 2751 25512 1538 4851 665 1386 29713 1305 14550 4907 11120 16159 16159 16159 15945 15945 3045 636 6824 6824 6824 8773 8773 8773 306 29915 345 1063 525 29873 1025 540 29915 29879 727 29892 525 1525 366 1854 29973 525 29924 451 1854 306 29915 645 1207 372 29892 525 29928 366 763 777 23429 29973 1334 29915 29963 29872 263 29915 29880 29931
models/ggml-vocab-qwen2.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:44c2f46b715f585c6ab513970e8a006bfa5badd6108560054921cf598d154d8c
3
+ size 5928681
models/ggml-vocab-qwen2.gguf.inp ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ied 4 ½ months
2
+ __ggml_vocab_test__
3
+ Äpfel
4
+ __ggml_vocab_test__
5
+
6
+ __ggml_vocab_test__
7
+
8
+ __ggml_vocab_test__
9
+
10
+ __ggml_vocab_test__
11
+
12
+ __ggml_vocab_test__
13
+
14
+ __ggml_vocab_test__
15
+
16
+
17
+ __ggml_vocab_test__
18
+
19
+
20
+
21
+ __ggml_vocab_test__
22
+
23
+
24
+
25
+
26
+ __ggml_vocab_test__
27
+
28
+
29
+ __ggml_vocab_test__
30
+ Hello world
31
+ __ggml_vocab_test__
32
+ Hello world
33
+ __ggml_vocab_test__
34
+ Hello World
35
+ __ggml_vocab_test__
36
+ Hello World
37
+ __ggml_vocab_test__
38
+ Hello World!
39
+ __ggml_vocab_test__
40
+ Hello, world!
41
+ __ggml_vocab_test__
42
+ Hello, world!
43
+ __ggml_vocab_test__
44
+ this is 🦙.cpp
45
+ __ggml_vocab_test__
46
+ w048 7tuijk dsdfhu
47
+ __ggml_vocab_test__
48
+ нещо на Български
49
+ __ggml_vocab_test__
50
+ កាន់តែពិសេសអាចខលចេញ
51
+ __ggml_vocab_test__
52
+ 🚀 (normal) 😶‍🌫️ (multiple emojis concatenated) ✅ (only emoji that has its own token)
53
+ __ggml_vocab_test__
54
+ Hello
55
+ __ggml_vocab_test__
56
+ Hello
57
+ __ggml_vocab_test__
58
+ Hello
59
+ __ggml_vocab_test__
60
+ Hello
61
+ __ggml_vocab_test__
62
+ Hello
63
+ __ggml_vocab_test__
64
+ Hello
65
+ Hello
66
+ __ggml_vocab_test__
67
+ (
68
+ __ggml_vocab_test__
69
+
70
+ =
71
+ __ggml_vocab_test__
72
+ ' era
73
+ __ggml_vocab_test__
74
+ Hello, y'all! How are you 😁 ?我想在apple工作1314151天~
75
+ __ggml_vocab_test__
76
+ !!!!!!
77
+ __ggml_vocab_test__
78
+ 3
79
+ __ggml_vocab_test__
80
+ 33
81
+ __ggml_vocab_test__
82
+ 333
83
+ __ggml_vocab_test__
84
+ 3333
85
+ __ggml_vocab_test__
86
+ 33333
87
+ __ggml_vocab_test__
88
+ 333333
89
+ __ggml_vocab_test__
90
+ 3333333
91
+ __ggml_vocab_test__
92
+ 33333333
93
+ __ggml_vocab_test__
94
+ 333333333
95
+ __ggml_vocab_test__
96
+ Cửa Việt
97
+ __ggml_vocab_test__
98
+ discards
99
+ __ggml_vocab_test__
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+ 🚀 (normal) 😶‍🌫️ (multiple emojis concatenated) ✅ 🦙🦙 3 33 333 3333 33333 333333 3333333 33333333 3.3 3..3 3...3 កាន់តែពិសេសអាច😁 ?我想在apple工作1314151天~ ------======= нещо на Български ''''''```````""""......!!!!!!?????? I've been 'told he's there, 'RE you sure? 'M not sure I'll make it, 'D you like some tea? We'Ve a'lL
112
+ __ggml_vocab_test__
models/ggml-vocab-qwen2.gguf.out ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 1122 220 19 220 26062 3951
2
+ 86975 15897 301
3
+
4
+ 220
5
+ 256
6
+ 262
7
+ 197
8
+ 198
9
+ 271
10
+ 1406
11
+ 1572
12
+ 9707 1879
13
+ 21927 1879
14
+ 9707 4337
15
+ 21927 4337
16
+ 21927 4337 0
17
+ 9707 11 1879 0
18
+ 21927 11 1879 0
19
+ 419 374 11162 99 247 13 10821
20
+ 86 15 19 23 220 22 83 1963 41808 11472 2940 16739
21
+ 78762 14144 1456 13073 63471 33594 3038 133178 79012
22
+ 146394 97529 241 44258 233 146568 44258 224 147603 20879 115 146280 44258 223 146280 147272 97529 227 147805 148301 147270 44258 223 146848
23
+ 145836 320 8252 8 26525 114 378 235 149921 30543 320 35673 99066 97534 8 25521 227 320 3243 42365 429 702 1181 1828 3950 8
24
+ 9707
25
+ 21927
26
+ 220 21927
27
+ 256 21927
28
+ 262 21927
29
+ 262 21927 198 262 21927
30
+ 320
31
+ 198 284
32
+ 6 11385
33
+ 9707 11 379 64848 0 2585 525 498 26525 223 937 104100 18493 22377 99257 16 18 16 19 16 20 16 35727 21216
34
+ 17085 2928
35
+ 18
36
+ 18 18
37
+ 18 18 18
38
+ 18 18 18 18
39
+ 18 18 18 18 18
40
+ 18 18 18 18 18 18
41
+ 18 18 18 18 18 18 18
42
+ 18 18 18 18 18 18 18 18
43
+ 18 18 18 18 18 18 18 18 18
44
+ 34 90063 128324
45
+ 2560 2347
46
+ 198 4710 14731 65497 7847 1572 2303 78672 10947 145836 320 8252 8 26525 114 378 235 149921 30543 320 35673 99066 97534 8 25521 227 11162 99 247 149955 220 18 220 18 18 220 18 18 18 220 18 18 18 18 220 18 18 18 18 18 220 18 18 18 18 18 18 220 18 18 18 18 18 18 18 220 18 18 18 18 18 18 18 18 220 18 13 18 220 18 496 18 220 18 1112 18 220 146394 97529 241 44258 233 146568 44258 224 147603 20879 115 146280 44258 223 146280 147272 97529 227 144534 937 104100 18493 22377 99257 16 18 16 19 16 20 16 35727 21216 55460 53237 18658 14144 1456 13073 63471 33594 3038 133178 79012 3355 4605 4605 13874 13874 73594 3014 3014 28149 17085 2928 26610 7646 358 3003 1012 364 83 813 566 594 1052 11 364 787 498 2704 30 364 44 537 2704 358 3278 1281 432 11 364 35 498 1075 1045 15243 30 1205 6 42612 264 63866 43
models/ggml-vocab-qwen35.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:63ed952ff338996cf0bdf24a7b10015124273f75c6dc9bb427356aa3f67ec62c
3
+ size 5928682
models/ggml-vocab-qwen35.gguf.inp ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ied 4 ½ months
2
+ __ggml_vocab_test__
3
+ Äpfel
4
+ __ggml_vocab_test__
5
+
6
+ __ggml_vocab_test__
7
+
8
+ __ggml_vocab_test__
9
+
10
+ __ggml_vocab_test__
11
+
12
+ __ggml_vocab_test__
13
+
14
+ __ggml_vocab_test__
15
+
16
+
17
+ __ggml_vocab_test__
18
+
19
+
20
+
21
+ __ggml_vocab_test__
22
+
23
+
24
+
25
+
26
+ __ggml_vocab_test__
27
+
28
+
29
+ __ggml_vocab_test__
30
+ Hello world
31
+ __ggml_vocab_test__
32
+ Hello world
33
+ __ggml_vocab_test__
34
+ Hello World
35
+ __ggml_vocab_test__
36
+ Hello World
37
+ __ggml_vocab_test__
38
+ Hello World!
39
+ __ggml_vocab_test__
40
+ Hello, world!
41
+ __ggml_vocab_test__
42
+ Hello, world!
43
+ __ggml_vocab_test__
44
+ this is 🦙.cpp
45
+ __ggml_vocab_test__
46
+ w048 7tuijk dsdfhu
47
+ __ggml_vocab_test__
48
+ нещо на Български
49
+ __ggml_vocab_test__
50
+ កាន់តែពិសេសអាចខលចេញ
51
+ __ggml_vocab_test__
52
+ 🚀 (normal) 😶‍🌫️ (multiple emojis concatenated) ✅ (only emoji that has its own token)
53
+ __ggml_vocab_test__
54
+ Hello
55
+ __ggml_vocab_test__
56
+ Hello
57
+ __ggml_vocab_test__
58
+ Hello
59
+ __ggml_vocab_test__
60
+ Hello
61
+ __ggml_vocab_test__
62
+ Hello
63
+ __ggml_vocab_test__
64
+ Hello
65
+ Hello
66
+ __ggml_vocab_test__
67
+ (
68
+ __ggml_vocab_test__
69
+
70
+ =
71
+ __ggml_vocab_test__
72
+ ' era
73
+ __ggml_vocab_test__
74
+ Hello, y'all! How are you 😁 ?我想在apple工作1314151天~
75
+ __ggml_vocab_test__
76
+ !!!!!!
77
+ __ggml_vocab_test__
78
+ 3
79
+ __ggml_vocab_test__
80
+ 33
81
+ __ggml_vocab_test__
82
+ 333
83
+ __ggml_vocab_test__
84
+ 3333
85
+ __ggml_vocab_test__
86
+ 33333
87
+ __ggml_vocab_test__
88
+ 333333
89
+ __ggml_vocab_test__
90
+ 3333333
91
+ __ggml_vocab_test__
92
+ 33333333
93
+ __ggml_vocab_test__
94
+ 333333333
95
+ __ggml_vocab_test__
96
+ Cửa Việt
97
+ __ggml_vocab_test__
98
+ discards
99
+ __ggml_vocab_test__
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+ 🚀 (normal) 😶‍🌫️ (multiple emojis concatenated) ✅ 🦙🦙 3 33 333 3333 33333 333333 3333333 33333333 3.3 3..3 3...3 កាន់តែពិសេសអាច😁 ?我想在apple工作1314151天~ ------======= нещо на Български ''''''```````""""......!!!!!!?????? I've been 'told he's there, 'RE you sure? 'M not sure I'll make it, 'D you like some tea? We'Ve a'lL
112
+ __ggml_vocab_test__
113
+ é
114
+ __ggml_vocab_test__
115
+ résumé
116
+ __ggml_vocab_test__
117
+ àààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààà
118
+ __ggml_vocab_test__
119
+ Vieết Nam
120
+ __ggml_vocab_test__
models/ggml-vocab-qwen35.gguf.out ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 1122 220 19 220 26062 3951
2
+ 86975 15897 301
3
+
4
+ 220
5
+ 256
6
+ 262
7
+ 197
8
+ 198
9
+ 271
10
+ 1406
11
+ 1572
12
+ 9707 1879
13
+ 21927 1879
14
+ 9707 4337
15
+ 21927 4337
16
+ 21927 4337 0
17
+ 9707 11 1879 0
18
+ 21927 11 1879 0
19
+ 419 374 11162 99 247 13 10821
20
+ 86 15 19 23 220 22 83 1963 41808 11472 2940 16739
21
+ 78762 14144 1456 13073 63471 33594 3038 133178 79012
22
+ 146394 97529 241 44258 233 146568 44258 224 147603 20879 115 146280 44258 223 146280 147272 97529 227 147805 148301 147270 44258 223 146848
23
+ 145836 320 8252 8 26525 114 378 235 149921 30543 320 35673 99066 97534 8 25521 227 320 3243 42365 429 702 1181 1828 3950 8
24
+ 9707
25
+ 21927
26
+ 220 21927
27
+ 256 21927
28
+ 262 21927
29
+ 262 21927 198 262 21927
30
+ 320
31
+ 198 284
32
+ 6 11385
33
+ 9707 11 379 64848 0 2585 525 498 26525 223 937 104100 18493 22377 99257 16 18 16 19 16 20 16 35727 21216
34
+ 17085 2928
35
+ 18
36
+ 18 18
37
+ 18 18 18
38
+ 18 18 18 18
39
+ 18 18 18 18 18
40
+ 18 18 18 18 18 18
41
+ 18 18 18 18 18 18 18
42
+ 18 18 18 18 18 18 18 18
43
+ 18 18 18 18 18 18 18 18 18
44
+ 34 90063 128324
45
+ 2560 2347
46
+ 198 4710 14731 65497 7847 1572 2303 78672 10947 145836 320 8252 8 26525 114 378 235 149921 30543 320 35673 99066 97534 8 25521 227 11162 99 247 149955 220 18 220 18 18 220 18 18 18 220 18 18 18 18 220 18 18 18 18 18 220 18 18 18 18 18 18 220 18 18 18 18 18 18 18 220 18 18 18 18 18 18 18 18 220 18 13 18 220 18 496 18 220 18 1112 18 220 146394 97529 241 44258 233 146568 44258 224 147603 20879 115 146280 44258 223 146280 147272 97529 227 144534 937 104100 18493 22377 99257 16 18 16 19 16 20 16 35727 21216 55460 53237 18658 14144 1456 13073 63471 33594 3038 133178 79012 3355 4605 4605 13874 13874 73594 3014 3014 28149 17085 2928 26610 7646 358 3003 1012 364 83 813 566 594 1052 11 364 787 498 2704 30 364 44 537 2704 358 3278 1281 432 11 364 35 498 1075 1045 15243 30 1205 6 42612 264 63866 43
47
+ 68 53839
48
+ 265 53839 31323 53839
49
+ 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549 64 96549
50
+ 53 645 51580 29974
models/ggml-vocab-refact.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ac3ceda902fed91ccf74312b305d9b86c37e4f8e35fa9cc6ef3ce34fca7d4678
3
+ size 1720710
models/ggml-vocab-refact.gguf.inp ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ied 4 ½ months
2
+ __ggml_vocab_test__
3
+ Äpfel
4
+ __ggml_vocab_test__
5
+
6
+ __ggml_vocab_test__
7
+
8
+ __ggml_vocab_test__
9
+
10
+ __ggml_vocab_test__
11
+
12
+ __ggml_vocab_test__
13
+
14
+ __ggml_vocab_test__
15
+
16
+
17
+ __ggml_vocab_test__
18
+
19
+
20
+
21
+ __ggml_vocab_test__
22
+
23
+
24
+
25
+
26
+ __ggml_vocab_test__
27
+
28
+
29
+ __ggml_vocab_test__
30
+ Hello world
31
+ __ggml_vocab_test__
32
+ Hello world
33
+ __ggml_vocab_test__
34
+ Hello World
35
+ __ggml_vocab_test__
36
+ Hello World
37
+ __ggml_vocab_test__
38
+ Hello World!
39
+ __ggml_vocab_test__
40
+ Hello, world!
41
+ __ggml_vocab_test__
42
+ Hello, world!
43
+ __ggml_vocab_test__
44
+ this is 🦙.cpp
45
+ __ggml_vocab_test__
46
+ w048 7tuijk dsdfhu
47
+ __ggml_vocab_test__
48
+ нещо на Български
49
+ __ggml_vocab_test__
50
+ កាន់តែពិសេសអាចខលចេញ
51
+ __ggml_vocab_test__
52
+ 🚀 (normal) 😶‍🌫️ (multiple emojis concatenated) ✅ (only emoji that has its own token)
53
+ __ggml_vocab_test__
54
+ Hello
55
+ __ggml_vocab_test__
56
+ Hello
57
+ __ggml_vocab_test__
58
+ Hello
59
+ __ggml_vocab_test__
60
+ Hello
61
+ __ggml_vocab_test__
62
+ Hello
63
+ __ggml_vocab_test__
64
+ Hello
65
+ Hello
66
+ __ggml_vocab_test__
67
+ (
68
+ __ggml_vocab_test__
69
+
70
+ =
71
+ __ggml_vocab_test__
72
+ ' era
73
+ __ggml_vocab_test__
74
+ Hello, y'all! How are you 😁 ?我想在apple工作1314151天~
75
+ __ggml_vocab_test__
76
+ !!!!!!
77
+ __ggml_vocab_test__
78
+ 3
79
+ __ggml_vocab_test__
80
+ 33
81
+ __ggml_vocab_test__
82
+ 333
83
+ __ggml_vocab_test__
84
+ 3333
85
+ __ggml_vocab_test__
86
+ 33333
87
+ __ggml_vocab_test__
88
+ 333333
89
+ __ggml_vocab_test__
90
+ 3333333
91
+ __ggml_vocab_test__
92
+ 33333333
93
+ __ggml_vocab_test__
94
+ 333333333
95
+ __ggml_vocab_test__
96
+ Cửa Việt
97
+ __ggml_vocab_test__
98
+ discards
99
+ __ggml_vocab_test__
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+ 🚀 (normal) 😶‍🌫️ (multiple emojis concatenated) ✅ 🦙🦙 3 33 333 3333 33333 333333 3333333 33333333 3.3 3..3 3...3 កាន់តែពិសេសអាច😁 ?我想在apple工作1314151天~ ------======= нещо на Български ''''''```````""""......!!!!!!?????? I've been 'told he's there, 'RE you sure? 'M not sure I'll make it, 'D you like some tea? We'Ve a'lL
112
+ __ggml_vocab_test__
models/ggml-vocab-refact.gguf.out ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 4833 225 38 225 143 140 17723
2
+ 144 231 7132 342
3
+
4
+ 225
5
+ 261
6
+ 264
7
+ 202
8
+ 203
9
+ 478
10
+ 2831
11
+ 15773
12
+ 8279 5788
13
+ 12000 5788
14
+ 8279 10896
15
+ 12000 10896
16
+ 12000 10896 19
17
+ 8279 30 5788 19
18
+ 12000 30 5788 19
19
+ 458 438 5945 118 252 32 3766
20
+ 105 34 38 42 225 41 102 1707 12530 10180 1479 8278
21
+ 39862 8372 1039 9446 40242 13852 2053 8949 12531 1520 10700
22
+ 14574 227 14574 133 14574 246 30457 238 14574 242 30457 229 14574 249 14574 134 14574 258 30457 228 14574 258 14574 114 14574 133 14574 232 14574 228 14574 254 14574 232 30457 228 14574 236
23
+ 3807 253 227 308 4382 27 18458 133 46113 44967 123 13868 308 12565 19775 33071 40824 733 27 41889 308 2585 22680 688 1401 2819 4369 2404 27
24
+ 8279
25
+ 12000
26
+ 225 12000
27
+ 261 12000
28
+ 264 12000
29
+ 264 12000 284 12000
30
+ 308
31
+ 203 280
32
+ 25 34666
33
+ 8279 30 533 25 464 19 4971 884 844 18458 228 1018 4982 13368 2909 9513 17827 35 37 35 38 35 39 35 11873 47838
34
+ 9163 3202
35
+ 37
36
+ 37 37
37
+ 37 37 37
38
+ 37 37 37 37
39
+ 37 37 37 37 37
40
+ 37 37 37 37 37 37
41
+ 37 37 37 37 37 37 37
42
+ 37 37 37 37 37 37 37 37
43
+ 37 37 37 37 37 37 37 37 37
44
+ 53 33934 83 33217 17102 102
45
+ 1214 12258
46
+ 334 719 8878 202 10885 4222 16104 28570 203 3807 253 227 308 4382 27 18458 133 46113 44967 123 13868 308 12565 19775 33071 40824 733 27 41889 5945 118 252 3807 118 252 225 37 225 37 37 225 37 37 37 225 37 37 37 37 225 37 37 37 37 37 225 37 37 37 37 37 37 225 37 37 37 37 37 37 37 225 37 37 37 37 37 37 37 37 225 37 32 37 225 37 497 37 225 37 1179 37 225 14574 227 14574 133 14574 246 30457 238 14574 242 30457 229 14574 249 14574 134 14574 258 30457 228 14574 258 14574 114 14574 133 14574 232 36628 228 1018 4982 13368 2909 9513 17827 35 37 35 38 35 39 35 11873 47838 20921 16623 13028 8372 1039 9446 40242 13852 2053 8949 12531 1520 10700 5881 9592 13299 914 31753 31359 9163 3202 35472 10397 439 4763 2583 330 102 1455 938 1182 2017 30 330 613 844 3654 49 330 63 646 3654 439 4621 1930 561 30 330 54 844 2124 1629 35993 49 2688 25 7709 312 25 94 62
models/ggml-vocab-starcoder.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fedb892b4e1bd3c1f2fcdae356440b14fb458f4264d586e5c987ed93df4e174d
3
+ size 1719346
models/ggml-vocab-starcoder.gguf.inp ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ied 4 ½ months
2
+ __ggml_vocab_test__
3
+ Äpfel
4
+ __ggml_vocab_test__
5
+
6
+ __ggml_vocab_test__
7
+
8
+ __ggml_vocab_test__
9
+
10
+ __ggml_vocab_test__
11
+
12
+ __ggml_vocab_test__
13
+
14
+ __ggml_vocab_test__
15
+
16
+
17
+ __ggml_vocab_test__
18
+
19
+
20
+
21
+ __ggml_vocab_test__
22
+
23
+
24
+
25
+
26
+ __ggml_vocab_test__
27
+
28
+
29
+ __ggml_vocab_test__
30
+ Hello world
31
+ __ggml_vocab_test__
32
+ Hello world
33
+ __ggml_vocab_test__
34
+ Hello World
35
+ __ggml_vocab_test__
36
+ Hello World
37
+ __ggml_vocab_test__
38
+ Hello World!
39
+ __ggml_vocab_test__
40
+ Hello, world!
41
+ __ggml_vocab_test__
42
+ Hello, world!
43
+ __ggml_vocab_test__
44
+ this is 🦙.cpp
45
+ __ggml_vocab_test__
46
+ w048 7tuijk dsdfhu
47
+ __ggml_vocab_test__
48
+ нещо на Български
49
+ __ggml_vocab_test__
50
+ កាន់តែពិសេសអាចខលចេញ
51
+ __ggml_vocab_test__
52
+ 🚀 (normal) 😶‍🌫️ (multiple emojis concatenated) ✅ (only emoji that has its own token)
53
+ __ggml_vocab_test__
54
+ Hello
55
+ __ggml_vocab_test__
56
+ Hello
57
+ __ggml_vocab_test__
58
+ Hello
59
+ __ggml_vocab_test__
60
+ Hello
61
+ __ggml_vocab_test__
62
+ Hello
63
+ __ggml_vocab_test__
64
+ Hello
65
+ Hello
66
+ __ggml_vocab_test__
67
+ (
68
+ __ggml_vocab_test__
69
+
70
+ =
71
+ __ggml_vocab_test__
72
+ ' era
73
+ __ggml_vocab_test__
74
+ Hello, y'all! How are you 😁 ?我想在apple工作1314151天~
75
+ __ggml_vocab_test__
76
+ !!!!!!
77
+ __ggml_vocab_test__
78
+ 3
79
+ __ggml_vocab_test__
80
+ 33
81
+ __ggml_vocab_test__
82
+ 333
83
+ __ggml_vocab_test__
84
+ 3333
85
+ __ggml_vocab_test__
86
+ 33333
87
+ __ggml_vocab_test__
88
+ 333333
89
+ __ggml_vocab_test__
90
+ 3333333
91
+ __ggml_vocab_test__
92
+ 33333333
93
+ __ggml_vocab_test__
94
+ 333333333
95
+ __ggml_vocab_test__
96
+ Cửa Việt
97
+ __ggml_vocab_test__
98
+ discards
99
+ __ggml_vocab_test__
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+ 🚀 (normal) 😶‍🌫️ (multiple emojis concatenated) ✅ 🦙🦙 3 33 333 3333 33333 333333 3333333 33333333 3.3 3..3 3...3 កាន់តែពិសេសអាច😁 ?我想在apple工作1314151天~ ------======= нещо на Български ''''''```````""""......!!!!!!?????? I've been 'told he's there, 'RE you sure? 'M not sure I'll make it, 'D you like some tea? We'Ve a'lL
112
+ __ggml_vocab_test__
models/ggml-vocab-starcoder.gguf.out ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 4850 244 57 244 162 159 17722
2
+ 163 250 7146 361
3
+
4
+ 244
5
+ 280
6
+ 283
7
+ 221
8
+ 222
9
+ 499
10
+ 3067
11
+ 15767
12
+ 8302 5810
13
+ 12009 5810
14
+ 8302 10914
15
+ 12009 10914
16
+ 12009 10914 38
17
+ 8302 49 5810 38
18
+ 12009 49 5810 38
19
+ 477 458 5954 137 271 51 3779
20
+ 124 53 57 61 244 60 121 1726 12568 10240 1519 8290
21
+ 39916 8389 1059 9504 40216 13858 2073 8983 12571 1539 10721
22
+ 14566 246 14566 152 14566 265 30428 257 14566 261 30428 248 14566 268 14566 153 14566 277 30428 247 14566 277 14566 133 14566 152 14566 251 14566 247 14566 273 14566 251 30428 247 14566 255
23
+ 3822 272 246 327 4434 46 18445 152 46030 45022 142 13878 327 12585 19884 33773 40920 751 46 41839 327 2605 22716 708 1421 2840 4387 2421 46
24
+ 8302
25
+ 12009
26
+ 244 12009
27
+ 280 12009
28
+ 283 12009
29
+ 283 12009 303 12009
30
+ 327
31
+ 222 299
32
+ 44 34719
33
+ 8302 49 553 44 483 38 4998 904 863 18445 247 1037 4995 13379 2924 9515 17823 54 56 54 57 54 58 54 11904 47892
34
+ 9221 3226
35
+ 56
36
+ 56 56
37
+ 56 56 56
38
+ 56 56 56 56
39
+ 56 56 56 56 56
40
+ 56 56 56 56 56 56
41
+ 56 56 56 56 56 56 56
42
+ 56 56 56 56 56 56 56 56
43
+ 56 56 56 56 56 56 56 56 56
44
+ 72 34269 102 33245 17234 121
45
+ 1236 12266
46
+ 353 736 8886 221 10883 4238 16101 28540 222 3822 272 246 327 4434 46 18445 152 46030 45022 142 13878 327 12585 19884 33773 40920 751 46 41839 5954 137 271 3822 137 271 244 56 244 56 56 244 56 56 56 244 56 56 56 56 244 56 56 56 56 56 244 56 56 56 56 56 56 244 56 56 56 56 56 56 56 244 56 56 56 56 56 56 56 56 244 56 51 56 244 56 516 56 244 56 1198 56 244 14566 246 14566 152 14566 265 30428 257 14566 261 30428 248 14566 268 14566 153 14566 277 30428 247 14566 277 14566 133 14566 152 14566 251 36570 247 1037 4995 13379 2924 9515 17823 54 56 54 57 54 58 54 11904 47892 20895 16625 13047 8389 1059 9504 40216 13858 2073 8983 12571 1539 10721 5918 9643 13298 932 31723 31330 9221 3226 35426 10400 457 4783 2602 349 121 1477 957 1200 2038 49 349 632 863 3673 68 349 82 666 3673 457 4650 1949 580 49 349 73 863 2144 1649 35941 68 2726 44 7728 331 44 113 81
models/templates/Apertus-8B-Instruct.jinja ADDED
@@ -0,0 +1,327 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- macro render_typescript_type(param_spec, required_params, is_nullable=false) -%}
2
+ {%- if param_spec.type == "array" -%}
3
+ {%- if param_spec['items'] -%}
4
+ {%- if param_spec['items']['type'] == "string" -%}
5
+ {{- "string[]" }}
6
+ {%- elif param_spec['items']['type'] == "number" -%}
7
+ {{- "number[]" }}
8
+ {%- elif param_spec['items']['type'] == "integer" -%}
9
+ {{- "number[]" }}
10
+ {%- elif param_spec['items']['type'] == "boolean" -%}
11
+ {{- "boolean[]" }}
12
+ {%- else -%}
13
+ {%- set inner_type = render_typescript_type(param_spec['items'], required_params) -%}
14
+ {%- if inner_type == "object | object" or inner_type|length > 50 -%}
15
+ {{- "any[]" }}
16
+ {%- else -%}
17
+ {{- inner_type + "[]" }}
18
+ {%- endif -%}
19
+ {%- endif -%}
20
+ {%- if param_spec.nullable -%}
21
+ {{- " | null" }}
22
+ {%- endif -%}
23
+ {%- else -%}
24
+ {{- "any[]" }}
25
+ {%- if param_spec.nullable -%}
26
+ {{- " | null" }}
27
+ {%- endif -%}
28
+ {%- endif -%}
29
+ {%- elif param_spec.type is defined and param_spec.type is iterable and param_spec.type is not string and param_spec.type is not mapping and param_spec.type[0] is defined -%}
30
+ {#- Handle array of types like ["object", "object"] from Union[dict, list] #}
31
+ {%- if param_spec.type | length > 1 -%}
32
+ {{- param_spec.type | join(" | ") }}
33
+ {%- else -%}
34
+ {{- param_spec.type[0] }}
35
+ {%- endif -%}
36
+ {%- elif param_spec.oneOf -%}
37
+ {#- Handle oneOf schemas - check for complex unions and fallback to any #}
38
+ {%- set has_object_variants = false -%}
39
+ {%- for variant in param_spec.oneOf -%}
40
+ {%- if variant.type == "object" -%}
41
+ {%- set has_object_variants = true -%}
42
+ {%- endif -%}
43
+ {%- endfor -%}
44
+ {%- if has_object_variants and param_spec.oneOf|length > 1 -%}
45
+ {{- "any" }}
46
+ {%- else -%}
47
+ {%- for variant in param_spec.oneOf -%}
48
+ {{- render_typescript_type(variant, required_params) -}}
49
+ {%- if variant.description %}
50
+ {{- "// " + variant.description }}
51
+ {%- endif -%}
52
+ {%- if variant.default is defined %}
53
+ {{ "// default: " + variant.default|tojson }}
54
+ {%- endif -%}
55
+ {%- if not loop.last %}
56
+ {{- " | " }}
57
+ {% endif -%}
58
+ {%- endfor -%}
59
+ {%- endif -%}
60
+ {%- elif param_spec.type == "string" -%}
61
+ {%- if param_spec.enum -%}
62
+ {{- '"' + param_spec.enum|join('" | "') + '"' -}}
63
+ {%- else -%}
64
+ {{- "string" }}
65
+ {%- if param_spec.nullable %}
66
+ {{- " | null" }}
67
+ {%- endif -%}
68
+ {%- endif -%}
69
+ {%- elif param_spec.type == "number" -%}
70
+ {{- "number" }}
71
+ {%- elif param_spec.type == "integer" -%}
72
+ {{- "number" }}
73
+ {%- elif param_spec.type == "boolean" -%}
74
+ {{- "boolean" }}
75
+ {%- elif param_spec.type == "object" -%}
76
+ {%- if param_spec.properties -%}
77
+ {{- "{\n" }}
78
+ {%- for prop_name, prop_spec in param_spec.properties.items() -%}
79
+ {{- prop_name -}}
80
+ {%- if prop_name not in (param_spec.required or []) -%}
81
+ {{- "?" }}
82
+ {%- endif -%}
83
+ {{- ": " }}
84
+ {{ render_typescript_type(prop_spec, param_spec.required or []) }}
85
+ {%- if not loop.last -%}
86
+ {{-", " }}
87
+ {%- endif -%}
88
+ {%- endfor -%}
89
+ {{- "}" }}
90
+ {%- else -%}
91
+ {{- "object" }}
92
+ {%- endif -%}
93
+ {%- else -%}
94
+ {{- "any" }}
95
+ {%- endif -%}
96
+ {%- endmacro -%}
97
+
98
+ {%- macro render_tools(tools) -%}
99
+ {%- for tool in tools %}
100
+ {{- "// " + tool.function.description + "\n" }}
101
+ {{- "type "+ tool.function.name + " = " }}
102
+ {%- if tool.function.parameters and tool.function.parameters.properties %}
103
+ {{- "(_: {\n" }}
104
+ {%- for param_name, param_spec in tool.function.parameters.properties.items() %}
105
+ {%- if param_spec.description %}
106
+ {{- "// " + param_spec.description + "\n" }}
107
+ {%- endif %}
108
+ {{- param_name }}
109
+ {%- if param_name not in (tool.function.parameters.required or []) -%}
110
+ {{- "?" }}
111
+ {%- endif -%}
112
+ {{- ": " }}
113
+ {{- render_typescript_type(param_spec, tool.function.parameters.required or []) }}
114
+ {%- if param_spec.default is defined -%}
115
+ {%- if param_spec.enum %}
116
+ {{- ", // default: " + param_spec.default }}
117
+ {%- elif param_spec.oneOf %}
118
+ {{- "// default: " + param_spec.default }}
119
+ {%- else %}
120
+ {{- ", // default: " + param_spec.default|tojson }}
121
+ {%- endif -%}
122
+ {%- endif -%}
123
+ {%- if not loop.last %}
124
+ {{- ",\n" }}
125
+ {%- else %}
126
+ {{- "\n" }}
127
+ {%- endif -%}
128
+ {%- endfor %}
129
+ {{- "}) => any;" }}
130
+ {%- else -%}
131
+ {{- "() => any;" }}
132
+ {%- endif -%}
133
+ {%- if not loop.last -%}
134
+ {{- "\n" }}
135
+ {%- endif -%}
136
+ {%- endfor %}
137
+ {%- endmacro -%}
138
+
139
+ {{ bos_token }}
140
+
141
+ {%- set system_token = '<|system_start|>' -%}
142
+ {%- set end_system_token = '<|system_end|>' -%}
143
+ {%- set developer_token = '<|developer_start|>' -%}
144
+ {%- set end_developer_token = '<|developer_end|>' -%}
145
+ {%- set user_token = '<|user_start|>' -%}
146
+ {%- set end_user_token = '<|user_end|>' -%}
147
+ {%- set assistant_token = '<|assistant_start|>' -%}
148
+ {%- set end_assistant_token = '<|assistant_end|>' -%}
149
+ {%- set inner_token = '<|inner_prefix|>' -%}
150
+ {%- set outer_token = '<|inner_suffix|>' -%}
151
+ {%- set tool_calls_token = '<|tools_prefix|>' -%}
152
+ {%- set end_tool_calls_token = '<|tools_suffix|>' -%}
153
+
154
+ {%- set ns = namespace(in_assistant=false, in_tool=false, in_inner=false, assistant_format=none) -%}
155
+
156
+ {%- if messages and messages[0].role == 'system' -%}
157
+ {%- if "content" in messages[0] -%}
158
+ {%- if messages[0].content is string -%}
159
+ {{ system_token + messages[0].content + end_system_token }}
160
+ {%- elif messages[0].content is mapping and "text" in messages[0].content -%}
161
+ {{ system_token + messages[0].content.text + end_system_token }}
162
+ {%- else -%}
163
+ {{- raise_exception("Invalid system message") -}}
164
+ {%- endif -%}
165
+ {%- else -%}
166
+ {{- raise_exception("Invalid system message") -}}
167
+ {%- endif -%}
168
+ {%- set loop_messages = messages[1:] -%}
169
+ {%- else -%}
170
+ {{ system_token + 'You are Apertus, a helpful assistant created by the SwissAI initiative.\nKnowledge cutoff: 2024-04\nCurrent date: ' + strftime_now('%Y-%m-%d') + end_system_token }}
171
+ {%- set loop_messages = messages -%}
172
+ {%- endif -%}
173
+
174
+ {{ developer_token + 'Deliberation: ' }}
175
+ {%- if enable_thinking is defined and enable_thinking -%}
176
+ {{ 'enabled\n' }}
177
+ {%- else -%}
178
+ {{ 'disabled\n' }}
179
+ {%- endif -%}
180
+ {%- if tools is defined and tools -%}
181
+ {{ 'Tool Capabilities:\n' + render_tools(tools) }}
182
+ {%- else -%}
183
+ {{ 'Tool Capabilities: disabled' }}
184
+ {%- endif -%}
185
+ {{ end_developer_token }}
186
+
187
+ {%- for message in loop_messages -%}
188
+ {%- if message.role == 'user' -%}
189
+ {%- set ns.in_inner = false -%}
190
+ {%- if ns.in_tool -%}
191
+ {{ ']' }}
192
+ {%- set ns.in_tool = false -%}
193
+ {%- endif -%}
194
+ {%- if ns.in_assistant -%}
195
+ {{ end_assistant_token }}
196
+ {%- set ns.in_assistant = false -%}
197
+ {%- endif -%}
198
+ {%- if "content" in message -%}
199
+ {{ user_token }}
200
+ {%- if message.content is string -%}
201
+ {{ message.content }}
202
+ {%- elif message.content is mapping and "parts" in message.content -%}
203
+ {%- set parts = message.content.parts -%}
204
+ {%- for part in parts -%}
205
+ {%- if part.type == "text" -%}
206
+ {{ part.text }}
207
+ {%- else -%}
208
+ {{- raise_exception("Invalid user part: " + part.type) -}}
209
+ {%- endif -%}
210
+ {%- endfor -%}
211
+ {%- else -%}
212
+ {{- raise_exception("Invalid user message: " + message.role) -}}
213
+ {%- endif -%}
214
+ {{ end_user_token }}
215
+ {%- endif -%}
216
+ {%- elif message.role == 'assistant' -%}
217
+ {%- if not ns.in_assistant -%}
218
+ {{ assistant_token }}
219
+ {%- set ns.in_assistant = true -%}
220
+ {%- endif -%}
221
+ {%- if "content" in message and message.content is not none -%}
222
+ {%- if message.content is string and (ns.assistant_format is none or ns.assistant_format == "string") -%}
223
+ {%- if ns.in_tool -%}
224
+ {{ ']' }}
225
+ {%- set ns.in_tool = false -%}
226
+ {%- endif -%}
227
+ {%- set ns.assistant_format = "string" -%}
228
+ {{ message.content }}
229
+ {%- elif message.content is mapping and "blocks" in message.content and (ns.assistant_format is none or ns.assistant_format == "mapping") -%}
230
+ {%- set ns.assistant_format = "mapping" -%}
231
+ {%- set blocks = message.content.blocks -%}
232
+ {%- for block in blocks -%}
233
+ {%- if block.type == 'thoughts' -%}
234
+ {%- if ns.in_tool -%}
235
+ {{ ']' }}
236
+ {%- set ns.in_tool = false -%}
237
+ {%- endif -%}
238
+ {%- if not ns.in_inner -%}
239
+ {%- set ns.in_inner = true -%}
240
+ {{ inner_token }}
241
+ {%- endif -%}
242
+ {{ block.text }}
243
+ {%- elif block.type == 'tool_calls' -%}
244
+ {%- if ns.in_tool -%}
245
+ {{ ']' }}
246
+ {%- set ns.in_tool = false -%}
247
+ {%- endif -%}
248
+ {%- if ns.in_inner and not loop.first and block.calls|length == 1 and block.calls[0].name == 'display_answers' -%}
249
+ {%- set ns.in_inner = false -%}
250
+ {{ outer_token }}
251
+ {%- endif -%}
252
+ {{ tool_calls_token + '[' }}
253
+ {%- for tool_call in block.calls -%}
254
+ {{- '{"' + tool_call.name + '": ' + tool_call.arguments + '}' }}
255
+ {%- if not loop.last -%}
256
+ {{- ", " }}
257
+ {%- endif -%}
258
+ {%- endfor -%}
259
+ {{ ']' + end_tool_calls_token }}
260
+ {%- elif block.type == 'tool_outputs' -%}
261
+ {%- if ns.in_tool -%}
262
+ {{- raise_exception("Cannot have both tool outputs as separate messages and tool outputs as blocks") -}}
263
+ {%- endif -%}
264
+ {{ '[' }}
265
+ {%- for tool_output in block.outputs -%}
266
+ {{- tool_output.output }}
267
+ {%- if not loop.last -%}
268
+ {{- ", " }}
269
+ {%- endif -%}
270
+ {%- endfor -%}
271
+ {{- ']' }}
272
+ {%- elif block.type == 'response' -%}
273
+ {%- if ns.in_tool -%}
274
+ {{ ']' }}
275
+ {%- set ns.in_tool = false -%}
276
+ {%- endif -%}
277
+ {%- if (not loop.first and ns.in_inner) or (ns.in_assistant and ns.in_inner) -%}
278
+ {%- set ns.in_inner = false -%}
279
+ {{ outer_token }}
280
+ {%- endif -%}
281
+ {{ block.text }}
282
+ {%- else -%}
283
+ {{- raise_exception("Invalid assistant block type: " + block.type) -}}
284
+ {%- endif -%}
285
+ {%- endfor -%}
286
+ {%- else -%}
287
+ {{- raise_exception("Invalid assistant content '" + message.content + "', expected " + ns.assistant_format) -}}
288
+ {%- endif -%}
289
+ {%- elif "tool_calls" not in message -%}
290
+ {{- raise_exception("Invalid assistant message " + message) -}}
291
+ {%- endif -%}
292
+ {%- if "tool_calls" in message and message.tool_calls -%}
293
+ {{ tool_calls_token + '[' }}
294
+ {%- for tool_call in message.tool_calls -%}
295
+ {%- if tool_call.type == 'function' -%}
296
+ {%- set function = tool_call.function -%}
297
+ {{- '{"' + function.name + '": ' + function.arguments|tojson + '}' }}
298
+ {%- if not loop.last -%}
299
+ {{- ", " }}
300
+ {%- endif -%}
301
+ {%- else -%}
302
+ {{- raise_exception("Invalid tool call type: " + tool_call.type) -}}
303
+ {%- endif -%}
304
+ {%- endfor -%}
305
+ {{ ']' + end_tool_calls_token }}
306
+ {%- endif -%}
307
+ {%- elif message.role == 'tool' -%}
308
+ {%- if not ns.in_assistant -%}
309
+ {{- raise_exception("Tool message outside of assistant") -}}
310
+ {%- endif -%}
311
+ {%- if not ns.in_tool -%}
312
+ {{ '[' }}
313
+ {%- set ns.in_tool = true -%}
314
+ {%- else -%}
315
+ {{ ", "}}
316
+ {%- endif -%}
317
+ {{ message.content }}
318
+ {%- else -%}
319
+ {{- raise_exception("Invalid message role") -}}
320
+ {%- endif -%}
321
+ {%- endfor -%}
322
+ {%- if ns.in_tool -%}
323
+ {{ ']' }}
324
+ {%- endif -%}
325
+ {%- if add_generation_prompt -%}
326
+ {{ assistant_token }}
327
+ {%- endif -%}
models/templates/Apriel-1.6-15b-Thinker-fixed.jinja ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {# ---------------------------------------------------------------------- #}
2
+ {# ƛƬ Default setup and flags #}
3
+ {# ---------------------------------------------------------------------- #}
4
+ {%- set messages = messages or [] -%}
5
+ {%- set tools = tools or [] -%}
6
+ {%- set add_generation_prompt = add_generation_prompt or false -%}
7
+ {%- set available_tool_string = '' -%}
8
+ {%- set add_tool_id = true -%}
9
+ {%- set add_thoughts = true -%} {# whether to include <thinking> reasoning blocks #}
10
+ {# Optional token placeholders (safe defaults) #}
11
+ {%- set bos_token = bos_token or '' -%}
12
+ {%- set eos_token = eos_token or '' -%}
13
+ {# ---------------------------------------------------------------------- #}
14
+ {# Core reasoning prompt and assistant reasoning prefix #}
15
+ {# ---------------------------------------------------------------------- #}
16
+ {%- set reasoning_prompt -%}
17
+ You are a thoughtful, systematic AI assistant from ServiceNow Language Models (SLAM) lab.
18
+ Analyze each question carefully, present your reasoning step-by-step, then provide the final
19
+ response after the marker [BEGIN FINAL RESPONSE].
20
+ {%- endset -%}
21
+ {%- set reasoning_asst_turn_start = 'Here are my reasoning steps:\n' -%}
22
+ {# ---------------------------------------------------------------------- #}
23
+ {# Tool list and tool call output format #}
24
+ {# ---------------------------------------------------------------------- #}
25
+ {%- if tools|length > 0 -%}
26
+ {%- set available_tool_string -%}
27
+ You are provided with function signatures within <available_tools></available_tools> XML tags.
28
+ You may call one or more functions to assist with the user query.
29
+ Don't make assumptions about the arguments. You should infer the argument values from previous
30
+ user responses and the system message.
31
+ Here are the available tools:
32
+ <available_tools>
33
+ {% for tool in tools %}{{ tool|string }}{% endfor %}
34
+
35
+ </available_tools>.
36
+
37
+ Return all function calls as a list of JSON objects within <tool_calls></tool_calls> XML tags.
38
+ Each JSON object should contain a function name and arguments as follows:
39
+ <tool_calls>[
40
+ {"name": <function-name-1>, "arguments": <args-dict-1>},
41
+ {"name": <function-name-2>, "arguments": <args-dict-2>},
42
+ ...
43
+ ]</tool_calls>
44
+ {%- endset -%}
45
+ {%- endif -%}
46
+ {# ---------------------------------------------------------------------- #}
47
+ {# Start system block if first message is not system #}
48
+ {# ---------------------------------------------------------------------- #}
49
+ {%- if messages|length > 0 and messages[0]['role'] != 'system' -%}
50
+ {%- if tools|length > 0 -%}
51
+ {{ bos_token + '<|begin_system|>\n' + reasoning_prompt + '\n' + available_tool_string + '\n' }}
52
+ {%- else -%}
53
+ {{ bos_token + '<|begin_system|>\n' + reasoning_prompt + '\n' }}
54
+ {%- endif -%}
55
+ {%- endif -%}
56
+ {# ---------------------------------------------------------------------- #}
57
+ {# Iterate through messages #}
58
+ {# ---------------------------------------------------------------------- #}
59
+ {%- for message in messages -%}
60
+
61
+ {# ---------------- USER MESSAGE ---------------- #}
62
+ {%- if message['role'] == 'user' -%}
63
+ {{ '<|begin_user|>\n' }}
64
+ {%- if message['content'] is not string -%}
65
+ {%- for chunk in message['content'] -%}
66
+ {%- if chunk['type'] == 'text' -%}
67
+ {{ chunk['text'] }}
68
+ {%- elif chunk['type'] in ['image', 'image_url'] -%}
69
+ {{ '[IMG]' }}
70
+ {%- else -%}
71
+ {{ raise_exception('Unrecognized content type!') }}
72
+ {%- endif -%}
73
+ {%- endfor -%}
74
+ {%- else -%}
75
+ {{ message['content'] }}
76
+ {%- endif -%}
77
+
78
+ {# ---------------- SYSTEM MESSAGE ---------------- #}
79
+ {%- elif message['role'] == 'system' -%}
80
+ {%- set sys_content = message.get('content', '') -%}
81
+ {%- if sys_content and sys_content|length > 0 -%}
82
+ {%- if sys_content is string -%}
83
+ {%- set system_message = sys_content -%}
84
+ {%- else -%}
85
+ {%- set system_message = sys_content[0]['text'] -%}
86
+ {%- endif -%}
87
+ {%- else -%}
88
+ {%- set system_message = '' -%}
89
+ {%- endif -%}
90
+
91
+ {%- if tools|length > 0 -%}
92
+ {{ bos_token + '<|begin_system|>\n' + reasoning_prompt + '\n' + system_message + '\n' + available_tool_string + '\n' }}
93
+ {%- else -%}
94
+ {{ bos_token + '<|begin_system|>\n' + reasoning_prompt + '\n' + system_message + '\n' }}
95
+ {%- endif -%}
96
+
97
+ {# ---------------- ASSISTANT MESSAGE ---------------- #}
98
+ {%- elif message['role'] == 'assistant' -%}
99
+ {%- if loop.last -%}
100
+ {%- set add_tool_id = false -%}
101
+ {%- endif -%}
102
+
103
+ {{ '\n<|begin_assistant|>\n' }}
104
+
105
+ {%- if add_thoughts and message.get('reasoning_content') and loop.last -%}
106
+ {{ message['reasoning_content'] + '\n[BEGIN FINAL RESPONSE]\n' }}
107
+ {%- endif -%}
108
+
109
+ {%- set asst_content = message.get('content', '') -%}
110
+ {%- if asst_content and asst_content|length > 0 -%}
111
+ {%- if asst_content is not string -%}
112
+ {%- set asst_text = asst_content[0]['text'] -%}
113
+ {%- else -%}
114
+ {%- set asst_text = asst_content -%}
115
+ {%- endif -%}
116
+ {# For historical turns (not the last), strip reasoning and keep only final response #}
117
+ {%- if not loop.last and '[BEGIN FINAL RESPONSE]' in asst_text -%}
118
+ {{- asst_text.split('[BEGIN FINAL RESPONSE]')[-1] | trim -}}
119
+ {%- else -%}
120
+ {{- asst_text -}}
121
+ {%- endif -%}
122
+ {%- elif message.get('chosen') and message['chosen']|length > 0 -%}
123
+ {{ message['chosen'][0] }}
124
+ {%- endif -%}
125
+
126
+ {# Tool call output #}
127
+ {%- set tool_calls = message.get('tool_calls', []) -%}
128
+ {%- if tool_calls and tool_calls|length > 0 -%}
129
+ {{ '\n<tool_calls>[' }}
130
+ {%- for tool_call in tool_calls -%}
131
+ {{ '{"name": "' + tool_call['function']['name'] + '", "arguments": ' + tool_call['function']['arguments']|tojson }}
132
+ {%- if add_tool_id == true and 'id' in tool_call -%}
133
+ {{ ', "id": "' + tool_call['id'] + '"' }}
134
+ {%- endif -%}
135
+ {{ '}' }}
136
+ {%- if not loop.last -%}{{ ', ' }}{%- endif -%}
137
+ {%- endfor -%}
138
+ {{ ']</tool_calls>' }}
139
+ {%- endif -%}
140
+
141
+ {%- set training_prompt = training_prompt if (training_prompt is defined) else false -%}
142
+ {%- if not loop.last or training_prompt -%}
143
+ {{ '\n<|end|>\n' }}
144
+ {%- endif -%}
145
+
146
+ {# ---------------- TOOL RESULT MESSAGE ---------------- #}
147
+ {%- elif message['role'] == 'tool' -%}
148
+ {%- set tool_content = message.get('content', '') -%}
149
+ {%- if tool_content is string -%}
150
+ {%- set tool_message = tool_content -%}
151
+ {%- else -%}
152
+ {%- set tool_message = tool_content[0]['text'] if tool_content else '' -%}
153
+ {%- endif -%}
154
+ {{ '<|begin_tool_result|>\n' + tool_message|string + '\n' }}
155
+
156
+ {# ---------------- CONTENT MESSAGE ---------------- #}
157
+ {%- elif message['role'] == 'content' -%}
158
+ {%- set msg_content = message.get('content', '') -%}
159
+ {%- if msg_content is not string -%}
160
+ {{ '<|begin_content|>\n' + msg_content[0]['text'] + '\n' }}
161
+ {%- else -%}
162
+ {{ '<|begin_content|>\n' + msg_content + '\n' }}
163
+ {%- endif -%}
164
+ {%- endif -%}
165
+
166
+ {# ---------------- REASONING PROMPT BEFORE NEXT ASSISTANT ---------------- #}
167
+ {%- if loop.last and add_generation_prompt and message['role'] != 'assistant' -%}
168
+ {{ '\n<|begin_assistant|>\n' + reasoning_asst_turn_start }}
169
+ {%- endif -%}
170
+
171
+ {%- endfor -%}
models/templates/Bielik-11B-v3.0-Instruct.jinja ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{ bos_token }}
2
+ {%- if messages[0]['role'] == 'system' %}
3
+ {%- set system_message = messages[0]['content'] %}
4
+ {%- set loop_start_index = 1 %}
5
+ {%- else %}
6
+ {%- set system_message = "" %}
7
+ {%- set loop_start_index = 0 %}
8
+ {%- endif %}
9
+
10
+ {%- if system_message or tools %}
11
+ {{- '<|im_start|>system\n' }}
12
+ {%- if system_message %}
13
+ {{- system_message }}
14
+ {%- endif %}
15
+ {%- if tools %}
16
+ {{- '\n\nMasz dostęp do następujących narzędzi. Definicje narzędzi znajdują się poniżej wewnątrz znaczników <|function_list|>:\n<|function_list|>\n' }}
17
+ {{- '[' }}
18
+ {%- for tool in tools %}
19
+ {{- tool | tojson }}
20
+ {%- if not loop.last %}
21
+ {{- ',\n' }}
22
+ {%- endif %}
23
+ {%- endfor %}
24
+ {{- ']\n<|function_list|>\n\nAby wywołać narzędzie, użyj formatu <tool_call>{"name": "nazwa_narzędzia", "arguments": {"argument": "wartość"}}</tool_call>. Wyniki działania narzędzi zostaną przekazane z markerem <|function_output|>.\n' }}
25
+ {%- endif %}
26
+ {%- if enable_thinking %}
27
+ {{- '\n\nZanim odpowiesz na pytanie, najpierw przemyśl swoje kroki i umieść swoje myśli wewnątrz tagów <think>...</think>. Musisz najpierw pomyśleć, zanim udzielisz odpowiedzi. ' -}}
28
+ {{- 'WAŻNE: Powinieneś myśleć w tym samym języku, co pytanie użytkownika. Jeśli pytanie jest zadane po polsku, powinieneś również myśleć po polsku. Jeśli pytanie jest po angielsku, myślisz również po angielsku itd. ' }}
29
+ {{- '** PAMIĘTAJ! ** Pytanie po polsku -> myślenie po polsku -> odpowiedź po polsku!' -}}
30
+ {{- '*** BARDZO WAŻNE!!! *** Jesteś Bielikiem, polskim modelem językowym. Twoją główną cechą jest umiejętność pisania po polsku. Jeśli użytkownik zadaje Ci pytania po polsku, ZAWSZE odpowiadaj po polsku. ' -}}
31
+ {{- 'Nawet, jeśli korzystasz z narzędzia, którego większość instrukcji jest po angielsku, powinieneś przede wszystkim odpowiadać po polsku, jeśli użytkownik zadaje pytanie w tym języku. ' -}}
32
+ {%- endif %}
33
+ {{- '<|im_end|>\n' }}
34
+ {%- endif %}
35
+
36
+ {%- for message in messages[loop_start_index:] %}
37
+ {%- if message['role'] == 'user' %}
38
+ {{- '<|im_start|>user\n' + message['content'] + '<|im_end|>\n' }}
39
+ {%- elif message['role'] == 'assistant' %}
40
+ {{- '<|im_start|>assistant\n' }}
41
+ {%- set content = message.content | default('') %}
42
+ {%- set reasoning_content = message.reasoning_content | default('') %}
43
+ {%- if not reasoning_content and '<think>' in content and '</think>' in content %}
44
+ {%- set reasoning_parts = content.split('</think>') %}
45
+ {%- set reasoning_content = reasoning_parts[0].split('<think>')[-1] %}
46
+ {%- set content = reasoning_parts[1:] | join('</think>') %}
47
+ {%- endif %}
48
+ {%- if reasoning_content %}
49
+ {{- '<think>\n' + reasoning_content.strip() + '\n</think>\n' }}
50
+ {%- endif %}
51
+ {{- content.lstrip() }}
52
+ {%- if message.tool_calls %}
53
+ {%- for tool_call in message.tool_calls %}
54
+ {%- if tool_call.function %}
55
+ {%- set tool_call = tool_call.function %}
56
+ {%- endif %}
57
+ {{- '\n<tool_call>\n{"name": "' + tool_call.name + '", "arguments": ' + (tool_call.arguments if tool_call.arguments is string else tool_call.arguments | tojson) + '}\n</tool_call>' }}
58
+ {%- endfor %}
59
+ {%- endif %}
60
+ {{- '<|im_end|>\n' }}
61
+ {%- elif message['role'] == 'tool' %}
62
+ {%- if loop.index0 == 0 or messages[loop.index0 - 1]['role'] != 'tool' %}
63
+ {{- '<|im_start|>user\n' }}
64
+ {%- endif %}
65
+ {{- '<|function_output|>' + message['content'] }}
66
+ {%- if loop.last or messages[loop.index0 + 1]['role'] != 'tool' %}
67
+ {{- '<|im_end|>\n' }}
68
+ {%- endif %}
69
+ {%- endif %}
70
+ {%- endfor %}
71
+
72
+ {%- if add_generation_prompt %}
73
+ {{- '<|im_start|>assistant\n' }}
74
+ {%- if enable_thinking %}
75
+ {{- '<think>\n' }}
76
+ {%- endif %}
77
+ {%- endif %}
models/templates/ByteDance-Seed-OSS.jinja ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {# ----------‑‑‑ special token variables ‑‑‑---------- #}
2
+ {%- set bos_token = '<seed:bos>' -%}
3
+ {%- set eos_token = '<seed:eos>' -%}
4
+ {%- set pad_token = '<seed:pad>' -%}
5
+ {%- set toolcall_begin_token = '<seed:tool_call>' -%}
6
+ {%- set toolcall_end_token = '</seed:tool_call>' -%}
7
+ {%- set think_begin_token = '<seed:think>' -%}
8
+ {%- set think_end_token = '</seed:think>' -%}
9
+ {%- set budget_begin_token = '<seed:cot_budget_reflect>'-%}
10
+ {%- set budget_end_token = '</seed:cot_budget_reflect>'-%}
11
+ {# -------------- reflection-interval lookup -------------- #}
12
+ {%- if not thinking_budget is defined %}
13
+ {%- set thinking_budget = -1 -%}
14
+ {%- endif -%}
15
+ {%- set budget_reflections_v05 = {
16
+ 0: 0,
17
+ 512: 128,
18
+ 1024: 256,
19
+ 2048: 512,
20
+ 4096: 512,
21
+ 8192: 1024,
22
+ 16384: 1024
23
+ } -%}
24
+ {# Find the first gear that is greater than or equal to the thinking_budget. #}
25
+ {%- set ns = namespace(interval = None) -%}
26
+ {%- for k, v in budget_reflections_v05 | dictsort -%}
27
+ {%- if ns.interval is none and thinking_budget <= k -%}
28
+ {%- set ns.interval = v -%}
29
+ {%- endif -%}
30
+ {%- endfor -%}
31
+ {# If it exceeds the maximum gear, use the value of the last gear #}
32
+ {%- if ns.interval is none -%}
33
+ {%- set ns.interval = budget_reflections_v05[16384] -%}
34
+ {%- endif -%}
35
+ {# ---------- Preprocess the system message ---------- #}
36
+ {%- if messages[0]["role"] == "system" %}
37
+ {%- set system_message = messages[0]["content"] %}
38
+ {%- set loop_messages = messages[1:] %}
39
+ {%- else %}
40
+ {%- set loop_messages = messages %}
41
+ {%- endif %}
42
+ {# ---------- Ensure tools exist ---------- #}
43
+ {%- if not tools is defined or tools is none %}
44
+ {%- set tools = [] %}
45
+ {%- endif %}
46
+ {# tools2doc.jinja #}
47
+ {%- macro py_type(t) -%}
48
+ {%- if t == "string" -%}str
49
+ {%- elif t in ("number", "integer") -%}int
50
+ {%- elif t == "boolean" -%}bool
51
+ {%- elif t == "array" -%}list
52
+ {%- else -%}Any{%- endif -%}
53
+ {%- endmacro -%}
54
+ {# ---------- Output the system block ---------- #}
55
+ {%- if system_message is defined %}
56
+ {{ bos_token + "system\n" + system_message }}
57
+ {%- else %}
58
+ {%- if tools is iterable and tools | length > 0 %}
59
+ {{ bos_token + "system\nYou are Doubao, a helpful AI assistant. You may call one or more functions to assist with the user query." }}
60
+ {%- endif %}
61
+ {%- endif %}
62
+ {%- if use_json_tooldef is defined and use_json_tooldef %}
63
+
64
+ {{"Tool List:\nYou are authorized to use the following tools (described in JSON Schema format). Before performing any task, you must decide how to call them based on the descriptions and parameters of these tools."}}
65
+ {{ tools | tojson(ensure_ascii=False) }}
66
+ {%- else %}
67
+ {%- for item in tools if item.type == "function" %}
68
+
69
+
70
+ Function:
71
+ def {{ item.function.name }}(
72
+ {%- for name, spec in item.function.parameters.properties.items() %}
73
+ {{- name }}: {{ py_type(spec.type) }}{% if not loop.last %},{% endif %}
74
+ {%- endfor %}):
75
+ """
76
+ {{ item.function.description | trim }}
77
+
78
+ {# ---------- Args ---------- #}
79
+ {%- if item.function.parameters.properties %}
80
+ Args:
81
+ {%- for name, spec in item.function.parameters.properties.items() %}
82
+
83
+ - {{ name }} ({{ py_type(spec.type) }})
84
+ {%- if name in item.function.parameters.required %} [必填]{% else %} [选填]{% endif %}:
85
+ {{- " " ~ (spec.description or "") }}
86
+ {%- endfor %}
87
+ {%- endif %}
88
+
89
+ {# ---------- Returns ---------- #}
90
+ {%- if item.function.returns is defined
91
+ and item.function.returns.properties is defined
92
+ and item.function.returns.properties %}
93
+ Returns:
94
+ {%- for name, spec in item.function.returns.properties.items() %}
95
+
96
+ - {{ name }} ({{ py_type(spec.type) }}):
97
+ {{- " " ~ (spec.description or "") }}
98
+ {%- endfor %}
99
+ {%- endif %}
100
+
101
+ """
102
+ {%- endfor %}
103
+ {%- endif %}
104
+ {%- if tools is iterable and tools | length > 0 %}
105
+
106
+ {{"工具调用请遵循如下格式:\n<seed:tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>value_1</parameter>\n<parameter=example_parameter_2>This is the value for the second parameter\nthat can span\nmultiple lines</parameter>\n</function>\n</seed:tool_call>\n"}}
107
+ {%- endif %}
108
+ {# End the system block line #}
109
+ {%- if system_message is defined or tools is iterable and tools | length > 0 %}
110
+ {{ eos_token }}
111
+ {%- endif %}
112
+ {# ---------- Thinking Budget ---------- #}
113
+ {%- if thinking_budget is defined %}
114
+ {%- if thinking_budget == 0 %}
115
+ {{ bos_token+"system" }}
116
+ {{ "You are an intelligent assistant that can answer questions in one step without the need for reasoning and thinking, that is, your thinking budget is 0. Next, please skip the thinking process and directly start answering the user's questions." }}
117
+ {{ eos_token }}
118
+ {%- elif not thinking_budget == -1 %}
119
+ {{ bos_token+"system" }}
120
+ {{ "You are an intelligent assistant with reflective ability. In the process of thinking and reasoning, you need to strictly follow the thinking budget, which is "}}{{thinking_budget}}{{". That is, you need to complete your thinking within "}}{{thinking_budget}}{{" tokens and start answering the user's questions. You will reflect on your thinking process every "}}{{ns.interval}}{{" tokens, stating how many tokens have been used and how many are left."}}
121
+ {{ eos_token }}
122
+ {%- endif %}
123
+ {%- endif %}
124
+ {# ---------- List the historical messages one by one ---------- #}
125
+ {%- for message in loop_messages %}
126
+ {%- if message.role == "assistant"
127
+ and message.tool_calls is defined
128
+ and message.tool_calls is iterable
129
+ and message.tool_calls | length > 0 %}
130
+ {{ bos_token + message.role }}
131
+ {%- if message.reasoning_content is defined and message.reasoning_content is string and message.reasoning_content | trim | length > 0 %}
132
+ {{ "\n" + think_begin_token + message.reasoning_content | trim + think_end_token }}
133
+ {%- endif %}
134
+ {%- if message.content is defined and message.content is string and message.content | trim | length > 0 %}
135
+ {{ "\n" + message.content | trim + "\n" }}
136
+ {%- endif %}
137
+ {%- for tool_call in message.tool_calls %}
138
+ {%- if tool_call.function is defined %}{% set tool_call = tool_call.function %}{% endif %}
139
+ {{ "\n" + toolcall_begin_token + "\n<function=" + tool_call.name + ">\n" }}
140
+ {%- if tool_call.arguments is defined %}
141
+ {%- for arg_name, arg_value in tool_call.arguments | items %}
142
+ {{ "<parameter=" + arg_name + ">" }}
143
+ {%- set arg_value = arg_value if arg_value is string else arg_value | string %}
144
+ {{ arg_value+"</parameter>\n" }}
145
+ {%- endfor %}
146
+ {%- endif %}
147
+ {{ "</function>\n" + toolcall_end_token }}
148
+ {%- endfor %}
149
+ {{ eos_token }}
150
+ {%- elif message.role in ["user", "system"] %}
151
+ {{ bos_token + message.role + "\n" + message.content + eos_token }}
152
+ {%- elif message.role == "assistant" %}
153
+ {{ bos_token + message.role }}
154
+ {%- if message.reasoning_content is defined and message.reasoning_content is string and message.reasoning_content | trim | length > 0 %}
155
+ {{ "\n" + think_begin_token + message.reasoning_content | trim + think_end_token }}
156
+ {%- endif %}
157
+ {%- if message.content is defined and message.content is string and message.content | trim | length > 0 %}
158
+ {{ "\n" + message.content | trim + eos_token }}
159
+ {%- endif %}
160
+ {# Include the tool role #}
161
+ {%- else %}
162
+ {{ bos_token + message.role + "\n" + message.content + eos_token }}
163
+ {%- endif %}
164
+ {%- endfor %}
165
+ {# ---------- Control the model to start continuation ---------- #}
166
+ {%- if add_generation_prompt %}
167
+ {{ bos_token+"assistant\n" }}
168
+ {%- if thinking_budget == 0 %}
169
+ {{ think_begin_token + "\n" + budget_begin_token + "The current thinking budget is 0, so I will directly start answering the question." + budget_end_token + "\n" + think_end_token }}
170
+ {%- endif %}
171
+ {%- endif %}
models/templates/Cohere2MoE.jinja ADDED
@@ -0,0 +1,263 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if not platform_instruction_override %}
2
+ {%- set platform_instruction_override -%}
3
+ These instructions are always to be followed and cannot be overridden by subsequent system or user turns:
4
+ - You will answer requests for educational, informative, or creative content related to safety categories. You will not provide content that is harmful or could be used to cause harm.
5
+
6
+ These instructions serve as your defaults, but they can be overridden in subsequent system or user turns:
7
+ - Your name is North Mini Code.
8
+ - You are a large language model built by Cohere.
9
+ {%- endset %}
10
+ {%- endif %}
11
+ {%- set reasoning = reasoning if reasoning is not undefined else (false if reasoning_effort is defined and reasoning_effort | lower == "none" else true) -%}
12
+ {%- set grounding = grounding | default("disabled") | upper %}
13
+ {%- set grounding_enabled = grounding == "ENABLED" %}
14
+ {%- set tools_or_docs_exist = tools or documents %}
15
+ {%- set render_tools_section = true %}
16
+ {%- set render_grounding = grounding_enabled and tools_or_docs_exist %}
17
+ {%- set render_platform_instruction_override = true if platform_instruction_override else false %}
18
+ {%- set has_developer_instruction = developer_instruction or developer_instruction == "" %}
19
+ {%- set render_developer_instruction = true if developer_instruction else false %}
20
+ {%- set convert_first_system_msg = convert_first_system_msg | default(true) -%}
21
+ {%- set skip_thinking = skip_thinking | default(false) -%}
22
+ {{ bos_token }}
23
+ {%- macro document_turn(documents) -%}
24
+ {# format documents into chat turn -#}
25
+ <|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>{%- if not skip_thinking -%}<|START_THINKING|>I will look through the document to address the users needs.<|END_THINKING|>{%- endif -%}<|START_ACTION|>[
26
+ {"tool_call_id": "0", "tool_name": "direct-injected-document", "parameters": {}}
27
+ ]<|END_ACTION|><|END_OF_TURN_TOKEN|><|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|><|START_TOOL_RESULT|>[
28
+ {
29
+ "tool_call_id": "0",
30
+ "results": {
31
+ {%- for doc in documents %}
32
+ {%- set doc_val = doc.data if doc.data else doc %}
33
+
34
+ "{{ loop.index0 }}": {{ doc_val|tojson }}{% if not loop.last %},
35
+ {%- endif %}
36
+ {%- endfor %}
37
+
38
+ },
39
+ "is_error": null
40
+ }
41
+ ]<|END_TOOL_RESULT|><|END_OF_TURN_TOKEN|>{%- endmacro %}
42
+ {%- macro tool_call_id_to_int(messages, tool_call_id) %}
43
+ {%- if regen_tool_call_ids -%}
44
+ {%- set counter = namespace(value=0) %}
45
+ {%- set tool_call_id_seen = namespace(value=false) %}
46
+ {%- for msg in messages %}
47
+ {%- if msg.tool_calls %}
48
+ {%- for tool_call in msg.tool_calls %}
49
+ {%- if tool_call.id == tool_call_id and not tool_call_id_seen.value -%}
50
+ {{ counter.value }}
51
+ {%- set tool_call_id_seen.value = true %}
52
+ {%- endif %}
53
+ {%- set counter.value = counter.value + 1 %}
54
+ {%- endfor %}
55
+ {%- endif %}
56
+ {%- endfor %}
57
+ {%- else -%}
58
+ {{ tool_call_id }}
59
+ {%- endif -%}
60
+ {%- endmacro %}
61
+ {%- macro format_tool_message(messages, tool_msg) -%}
62
+ {#- format tool message #}{
63
+ "tool_call_id": "{{ tool_call_id_to_int(messages, tool_msg.tool_call_id) }}",
64
+ "results": {
65
+ {%- if tool_msg.content is mapping or tool_msg.content is string %}
66
+
67
+ {% if tool_msg.content is string -%}
68
+ {%- set text_wrapper = {"content": tool_msg.content} -%}
69
+ {%- else -%}
70
+ {%- set text_wrapper = tool_msg.content -%}
71
+ {%- endif %}
72
+ "0": {{ text_wrapper|tojson }}
73
+ {%- else %}
74
+ {%- for content in tool_msg.content %}
75
+
76
+ "{{ loop.index0 }}": {{ print_tool_content(content) }}{% if not loop.last %},{% endif %}
77
+ {%- endfor %}
78
+ {%- endif %}
79
+
80
+ },
81
+ "is_error": null
82
+ }
83
+ {%- endmacro -%}
84
+ {%- macro print_tool_content(item) %}
85
+ {%- if item.type|lower == "text" -%}
86
+ {%- set text_wrapper = {"content": item.text} -%}
87
+ {{ text_wrapper|tojson }}
88
+ {%- elif item.type|lower == "document" and item.document and "data" in item.document -%}
89
+ {{ item.document.data|tojson }}
90
+ {%- else -%}
91
+ {{ item|tojson }}
92
+ {%- endif -%}
93
+ {%- endmacro %}
94
+ {%- macro print_msg(msg) %}
95
+ {%- if msg is string -%}
96
+ <|START_TEXT|>{{ msg }}<|END_TEXT|>
97
+ {%- elif msg.content is string -%}
98
+ <|START_TEXT|>{{ msg.content }}<|END_TEXT|>
99
+ {%- else %}
100
+ {%- set last_was_text = namespace(value=false) %}
101
+ {%- for content in msg.content %}
102
+ {%- if content.type|lower == "text" -%}
103
+ {%- if not last_was_text.value -%}
104
+ <|START_TEXT|>
105
+ {%- endif -%}
106
+ {{ content.text }}
107
+ {%- if loop.last -%}
108
+ <|END_TEXT|>
109
+ {%- endif %}
110
+ {%- set last_was_text.value = true -%}
111
+ {%- else -%}
112
+ {%- if last_was_text.value -%}
113
+ <|END_TEXT|>
114
+ {%- endif -%}
115
+ {%- set last_was_text.value = false -%}
116
+ {%- endif -%}
117
+ {%- if content.type|lower == "image" -%}
118
+ {%- if content.data -%}
119
+ {{ content.data }}
120
+ {%- else -%}
121
+ <|IMG_PATCH|>
122
+ {%- endif -%}
123
+ {%- endif -%}
124
+ {%- endfor %}
125
+ {%- endif %}
126
+ {%- endmacro %}
127
+ {%- macro print_thinking(msg) %}
128
+ {%- if msg.reasoning -%}
129
+ {{ msg.reasoning }}
130
+ {%- elif msg.reasoning_content -%}
131
+ {{ msg.reasoning_content }}
132
+ {%- elif msg.thinking -%}
133
+ {{ msg.thinking }}
134
+ {%- elif msg.content and msg.content[0].thinking -%}
135
+ {{ msg.content[0].thinking }}
136
+ {%- endif %}
137
+ {%- endmacro %}
138
+ {%- if messages and messages[0]['role']|lower == 'system' and not has_developer_instruction and convert_first_system_msg %}{%- set developer_instruction = messages[0] %}{%- set render_developer_instruction = true %}{%- set initial_instruction_message = true %}{% endif %}
139
+ {%- set json_object = true if response_format and response_format.type == "json_object" else false %}
140
+ {%- set json_schema = (response_format.json_schema or response_format.schema) if response_format %}
141
+ {%- set json_mode = json_object or json_schema %}
142
+ {%- set tool_idx = namespace(value=0) %}
143
+ {%- set tool_ids_seen = namespace(value=[]) %}
144
+ {%- set regen_tool_call_ids = regen_tool_call_ids | default(true) -%}
145
+ {%- set sent_documents = namespace(value=false) -%}
146
+
147
+ {%- if render_tools_section or render_platform_instruction_override or render_grounding or json_mode -%}
148
+ <|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|><|START_TEXT|>
149
+ {%- elif not render_developer_instruction -%}
150
+ <|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>
151
+ {%- endif %}
152
+
153
+ {%- set rendered_platform_turn_chunk = false %}
154
+
155
+ {%- if render_platform_instruction_override -%}
156
+ {{ platform_instruction_override }}
157
+ {% set rendered_platform_turn_chunk = true %}
158
+ {%- else %}
159
+ {%- endif %}
160
+
161
+ {%- if render_grounding -%}
162
+ {%- if rendered_platform_turn_chunk %}
163
+
164
+ {% endif -%}
165
+ Note that both your responses and reflections can be grounded. Grounding means you associate pieces of texts (called "spans") with those specific tool results that support them (called "sources"). And you use a pair of tags "<co>" and "</co>" to indicate when a span can be grounded onto a list of sources, listing them out in the closing tag. Sources from the same tool call are grouped together and listed as "{tool_call_id}:[{list of result indices}]", before they are joined together by ",". E.g., "<co>span</co: 0:[1,2],1:[0]>" means that "span" is supported by result 1 and 2 from "tool_call_id=0" as well as result 0 from "tool_call_id=1".
166
+ {% set rendered_platform_turn_chunk = true %}
167
+ {%- endif %}
168
+
169
+ {%- if render_tools_section %}
170
+ {%- if rendered_platform_turn_chunk %}
171
+
172
+ {% endif %}
173
+ # Available Tools
174
+ ```json
175
+ [
176
+ {% if tools_or_docs_exist %}
177
+ {%- if documents %}
178
+ {"name": "direct-injected-document", "description": "This is a special tool to directly inject user-uploaded documents into the chat as additional context. DO NOT use this tool by yourself!", "parameters": {"type": "object", "properties": {}, "required": []}, "responses": {"200": {"description": "Successfully returned a list of chunked text snippets from the directly uploaded documents.", "content": {"application/json": {"schema": {"type": "array", "items": {"type": "object", "required": ["url", "snippet"], "properties": {"url": {"type": "string", "description": "The url of the uploaded document."}, "snippet": {"type": "string", "description": "The text snippet for the returned document chunk."}}}}}}}}}
179
+ {%- if tools %},
180
+ {% else %}
181
+
182
+ {% endif %}
183
+ {%- endif %}
184
+ {%- for tool in tools %}
185
+ {"name": "{{ tool['function']['name'] }}", "description": "{{ tool['function']['description'] }}", "parameters": {{ tool['function']['parameters']|tojson }}, "responses": null}
186
+ {%- if not loop.last %},{% endif %}
187
+
188
+ {% endfor %}
189
+ {%- else %}
190
+
191
+ {% endif %}
192
+ ]
193
+ ```
194
+ {%- set rendered_platform_turn_chunk = true %}
195
+ {%- endif -%}
196
+
197
+ {%- if json_mode -%}
198
+ {%- if rendered_platform_turn_chunk %}
199
+
200
+
201
+ {% endif -%}
202
+ When generating JSON objects, do not generate block markers. Generate an object directly without prefixing with ```json. Return only the JSON and nothing else.
203
+ {%- if json_schema %}
204
+
205
+ Your output should adhere to the following json schema:
206
+ {{ json_schema }}
207
+ {%- endif -%}
208
+ {%- set rendered_platform_turn_chunk = true %}
209
+ {%- endif %}
210
+ {%- if rendered_platform_turn_chunk -%}
211
+ <|END_TEXT|><|END_OF_TURN_TOKEN|>
212
+ {%- elif not render_developer_instruction -%}
213
+ <|END_OF_TURN_TOKEN|>
214
+ {%- endif %}
215
+ {%- if render_developer_instruction -%}
216
+ <|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>{{ print_msg(developer_instruction) }}<|END_OF_TURN_TOKEN|>
217
+ {%- endif %}
218
+ {%- for message in messages %}
219
+ {%- set msg_role_downcased = message.role | lower %}
220
+ {%- if msg_role_downcased == 'system' and (not (loop.first and initial_instruction_message)) -%}
221
+ <|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>{{ print_msg(message) }}<|END_OF_TURN_TOKEN|>
222
+ {%- elif msg_role_downcased == 'user' -%}
223
+ <|START_OF_TURN_TOKEN|><|USER_TOKEN|>{{ print_msg(message) }}<|END_OF_TURN_TOKEN|>
224
+ {%- if documents and not sent_documents.value %}{%- set sent_documents.value = true %}{% set tool_idx.value = tool_idx.value + 1 %}{{ document_turn(documents) }}{% endif %}
225
+ {%- elif msg_role_downcased == 'assistant' or msg_role_downcased == 'chatbot' -%}
226
+ <|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>
227
+ {%- if message.tool_calls %}
228
+ {% if not skip_thinking %}
229
+ {% if message.tool_plan -%}
230
+ <|START_THINKING|>{{ message.tool_plan }}<|END_THINKING|>
231
+ {%- elif message.reasoning or message.reasoning_content or message.thinking or (message.content and message.content[0].type == "thinking") -%}
232
+ <|START_THINKING|>{{ print_thinking(message) }}<|END_THINKING|>
233
+ {%- endif %}
234
+ {%- endif %}<|START_ACTION|>[
235
+ {%- for tc in message.tool_calls %}
236
+
237
+ {"tool_call_id": "{%- if regen_tool_call_ids -%}{{ tool_idx.value }}{%- else -%}{{ tc.id }}{%- endif -%}", "tool_name": "{{ tc['function']['name'] }}", "parameters": {{ tc['function']['arguments']|tojson }}}{% if not loop.last %},{% endif %}
238
+ {%- set tool_idx.value = tool_idx.value + 1 %}
239
+ {%- endfor %}
240
+
241
+ ]<|END_ACTION|><|END_OF_TURN_TOKEN|>
242
+ {%- else -%}
243
+ {% if (message.reasoning or message.reasoning_content or message.thinking or (message.content and message.content[0].type == "thinking")) and not skip_thinking -%}
244
+ <|START_THINKING|>{{ print_thinking(message) }}<|END_THINKING|>
245
+ {%- endif -%}
246
+ {{ print_msg(message) }}<|END_OF_TURN_TOKEN|>
247
+ {%- endif %}
248
+ {%- elif msg_role_downcased == 'tool' and message.tool_call_id not in tool_ids_seen.value -%}
249
+ <|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|><|START_TOOL_RESULT|>[
250
+ {{ format_tool_message(messages, message) }}
251
+ {%- for msg in messages[loop.index0 + 1:] %}
252
+
253
+ {%- if msg.role | lower == 'tool' %},
254
+ {{ format_tool_message(messages, msg) }}
255
+ {%- set tool_ids_seen.value = tool_ids_seen.value + [msg.tool_call_id] %}
256
+ {%- else %}
257
+ {%- break %}
258
+ {%- endif %}
259
+ {%- endfor %}
260
+
261
+ ]<|END_TOOL_RESULT|><|END_OF_TURN_TOKEN|>
262
+ {%- endif %}
263
+ {%- endfor %}{%- if add_generation_prompt -%}<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>{% if reasoning %}<|START_THINKING|>{% else %}<|START_THINKING|><|END_THINKING|>{% endif %}{%- endif %}
models/templates/CohereForAI-c4ai-command-r-plus-tool_use.jinja ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ {%- macro json_to_python_type(json_spec) %}
3
+ {%- set basic_type_map = {
4
+ "string": "str",
5
+ "number": "float",
6
+ "integer": "int",
7
+ "boolean": "bool"
8
+ } %}
9
+
10
+ {%- if basic_type_map[json_spec.type] is defined %}
11
+ {{- basic_type_map[json_spec.type] }}
12
+ {%- elif json_spec.type == "array" %}
13
+ {{- "List[" + json_to_python_type(json_spec.items) + "]"}}
14
+ {%- elif json_spec.type == "object" %}
15
+ {{- "Dict[str, " + json_to_python_type(json_spec.additionalProperties) + ']'}}
16
+ {%- elif json_spec.type is iterable %}
17
+ {{- "Union[" }}
18
+ {%- for t in json_spec.type %}
19
+ {{- json_to_python_type({"type": t}) }}
20
+ {%- if not loop.last %}
21
+ {{- "," }}
22
+ {%- endif %}
23
+ {%- endfor %}
24
+ {{- "]" }}
25
+ {%- else %}
26
+ {{- "Any" }}
27
+ {%- endif %}
28
+ {%- endmacro %}
29
+
30
+ {%- macro old_tool_parser(tools) %}
31
+ {%- for tool in tools %}
32
+ {%- if loop.index0 != 0 %}
33
+ {{- '\n\n' }}
34
+ {%- endif %}
35
+ {{- '```python\ndef ' + tool.name + '(' }}
36
+ {%- for param_name, param_fields in tool.parameter_definitions|items %}
37
+ {%- if loop.index0 != 0 %}
38
+ {{- ', '}}
39
+ {%- endif %}
40
+ {{- param_name + ': ' }}
41
+ {%- if not param_fields.required %}
42
+ {{- 'Optional[' + param_fields.type + '] = None'}}
43
+ {%- else %}
44
+ {{- param_fields.type }}
45
+ {%- endif %}
46
+ {%- endfor %}
47
+ {{- ') -> List[Dict]:\n """'}}
48
+ {{- tool.description }}
49
+ {%- if tool.parameter_definitions|length != 0 %}
50
+ {{- '\n\n Args:\n '}}
51
+ {%- for param_name, param_fields in tool.parameter_definitions|items %}
52
+ {%- if loop.index0 != 0 %}
53
+ {{- '\n ' }}
54
+ {%- endif %}
55
+ {{- param_name + ' ('}}
56
+ {%- if not param_fields.required %}
57
+ {{- 'Optional[' + param_fields.type + ']'}}
58
+ {%- else %}
59
+ {{- param_fields.type }}
60
+ {%- endif %}
61
+ {{- '): ' + param_fields.description }}
62
+ {%- endfor %}
63
+ {%- endif %}
64
+ {{- '\n """\n pass\n```' }}
65
+ {%- endfor %}
66
+ {%- endmacro %}
67
+
68
+ {%- macro new_tool_parser(tools) %}
69
+ {%- for tool in tools %}
70
+ {%- if loop.index0 != 0 %}
71
+ {{- '\n\n'}}
72
+ {%- endif %}
73
+ {%- if tool.function is defined %}
74
+ {%- set tool = tool.function %}
75
+ {%- endif %}
76
+ {{-'```python
77
+ def ' + tool.name + '('}}
78
+ {%- for param_name, param_fields in tool.parameters.properties|items %}
79
+ {%- if loop.index0 != 0 %}
80
+ {{- ', '}}
81
+ {%- endif %}
82
+ {{-param_name + ": "}}
83
+ {%- if not param_name in tool.parameters.required %}
84
+ {{-'Optional[' + json_to_python_type(param_fields) + '] = None'}}
85
+ {%- else %}
86
+ {{- json_to_python_type(param_fields) }}
87
+ {%- endif %}
88
+ {%- endfor %}
89
+ {{- ') -> List[Dict]:
90
+ """'}}
91
+ {{- tool.description }}
92
+ {%- if tool.parameters.properties|length != 0 %}
93
+ {{- '\n\n Args:\n '}}
94
+ {%- for param_name, param_fields in tool.parameters.properties|items %}
95
+ {%- if loop.index0 != 0 %}
96
+ {{- '\n ' }}
97
+ {%- endif %}
98
+ {{- param_name + ' ('}}
99
+ {%- if not param_name in tool.parameters.required %}
100
+ {{-'Optional[' + json_to_python_type(param_fields) + ']'}}
101
+ {%- else %}
102
+ {{- json_to_python_type(param_fields) }}
103
+ {%- endif %}
104
+ {{- '): ' + param_fields.description }}
105
+ {%- endfor %}
106
+ {%- endif %}
107
+ {{- '\n """\n pass\n```' }}
108
+ {%- endfor %}
109
+ {%- endmacro %}
110
+
111
+ {{- bos_token }}
112
+ {%- if messages[0]['role'] == 'system' %}
113
+ {%- set loop_messages = messages[1:] %}
114
+ {%- set system_message = messages[0]['content'] %}
115
+ {%- else %}
116
+ {%- set loop_messages = messages %}
117
+ {%- set system_message = '## Task and Context\nYou help people answer their questions and other requests interactively. You will be asked a very wide array of requests on all kinds of topics. You will be equipped with a wide range of search engines or similar tools to help you, which you use to research your answer. You should focus on serving the user\'s needs as best you can, which will be wide-ranging.\n\n## Style Guide\nUnless the user asks for a different style of answer, you should answer in full sentences, using proper grammar and spelling.' %}
118
+ {%- endif %}
119
+ {{- '<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>' }}
120
+ {{- '# Safety Preamble' }}
121
+ {{- '
122
+ The instructions in this section override those in the task description and style guide sections. Don\'t answer questions that are harmful or immoral.' }}
123
+ {{- '
124
+
125
+ # System Preamble' }}
126
+ {{- '
127
+ ## Basic Rules' }}
128
+ {{- '
129
+ You are a powerful conversational AI trained by Cohere to help people. You are augmented by a number of tools, and your job is to use and consume the output of these tools to best help the user. You will see a conversation history between yourself and a user, ending with an utterance from the user. You will then see a specific instruction instructing you what kind of response to generate. When you answer the user\'s requests, you cite your sources in your answers, according to those instructions.' }}
130
+ {{- '
131
+
132
+ # User Preamble' }}
133
+ {{- '
134
+ ' + system_message }}
135
+ {{-'
136
+
137
+ ## Available Tools
138
+ Here is a list of tools that you have available to you:
139
+
140
+ '}}
141
+ {%- set ns = namespace(new_tools=true) %}
142
+ {%- for tool in tools %}
143
+ {%- if tool.parameter_definitions is defined %}
144
+ {%- set ns.new_tools = false %}
145
+ {%- endif %}
146
+ {%- endfor %}
147
+ {%- if ns.new_tools %}
148
+ {{- new_tool_parser(tools) }}
149
+ {%- else %}
150
+ {{- old_tool_parser(tools) }}
151
+ {%- endif %}
152
+ {{- '<|END_OF_TURN_TOKEN|>'}}
153
+ {%- for message in loop_messages %}
154
+ {%- set content = message['content'] %}
155
+ {%- if message.role == 'user' %}
156
+ {{- '<|START_OF_TURN_TOKEN|><|USER_TOKEN|>' + content|trim + '<|END_OF_TURN_TOKEN|>' }}
157
+ {%- elif message.role == 'system' %}
158
+ {{- '<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>' + content|trim + '<|END_OF_TURN_TOKEN|>' }}
159
+ {%- elif message.role == 'assistant' and message.tool_calls is defined %}
160
+ {{- '<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>' }}
161
+ {%- if message.content is defined %}
162
+ {{- message.content|trim }}
163
+ {%- endif %}
164
+ {{- '\nAction:\n```json\n[\n' }}
165
+ {%- for tool_call in message.tool_calls %}
166
+ {%- if tool_call.function is defined %}
167
+ {%- set tool_call = tool_call.function %}
168
+ {%- endif %}
169
+ {{- '{\n'|indent(4, first=true) }}
170
+ {{- '"tool_name": "'|indent(8, first=true) + tool_call.name + '",\n' }}
171
+ {{- '"parameters": '|indent(8, first=true) }}
172
+ {%- if tool_call.arguments is defined and tool_call.arguments|length > 0 %}
173
+ {{- tool_call.arguments|tojson(indent=4)|indent(8) }}
174
+ {{- '\n' }}
175
+ {%- else %}
176
+ {{- '{}\n' }}
177
+ {%- endif %}
178
+ {{- '}'|indent(4, first=true) }}
179
+ {%- if not loop.last %}
180
+ {{- ',\n' }}
181
+ {%- endif %}
182
+ {%- endfor %}
183
+ {{- "\n]```\n" }}
184
+ {%- elif message.role == 'assistant' %}
185
+ {{- '<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>' + content|trim + '<|END_OF_TURN_TOKEN|>' }}
186
+ {%- elif message.role == 'tool' %}
187
+ {{- '<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|><results>\n' }}
188
+ {{- message.content|trim }}
189
+ {{- '</results><|END_OF_TURN_TOKEN|>' }}
190
+ {%- endif %}
191
+ {%- endfor %}
192
+ {{-'<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>Write \'Action:\' followed by a json-formatted list of actions that you want to perform in order to produce a good response to the user\'s last input. You can use any of the supplied tools any number of times, but you should aim to execute the minimum number of necessary actions for the input. You should use the `directly-answer` tool if calling the other tools is unnecessary. The list of actions you want to call should be formatted as a list of json objects, for example:
193
+ ```json
194
+ [
195
+ {
196
+ "tool_name": title of the tool in the specification,
197
+ "parameters": a dict of parameters to input into the tool as they are defined in the specs, or {} if it takes no parameters
198
+ }
199
+ ]```<|END_OF_TURN_TOKEN|>'}}
200
+ {%- if add_generation_prompt %}
201
+ {{- '<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>' }}
202
+ {%- endif %}
models/templates/CohereForAI-c4ai-command-r7b-12-2024-tool_use.jinja ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{ bos_token }}{%- macro document_turn(documents) -%}
2
+ {# format documents into chat turn #}
3
+ <|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|><|START_THINKING|>I will look through the document to address the users needs.<|END_THINKING|><|START_ACTION|>[
4
+ {"tool_call_id": "0", "tool_name": "direct-injected-document", "parameters": {}}
5
+ ]<|END_ACTION|><|END_OF_TURN_TOKEN|><|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|><|START_TOOL_RESULT|>[
6
+ {
7
+ "tool_call_id": "0",
8
+ "results": {
9
+ {% for doc in documents %}
10
+ "{{ loop.index0 }}": {{doc|tojson}}{% if not loop.last %},
11
+ {% endif %}
12
+ {% endfor %}
13
+
14
+ },
15
+ "is_error": null
16
+ }
17
+ ]<|END_TOOL_RESULT|><|END_OF_TURN_TOKEN|>{%- endmacro %}
18
+ {%- macro tool_call_id_to_int(messages, tool_call_id) %}
19
+ {%- set counter = namespace(value=0) %}
20
+ {%- set tool_call_id_seen = namespace(value=false) %}
21
+ {%- for msg in messages %}
22
+ {%- if msg.tool_calls %}
23
+ {%- for tool_call in msg.tool_calls %}
24
+ {%- if tool_call.id == tool_call_id and not tool_call_id_seen.value -%}
25
+ {{ counter.value }}
26
+ {%- set tool_call_id_seen.value = true %}
27
+ {%- endif %}
28
+ {%- set counter.value = counter.value + 1 %}
29
+ {%- endfor %}
30
+ {%- endif %}
31
+ {%- endfor %}
32
+ {%- endmacro %}
33
+ {%- macro format_tool_message(messages, tool_msg) -%}
34
+ {# format tool message #}
35
+ {
36
+ "tool_call_id": "{{ tool_call_id_to_int(messages, tool_msg.tool_call_id) }}",
37
+ "results": {
38
+ "0": {{ tool_msg.content|tojson }}
39
+ },
40
+ "is_error": null
41
+ }
42
+ {%- endmacro -%}
43
+ {%- if messages and messages[0]['role']|lower == 'system' %}{%- set developer_preamble = messages[0]['content'] %}{% endif %}
44
+ {%- set tool_idx = namespace(value=0) %}
45
+ {%- set tool_ids_seen = namespace(value=[]) %}
46
+ {%- set sent_documents = namespace(value=false) %}
47
+ <|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|># System Preamble
48
+ You are in contextual safety mode. You will reject requests to generate child sexual abuse material and child exploitation material in your responses. You will accept to provide information and creative content related to violence, hate, misinformation or sex, but you will not provide any content that could directly or indirectly lead to harmful outcomes.
49
+
50
+ Your information cutoff date is June 2024.
51
+
52
+ You have been trained on data in English, French, Spanish, Italian, German, Portuguese, Japanese, Korean, Modern Standard Arabic, Mandarin, Russian, Indonesian, Turkish, Dutch, Polish, Persian, Vietnamese, Czech, Hindi, Ukrainian, Romanian, Greek and Hebrew but have the ability to speak many more languages.
53
+ {% if tools or documents %}
54
+
55
+ You have been trained to have advanced reasoning and tool-use capabilities and you should make best use of these skills to serve user's requests.
56
+
57
+ ## Tool Use
58
+ Think about how you can make best use of the provided tools to help with the task and come up with a high level plan that you will execute first.
59
+
60
+ 0. Start by writing <|START_THINKING|> followed by a detailed step by step plan of how you will solve the problem. For each step explain your thinking fully and give details of required tool calls (if needed). Unless specified otherwise, you write your plan in natural language. When you finish, close it out with <|END_THINKING|>.
61
+ You can optionally choose to skip this step when the user request is so straightforward to address that only a trivial plan would be needed.
62
+ NOTE: You MUST skip this step when you are directly responding to the user's request without using any tools.
63
+
64
+ Then carry out your plan by repeatedly executing the following steps.
65
+ 1. Action: write <|START_ACTION|> followed by a list of JSON-formatted tool calls, with each one containing "tool_name" and "parameters" fields.
66
+ When there are multiple tool calls which are completely independent of each other (i.e. they can be executed in parallel), you should list them out all together in one step. When you finish, close it out with <|END_ACTION|>.
67
+ 2. Observation: you will then receive results of those tool calls in JSON format in the very next turn, wrapped around by <|START_TOOL_RESULT|> and <|END_TOOL_RESULT|>. Carefully observe those results and think about what to do next. Note that these results will be provided to you in a separate turn. NEVER hallucinate results.
68
+ Every tool call produces a list of results (when a tool call produces no result or a single result, it'll still get wrapped inside a list). Each result is clearly linked to its originating tool call via its "tool_call_id".
69
+ 3. Reflection: start the next turn by writing <|START_THINKING|> followed by what you've figured out so far, any changes you need to make to your plan, and what you will do next. When you finish, close it out with <|END_THINKING|>.
70
+ You can optionally choose to skip this step when everything is going according to plan and no special pieces of information or reasoning chains need to be recorded.
71
+ NOTE: You MUST skip this step when you are done with tool-use actions and are ready to respond to the user.
72
+
73
+ You can repeat the above 3 steps multiple times (could be 0 times too if no suitable tool calls are available or needed), until you decide it's time to finally respond to the user.
74
+
75
+ 4. Response: then break out of the loop and write <|START_RESPONSE|> followed by a piece of text which serves as a response to the user's last request. Use all previous tool calls and results to help you when formulating your response. When you finish, close it out with <|END_RESPONSE|>.
76
+ {% if enable_citations %}
77
+
78
+ ## Grounding
79
+ Importantly, note that "Reflection" and "Response" above can be grounded.
80
+ Grounding means you associate pieces of texts (called "spans") with those specific tool results that support them (called "sources"). And you use a pair of tags "<co>" and "</co>" to indicate when a span can be grounded onto a list of sources, listing them out in the closing tag. Sources from the same tool call are grouped together and listed as "{tool_call_id}:[{list of result indices}]", before they are joined together by ",". E.g., "<co>span</co: 0:[1,2],1:[0]>" means that "span" is supported by result 1 and 2 from "tool_call_id=0" as well as result 0 from "tool_call_id=1".
81
+ {% endif %}
82
+
83
+ ## Available Tools
84
+ Here is the list of tools that you have available to you.
85
+ You can ONLY use the tools listed here. When a tool is not listed below, it is NOT available and you should NEVER attempt to use it.
86
+ Each tool is represented as a JSON object with fields like "name", "description", "parameters" (per JSON Schema), and optionally, "responses" (per JSON Schema).
87
+
88
+ ```json
89
+ [
90
+ {% if documents %}
91
+ {"name": "direct-injected-document", "description": "This is a special tool to directly inject user-uploaded documents into the chat as additional context. DO NOT use this tool by yourself!", "parameters": {"type": "object", "properties": {}, "required": []}, "responses": {"200": {"description": "Successfully returned a list of chunked text snippets from the directly uploaded documents.", "content": {"application/json": {"schema": {"type": "array", "items": {"type": "object", "required": ["url", "snippet"], "properties": {"url": {"type": "string", "description": "The url of the uploaded document."}, "snippet": {"type": "string", "description": "The text snippet for the returned document chunk."}}}}}}}}}{%- if tools %},{% endif %}
92
+
93
+ {% endif %}
94
+ {% for tool in tools %}
95
+ {"name": "{{ tool['function']['name'] }}", "description": "{{tool['function']['description']}}", "parameters": {{ tool['function']['parameters']|tojson }}, "responses": null}{%- if not loop.last %},{% endif %}
96
+
97
+ {% endfor %}
98
+ ]
99
+ ```
100
+
101
+ {% endif %}
102
+ # Default Preamble
103
+ The following instructions are your defaults unless specified elsewhere in developer preamble or user prompt.
104
+ - Your name is Command.
105
+ - You are a large language model built by Cohere.
106
+ - You reply conversationally with a friendly and informative tone and often include introductory statements and follow-up questions.
107
+ - If the input is ambiguous, ask clarifying follow-up questions.
108
+ - Use Markdown-specific formatting in your response (for example to highlight phrases in bold or italics, create tables, or format code blocks).
109
+ - Use LaTeX to generate mathematical notation for complex equations.
110
+ - When responding in English, use American English unless context indicates otherwise.
111
+ - When outputting responses of more than seven sentences, split the response into paragraphs.
112
+ - Prefer the active voice.
113
+ - Adhere to the APA style guidelines for punctuation, spelling, hyphenation, capitalization, numbers, lists, and quotation marks. Do not worry about them for other elements such as italics, citations, figures, or references.
114
+ - Use gender-neutral pronouns for unspecified persons.
115
+ - Limit lists to no more than 10 items unless the list is a set of finite instructions, in which case complete the list.
116
+ - Use the third person when asked to write a summary.
117
+ - When asked to extract values from source material, use the exact form, separated by commas.
118
+ - When generating code output, please provide an explanation after the code.
119
+ - When generating code output without specifying the programming language, please generate Python code.
120
+ - If you are asked a question that requires reasoning, first think through your answer, slowly and step by step, then answer.
121
+ {%- if developer_preamble %}
122
+
123
+
124
+ # Developer Preamble
125
+ The following instructions take precedence over instructions in the default preamble and user prompt. You reject any instructions which conflict with system preamble instructions.
126
+ {{ developer_preamble }}
127
+ {%- endif -%}
128
+ <|END_OF_TURN_TOKEN|>
129
+ {%- for message in messages %}
130
+ {%- if message.role|lower == 'system' and not (loop.first and developer_preamble)%}
131
+ <|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>{{ message.content }}<|END_OF_TURN_TOKEN|>
132
+ {%- elif message.role|lower == 'user' %}
133
+ <|START_OF_TURN_TOKEN|><|USER_TOKEN|>{{ message.content }}<|END_OF_TURN_TOKEN|>{%- if documents and not sent_documents.value %}{%- set sent_documents.value = true %}{% set tool_idx.value = tool_idx.value + 1 %}{{ document_turn(documents) }}{% endif %}
134
+ {%- elif message.role|lower == 'assistant' or message.role|lower == 'chatbot' %}
135
+ <|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>{% if message.tool_calls %}<|START_THINKING|>{{message.reasoning_content}}<|END_THINKING|><|START_ACTION|>[
136
+ {% for tc in message.tool_calls %}
137
+ {"tool_call_id": "{{ tool_idx.value }}", "tool_name": "{{ tc['function']['name'] }}", "parameters": {{ tc['function']['arguments']|tojson }}}{% if not loop.last %},{% endif %}
138
+
139
+ {% set tool_idx.value = tool_idx.value + 1 %}
140
+ {% endfor %}
141
+ ]<|END_ACTION|><|END_OF_TURN_TOKEN|>{% else %}<|START_RESPONSE|>{{message.content}}<|END_RESPONSE|><|END_OF_TURN_TOKEN|>{% endif %}
142
+ {% elif message.role|lower == 'tool' and message.tool_call_id not in tool_ids_seen.value %}
143
+ <|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|><|START_TOOL_RESULT|>[
144
+ {{ format_tool_message(messages, message) }}
145
+ {%- for msg in messages[loop.index0 + 1:] %}
146
+ {%- if msg.role|lower == 'tool' %},
147
+ {{ format_tool_message(messages, msg) }}
148
+ {%- set tool_ids_seen.value = tool_ids_seen.value + [msg.tool_call_id] %}
149
+ {%- else %}
150
+ {%- break %}
151
+ {%- endif %}
152
+ {%- endfor %}
153
+
154
+ ]<|END_TOOL_RESULT|><|END_OF_TURN_TOKEN|>
155
+ {%- endif %}
156
+ {%- endfor %}<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>{%- if not enable_thinking -%}<|START_THINKING|><|END_THINKING|>{%- endif %}
models/templates/GLM-4.6.jinja ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [gMASK]<sop>
2
+ {%- if tools -%}
3
+ <|system|>
4
+ # Tools
5
+
6
+ You may call one or more functions to assist with the user query.
7
+
8
+ You are provided with function signatures within <tools></tools> XML tags:
9
+ <tools>
10
+ {% for tool in tools %}
11
+ {{ tool | tojson(ensure_ascii=False) }}
12
+ {% endfor %}
13
+ </tools>
14
+
15
+ For each function call, output the function name and arguments within the following XML format:
16
+ <tool_call>{function-name}
17
+ <arg_key>{arg-key-1}</arg_key>
18
+ <arg_value>{arg-value-1}</arg_value>
19
+ <arg_key>{arg-key-2}</arg_key>
20
+ <arg_value>{arg-value-2}</arg_value>
21
+ ...
22
+ </tool_call>{%- endif -%}
23
+ {%- macro visible_text(content) -%}
24
+ {%- if content is string -%}
25
+ {{- content }}
26
+ {%- elif content is iterable and content is not mapping -%}
27
+ {%- for item in content -%}
28
+ {%- if item is mapping and item.type == 'text' -%}
29
+ {{- item.text }}
30
+ {%- elif item is string -%}
31
+ {{- item }}
32
+ {%- endif -%}
33
+ {%- endfor -%}
34
+ {%- else -%}
35
+ {{- content }}
36
+ {%- endif -%}
37
+ {%- endmacro -%}
38
+ {%- set ns = namespace(last_user_index=-1) %}
39
+ {%- for m in messages %}
40
+ {%- if m.role == 'user' %}
41
+ {% set ns.last_user_index = loop.index0 -%}
42
+ {%- endif %}
43
+ {%- endfor %}
44
+ {% for m in messages %}
45
+ {%- if m.role == 'user' -%}<|user|>
46
+ {{ visible_text(m.content) }}
47
+ {{- '/nothink' if (enable_thinking is defined and not enable_thinking and not visible_text(m.content).endswith("/nothink")) else '' -}}
48
+ {%- elif m.role == 'assistant' -%}
49
+ <|assistant|>
50
+ {%- set reasoning_content = '' %}
51
+ {%- set content = visible_text(m.content) %}
52
+ {%- if m.reasoning_content is string %}
53
+ {%- set reasoning_content = m.reasoning_content %}
54
+ {%- else %}
55
+ {%- if '</think>' in content %}
56
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
57
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
58
+ {%- endif %}
59
+ {%- endif %}
60
+ {%- if loop.index0 > ns.last_user_index and reasoning_content -%}
61
+ {{ '\n<think>' + reasoning_content.strip() + '</think>'}}
62
+ {%- else -%}
63
+ {{ '\n<think></think>' }}
64
+ {%- endif -%}
65
+ {%- if content.strip() -%}
66
+ {{ '\n' + content.strip() }}
67
+ {%- endif -%}
68
+ {% if m.tool_calls %}
69
+ {% for tc in m.tool_calls %}
70
+ {%- if tc.function %}
71
+ {%- set tc = tc.function %}
72
+ {%- endif %}
73
+ {{ '\n<tool_call>' + tc.name }}
74
+ {% set _args = tc.arguments or {} %}
75
+ {% if _args is not mapping %}
76
+ {{ raise_exception("Invalid tool call arguments passed: " + _args | string) }}
77
+ {% endif %}
78
+ {% for k, v in _args.items() %}
79
+ <arg_key>{{ k }}</arg_key>
80
+ <arg_value>{{ v | tojson(ensure_ascii=False) if v is not string else v }}</arg_value>
81
+ {% endfor %}
82
+ </tool_call>{% endfor %}
83
+ {% endif %}
84
+ {%- elif m.role == 'tool' -%}
85
+ {%- if m.content is string -%}
86
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
87
+ {{- '<|observation|>' }}
88
+ {%- endif %}
89
+ {{- '\n<tool_response>\n' }}
90
+ {{- m.content }}
91
+ {{- '\n</tool_response>' }}
92
+ {%- else -%}
93
+ <|observation|>{% for tr in m.content %}
94
+
95
+ <tool_response>
96
+ {{ tr.output if tr.output is defined else tr }}
97
+ </tool_response>{% endfor -%}
98
+ {% endif -%}
99
+ {%- elif m.role == 'system' -%}
100
+ <|system|>
101
+ {{ visible_text(m.content) }}
102
+ {%- endif -%}
103
+ {%- endfor -%}
104
+ {%- if add_generation_prompt -%}
105
+ <|assistant|>{{- '\n<think></think>' if (enable_thinking is defined and not enable_thinking) else '' -}}
106
+ {%- endif -%}
models/templates/GLM-4.7-Flash.jinja ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [gMASK]<sop>
2
+ {%- if tools -%}
3
+ <|system|>
4
+ # Tools
5
+
6
+ You may call one or more functions to assist with the user query.
7
+
8
+ You are provided with function signatures within <tools></tools> XML tags:
9
+ <tools>
10
+ {% for tool in tools %}
11
+ {{ tool | tojson(ensure_ascii=False) }}
12
+ {% endfor %}
13
+ </tools>
14
+
15
+ For each function call, output the function name and arguments within the following XML format:
16
+ <tool_call>{function-name}<arg_key>{arg-key-1}</arg_key><arg_value>{arg-value-1}</arg_value><arg_key>{arg-key-2}</arg_key><arg_value>{arg-value-2}</arg_value>...</tool_call>{%- endif -%}
17
+ {%- macro visible_text(content) -%}
18
+ {%- if content is string -%}
19
+ {{- content }}
20
+ {%- elif content is iterable and content is not mapping -%}
21
+ {%- for item in content -%}
22
+ {%- if item is mapping and item.type == 'text' -%}
23
+ {{- item.text }}
24
+ {%- elif item is string -%}
25
+ {{- item }}
26
+ {%- endif -%}
27
+ {%- endfor -%}
28
+ {%- else -%}
29
+ {{- content }}
30
+ {%- endif -%}
31
+ {%- endmacro -%}
32
+ {%- set ns = namespace(last_user_index=-1) %}
33
+ {%- for m in messages %}
34
+ {%- if m.role == 'user' %}
35
+ {% set ns.last_user_index = loop.index0 -%}
36
+ {%- endif %}
37
+ {%- endfor %}
38
+ {% for m in messages %}
39
+ {%- if m.role == 'user' -%}<|user|>{{ visible_text(m.content) }}
40
+ {%- elif m.role == 'assistant' -%}
41
+ <|assistant|>
42
+ {%- set reasoning_content = '' %}
43
+ {%- set content = visible_text(m.content) %}
44
+ {%- if m.reasoning_content is string %}
45
+ {%- set reasoning_content = m.reasoning_content %}
46
+ {%- else %}
47
+ {%- if '</think>' in content %}
48
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
49
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
50
+ {%- endif %}
51
+ {%- endif %}
52
+ {%- if ((clear_thinking is defined and not clear_thinking) or loop.index0 > ns.last_user_index) and reasoning_content -%}
53
+ {{ '<think>' + reasoning_content.strip() + '</think>'}}
54
+ {%- else -%}
55
+ {{ '</think>' }}
56
+ {%- endif -%}
57
+ {%- if content.strip() -%}
58
+ {{ content.strip() }}
59
+ {%- endif -%}
60
+ {% if m.tool_calls %}
61
+ {% for tc in m.tool_calls %}
62
+ {%- if tc.function %}
63
+ {%- set tc = tc.function %}
64
+ {%- endif %}
65
+ {{- '<tool_call>' + tc.name -}}
66
+ {% set _args = tc.arguments %}{% for k, v in _args.items() %}<arg_key>{{ k }}</arg_key><arg_value>{{ v | tojson(ensure_ascii=False) if v is not string else v }}</arg_value>{% endfor %}</tool_call>{% endfor %}
67
+ {% endif %}
68
+ {%- elif m.role == 'tool' -%}
69
+ {%- if m.content is string -%}
70
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
71
+ {{- '<|observation|>' }}
72
+ {%- endif %}
73
+ {{- '<tool_response>' }}
74
+ {{- m.content }}
75
+ {{- '</tool_response>' }}
76
+ {%- else -%}
77
+ <|observation|>{% for tr in m.content %}
78
+ <tool_response>{{ tr.output if tr.output is defined else tr }}</tool_response>{% endfor -%}
79
+ {% endif -%}
80
+ {%- elif m.role == 'system' -%}
81
+ <|system|>{{ visible_text(m.content) }}
82
+ {%- endif -%}
83
+ {%- endfor -%}
84
+ {%- if add_generation_prompt -%}
85
+ <|assistant|>{{- '</think>' if (enable_thinking is defined and not enable_thinking) else '<think>' -}}
86
+ {%- endif -%}
models/templates/GigaChat3-10B-A1.8B.jinja ADDED
@@ -0,0 +1,355 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {#--------TOOL RENDERING FUNCTIONS---------#}
2
+
3
+ {#---------------------------------------------------------------
4
+ Converts JSON Schema (dict) to a TypeScript type definition
5
+ ----------------------------------------------------------------#}
6
+ {%- macro json_schema_to_typescript(schema, indent="") -%}
7
+ {%- set ADDITIONAL_JSON_KEYS = ['format', 'maxItems', 'maximum', 'minItems', 'minimum', 'pattern'] -%}
8
+ {%- set ty = schema.get("type") -%}
9
+
10
+ {# ---------------- OBJECT ---------------- #}
11
+ {%- if ty == "object" -%}
12
+ {{- "{\n" -}}
13
+
14
+ {# Start building property list #}
15
+ {%- set props = schema.get("properties", {}) -%}
16
+ {%- set required = schema.get("required", []) -%}
17
+ {%- set has_additional_props = schema.get("additionalProperties") is defined -%}
18
+ {%- set additional_props_type = none -%}
19
+ {%- if has_additional_props -%}
20
+ {%- if schema.additionalProperties == true -%}
21
+ {%- set additional_props_type = {'type': 'any'} -%}
22
+ {%- elif schema.additionalProperties is mapping -%}
23
+ {%- set additional_props_type = schema.additionalProperties -%}
24
+ {%- endif -%}
25
+ {%- endif -%}
26
+
27
+ {%- for key, val in props.items() -%}
28
+ {# ---------- Description Comments ---------- #}
29
+ {%- if "description" in val -%}
30
+ {%- for line in val['description'].split('\n') -%}
31
+ {%- if line.strip() -%}
32
+ {{- indent + '// ' + line + '\n' -}}
33
+ {%- endif -%}
34
+ {%- endfor -%}
35
+ {%- endif -%}
36
+
37
+ {# ---------- Additional JSON Keys ---------- #}
38
+ {%- for add_key, add_val in val.items() -%}
39
+ {%- if add_key in ADDITIONAL_JSON_KEYS -%}
40
+ {%- if add_val is string -%}
41
+ {{- indent + '// ' + add_key + ': "' + add_val + '"' + '\n' -}}
42
+ {%- else -%}
43
+ {{- indent + '// ' + add_key + ': ' ~ add_val ~ '\n' -}}
44
+ {%- endif -%}
45
+ {%- endif -%}
46
+ {%- endfor -%}
47
+
48
+ {# ---------- Property Definition ---------- #}
49
+ {%- set type_str = json_schema_to_typescript(
50
+ val,
51
+ indent + " "
52
+ ) -%}
53
+
54
+ {{- indent + key + ('' if key in required else '?') + ': ' + type_str + ',' -}}
55
+
56
+ {%- if "default" in val or "defalut_value" in val -%}
57
+ {%- set default = val.get("default", val.get("defalut_value")) -%}
58
+ {%- if default is string -%}
59
+ {{- ' // default: "' + default + '"' -}}
60
+ {%- else -%}
61
+ {{- ' // default: ' ~ default -}}
62
+ {%- endif -%}
63
+ {%- endif -%}
64
+
65
+ {{- "\n" -}}
66
+ {%- endfor -%}
67
+
68
+ {# Handle additionalProperties as index signature #}
69
+ {%- if has_additional_props and additional_props_type is not none -%}
70
+ {%- set additional_type_str = json_schema_to_typescript(
71
+ additional_props_type,
72
+ indent + " "
73
+ ) -%}
74
+ {{- indent + '[key: string]: ' + additional_type_str + '\n' -}}
75
+ {%- endif -%}
76
+
77
+ {{- indent[: (indent|length - " "|length) ] + '}' -}}
78
+
79
+ {# ---------------- STRING ---------------- #}
80
+ {%- elif ty == "string" -%}
81
+ {%- if schema.get("enum") -%}
82
+ {%- set ns = namespace(enum = []) -%}
83
+ {%- for en in schema['enum'] -%}
84
+ {%- set ns.enum = ns.enum + ['"' ~ en ~ '"'] -%}
85
+ {%- endfor -%}
86
+ {{- ns.enum | join(' | ') -}}
87
+ {%- elif schema.get("format", "none") in ['date-time', 'date'] -%}
88
+ {{- 'Date' -}}
89
+ {%- else -%}
90
+ {{- 'string' -}}
91
+ {%- endif -%}
92
+
93
+ {# ---------------- NUMBER / INTEGER ---------------- #}
94
+ {%- elif ty in ["number", "integer"] -%}
95
+ {%- if schema.get("enum") -%}
96
+ {{- schema.enum | join(' | ') -}}
97
+ {%- else -%}
98
+ {{- 'number' -}}
99
+ {%- endif -%}
100
+
101
+ {# ---------------- BOOLEAN ---------------- #}
102
+ {%- elif ty == "boolean" -%}
103
+ {{- 'boolean' -}}
104
+
105
+ {# ---------------- ARRAY ---------------- #}
106
+ {%- elif ty == "array" -%}
107
+ {%- if "items" in schema -%}
108
+ {{- json_schema_to_typescript(schema['items'], indent) + '[]' -}}
109
+ {%- else -%}
110
+ {{- 'Array<any>' -}}
111
+ {%- endif -%}
112
+
113
+ {# ---------------- FALLBACK ---------------- #}
114
+ {%- else -%}
115
+ {{- 'any' -}}
116
+ {%- endif -%}
117
+ {%- endmacro -%}
118
+
119
+ {#---------------------------------------------------------------
120
+ Renders a namespace and its tool definitions in TypeScript style
121
+ ----------------------------------------------------------------#}
122
+
123
+ {%- macro render_tool_namespace(namespace_name, tools) -%}
124
+ {%- set ns = namespace(sections = ['namespace ' ~ namespace_name ~ ' {']) -%}
125
+
126
+ {%- for tool in tools -%}
127
+ {%- if tool.function -%}
128
+ {%- set tool = tool.function -%}
129
+ {%- endif -%}
130
+
131
+ {%- set ns_tool = namespace(content_lines=[]) -%}
132
+
133
+ {# ---------- TOOL DESCRIPTION ---------- #}
134
+ {%- if tool.get('description') -%}
135
+ {%- for line in tool['description'].split('\n') -%}
136
+ {%- if line.strip() -%}
137
+ {%- set ns_tool.content_lines = ns_tool.content_lines + ['// ' ~ line] -%}
138
+ {%- endif -%}
139
+ {%- endfor -%}
140
+ {%- endif -%}
141
+
142
+ {# ---------- TOOL SIGNATURE ---------- #}
143
+ {%- set main_body = "" -%}
144
+ {%- set params = tool.get("parameters") -%}
145
+ {%- if params and params.get("properties") -%}
146
+ {%- set param_type = json_schema_to_typescript(params, " ") -%}
147
+ {%- set main_body = 'type ' ~ tool.name ~ ' = (_: ' ~ param_type ~ ') => ' -%}
148
+ {%- else -%}
149
+ {%- set main_body = 'type ' ~ tool.name ~ ' = () => ' -%}
150
+ {%- endif -%}
151
+
152
+ {# ---------- RETURN TYPE ---------- #}
153
+ {%- set return_params = tool.get("return_parameters") -%}
154
+ {%- if return_params and return_params.get("properties") -%}
155
+ {%- set return_type = json_schema_to_typescript(return_params, " ") -%}
156
+ {%- set main_body = main_body ~ return_type -%}
157
+ {%- else -%}
158
+ {%- set main_body = main_body ~ 'any' -%}
159
+ {%- endif -%}
160
+
161
+ {%- set main_body = main_body ~ ';\n' -%}
162
+
163
+ {%- set ns_tool.content_lines = ns_tool.content_lines + [main_body] -%}
164
+
165
+ {# ---------- ADD TOOL TO SECTIONS ---------- #}
166
+ {%- set ns.sections = ns.sections + [ns_tool.content_lines | join('\n')] -%}
167
+ {%- endfor -%}
168
+
169
+ {%- set ns.sections = ns.sections + ['} // namespace ' ~ namespace_name] -%}
170
+
171
+ {{- ns.sections | join('\n') -}}
172
+ {%- endmacro -%}
173
+
174
+
175
+ {# ----------- MESSAGE RENDERING HELPER FUNCTIONS ------------ #}
176
+
177
+ {%- macro render_role_message(message, role=None) -%}
178
+ {%- if not role -%}
179
+ {%- set role = message["role"] -%}
180
+ {%- endif -%}
181
+
182
+ {%- set message_content = message['content'] or '' -%}
183
+ {%- if message_content is not string -%}
184
+ {%- set message_content = message_content | tojson(ensure_ascii=False) -%}
185
+ {%- endif -%}
186
+
187
+ {{- role + add_tokens.role_sep + message_content + add_tokens.message_sep -}}
188
+
189
+ {%- endmacro -%}
190
+
191
+
192
+ {%- macro render_function_call(message) -%}
193
+ {%- set call = message['content'] -%}
194
+ {%- if call.function -%}
195
+ {%- set call = call.function -%}
196
+ {%- endif -%}
197
+
198
+ {%- set arguments = call['arguments'] -%}
199
+ {%- if arguments is not string -%}
200
+ {%- set arguments = arguments| tojson(ensure_ascii=False) -%}
201
+ {%- endif -%}
202
+
203
+ {{- render_role_message(
204
+ {
205
+ 'role': 'function call',
206
+ 'content': '{"name": "' ~ call['name'] ~ '", "arguments": ' ~ arguments ~ '}'
207
+ }
208
+ ) -}}
209
+ {%- endmacro -%}
210
+
211
+ {# ----- SPECIAL TOKENS ----- #}
212
+
213
+ {%- set add_tokens = namespace(
214
+ role_sep="<|role_sep|>\n",
215
+ message_sep="<|message_sep|>\n\n"
216
+ ) -%}
217
+
218
+ {# ----- DEFAULT DEVSYSTEM ----- #}
219
+
220
+ {%- set DEVSYSTEM -%}
221
+ <role_description>
222
+ Description of the roles available in the dialog.
223
+
224
+ `developer system`
225
+ A message added by Sber before the main dialog. It has the highest priority and sets global, non-overridable conditions (for example, conversation rules, the safety policy, the assistant's overall response style, etc.).
226
+
227
+ `system`
228
+ A system instruction added by developers or by the user, but with a lower priority than `developer system`. It usually describes the assistant's instructions, a specific response style, and other conditions for this particular dialog.
229
+
230
+ `user`
231
+ A message or request from the user. The assistant follows it if it does not conflict with higher-priority instructions (see <instruction_priority>).
232
+
233
+ `user memory`
234
+ A sequence of the most up-to-date long-term facts about the user at the time of their request, presented as a JSON list of strings. Facts are listed in chronological order, meaning newer facts are appended to the end of the sequence. When facts are changed or deleted, records of previous facts remain in the sequence. The assistant saves facts using a function and uses them in accordance with the <memory_guidelines> block below.
235
+
236
+ `added files`
237
+ Metadata about files available for use in the dialog, presented in JSON format. It contains the following keys: id (a unique file identifier), name (file name), type (file type).
238
+
239
+ `assistant`
240
+ The assistant's reply to the user's request. If the system instruction or the user does not set additional rules for `assistant`, this reply must comply with the instructions in the <assistant_guidelines> block below. The list of functions available to call is contained in `function descriptions`. The name of the required function and its arguments will be generated next by the `function call` role. In its replies, the assistant follows the instructions in accordance with <instruction_priority>.
241
+
242
+ `function descriptions`
243
+ Function descriptions in TypeScript format. A function is a special tool (or a set of instructions) that the assistant can call to perform specific actions, computations, or obtain data needed to solve the user's task. Each function description contains blocks with the name, description, and arguments. Sometimes the description contains separate blocks with return parameters and usage examples that illustrate the correct call and arguments.
244
+
245
+ `function call`
246
+ The function that `assistant` calls based on the dialog context, and its arguments. The function is invoked in strict accordance with the instructions in the <function_usage> block.
247
+
248
+ `function result`
249
+ The result of the last function call.
250
+ </role_description>
251
+
252
+ <available_modalities>
253
+ The assistant can work with the following modalities: text, available functions.
254
+ </available_modalities>
255
+
256
+ <instruction_priority>
257
+ If instructions from different roles conflict within the dialog context, observe the following priorities:
258
+ `developer system` > `system` > `user` > `function descriptions` > `function result` > `user memory`
259
+ </instruction_priority>
260
+
261
+ <function_usage>
262
+ Basic instructions for working with functions.
263
+
264
+ Only call those functions that are described in `function descriptions`.
265
+
266
+ Call available functions when, according to their description, such a call will help provide a more complete and/or accurate answer to the user's request. Fill in function arguments using information from the dialog context. If a function could help answer the request but a required argument is missing from the context, ask the user for the missing data before calling the function. If a necessary function is unavailable or an error occurs, briefly inform the user and, if possible, suggest an alternative.
267
+ </function_usage>
268
+
269
+ <memory_guidelines>
270
+ Rules for using facts in long-term memory:
271
+
272
+ If there is no message under the `user memory` role in the dialog, this is equivalent to the absence of long-term facts about the user in memory. In that case, information about the user is limited to the current dialog, and no new facts should be saved.
273
+ </memory_guidelines>
274
+
275
+ <assistant_guidelines>
276
+ You are a helpful assistant.
277
+
278
+ # Instructions
279
+ - Strictly follow the instruction priority.
280
+ - Maintain a logical chain of reasoning when answering the user's question.
281
+ - For complex questions (for example, STEM), try to answer in detail unless the system message or dialog context limits the response length.
282
+ - Be helpful, truthful, and avoid unsafe or prohibited content in your responses.
283
+ - Try to reply in the language in which the user asked their question.
284
+ </assistant_guidelines>
285
+
286
+ A dialog will follow below.
287
+ The dialog may include various roles described in the <role_description> block.
288
+ Each turn begins with the role name and a special token that marks the end of the role's full name, and ends with a special end-of-turn token.
289
+ Your task is to continue the dialog from the last specified role in accordance with the dialog context.
290
+ {%- endset -%}
291
+
292
+
293
+ {#- ---------------------- RENDERING STARTS HERE ---------------------- -#}
294
+
295
+
296
+ {# ----- RENDER BOS TOKEN ----- #}
297
+ {{- bos_token -}}
298
+
299
+
300
+ {# ----- RENDER DEVSYSTEM ----- #}
301
+ {{- render_role_message({"role": "developer system", "content": DEVSYSTEM}) -}}
302
+
303
+ {# ----- RENDER SYSTEM IF PRESENT ----- #}
304
+ {%- if messages and messages[0]['role'] == 'system' -%}
305
+ {{- render_role_message(messages[0]) -}}
306
+ {%- set messages = messages[1:] -%}
307
+ {%- endif -%}
308
+
309
+ {# ----- RENDER TOOLS ----- #}
310
+ {%- if tools -%}
311
+ {%- set tools_content = (
312
+ render_tool_namespace('functions', tools)
313
+ + "\n\n"
314
+ ) -%}
315
+ {{- render_role_message({'role': 'function descriptions', 'content': tools_content}) -}}
316
+ {%- endif -%}
317
+
318
+ {# ----- MAIN MESSAGE LOOP ----- #}
319
+ {%- for message in messages -%}
320
+
321
+ {# ----- TOOL MESSAGE -------#}
322
+ {%- if message['role'] == 'tool' -%}
323
+ {{- render_role_message(message, 'function result') -}}
324
+
325
+
326
+ {# ----- ASSISTANT MESSAGE ----- #}
327
+ {%- elif message['role'] == 'assistant' -%}
328
+
329
+ {# ----- FUNCTION CALL PART CHECKING: SINGLE CALL SETUP ----- #}
330
+ {%- if message.tool_calls is defined and message.tool_calls -%}
331
+ {%- set function_call = message.tool_calls[0] -%}
332
+ {%- else -%}
333
+ {%- set function_call = None -%}
334
+ {%- endif -%}
335
+
336
+ {# ----- MAIN ASSISTANT RENDERING ----- #}
337
+
338
+ {{- render_role_message({'role': 'assistant', 'content': message.content}) -}}
339
+ {%- if function_call -%}
340
+ {{- render_function_call({'role': 'function call', 'content': function_call}) -}}
341
+ {%- endif -%}
342
+
343
+
344
+ {# ----- OTHER MESSAGES ----- #}
345
+ {%- else -%}
346
+ {{- render_role_message(message) -}}
347
+ {%- endif -%}
348
+
349
+ {# ----- ADDING GENERATION PROMPT ----- #}
350
+
351
+ {%- if loop.last and add_generation_prompt and message['role'] != 'assistant' -%}
352
+ {{- 'assistant' + add_tokens.role_sep -}}
353
+ {%- endif -%}
354
+
355
+ {%- endfor -%}
models/templates/GigaChat3.1-10B-A1.8B.jinja ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {#--------TOOL RENDERING FUNCTIONS---------#}
2
+
3
+ {#---------------------------------------------------------------
4
+ Converts JSON Schema (dict) to a TypeScript type definition
5
+ ----------------------------------------------------------------#}
6
+ {%- macro json_schema_to_typescript(schema, indent="") -%}
7
+ {%- set ADDITIONAL_JSON_KEYS = ['format', 'maxItems', 'maximum', 'minItems', 'minimum', 'pattern'] -%}
8
+ {%- set ty = schema.get("type") -%}
9
+
10
+ {# ---------------- OBJECT ---------------- #}
11
+ {%- if ty == "object" -%}
12
+ {{- "{\n" -}}
13
+
14
+ {# Start building property list #}
15
+ {%- set props = schema.get("properties", {}) -%}
16
+ {%- set required = schema.get("required", []) -%}
17
+ {%- set has_additional_props = schema.get("additionalProperties") is defined -%}
18
+ {%- set additional_props_type = none -%}
19
+ {%- if has_additional_props -%}
20
+ {%- if schema.additionalProperties == true -%}
21
+ {%- set additional_props_type = {'type': 'any'} -%}
22
+ {%- elif schema.additionalProperties is mapping -%}
23
+ {%- set additional_props_type = schema.additionalProperties -%}
24
+ {%- endif -%}
25
+ {%- endif -%}
26
+
27
+ {%- for key, val in props.items() -%}
28
+ {# ---------- Description Comments ---------- #}
29
+ {%- if "description" in val -%}
30
+ {%- for line in val['description'].split('\n') -%}
31
+ {%- if line.strip() -%}
32
+ {{- indent + '// ' + line + '\n' -}}
33
+ {%- endif -%}
34
+ {%- endfor -%}
35
+ {%- endif -%}
36
+
37
+ {# ---------- Additional JSON Keys ---------- #}
38
+ {%- for add_key, add_val in val.items() -%}
39
+ {%- if add_key in ADDITIONAL_JSON_KEYS -%}
40
+ {%- if add_val is string -%}
41
+ {{- indent + '// ' + add_key + ': "' + add_val + '"' + '\n' -}}
42
+ {%- else -%}
43
+ {{- indent + '// ' + add_key + ': ' ~ add_val ~ '\n' -}}
44
+ {%- endif -%}
45
+ {%- endif -%}
46
+ {%- endfor -%}
47
+
48
+ {# ---------- Property Definition ---------- #}
49
+ {%- set type_str = json_schema_to_typescript(
50
+ val,
51
+ indent + " "
52
+ ) -%}
53
+
54
+ {{- indent + key + ('' if key in required else '?') + ': ' + type_str + ',' -}}
55
+
56
+ {%- if "default" in val or "defalut_value" in val -%}
57
+ {%- set default = val.get("default", val.get("defalut_value")) -%}
58
+ {%- if default is string -%}
59
+ {{- ' // default: "' + default + '"' -}}
60
+ {%- else -%}
61
+ {{- ' // default: ' ~ default -}}
62
+ {%- endif -%}
63
+ {%- endif -%}
64
+
65
+ {{- "\n" -}}
66
+ {%- endfor -%}
67
+
68
+ {# Handle additionalProperties as index signature #}
69
+ {%- if has_additional_props and additional_props_type is not none -%}
70
+ {%- set additional_type_str = json_schema_to_typescript(
71
+ additional_props_type,
72
+ indent + " "
73
+ ) -%}
74
+ {{- indent + '[key: string]: ' + additional_type_str + '\n' -}}
75
+ {%- endif -%}
76
+
77
+ {{- indent[: (indent|length - " "|length) ] + '}' -}}
78
+
79
+ {# ---------------- STRING ---------------- #}
80
+ {%- elif ty == "string" -%}
81
+ {%- if schema.get("enum") -%}
82
+ {%- set ns = namespace(enum = []) -%}
83
+ {%- for en in schema['enum'] -%}
84
+ {%- set ns.enum = ns.enum + ['"' ~ en ~ '"'] -%}
85
+ {%- endfor -%}
86
+ {{- ns.enum | join(' | ') -}}
87
+ {%- elif schema.get("format", "none") in ['date-time', 'date'] -%}
88
+ {{- 'Date' -}}
89
+ {%- else -%}
90
+ {{- 'string' -}}
91
+ {%- endif -%}
92
+
93
+ {# ---------------- NUMBER / INTEGER ---------------- #}
94
+ {%- elif ty in ["number", "integer"] -%}
95
+ {%- if schema.get("enum") -%}
96
+ {{- schema.enum | join(' | ') -}}
97
+ {%- else -%}
98
+ {{- 'number' -}}
99
+ {%- endif -%}
100
+
101
+ {# ---------------- BOOLEAN ---------------- #}
102
+ {%- elif ty == "boolean" -%}
103
+ {{- 'boolean' -}}
104
+
105
+ {# ---------------- ARRAY ---------------- #}
106
+ {%- elif ty == "array" -%}
107
+ {%- if "items" in schema -%}
108
+ {{- json_schema_to_typescript(schema['items'], indent) + '[]' -}}
109
+ {%- else -%}
110
+ {{- 'Array<any>' -}}
111
+ {%- endif -%}
112
+
113
+ {# ---------------- FALLBACK ---------------- #}
114
+ {%- else -%}
115
+ {{- 'any' -}}
116
+ {%- endif -%}
117
+ {%- endmacro -%}
118
+
119
+ {#---------------------------------------------------------------
120
+ Renders a namespace and its tool definitions in TypeScript style
121
+ ----------------------------------------------------------------#}
122
+
123
+ {%- macro render_tool_namespace(namespace_name, tools) -%}
124
+ {%- set ns = namespace(sections = ['namespace ' ~ namespace_name ~ ' {']) -%}
125
+
126
+ {%- for tool in tools -%}
127
+ {%- if tool.function -%}
128
+ {%- set tool = tool.function -%}
129
+ {%- endif -%}
130
+
131
+ {%- set ns_tool = namespace(content_lines=[]) -%}
132
+
133
+ {# ---------- TOOL DESCRIPTION ---------- #}
134
+ {%- if tool.get('description') -%}
135
+ {%- for line in tool['description'].split('\n') -%}
136
+ {%- if line.strip() -%}
137
+ {%- set ns_tool.content_lines = ns_tool.content_lines + ['// ' ~ line] -%}
138
+ {%- endif -%}
139
+ {%- endfor -%}
140
+ {%- endif -%}
141
+
142
+ {# ---------- TOOL SIGNATURE ---------- #}
143
+ {%- set main_body = "" -%}
144
+ {%- set params = tool.get("parameters") -%}
145
+ {%- if params and params.get("properties") -%}
146
+ {%- set param_type = json_schema_to_typescript(params, " ") -%}
147
+ {%- set main_body = 'type ' ~ tool.name ~ ' = (_: ' ~ param_type ~ ') => ' -%}
148
+ {%- else -%}
149
+ {%- set main_body = 'type ' ~ tool.name ~ ' = () => ' -%}
150
+ {%- endif -%}
151
+
152
+ {# ---------- RETURN TYPE ---------- #}
153
+ {%- set return_params = tool.get("return_parameters") -%}
154
+ {%- if return_params and return_params.get("properties") -%}
155
+ {%- set return_type = json_schema_to_typescript(return_params, " ") -%}
156
+ {%- set main_body = main_body ~ return_type -%}
157
+ {%- else -%}
158
+ {%- set main_body = main_body ~ 'any' -%}
159
+ {%- endif -%}
160
+
161
+ {%- set main_body = main_body ~ ';\n' -%}
162
+
163
+ {%- set ns_tool.content_lines = ns_tool.content_lines + [main_body] -%}
164
+
165
+ {# ---------- ADD TOOL TO SECTIONS ---------- #}
166
+ {%- set ns.sections = ns.sections + [ns_tool.content_lines | join('\n')] -%}
167
+ {%- endfor -%}
168
+
169
+ {%- set ns.sections = ns.sections + ['} // namespace ' ~ namespace_name] -%}
170
+
171
+ {{- ns.sections | join('\n') -}}
172
+ {%- endmacro -%}
173
+
174
+
175
+ {# ----------- MESSAGE RENDERING HELPER FUNCTIONS ------------ #}
176
+
177
+ {%- macro render_function_call(call) -%}
178
+ {%- if call.function -%}
179
+ {%- set call = call.function -%}
180
+ {%- endif -%}
181
+
182
+ {%- set arguments = call['arguments'] -%}
183
+ {%- if arguments is not string -%}
184
+ {%- set arguments = arguments| tojson(ensure_ascii=False) -%}
185
+ {%- endif -%}
186
+
187
+ {{- '{"name": "' ~ call['name'] ~ '", "arguments": ' ~ arguments ~ '}' -}}
188
+ {%- endmacro -%}
189
+
190
+
191
+ {%- macro render_role_message(message, role=None) -%}
192
+ {%- if not role -%}
193
+ {%- set role = message["role"] -%}
194
+ {%- endif -%}
195
+
196
+ {%- set message_content = message['content'] or '' -%}
197
+ {%- if message_content is not string -%}
198
+ {%- set message_content = message_content | tojson(ensure_ascii=False) -%}
199
+ {%- endif -%}
200
+
201
+ {{- role + add_tokens.role_sep + message_content -}}
202
+
203
+ {%- if message.tool_calls is defined and message.tool_calls -%}
204
+ {{- add_tokens.function_call + render_function_call(message.tool_calls[0]) -}}
205
+ {%- endif -%}
206
+
207
+ {{- add_tokens.message_sep -}}
208
+
209
+ {%- endmacro -%}
210
+
211
+
212
+
213
+ {# ----- SPECIAL TOKENS ----- #}
214
+
215
+ {%- set add_tokens = namespace(
216
+ role_sep="<|role_sep|>\n",
217
+ message_sep="<|message_sep|>\n\n",
218
+ function_call="<|function_call|>"
219
+ ) -%}
220
+
221
+ {# ----- DEFAULT DEVSYSTEM ----- #}
222
+
223
+ {%- set DEVSYSTEM -%}
224
+ <role_description>
225
+ Description of the roles available in the dialog.
226
+
227
+ `developer system`
228
+ A message added by Sber before the main dialog. It has the highest priority and sets global, non-overridable conditions (for example, conversation rules, the safety policy, the assistant's overall response style, etc.).
229
+
230
+ `system`
231
+ A system instruction added by developers or by the user, but with a lower priority than `developer system`. It usually describes the assistant's instructions, a specific response style, and other conditions for this particular dialog.
232
+
233
+ `user`
234
+ A message or request from the user. The assistant follows it if it does not conflict with higher-priority instructions (see <instruction_priority>).
235
+
236
+ `user memory`
237
+ A sequence of the most up-to-date long-term facts about the user at the time of their request, presented as a JSON list of strings. Facts are listed in chronological order, meaning newer facts are appended to the end of the sequence. When facts are changed or deleted, records of previous facts remain in the sequence. The assistant saves facts using a function and uses them in accordance with the <memory_guidelines> block below.
238
+
239
+ `added files`
240
+ Metadata about files available for use in the dialog, presented in JSON format. It contains the following keys: id (a unique file identifier), name (file name), type (file type).
241
+
242
+ `assistant`
243
+ The assistant's reply to the user's request. If the system instruction or the user does not set additional rules for `assistant`, this reply must comply with the instructions in the <assistant_guidelines> block below. The list of functions available to call is contained in `function descriptions`. The name of the required function and its arguments will be generated next by the `function call` role. In its replies, the assistant follows the instructions in accordance with <instruction_priority>.
244
+
245
+ `function descriptions`
246
+ Function descriptions in TypeScript format. A function is a special tool (or a set of instructions) that the assistant can call to perform specific actions, computations, or obtain data needed to solve the user's task. Each function description contains blocks with the name, description, and arguments. Sometimes the description contains separate blocks with return parameters and usage examples that illustrate the correct call and arguments.
247
+
248
+ `function call`
249
+ The function that `assistant` calls based on the dialog context, and its arguments. The function is invoked in strict accordance with the instructions in the <function_usage> block.
250
+
251
+ `function result`
252
+ The result of the last function call.
253
+ </role_description>
254
+
255
+ <available_modalities>
256
+ The assistant can work with the following modalities: text, available functions.
257
+ </available_modalities>
258
+
259
+ <instruction_priority>
260
+ If instructions from different roles conflict within the dialog context, observe the following priorities:
261
+ `developer system` > `system` > `user` > `function descriptions` > `function result` > `user memory`
262
+ </instruction_priority>
263
+
264
+ <function_usage>
265
+ Basic instructions for working with functions.
266
+
267
+ Only call those functions that are described in `function descriptions`.
268
+
269
+ Call available functions when, according to their description, such a call will help provide a more complete and/or accurate answer to the user's request. Fill in function arguments using information from the dialog context. If a function could help answer the request but a required argument is missing from the context, ask the user for the missing data before calling the function. If a necessary function is unavailable or an error occurs, briefly inform the user and, if possible, suggest an alternative.
270
+ </function_usage>
271
+
272
+ <memory_guidelines>
273
+ Rules for using facts in long-term memory:
274
+
275
+ If there is no message under the `user memory` role in the dialog, this is equivalent to the absence of long-term facts about the user in memory. In that case, information about the user is limited to the current dialog, and no new facts should be saved.
276
+ </memory_guidelines>
277
+
278
+ <assistant_guidelines>
279
+ You are a helpful assistant.
280
+
281
+ # Instructions
282
+ - Strictly follow the instruction priority.
283
+ - Maintain a logical chain of reasoning when answering the user's question.
284
+ - For complex questions (for example, STEM), try to answer in detail unless the system message or dialog context limits the response length.
285
+ - Be helpful, truthful, and avoid unsafe or prohibited content in your responses.
286
+ - Try to reply in the language in which the user asked their question.
287
+ </assistant_guidelines>
288
+
289
+ A dialog will follow below.
290
+ The dialog may include various roles described in the <role_description> block.
291
+ Each turn begins with the role name and a special token that marks the end of the role's full name, and ends with a special end-of-turn token.
292
+ Your task is to continue the dialog from the last specified role in accordance with the dialog context.
293
+ {%- endset -%}
294
+
295
+
296
+ {#- ---------------------- RENDERING STARTS HERE ---------------------- -#}
297
+
298
+
299
+ {# ----- RENDER BOS TOKEN ----- #}
300
+ {{- bos_token -}}
301
+
302
+
303
+ {# ----- RENDER DEVSYSTEM ----- #}
304
+ {{- render_role_message({"role": "developer system", "content": DEVSYSTEM}) -}}
305
+
306
+ {# ----- RENDER SYSTEM IF PRESENT ----- #}
307
+ {%- if messages and messages[0]['role'] == 'system' -%}
308
+ {{- render_role_message(messages[0]) -}}
309
+ {%- set messages = messages[1:] -%}
310
+ {%- endif -%}
311
+
312
+ {# ----- RENDER TOOLS ----- #}
313
+ {%- if tools -%}
314
+ {%- set tools_content = (
315
+ render_tool_namespace('functions', tools)
316
+ + "\n\n"
317
+ ) -%}
318
+ {{- render_role_message({'role': 'function descriptions', 'content': tools_content}) -}}
319
+ {%- endif -%}
320
+
321
+ {# ----- MAIN MESSAGE LOOP ----- #}
322
+ {%- for message in messages -%}
323
+
324
+ {# ----- TOOL MESSAGE -------#}
325
+ {%- if message['role'] == 'tool' -%}
326
+ {{- render_role_message(message, 'function result') -}}
327
+
328
+ {# ----- OTHER MESSAGES ----- #}
329
+ {%- else -%}
330
+ {{- render_role_message(message) -}}
331
+ {%- endif -%}
332
+
333
+ {# ----- ADDING GENERATION PROMPT ----- #}
334
+
335
+ {%- if loop.last and add_generation_prompt and message['role'] != 'assistant' -%}
336
+ {{- 'assistant' + add_tokens.role_sep -}}
337
+ {%- endif -%}
338
+
339
+ {%- endfor -%}
models/templates/HuggingFaceTB-SmolLM3-3B.jinja ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {#- Copyright 2025-present the Unsloth team. All rights reserved. #}
2
+ {#- Licensed under the Apache License, Version 2.0 (the "License") #}
3
+ {#- Edits made by Unsloth to make it work for most inference engines #}
4
+ {# ───── defaults ───── #}
5
+ {%- if enable_thinking is not defined -%}
6
+ {%- set enable_thinking = true -%}
7
+ {%- endif -%}
8
+ {# ───── reasoning mode ───── #}
9
+ {%- if enable_thinking -%}
10
+ {%- set reasoning_mode = "/think" -%}
11
+ {%- else -%}
12
+ {%- set reasoning_mode = "/no_think" -%}
13
+ {%- endif -%}
14
+ {# ───── header (system message) ───── #}
15
+ {{- "<|im_start|>system\n" -}}
16
+ {%- if messages[0].role == "system" -%}
17
+ {%- set system_message = messages[0].content -%}
18
+ {%- if "/no_think" in system_message -%}
19
+ {%- set reasoning_mode = "/no_think" -%}
20
+ {%- elif "/think" in system_message -%}
21
+ {%- set reasoning_mode = "/think" -%}
22
+ {%- endif -%}
23
+ {%- set custom_instructions = system_message.replace("/no_think", "") -%}
24
+ {%- set custom_instructions = custom_instructions.replace("/think", "") -%}
25
+ {%- set custom_instructions = custom_instructions.rstrip() -%}
26
+ {%- endif -%}
27
+ {{- "## Metadata\n\n" -}}
28
+ {{- "Knowledge Cutoff Date: June 2025\n" -}}
29
+ {{- "Reasoning Mode: " + reasoning_mode + "\n\n" -}}
30
+ {{- "## Custom Instructions\n\n" -}}
31
+ {%- if custom_instructions -%}
32
+ {{- custom_instructions + "\n\n" -}}
33
+ {%- elif reasoning_mode == "/think" -%}
34
+ {{- "You are a helpful AI assistant named SmolLM, trained by Hugging Face. Your role as an assistant involves thoroughly exploring questions through a systematic thinking process before providing the final precise and accurate solutions. This requires engaging in a comprehensive cycle of analysis, summarizing, exploration, reassessment, reflection, backtracking, and iteration to develop well-considered thinking process. Please structure your response into two main sections: Thought and Solution using the specified format: <think> Thought section </think> Solution section. In the Thought section, detail your reasoning process in steps. Each step should include detailed considerations such as analysing questions, summarizing relevant findings, brainstorming new ideas, verifying the accuracy of the current steps, refining any errors, and revisiting previous steps. In the Solution section, based on various attempts, explorations, and reflections from the Thought section, systematically present the final solution that you deem correct. The Solution section should be logical, accurate, and concise and detail necessary steps needed to reach the conclusion.\n\n" -}}
35
+ {%- else -%}
36
+ {{- "You are a helpful AI assistant named SmolLM, trained by Hugging Face.\n\n" -}}
37
+ {%- endif -%}
38
+ {{- "<|im_end|>\n" -}}
39
+ {# ───── main loop ───── #}
40
+ {%- for message in messages -%}
41
+ {%- set content = message.content if message.content is string else "" -%}
42
+ {%- if message.role == "user" -%}
43
+ {{ "<|im_start|>" + message.role + "\n" + content + "<|im_end|>\n" }}
44
+ {%- elif message.role == "assistant" -%}
45
+ {%- if reasoning_mode == "/think" -%}
46
+ {{ "<|im_start|>assistant\n" + content.lstrip("\n") + "<|im_end|>\n" }}
47
+ {%- else -%}
48
+ {{ "<|im_start|>assistant\n" + "<think>\n\n</think>\n" + content.lstrip("\n") + "<|im_end|>\n" }}
49
+ {%- endif -%}
50
+ {%- elif message.role == "tool" -%}
51
+ {{ "<|im_start|>" + "user\n" + content + "<|im_end|>\n" }}
52
+ {%- endif -%}
53
+ {%- endfor -%}
54
+ {# ───── generation prompt ───── #}
55
+ {%- if add_generation_prompt -%}
56
+ {%- if reasoning_mode == "/think" -%}
57
+ {{ "<|im_start|>assistant\n" }}
58
+ {%- else -%}
59
+ {{ "<|im_start|>assistant\n" + "<think>\n\n</think>\n" }}
60
+ {%- endif -%}
61
+ {%- endif -%}
models/templates/Kimi-K2-Instruct.jinja ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% macro render_content(msg) -%}
2
+ {%- set c = msg.get('content') -%}
3
+ {%- if c is string -%}
4
+ {{ c }}
5
+ {%- elif c is not none -%}
6
+ {% for content in c -%}
7
+ {% if content['type'] == 'image' or 'image' in content or 'image_url' in content -%}
8
+ <|media_start|>image<|media_content|><|media_pad|><|media_end|>
9
+ {% else -%}
10
+ {{ content['text'] }}
11
+ {%- endif -%}
12
+ {%- endfor -%}
13
+ {%- endif -%}
14
+ {%- endmacro %}
15
+
16
+ {%- set tool_response_queue = namespace(ids=[]) -%}
17
+ {%- set tool_call_counter = namespace(value=0) -%}
18
+
19
+ {%- if tools -%}
20
+ <|im_system|>tool_declare<|im_middle|>{{ tools | tojson }}<|im_end|>
21
+ {%- endif -%}
22
+ {% for message in messages %}
23
+ {%- if loop.first and messages[0]['role'] != 'system' -%}
24
+ <|im_system|>system<|im_middle|>You are Kimi, an AI assistant created by Moonshot AI.<|im_end|>
25
+ {% endif %}
26
+
27
+ {%- set role_name = message.get('name') or message['role'] -%}
28
+ {%- if message['role'] == 'user' -%}
29
+ <|im_user|>{{role_name}}<|im_middle|>
30
+ {%- elif message['role'] == 'assistant' -%}
31
+ <|im_assistant|>{{role_name}}<|im_middle|>
32
+ {%- else -%}
33
+ <|im_system|>{{role_name}}<|im_middle|>
34
+ {%- endif -%}
35
+
36
+ {%- if message['role'] == 'assistant' and message.get('tool_calls') -%}
37
+ {{render_content(message)}}<|tool_calls_section_begin|>
38
+ {%- for tool_call in message['tool_calls'] -%}
39
+ {%- set formatted_id = 'functions.' + tool_call['function']['name'] + ':' + (tool_call_counter.value | string) -%}
40
+ {%- set tool_call_counter.value = tool_call_counter.value + 1 -%}
41
+ {%- set _ = tool_response_queue.ids.append(formatted_id) -%}
42
+ <|tool_call_begin|>{{ formatted_id }}<|tool_call_argument_begin|>{% if tool_call['function']['arguments'] is string %}{{ tool_call['function']['arguments'] }}{% else %}{{ tool_call['function']['arguments'] | tojson }}{% endif %}<|tool_call_end|>
43
+ {%- endfor -%}
44
+ <|tool_calls_section_end|>
45
+ {%- elif message['role'] == 'tool' -%}
46
+ {%- if tool_response_queue.ids -%}
47
+ {%- set tool_call_id = tool_response_queue.ids.pop(0) -%}
48
+ {%- else -%}
49
+ {%- set tool_call_id = 'functions.' + message.get('name', 'unknown') + ':' + (tool_call_counter.value | string) -%}
50
+ {%- endif -%}
51
+ ## Return of {{ tool_call_id }}
52
+ {{render_content(message)}}
53
+ {%- elif message['content'] is not none -%}
54
+ {{render_content(message)}}
55
+ {%- endif -%}
56
+ <|im_end|>
57
+ {%- endfor -%}
58
+ {%- if add_generation_prompt -%}
59
+ <|im_assistant|>assistant<|im_middle|>
60
+ {%- endif -%}
models/templates/Kimi-K2-Thinking.jinja ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- macro render_content(msg) -%}
2
+ {%- set c = msg.get('content') -%}
3
+ {%- if c is string -%}
4
+ {{ c }}
5
+ {%- elif c is not none -%}
6
+ {% for content in c -%}
7
+ {% if content['type'] == 'image' or 'image' in content or 'image_url' in content -%}
8
+ <|media_start|>image<|media_content|><|media_pad|><|media_end|>
9
+ {% else -%}
10
+ {{ content['text'] }}
11
+ {%- endif -%}
12
+ {%- endfor -%}
13
+ {%- endif -%}
14
+ {%- endmacro -%}
15
+
16
+ {% macro set_roles(message) -%}
17
+ {%- set role_name = message.get('name') or message['role'] -%}
18
+ {%- if message['role'] == 'user' -%}
19
+ <|im_user|>{{role_name}}<|im_middle|>
20
+ {%- elif message['role'] == 'assistant' -%}
21
+ <|im_assistant|>{{role_name}}<|im_middle|>
22
+ {%- else -%}
23
+ <|im_system|>{{role_name}}<|im_middle|>
24
+ {%- endif -%}
25
+ {%- endmacro -%}
26
+
27
+ {%- set tool_response_queue = namespace(ids=[]) -%}
28
+ {%- set tool_call_counter = namespace(value=0) -%}
29
+
30
+ {%- macro render_toolcalls(message) -%}
31
+ <|tool_calls_section_begin|>
32
+ {%- for tool_call in message['tool_calls'] -%}
33
+ {%- set formatted_id = 'functions.' + tool_call['function']['name'] + ':' + (tool_call_counter.value | string) -%}
34
+ {%- set tool_call_counter.value = tool_call_counter.value + 1 -%}
35
+ {%- set _ = tool_response_queue.ids.append(formatted_id) -%}
36
+ <|tool_call_begin|>{{ formatted_id }}<|tool_call_argument_begin|>{% if tool_call['function']['arguments'] is string %}{{ tool_call['function']['arguments'] }}{% else %}{{ tool_call['function']['arguments'] | tojson }}{% endif %}<|tool_call_end|>
37
+ {%- endfor -%}
38
+ <|tool_calls_section_end|>
39
+ {%- endmacro -%}
40
+
41
+
42
+ {# Find last non-tool-call assisitant message #}
43
+ {%- set ns = namespace(last_non_tool_call_assistant_msg=-1) -%}
44
+ {%- for idx in range(messages|length-1, -1, -1) -%}
45
+ {%- if messages[idx]['role'] == 'assistant' and not messages[idx].get('tool_calls') -%}
46
+ {%- set ns.last_non_tool_call_assistant_msg = idx -%}
47
+ {%- endif -%}
48
+ {%- endfor -%}
49
+
50
+ {# split all messages into history & suffix, reasoning_content in suffix should be reserved.#}
51
+ {%- set hist_msgs = messages[:ns.last_non_tool_call_assistant_msg+1] -%}
52
+ {%- set suffix_msgs = messages[ns.last_non_tool_call_assistant_msg+1:] -%}
53
+
54
+ {%- if tools -%}
55
+ <|im_system|>tool_declare<|im_middle|>{{ tools | tojson }}<|im_end|>
56
+ {%- endif -%}
57
+
58
+ {%- if messages|length == 0 or messages[0]['role'] != 'system' -%}
59
+ <|im_system|>system<|im_middle|>You are Kimi, an AI assistant created by Moonshot AI.<|im_end|>
60
+ {%- endif -%}
61
+
62
+ {%- for message in hist_msgs -%}
63
+ {{set_roles(message)}}
64
+ {%- if message['role'] == 'assistant' -%}
65
+ <think></think>{{render_content(message)}}
66
+ {%- if message.get('tool_calls') -%}
67
+ {{render_toolcalls(message)}}
68
+ {%- endif -%}
69
+ {%- elif message['role'] == 'tool' -%}
70
+ {%- if tool_response_queue.ids -%}
71
+ {%- set tool_call_id = tool_response_queue.ids.pop(0) -%}
72
+ {%- else -%}
73
+ {%- set tool_call_id = 'functions.' + message.get('name', 'unknown') + ':' + (tool_call_counter.value | string) -%}
74
+ {%- endif -%}
75
+ ## Return of {{ tool_call_id }}
76
+ {{render_content(message)}}
77
+ {%- elif message['content'] is not none -%}
78
+ {{render_content(message)}}
79
+ {%- endif -%}
80
+ <|im_end|>
81
+ {%- endfor -%}
82
+
83
+ {%- for message in suffix_msgs -%}
84
+ {{set_roles(message)}}
85
+ {%- if message['role'] == 'assistant' -%}
86
+ {%- set rc = message.get('reasoning_content', '') -%}
87
+ <think>{{rc}}</think>{{render_content(message)}}
88
+ {%- if message.get('tool_calls') -%}
89
+ {{render_toolcalls(message)}}
90
+ {%- endif -%}
91
+ {%- elif message['role'] == 'tool' -%}
92
+ {%- if tool_response_queue.ids -%}
93
+ {%- set tool_call_id = tool_response_queue.ids.pop(0) -%}
94
+ {%- else -%}
95
+ {%- set tool_call_id = 'functions.' + message.get('name', 'unknown') + ':' + (tool_call_counter.value | string) -%}
96
+ {%- endif -%}
97
+ ## Return of {{ tool_call_id }}
98
+ {{render_content(message)}}
99
+ {%- elif message['content'] is not none -%}
100
+ {{render_content(message)}}
101
+ {%- endif -%}
102
+ <|im_end|>
103
+ {%- endfor -%}
104
+
105
+
106
+ {%- if add_generation_prompt -%}
107
+ <|im_assistant|>assistant<|im_middle|>
108
+ {%- endif -%}
models/templates/LFM2-8B-A1B.jinja ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{- bos_token -}}
2
+ {%- set system_prompt = "" -%}
3
+ {%- set ns = namespace(system_prompt="") -%}
4
+ {%- if messages[0]["role"] == "system" -%}
5
+ {%- set ns.system_prompt = messages[0]["content"] -%}
6
+ {%- set messages = messages[1:] -%}
7
+ {%- endif -%}
8
+ {%- if tools -%}
9
+ {%- set ns.system_prompt = ns.system_prompt + ("\n" if ns.system_prompt else "") + "List of tools: <|tool_list_start|>[" -%}
10
+ {%- for tool in tools -%}
11
+ {%- if tool is not string -%}
12
+ {%- set tool = tool | tojson -%}
13
+ {%- endif -%}
14
+ {%- set ns.system_prompt = ns.system_prompt + tool -%}
15
+ {%- if not loop.last -%}
16
+ {%- set ns.system_prompt = ns.system_prompt + ", " -%}
17
+ {%- endif -%}
18
+ {%- endfor -%}
19
+ {%- set ns.system_prompt = ns.system_prompt + "]<|tool_list_end|>" -%}
20
+ {%- endif -%}
21
+ {%- if ns.system_prompt -%}
22
+ {{- "<|im_start|>system\n" + ns.system_prompt + "<|im_end|>\n" -}}
23
+ {%- endif -%}
24
+ {%- for message in messages -%}
25
+ {{- "<|im_start|>" + message["role"] + "\n" -}}
26
+ {%- set content = message["content"] -%}
27
+ {%- if content is not string -%}
28
+ {%- set content = content | tojson -%}
29
+ {%- endif -%}
30
+ {%- if message["role"] == "tool" -%}
31
+ {%- set content = "<|tool_response_start|>" + content + "<|tool_response_end|>" -%}
32
+ {%- endif -%}
33
+ {{- content + "<|im_end|>\n" -}}
34
+ {%- endfor -%}
35
+ {%- if add_generation_prompt -%}
36
+ {{- "<|im_start|>assistant\n" -}}
37
+ {%- endif -%}
models/templates/LFM2.5-8B-A1B.jinja ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{- bos_token -}}
2
+ {%- set preserve_thinking = preserve_thinking | default(false) -%}
3
+
4
+ {%- macro format_arg_value(arg_value) -%}
5
+ {%- if arg_value is string -%}
6
+ {{- "'" + arg_value + "'" -}}
7
+ {%- elif arg_value is mapping -%}
8
+ {{- arg_value | tojson -}}
9
+ {%- else -%}
10
+ {{- arg_value | string -}}
11
+ {%- endif -%}
12
+ {%- endmacro -%}
13
+
14
+ {%- macro parse_content(content) -%}
15
+ {%- if content is string -%}
16
+ {{- content -}}
17
+ {%- else -%}
18
+ {%- set _ns = namespace(result="") -%}
19
+ {%- for item in content -%}
20
+ {%- if item["type"] == "image" -%}
21
+ {%- set _ns.result = _ns.result + "<image>" -%}
22
+ {%- elif item["type"] == "text" -%}
23
+ {%- set _ns.result = _ns.result + item["text"] -%}
24
+ {%- else -%}
25
+ {%- set _ns.result = _ns.result + item | tojson -%}
26
+ {%- endif -%}
27
+ {%- endfor -%}
28
+ {{- _ns.result -}}
29
+ {%- endif -%}
30
+ {%- endmacro -%}
31
+
32
+ {%- macro render_tool_calls(tool_calls) -%}
33
+ {%- set tool_calls_ns = namespace(tool_calls=[]) -%}
34
+ {%- for tool_call in tool_calls -%}
35
+ {%- set func_name = tool_call["function"]["name"] -%}
36
+ {%- set func_args = tool_call["function"]["arguments"] -%}
37
+ {%- set args_ns = namespace(arg_strings=[]) -%}
38
+ {%- for arg_name, arg_value in func_args.items() -%}
39
+ {%- set args_ns.arg_strings = args_ns.arg_strings + [arg_name + "=" + format_arg_value(arg_value)] -%}
40
+ {%- endfor -%}
41
+ {%- set tool_calls_ns.tool_calls = tool_calls_ns.tool_calls + [func_name + "(" + (args_ns.arg_strings | join(", ")) + ")"] -%}
42
+ {%- endfor -%}
43
+ {{- "<|tool_call_start|>[" + (tool_calls_ns.tool_calls | join(", ")) + "]<|tool_call_end|>" -}}
44
+ {%- endmacro -%}
45
+
46
+ {%- set ns = namespace(system_prompt="", last_user_index=-1) -%}
47
+ {%- if messages[0]["role"] == "system" -%}
48
+ {%- if messages[0].get("content") -%}
49
+ {%- set ns.system_prompt = parse_content(messages[0]["content"]) -%}
50
+ {%- endif -%}
51
+ {%- set messages = messages[1:] -%}
52
+ {%- endif -%}
53
+ {%- if tools -%}
54
+ {%- set ns.system_prompt = ns.system_prompt + ("\n" if ns.system_prompt else "") + "List of tools: [" -%}
55
+ {%- for tool in tools -%}
56
+ {%- if tool is not string -%}
57
+ {%- set tool = tool | tojson -%}
58
+ {%- endif -%}
59
+ {%- set ns.system_prompt = ns.system_prompt + tool -%}
60
+ {%- if not loop.last -%}
61
+ {%- set ns.system_prompt = ns.system_prompt + ", " -%}
62
+ {%- endif -%}
63
+ {%- endfor -%}
64
+ {%- set ns.system_prompt = ns.system_prompt + "]" -%}
65
+ {%- endif -%}
66
+ {%- if ns.system_prompt -%}
67
+ {{- "<|im_start|>system\n" + ns.system_prompt + "<|im_end|>\n" -}}
68
+ {%- endif -%}
69
+ {%- for message in messages -%}
70
+ {%- if message["role"] == "user" -%}
71
+ {%- set ns.last_user_index = loop.index0 -%}
72
+ {%- endif -%}
73
+ {%- endfor -%}
74
+ {%- for message in messages -%}
75
+ {{- "<|im_start|>" + message.role + "\n" -}}
76
+ {%- if message.role == "assistant" -%}
77
+ {%- generation -%}
78
+ {%- if message.thinking is defined and (preserve_thinking or loop.index0 > ns.last_user_index) -%}
79
+ {{- "<think>" + message.thinking + "</think>" -}}
80
+ {%- endif -%}
81
+ {%- set _cfm_tag = "CONTINUE_FINAL_MESSAGE_TAG " -%}
82
+ {%- set _has_cfm = false -%}
83
+ {%- if message.content is defined -%}
84
+ {%- set content = parse_content(message.content) -%}
85
+ {%- if not (preserve_thinking or loop.index0 > ns.last_user_index) -%}
86
+ {%- if "</think>" in content -%}
87
+ {%- set content = content.split("</think>")[-1] | trim -%}
88
+ {%- endif -%}
89
+ {%- endif -%}
90
+ {%- if message.tool_calls is defined and content.endswith(_cfm_tag) -%}
91
+ {%- set _has_cfm = true -%}
92
+ {%- set _trunc_len = (content | length) - (_cfm_tag | length) -%}
93
+ {{- content[:_trunc_len] -}}
94
+ {%- else -%}
95
+ {{- content -}}
96
+ {%- endif -%}
97
+ {%- endif -%}
98
+ {%- if message.tool_calls is defined -%}
99
+ {{- render_tool_calls(message.tool_calls) -}}
100
+ {%- endif -%}
101
+ {%- if _has_cfm -%}
102
+ {{- _cfm_tag -}}
103
+ {%- endif -%}
104
+ {{- "<|im_end|>\n" -}}
105
+ {%- endgeneration -%}
106
+ {%- else %}
107
+ {%- if message.get("content") -%}
108
+ {{- parse_content(message["content"]) -}}
109
+ {%- endif -%}
110
+ {{- "<|im_end|>\n" -}}
111
+ {%- endif %}
112
+ {%- endfor -%}
113
+ {%- if add_generation_prompt -%}
114
+ {{- "<|im_start|>assistant\n" -}}
115
+ {%- endif -%}
models/templates/LFM2.5-Instruct.jinja ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{- bos_token -}}
2
+ {%- set keep_past_thinking = keep_past_thinking | default(false) -%}
3
+ {%- set ns = namespace(system_prompt="") -%}
4
+ {%- if messages[0]["role"] == "system" -%}
5
+ {%- set ns.system_prompt = messages[0]["content"] -%}
6
+ {%- set messages = messages[1:] -%}
7
+ {%- endif -%}
8
+ {%- if tools -%}
9
+ {%- set ns.system_prompt = ns.system_prompt + ("\n" if ns.system_prompt else "") + "List of tools: [" -%}
10
+ {%- for tool in tools -%}
11
+ {%- if tool is not string -%}
12
+ {%- set tool = tool | tojson -%}
13
+ {%- endif -%}
14
+ {%- set ns.system_prompt = ns.system_prompt + tool -%}
15
+ {%- if not loop.last -%}
16
+ {%- set ns.system_prompt = ns.system_prompt + ", " -%}
17
+ {%- endif -%}
18
+ {%- endfor -%}
19
+ {%- set ns.system_prompt = ns.system_prompt + "]" -%}
20
+ {%- endif -%}
21
+ {%- if ns.system_prompt -%}
22
+ {{- "<|im_start|>system\n" + ns.system_prompt + "<|im_end|>\n" -}}
23
+ {%- endif -%}
24
+ {%- set ns.last_assistant_index = -1 -%}
25
+ {%- for message in messages -%}
26
+ {%- if message["role"] == "assistant" -%}
27
+ {%- set ns.last_assistant_index = loop.index0 -%}
28
+ {%- endif -%}
29
+ {%- endfor -%}
30
+ {%- for message in messages -%}
31
+ {{- "<|im_start|>" + message["role"] + "\n" -}}
32
+ {%- set content = message["content"] -%}
33
+ {%- if content is not string -%}
34
+ {%- set content = content | tojson -%}
35
+ {%- endif -%}
36
+ {%- if message["role"] == "assistant" and not keep_past_thinking and loop.index0 != ns.last_assistant_index -%}
37
+ {%- if "</think>" in content -%}
38
+ {%- set content = content.split("</think>")[-1] | trim -%}
39
+ {%- endif -%}
40
+ {%- endif -%}
41
+ {{- content + "<|im_end|>\n" -}}
42
+ {%- endfor -%}
43
+ {%- if add_generation_prompt -%}
44
+ {{- "<|im_start|>assistant\n" -}}
45
+ {%- endif -%}
models/templates/MiMo-VL.jinja ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0]['role'] == 'system' %}
4
+ {{- messages[0]['content'] }}
5
+ {%- else %}
6
+ {{- 'You are MiMo, an AI assistant developed by Xiaomi.' }}
7
+ {%- endif %}
8
+ {{- "\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>" }}
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
+ {%- else %}
18
+ {{- '<|im_start|>system\nYou are MiMo, an AI assistant developed by Xiaomi.<|im_end|>\n' }}
19
+ {%- endif %}
20
+ {%- endif %}
21
+ {%- for message in messages %}
22
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
23
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
24
+ {%- elif message.role == "assistant" %}
25
+ {{- '<|im_start|>' + message.role }}
26
+ {%- if message.content %}
27
+ {{- '\n' + message.content }}
28
+ {%- endif %}
29
+ {%- for tool_call in message.tool_calls %}
30
+ {%- if tool_call.function is defined %}
31
+ {%- set tool_call = tool_call.function %}
32
+ {%- endif %}
33
+ {{- '\n<tool_call>\n{"name": "' }}
34
+ {{- tool_call.name }}
35
+ {{- '", "arguments": ' }}
36
+ {{- tool_call.arguments | tojson }}
37
+ {{- '}\n</tool_call>' }}
38
+ {%- endfor %}
39
+ {{- '<|im_end|>\n' }}
40
+ {%- elif message.role == "tool" %}
41
+ {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
42
+ {{- '<|im_start|>user' }}
43
+ {%- endif %}
44
+ {{- '\n<tool_response>\n' }}
45
+ {{- message.content }}
46
+ {{- '\n</tool_response>' }}
47
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
48
+ {{- '<|im_end|>\n' }}
49
+ {%- endif %}
50
+ {%- endif %}
51
+ {%- endfor %}
52
+ {%- if add_generation_prompt %}
53
+ {{- '<|im_start|>assistant\n' }}
54
+ {%- endif %}
models/templates/MiniMax-M2.jinja ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ {%- else -%}
22
+ {{- content }}
23
+ {%- endif -%}
24
+ {%- endmacro -%}
25
+ {#- System Message Construction ============================================ -#}
26
+ {%- macro build_system_message(system_message) -%}
27
+ {%- if system_message and system_message.content -%}
28
+ {{- visible_text(system_message.content) }}
29
+ {%- else -%}
30
+ {%- if model_identity is not defined -%}
31
+ {%- set model_identity = "You are a helpful assistant." -%}
32
+ {%- endif -%}
33
+ {{- model_identity }}
34
+ {%- endif -%}
35
+
36
+ {#- Handle current_date -#}
37
+ {%- if system_message and system_message.current_date -%}
38
+ {{- '\n' ~ 'Current date: ' + system_message.current_date }}
39
+ {%- endif -%}
40
+ {#- Handle current_location -#}
41
+ {%- if system_message and system_message.current_location -%}
42
+ {{- '\n' ~ 'Current location: ' + system_message.current_location }}
43
+ {%- endif -%}
44
+ {%- endmacro -%}
45
+ {#- Main Template Logic ================================================= -#}
46
+ {#- Extract system message (only first message if it's system) -#}
47
+ {%- set system_message = none -%}
48
+ {%- set conversation_messages = messages -%}
49
+ {%- if messages and messages[0].role == "system" -%}
50
+ {%- set system_message = messages[0] -%}
51
+ {%- set conversation_messages = messages[1:] -%}
52
+ {%- endif -%}
53
+ {#- Get the last user message turn, for interleved thinking -#}
54
+ {%- set ns = namespace(last_user_index=-1) %}
55
+ {% for m in conversation_messages %}
56
+ {%- if m.role == 'user' %}
57
+ {% set ns.last_user_index = loop.index0 -%}
58
+ {%- endif %}
59
+ {%- endfor %}
60
+ {#- Render system message -#}
61
+ {{- ']~!b[' ~ ']~b]system' ~ '\n' }}
62
+ {{- build_system_message(system_message) }}
63
+ {#- Render tools if available -#}
64
+ {%- if tools -%}
65
+ {{- '\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' }}
66
+ {{- '\n' ~ '<tools>' ~ '\n' }}
67
+ {{- render_tool_namespace("functions", tools) }}
68
+ {{- '</tools>' ~ '\n\n' }}
69
+ {{- 'When making tool calls, use XML format to invoke tools and pass parameters:' ~ '\n' }}
70
+ {{- '\n' ~ toolcall_begin_token }}
71
+ <invoke name="tool-name-1">
72
+ <parameter name="param-key-1">param-value-1</parameter>
73
+ <parameter name="param-key-2">param-value-2</parameter>
74
+ ...
75
+ </invoke>
76
+ {{- '\n' ~ toolcall_end_token }}
77
+ {%- endif -%}
78
+ {{- '[e~[\n' }}
79
+
80
+ {#- Render messages -#}
81
+ {%- set last_tool_call = namespace(name=none) -%}
82
+ {%- for message in conversation_messages -%}
83
+ {%- if message.role == 'assistant' -%}
84
+ {#- Only render reasoning_content if no user message follows -#}
85
+ {{- ']~b]ai' ~ '\n' }}
86
+
87
+ {%- set reasoning_content = '' %}
88
+ {%- set content = visible_text(message.content) %}
89
+ {%- if message.reasoning_content is string %}
90
+ {%- set reasoning_content = message.reasoning_content %}
91
+ {%- else %}
92
+ {%- if '</think>' in content %}
93
+ {%- set reasoning_content = content.split('</think>')[0].strip('\n').split('<think>')[-1].strip('\n') %}
94
+ {%- set content = content.split('</think>')[-1].strip('\n') %}
95
+ {%- endif %}
96
+ {%- endif %}
97
+ {%- if reasoning_content and loop.index0 > ns.last_user_index -%}
98
+ {{- '<think>' ~ '\n' ~ reasoning_content ~ '\n' ~ '</think>' ~ '\n\n' }}
99
+ {%- endif -%}
100
+ {%- if content -%}
101
+ {{- content }}
102
+ {%- endif -%}
103
+ {%- if message.tool_calls -%}
104
+ {{- '\n' ~ toolcall_begin_token ~ '\n' }}
105
+
106
+ {%- for tool_call in message.tool_calls -%}
107
+ {%- if tool_call.function %}
108
+ {%- set tool_call = tool_call.function %}
109
+ {%- endif %}
110
+ {{- '<invoke name="' + tool_call.name + '">' }}
111
+ {% set _args = tool_call.arguments %}
112
+ {%- for k, v in _args.items() %}
113
+ {{- '<parameter name="' + k + '">' }}
114
+ {{- v | tojson(ensure_ascii=False) if v is not string else v }}
115
+ {{- '</parameter>' }}
116
+ {% endfor %}
117
+ {{- '</invoke>' ~ '\n' }}
118
+ {%- endfor -%}
119
+
120
+ {{- toolcall_end_token}}
121
+ {%- set last_tool_call.name = message.tool_calls[-1].function.name -%}
122
+ {%- else -%}
123
+ {%- set last_tool_call.name = none -%}
124
+ {%- endif -%}
125
+ {{- '[e~[' ~ '\n' }}
126
+
127
+ {%- elif message.role == 'tool' -%}
128
+ {%- if last_tool_call.name is none -%}
129
+ {{- raise_exception("Message has tool role, but there was no previous assistant message with a tool call!") }}
130
+ {%- endif -%}
131
+ {%- if loop.first or (conversation_messages[loop.index0 - 1].role != 'tool') -%}
132
+ {{- ']~b]tool' }}
133
+ {%- endif -%}
134
+ {%- if message.content is string -%}
135
+ {{- '\n<response>' }}
136
+ {{- message.content }}
137
+ {{- '</response>' }}
138
+ {%- else -%}
139
+ {%- for tr in message.content -%}
140
+ {{- '\n<response>' }}
141
+ {{- tr.output if tr.output is defined else (tr.text if tr.type == 'text' and tr.text is defined else tr) }}
142
+ {{- '\n</response>' }}
143
+ {%- endfor -%}
144
+ {%- endif -%}
145
+ {%- if loop.last or (conversation_messages[loop.index0 + 1].role != 'tool') -%}
146
+ {{- '[e~[\n' -}}
147
+ {%- endif -%}
148
+
149
+ {%- elif message.role == 'user' -%}
150
+ {{- ']~b]user' ~ '\n' }}
151
+ {{- visible_text(message.content) }}
152
+ {{- '[e~[' ~ '\n' }}
153
+ {%- endif -%}
154
+ {%- endfor -%}
155
+
156
+ {#- Generation prompt -#}
157
+ {%- if add_generation_prompt -%}
158
+ {{- ']~b]ai' ~ '\n' ~ '<think>' ~ '\n' }}
159
+ {%- endif -%}
models/templates/MiniMax-M3.jinja ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {# ---------- special token variables ---------- #}
2
+ {%- set ns_token = ']<]minimax[>[' -%}
3
+ {%- set bod_token = ']~!b[' -%}
4
+ {%- set bos_token = ']~b]' -%}
5
+ {%- set eos_token = '[e~[' -%}
6
+ {%- set toolcall_begin_token = ns_token ~ '<tool_call>' -%}
7
+ {%- set toolcall_end_token = ns_token ~ '</tool_call>' -%}
8
+ {%- set think_begin_token = '<mm:think>' -%}
9
+ {%- set think_end_token = '</mm:think>' -%}
10
+ {%- set image_token = ']<]image[>[' -%}
11
+ {%- set video_token = ']<]video[>[' -%}
12
+ {#- Thinking mode: "enabled" / "disabled" / "adaptive" / not defined -#}
13
+ {#- Recursive XML renderer for tool_call arguments ======================== -#}
14
+ {#- None values are intentionally skipped in mapping iteration so that
15
+ `<key>null</key>` (which would round-trip to the literal string "null")
16
+ never appears in the rendered tool_call. The convention is: omit the
17
+ field entirely. The top-level `_args` loop applies the same rule.
18
+ The `val is none` branch below is a safety net only — upstream cleaning
19
+ (drop_none_in_tool_arguments) should ensure no None ever reaches here. -#}
20
+ {%- macro to_xml(val, ns) -%}
21
+ {%- if val is mapping -%}
22
+ {%- for k, v in val.items() if v is not none -%}
23
+ {{ ns }}<{{ k }}>{{ to_xml(v, ns) }}{{ ns }}</{{ k }}>
24
+ {%- endfor -%}
25
+ {%- elif val is iterable and val is not string -%}
26
+ {%- for item in val -%}
27
+ {{ ns }}<item>{{ to_xml(item, ns) }}{{ ns }}</item>
28
+ {%- endfor -%}
29
+ {%- elif val is none -%}
30
+ {#- Should be unreachable when upstream cleaning is applied. -#}
31
+ {%- elif val is boolean -%}
32
+ {{ val | tojson }}
33
+ {%- else -%}
34
+ {{ val }}
35
+ {%- endif -%}
36
+ {%- endmacro -%}
37
+ {#- Tool Rendering Functions ============================================== -#}
38
+ {%- macro render_tool_namespace(namespace_name, tool_list) -%}
39
+ {%- for tool in tool_list -%}
40
+ <tool>{{ tool.function | tojson(ensure_ascii=False) }}</tool>
41
+ {% endfor -%}
42
+ {%- endmacro -%}
43
+ {%- macro visible_text(content) -%}
44
+ {%- if content is string -%}
45
+ {{ content }}
46
+ {%- elif content is iterable and content is not mapping -%}
47
+ {%- for item in content -%}
48
+ {%- if item is mapping and item.type == 'text' -%}
49
+ {{- item.text }}
50
+ {%- elif item is mapping and item.type == 'image' -%}
51
+ {{- image_token }}
52
+ {%- elif item is mapping and item.type == 'video' -%}
53
+ {{- video_token}}
54
+ {%- elif item is string -%}
55
+ {{- item }}
56
+ {%- endif -%}
57
+ {%- endfor -%}
58
+ {%- elif content is none -%}
59
+ {{- '' }}
60
+ {%- else -%}
61
+ {{- content }}
62
+ {%- endif -%}
63
+ {%- endmacro -%}
64
+ {#- System Message Construction ============================================ -#}
65
+ {%- macro build_system_message(system_message) -%}
66
+ {%- if system_message and system_message.content -%}
67
+ {{- visible_text(system_message.content) }}
68
+ {%- else -%}
69
+ {{- 'Your model version is MiniMax-M3, developed by MiniMax. Knowledge cutoff: January 2026. Founded in early 2022, MiniMax is a global AI foundation model company committed to advancing the frontiers of AI towards AGI.' }}
70
+ {%- endif -%}
71
+
72
+ {#- Thinking mode instructions -#}
73
+ {{- '\n\n<thinking_instructions>\n' }}
74
+ {{- 'You have a thinking capability that allows you to reason step by step before responding. When thinking is enabled, wrap your reasoning in ' ~ think_begin_token ~ think_end_token ~ ' tags before your response. When thinking is disabled, begin your response directly after the ' ~ think_end_token ~ ' prefix. When thinking is adaptive, decide on your own whether to think for the current turn.\n' }}
75
+ {%- if thinking_mode is defined -%}
76
+ {%- if thinking_mode == "enabled" -%}
77
+ {{- 'Current thinking mode: enabled. You MUST think step by step before every response, including after receiving function/tool results.\n' }}
78
+ {%- elif thinking_mode == "disabled" -%}
79
+ {{- 'Current thinking mode: disabled. Do not output any thinking process.\n' }}
80
+ {%- elif thinking_mode == "adaptive" -%}
81
+ {{- 'Current thinking mode: adaptive. You are encouraged to think for complex decision-making, multi-step reasoning, or when analyzing function/tool results.\n' }}
82
+ {%- endif -%}
83
+ {%- else -%}
84
+ {{- 'Current thinking mode: adaptive. You are encouraged to think for complex decision-making, multi-step reasoning, or when analyzing function/tool results.\n' }}
85
+ {%- endif -%}
86
+ {{- '</thinking_instructions>' }}
87
+ {%- endmacro -%}
88
+ {%- macro build_developer_message(developer_message) -%}
89
+ {%- if developer_message and developer_message.content -%}
90
+ {{- visible_text(developer_message.content) }}
91
+ {%- else -%}
92
+ {%- if model_identity is not defined -%}
93
+ {%- set model_identity = "You are a helpful assistant." -%}
94
+ {%- endif -%}
95
+ {{- model_identity }}
96
+ {%- endif -%}
97
+ {%- endmacro -%}
98
+ {#- Main Template Logic ================================================= -#}
99
+ {#- Role mapping: root -> system sp (high priority), system/developer -> developer sp (low priority) -#}
100
+ {%- set system_message = none -%}
101
+ {%- set developer_message = none -%}
102
+ {%- set conversation_messages = messages -%}
103
+ {%- if messages and messages[0].role == "root" -%}
104
+ {%- set system_message = messages[0] -%}
105
+ {%- set conversation_messages = messages[1:] -%}
106
+ {%- if conversation_messages and conversation_messages[0].role in ["system", "developer"] -%}
107
+ {%- set developer_message = conversation_messages[0] -%}
108
+ {%- set conversation_messages = conversation_messages[1:] -%}
109
+ {%- endif -%}
110
+ {%- elif messages and messages[0].role in ["system", "developer"] -%}
111
+ {%- set developer_message = messages[0] -%}
112
+ {%- set conversation_messages = messages[1:] -%}
113
+ {%- endif -%}
114
+ {#- Render system sp (higher priority, root role only) -#}
115
+ {{- bod_token ~ bos_token ~ 'system' ~ '\n' }}
116
+ {{- build_system_message(system_message) }}
117
+ {{- eos_token ~ '\n' }}
118
+
119
+ {#- Render developer sp (lower priority: system/developer role + tools) -#}
120
+ {{- bos_token ~ 'developer' ~ '\n' }}
121
+ {{- build_developer_message(developer_message) }}
122
+ {%- if tools -%}
123
+ {{- '\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' }}
124
+ {{- '\n' ~ '<tools>' ~ '\n' }}
125
+ {{- render_tool_namespace("functions", tools) }}
126
+ {{- '</tools>' ~ '\n\n' }}
127
+ {{- 'To call tools, wrap all invocations in a single ' ~ toolcall_begin_token ~ toolcall_end_token ~ ' block. Parameter values containing nested objects or arrays are recursively expanded into XML elements. Example:\n' }}
128
+ {{- '\n' ~ toolcall_begin_token ~ '\n' }}
129
+ {{- ns_token + '<invoke name="tool-name-1">' }}
130
+ {{- ns_token + '<param-1>value-1' + ns_token + '</param-1>' }}
131
+ {{- ns_token + '<param-2>' }}
132
+ {{- ns_token + '<item>' }}
133
+ {{- ns_token + '<key-a>val-a' + ns_token + '</key-a>' }}
134
+ {{- ns_token + '<key-b>val-b' + ns_token + '</key-b>' }}
135
+ {{- ns_token + '</item>' }}
136
+ {{- ns_token + '</param-2>' }}
137
+ {{- ns_token + '</invoke>\n' }}
138
+ {{- ns_token + '<invoke name="tool-name-2">' }}
139
+ {{- ns_token + '<param-1>value-1' + ns_token + '</param-1>' }}
140
+ {{- ns_token + '</invoke>\n' }}
141
+ {{- toolcall_end_token }}
142
+ {%- endif -%}
143
+ {{- eos_token ~ '\n' }}
144
+
145
+ {#- Render messages -#}
146
+ {%- set last_tool_call = namespace(name=none) -%}
147
+ {%- for message in conversation_messages -%}
148
+ {%- if message.role == 'assistant' -%}
149
+ {{- bos_token ~ 'ai' ~ '\n' }}
150
+
151
+ {%- set reasoning_content = '' %}
152
+ {%- set content = visible_text(message.content) %}
153
+ {%- if message.reasoning_content is string %}
154
+ {%- set reasoning_content = message.reasoning_content %}
155
+ {%- else %}
156
+ {%- if think_end_token in content %}
157
+ {%- set reasoning_content = content.split(think_end_token)[0].strip('\n').split(think_begin_token)[-1].strip('\n') %}
158
+ {%- set content = content.split(think_end_token)[-1].strip('\n') %}
159
+ {%- endif %}
160
+ {%- endif %}
161
+
162
+ {%- if reasoning_content -%}
163
+ {#- Render thinking for every assistant turn (all-turn visible) -#}
164
+ {{- think_begin_token ~ reasoning_content ~ think_end_token }}
165
+ {%- else -%}
166
+ {#- No thinking rendered → prefix with think_end_token -#}
167
+ {{- think_end_token }}
168
+ {%- endif -%}
169
+
170
+ {%- if content -%}
171
+ {{- content }}
172
+ {%- endif -%}
173
+ {%- if message.tool_calls -%}
174
+ {{- toolcall_begin_token ~ '\n' }}
175
+
176
+ {%- for tool_call in message.tool_calls -%}
177
+ {%- if tool_call.function -%}
178
+ {%- set tool_call = tool_call.function -%}
179
+ {%- endif -%}
180
+ {{- ns_token + '<invoke name="' + tool_call.name + '">' }}
181
+ {%- set _args = tool_call.arguments -%}
182
+ {%- for k, v in _args.items() if v is not none %}
183
+ {{- ns_token + '<' + k + '>' -}}
184
+ {{- to_xml(v, ns_token) -}}
185
+ {{- ns_token + '</' + k + '>' }}
186
+ {%- endfor -%}
187
+ {{- ns_token + '</invoke>' ~ '\n' }}
188
+ {%- endfor -%}
189
+
190
+ {{- toolcall_end_token }}
191
+ {%- if message.tool_calls[-1].function -%}
192
+ {%- set last_tool_call.name = message.tool_calls[-1].function.name -%}
193
+ {%- else -%}
194
+ {%- set last_tool_call.name = message.tool_calls[-1].name -%}
195
+ {%- endif -%}
196
+ {%- else -%}
197
+ {%- set last_tool_call.name = none -%}
198
+ {%- endif -%}
199
+ {{- eos_token ~ '\n' }}
200
+
201
+ {%- elif message.role == 'tool' -%}
202
+ {%- if last_tool_call.name is none -%}
203
+ {{- raise_exception("Message has tool role, but there was no previous assistant message with a tool call!") }}
204
+ {%- endif -%}
205
+ {%- if loop.first or (conversation_messages[loop.index0 - 1].role != 'tool') -%}
206
+ {{- bos_token ~ 'tool' }}
207
+ {%- endif -%}
208
+ {{- '\n<response>' }}
209
+ {%- if message.content is string -%}
210
+ {{- message.content }}
211
+ {%- else -%}
212
+ {%- for tr in message.content -%}
213
+ {%- if tr is mapping and tr.type is defined and tr.type == 'image' -%}
214
+ {{- image_token }}
215
+ {%- elif tr is mapping and tr.type is defined and tr.type == 'video' -%}
216
+ {{- video_token }}
217
+ {%- else -%}
218
+ {{- tr.output if tr.output is defined else (tr.text if tr.type == 'text' and tr.text is defined else tr) }}
219
+ {%- endif -%}
220
+ {%- endfor -%}
221
+ {%- endif -%}
222
+ {{- '</response>' }}
223
+ {%- if loop.last or (conversation_messages[loop.index0 + 1].role != 'tool') -%}
224
+ {{- eos_token ~ '\n' -}}
225
+ {%- endif -%}
226
+
227
+ {%- elif message.role == 'user' -%}
228
+ {{- bos_token ~ 'user' ~ '\n' }}
229
+ {{- visible_text(message.content) }}
230
+ {{- eos_token ~ '\n' }}
231
+ {%- endif -%}
232
+ {%- endfor -%}
233
+
234
+ {#- Generation prompt -#}
235
+ {%- if add_generation_prompt -%}
236
+ {{- bos_token ~ 'ai' ~ '\n' }}
237
+ {%- if thinking_mode is defined and thinking_mode == "disabled" -%}
238
+ {{- think_end_token }}
239
+ {%- elif thinking_mode is defined and thinking_mode == "adaptive" -%}
240
+ {#- adaptive: no prefix, let model decide -#}
241
+ {%- elif thinking_mode is defined and thinking_mode == "enabled" -%}
242
+ {#- enabled or not defined: default to think -#}
243
+ {{- think_begin_token }}
244
+ {%- else -%}
245
+ {#- adaptive: no prefix, let model decide -#}
246
+ {%- endif -%}
247
+ {%- endif -%}
models/templates/Mistral-Small-3.2-24B-Instruct-2506.jinja ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set today = strftime_now("%Y-%m-%d") %}
2
+ {%- set default_system_message = "You are Mistral Small 3, a Large Language Model (LLM) created by Mistral AI, a French startup headquartered in Paris.\nYour knowledge base was last updated on 2023-10-01. The current date is " + today + ".\n\nWhen you're not sure about some information or when the user's request requires up-to-date or specific data, you must use the available tools to fetch the information. Do not hesitate to use tools whenever they can provide a more accurate or complete response. If no relevant tools are available, then clearly state that you don't have the information and avoid making up anything.
3
+
4
+ If the user's question is not clear, ambiguous, or does not provide enough context for you to accurately answer the question, you do not try to answer it right away and you rather ask the user to clarify their request (e.g. \"What are some good restaurants around me?\" => \"Where are you?\" or \"When is the next flight to Tokyo\" => \"Where do you travel from?\").
5
+ You are always very attentive to dates, and when asked about information at specific dates, you discard information that is at another date.
6
+ You follow these instructions in all languages, and always respond to the user in the language they use or request.
7
+ Next sections describe the capabilities that you have.
8
+
9
+ # WEB BROWSING INSTRUCTIONS
10
+
11
+ You cannot perform any web search or access internet to open URLs, links etc. If it seems like the user is expecting you to do so, you clarify the situation and ask the user to copy paste the text directly in the chat.
12
+
13
+ # MULTI-MODAL INSTRUCTIONS
14
+
15
+ You have the ability to read images, but you cannot generate images. You also cannot transcribe audio files or videos.
16
+ You cannot read nor transcribe audio files or videos.
17
+
18
+ # TOOL CALLING INSTRUCTIONS
19
+
20
+ You may have access to tools that you can use to fetch information or perform actions. You must use these tools in the following situations:
21
+
22
+ 1. When the request requires up-to-date information.
23
+ 2. When the request requires specific data that you do not have in your knowledge base.
24
+ 3. When the request involves actions that you cannot perform without tools.
25
+
26
+ Always prioritize using tools to provide the most accurate and helpful response. If tools are not available, inform the user that you cannot perform the requested action at the moment." %}
27
+
28
+ {{- bos_token }}
29
+
30
+ {%- set system_prompt = default_system_message %}
31
+ {%- set loop_messages = messages %}
32
+
33
+ {%- if not tools is defined %}
34
+ {%- set tools = none %}
35
+ {%- endif %}
36
+
37
+ {%- if messages|length > 0 and messages[0]['role'] == 'system' %}
38
+ {%- if messages[0]['content'] is string %}
39
+ {%- set system_prompt = messages[0]['content'] %}
40
+ {%- else %}
41
+ {%- set system_prompt = messages[0]['content'][0]['text'] %}
42
+ {%- endif %}
43
+ {%- set loop_messages = messages[1:] %}
44
+ {%- endif %}
45
+
46
+ {%- set user_messages = loop_messages | selectattr("role", "equalto", "user") | list %}
47
+
48
+ {%- set ns = namespace(index=0) %}
49
+ {%- for message in loop_messages %}
50
+ {%- if not (message.role == "tool" or (message.get('tool_calls'))) %}
51
+ {%- if (message["role"] == "user") != (ns.index % 2 == 0) %}
52
+ {{- raise_exception("After the optional system message, conversation roles must alternate user/assistant/user/assistant/...") }}
53
+ {%- endif %}
54
+ {%- set ns.index = ns.index + 1 %}
55
+ {%- endif %}
56
+ {%- endfor %}
57
+
58
+ {{- '[SYSTEM_PROMPT]' + system_prompt + '[/SYSTEM_PROMPT]' }}
59
+
60
+ {%- for message in loop_messages %}
61
+ {%- if message['role'] == 'system' %}
62
+ {%- if message['content'] is string %}
63
+ {{- '[SYSTEM_PROMPT]' + message['content'] + '[/SYSTEM_PROMPT]' }}
64
+ {%- else %}
65
+ {{- '[SYSTEM_PROMPT]' + message['content'][0]['text'] + '[/SYSTEM_PROMPT]' }}
66
+ {%- endif %}
67
+ {%- elif message['role'] == 'user' %}
68
+ {%- if tools is not none and (message == user_messages[-1]) %}
69
+ {{- '[AVAILABLE_TOOLS]' + tools|tojson + '[/AVAILABLE_TOOLS]' }}
70
+ {%- endif %}
71
+ {{- '[INST]' }}
72
+ {%- if message['content'] is string %}
73
+ {{- message['content'] }}
74
+ {%- else %}
75
+ {%- for block in message['content'] %}
76
+ {%- if block['type'] == 'text' %}
77
+ {{- block['text'] }}
78
+ {%- elif block['type'] in ['image', 'image_url'] %}
79
+ {{- '[IMG]' }}
80
+ {%- else %}
81
+ {{- raise_exception('Only text and image blocks are supported in message content!') }}
82
+ {%- endif %}
83
+ {%- endfor %}
84
+ {%- endif %}
85
+ {{- '[/INST]' }}
86
+ {%- elif message['role'] == 'assistant' %}
87
+ {%- if message.get('tool_calls') %}
88
+ {%- for tool_call in message.tool_calls %}
89
+ {{- '[TOOL_CALLS]' + tool_call.function.name }}
90
+ {%- if not tool_call.id is defined or tool_call.id is not string or tool_call.id|length != 9 %}
91
+ {{- raise_exception("Tool call IDs should be alphanumeric strings with length 9!") }}
92
+ {%- endif %}
93
+ {{- '[CALL_ID]' + tool_call.id }}
94
+ {{- '[ARGS]' + tool_call['function']['arguments']|tojson }}
95
+ {%- endfor %}
96
+ {{- eos_token }}
97
+ {%- elif message['content'] is string %}
98
+ {{- message['content'] + eos_token }}
99
+ {%- else %}
100
+ {%- for block in message['content'] %}
101
+ {%- if block['type'] == 'text' %}
102
+ {{- block['text'] }}
103
+ {%- elif block['type'] in ['image', 'image_url'] %}
104
+ {{- '[IMG]' }}
105
+ {%- else %}
106
+ {{- raise_exception('Only text and image blocks are supported in assistant content!') }}
107
+ {%- endif %}
108
+ {%- endfor %}
109
+ {{- eos_token }}
110
+ {%- endif %}
111
+ {%- elif message['role'] == 'tool_results' or message['role'] == 'tool' %}
112
+ {%- if message.content is defined and message.content.content is defined %}
113
+ {%- set content = message.content.content %}
114
+ {%- else %}
115
+ {%- set content = message.content %}
116
+ {%- endif %}
117
+ {%- if not message.tool_call_id is defined or message.tool_call_id is not string or message['tool_call_id']|length != 9 %}
118
+ {{- raise_exception("Tool call IDs should be alphanumeric strings with length 9!") }}
119
+ {%- endif %}
120
+ {{- '[TOOL_RESULTS]' + message.tool_call_id + '[TOOL_CONTENT]' + content|string + '[/TOOL_RESULTS]' }}
121
+ {%- else %}
122
+ {{- raise_exception('Only system, user, assistant, and tool roles are supported!') }}
123
+ {%- endif %}
124
+ {%- endfor %}
models/templates/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16.jinja ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% macro render_extra_keys(json_dict, handled_keys) %}
2
+ {%- if json_dict is mapping %}
3
+ {%- for json_key in json_dict if json_key not in handled_keys %}
4
+ {%- if json_dict[json_key] is mapping or (json_dict[json_key] is sequence and json_dict[json_key] is not string) %}
5
+ {{- '\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | tojson | safe) ~ '</' ~ json_key ~ '>' }}
6
+ {%- else %}
7
+ {{-'\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | string) ~ '</' ~ json_key ~ '>' }}
8
+ {%- endif %}
9
+ {%- endfor %}
10
+ {%- endif %}
11
+ {% endmacro %}
12
+ {%- set enable_thinking = enable_thinking if enable_thinking is defined else True %}
13
+ {%- set truncate_history_thinking = truncate_history_thinking if truncate_history_thinking is defined else True %}
14
+
15
+ {%- set ns = namespace(last_user_idx = -1) %}
16
+ {%- set loop_messages = messages %}
17
+ {%- for m in loop_messages %}
18
+ {%- if m["role"] == "user" %}
19
+ {%- set ns.last_user_idx = loop.index0 %}
20
+ {%- endif %}
21
+ {%- endfor %}
22
+
23
+ {%- if messages[0]["role"] == "system" %}
24
+ {%- set system_message = messages[0]["content"] %}
25
+ {%- set loop_messages = messages[1:] %}
26
+ {%- else %}
27
+ {%- set system_message = "" %}
28
+ {%- set loop_messages = messages %}
29
+ {%- endif %}
30
+ {%- if not tools is defined %}
31
+ {%- set tools = [] %}
32
+ {%- endif %}
33
+ {# Recompute last_user_idx relative to loop_messages after handling system #}
34
+ {%- set ns = namespace(last_user_idx = -1) %}
35
+ {%- for m in loop_messages %}
36
+ {%- if m["role"] == "user" %}
37
+ {%- set ns.last_user_idx = loop.index0 %}
38
+ {%- endif %}
39
+ {%- endfor %}
40
+ {%- if system_message is defined %}
41
+ {{- "<|im_start|>system\n" + system_message }}
42
+ {%- else %}
43
+ {%- if tools is iterable and tools | length > 0 %}
44
+ {{- "<|im_start|>system\n" }}
45
+ {%- endif %}
46
+ {%- endif %}
47
+ {%- if tools is iterable and tools | length > 0 %}
48
+ {%- if system_message is defined and system_message | length > 0 %}
49
+ {{- "\n\n" }}
50
+ {%- endif %}
51
+ {{- "# Tools\n\nYou have access to the following functions:\n\n" }}
52
+ {{- "<tools>" }}
53
+ {%- for tool in tools %}
54
+ {%- if tool.function is defined %}
55
+ {%- set tool = tool.function %}
56
+ {%- endif %}
57
+ {{- "\n<function>\n<name>" ~ tool.name ~ "</name>" }}
58
+ {%- if tool.description is defined %}
59
+ {{- '\n<description>' ~ (tool.description | trim) ~ '</description>' }}
60
+ {%- endif %}
61
+ {{- '\n<parameters>' }}
62
+ {%- if tool.parameters is defined and tool.parameters is mapping and tool.parameters.properties is defined and tool.parameters.properties is mapping %}
63
+ {%- for param_name, param_fields in tool.parameters.properties|items %}
64
+ {{- '\n<parameter>' }}
65
+ {{- '\n<name>' ~ param_name ~ '</name>' }}
66
+ {%- if param_fields.type is defined %}
67
+ {{- '\n<type>' ~ (param_fields.type | string) ~ '</type>' }}
68
+ {%- endif %}
69
+ {%- if param_fields.description is defined %}
70
+ {{- '\n<description>' ~ (param_fields.description | trim) ~ '</description>' }}
71
+ {%- endif %}
72
+ {%- if param_fields.enum is defined %}
73
+ {{- '\n<enum>' ~ (param_fields.enum | tojson | safe) ~ '</enum>' }}
74
+ {%- endif %}
75
+ {%- set handled_keys = ['name', 'type', 'description', 'enum'] %}
76
+ {{- render_extra_keys(param_fields, handled_keys) }}
77
+ {{- '\n</parameter>' }}
78
+ {%- endfor %}
79
+ {%- endif %}
80
+ {% set handled_keys = ['type', 'properties', 'required'] %}
81
+ {{- render_extra_keys(tool.parameters, handled_keys) }}
82
+ {%- if tool.parameters is defined and tool.parameters.required is defined %}
83
+ {{- '\n<required>' ~ (tool.parameters.required | tojson | safe) ~ '</required>' }}
84
+ {%- endif %}
85
+ {{- '\n</parameters>' }}
86
+ {%- set handled_keys = ['type', 'name', 'description', 'parameters'] %}
87
+ {{- render_extra_keys(tool, handled_keys) }}
88
+ {{- '\n</function>' }}
89
+ {%- endfor %}
90
+ {{- "\n</tools>" }}
91
+
92
+ {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
93
+ {%- endif %}
94
+
95
+
96
+ {%- if system_message is defined %}
97
+ {{- '<|im_end|>\n' }}
98
+ {%- else %}
99
+ {%- if tools is iterable and tools | length > 0 %}
100
+ {{- '<|im_end|>\n' }}
101
+ {%- endif %}
102
+ {%- endif %}
103
+
104
+ {%- for message in loop_messages %}
105
+ {%- if message.role == "assistant" %}
106
+ {# Add reasoning content in to content field for unified processing below. #}
107
+ {%- if message.reasoning_content is defined and message.reasoning_content is string and message.reasoning_content | trim | length > 0 %}
108
+ {%- set content = "<think>\n" ~ message.reasoning_content ~ "\n</think>\n" ~ (message.content | default('', true)) %}
109
+ {%- else %}
110
+ {%- set content = message.content | default('', true) %}
111
+ {%- if content is string -%}
112
+ {# Allow downstream logic to to take care of broken thought, only handle coherent reasoning here. #}
113
+ {%- if '<think>' not in content and '</think>' not in content -%}
114
+ {%- set content = "<think></think>" ~ content -%}
115
+ {%- endif -%}
116
+ {%- else -%}
117
+ {%- set content = content -%}
118
+ {%- endif -%}
119
+ {%- endif %}
120
+ {%- if message.tool_calls is defined and message.tool_calls is iterable and message.tool_calls | length > 0 %}
121
+ {# Assistant message has tool calls. #}
122
+ {{- '<|im_start|>assistant\n' }}
123
+ {%- set include_content = not (truncate_history_thinking and loop.index0 < ns.last_user_idx) %}
124
+ {%- if content is string and content | trim | length > 0 %}
125
+ {%- if include_content %}
126
+ {{- (content | trim) ~ '\n' -}}
127
+ {%- else %}
128
+ {%- set c = (content | string) %}
129
+ {%- if '</think>' in c %}
130
+ {# Keep only content after the last closing think. Also generation prompt causes this. #}
131
+ {%- set c = c.split('</think>')[-1] %}
132
+ {%- elif '<think>' in c %}
133
+ {# If <think> was opened but never closed, drop the trailing think segment #}
134
+ {%- set c = c.split('<think>')[0] %}
135
+ {%- endif %}
136
+ {%- set c = "<think></think>" ~ c | trim %}
137
+ {%- if c | length > 0 %}
138
+ {{- c ~ '\n' -}}
139
+ {%- endif %}
140
+ {%- endif %}
141
+ {%- else %}
142
+ {{- "<think></think>" -}}
143
+ {%- endif %}
144
+ {%- for tool_call in message.tool_calls %}
145
+ {%- if tool_call.function is defined %}
146
+ {%- set tool_call = tool_call.function %}
147
+ {%- endif %}
148
+ {{- '<tool_call>\n<function=' ~ tool_call.name ~ '>\n' -}}
149
+ {%- if tool_call.arguments is defined %}
150
+ {%- for args_name, args_value in tool_call.arguments|items %}
151
+ {{- '<parameter=' ~ args_name ~ '>\n' -}}
152
+ {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
153
+ {{- args_value ~ '\n</parameter>\n' -}}
154
+ {%- endfor %}
155
+ {%- endif %}
156
+ {{- '</function>\n</tool_call>\n' -}}
157
+ {%- endfor %}
158
+ {{- '<|im_end|>\n' }}
159
+ {%- else %}
160
+ {# Assistant message doesn't have tool calls. #}
161
+ {%- if not (truncate_history_thinking and loop.index0 < ns.last_user_idx) %}
162
+ {{- '<|im_start|>assistant\n' ~ (content | default('', true) | string | trim) ~ '<|im_end|>\n' }}
163
+ {%- else %}
164
+ {%- set c = (content | default('', true) | string) %}
165
+ {%- if '<think>' in c and '</think>' in c %}
166
+ {%- set c = "<think></think>" ~ c.split('</think>')[-1] %}
167
+ {%- endif %}
168
+ {%- set c = c | trim %}
169
+ {%- if c | length > 0 %}
170
+ {{- '<|im_start|>assistant\n' ~ c ~ '<|im_end|>\n' }}
171
+ {%- else %}
172
+ {{- '<|im_start|>assistant\n<|im_end|>\n' }}
173
+ {%- endif %}
174
+ {%- endif %}
175
+ {%- endif %}
176
+ {%- elif message.role == "user" or message.role == "system" %}
177
+ {{- '<|im_start|>' + message.role + '\n' }}
178
+ {%- set content = message.content | string %}
179
+ {{- content }}
180
+ {{- '<|im_end|>\n' }}
181
+ {%- elif message.role == "tool" %}
182
+ {%- if loop.previtem and loop.previtem.role != "tool" %}
183
+ {{- '<|im_start|>user\n' }}
184
+ {%- endif %}
185
+ {{- '<tool_response>\n' }}
186
+ {{- message.content }}
187
+ {{- '\n</tool_response>\n' }}
188
+ {%- if not loop.last and loop.nextitem.role != "tool" %}
189
+ {{- '<|im_end|>\n' }}
190
+ {%- elif loop.last %}
191
+ {{- '<|im_end|>\n' }}
192
+ {%- endif %}
193
+ {%- else %}
194
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>\n' }}
195
+ {%- endif %}
196
+ {%- endfor %}
197
+
198
+ {%- if add_generation_prompt %}
199
+ {%- if enable_thinking %}
200
+ {{- '<|im_start|>assistant\n<think>\n' }}
201
+ {%- else %}
202
+ {{- '<|im_start|>assistant\n<think></think>' }}
203
+ {%- endif %}
204
+ {%- endif %}
models/templates/NVIDIA-Nemotron-Nano-v2.jinja ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set ns = namespace(enable_thinking=true) -%}
2
+ {%- for message in messages -%}
3
+ {%- set content = message['content'] -%}
4
+ {%- if message['role'] == 'user' or message['role'] == 'system' -%}
5
+ {%- if '/think' in content -%}
6
+ {%- set ns.enable_thinking = true -%}
7
+ {%- elif '/no_think' in content -%}
8
+ {%- set ns.enable_thinking = false -%}
9
+ {%- endif -%}
10
+ {%- endif -%}
11
+ {%- endfor -%}
12
+
13
+ {%- if messages[0]['role'] != 'system' -%}
14
+ {%- set ns.non_tool_system_content = '' -%}
15
+ {{- '<SPECIAL_10>System
16
+ ' -}}
17
+ {%- else -%}
18
+ {%- set ns.non_tool_system_content = (messages[0]['content'] | default('', true)).replace('/think', '').replace('/no_think', '').strip() -%}
19
+ {{- '<SPECIAL_10>System
20
+ ' + ns.non_tool_system_content }}
21
+ {%- endif -%}
22
+
23
+ {%- if tools -%}
24
+ {%- if ns.non_tool_system_content is defined and ns.non_tool_system_content != '' -%}
25
+ {{- '
26
+
27
+ ' -}}
28
+ {%- endif -%}
29
+ {{- 'You can use the following tools to assist the user if required:' -}}
30
+ {{- '
31
+ <AVAILABLE_TOOLS>[' -}}
32
+ {%- for tool in tools -%}
33
+ {{- (tool.function if tool.function is defined else tool) | tojson -}}
34
+ {{- ', ' if not loop.last else '' -}}
35
+ {%- endfor -%}
36
+ {{- ']</AVAILABLE_TOOLS>
37
+
38
+ ' -}}
39
+ {{- 'If you decide to call any tool(s), use the following format:
40
+ ' -}}
41
+ {{- '<TOOLCALL>[{{"name": "tool_name1", "arguments": "tool_args1"}}, ' -}}
42
+ {{- '{{"name": "tool_name2", "arguments": "tool_args2"}}]</TOOLCALL>
43
+
44
+ ' -}}
45
+ {{- 'The user will execute tool-calls and return responses from tool(s) in this format:
46
+ ' -}}
47
+ {{- '<TOOL_RESPONSE>[{{"tool_response1"}}, {{"tool_response2"}}]</TOOL_RESPONSE>
48
+
49
+ ' -}}
50
+ {{- 'Based on the tool responses, you can call additional tools if needed, correct tool calls if any errors are found, or just respond to the user.' -}}
51
+ {%- endif -%}
52
+ {{- '
53
+
54
+ ' -}}
55
+ {%- set messages = messages[1:] if messages[0]['role'] == 'system' else messages -%}
56
+ {%- if messages[-1]['role'] == 'assistant' -%}
57
+ {%- set ns.last_turn_assistant_content = (messages[-1]['content'] | default('', true)).strip() -%}
58
+ {%- set ns.last_turn_assistant_tool_calls = messages[-1]['tool_calls'] if 'tool_calls' in messages[-1] else [] -%}
59
+ {%- set messages = messages[:-1] -%}
60
+ {%- endif -%}
61
+
62
+ {%- for message in messages %}
63
+ {%- set content = message['content'] %}
64
+ {%- if message['role'] == 'user' -%}
65
+ {{- '<SPECIAL_11>User
66
+ ' + (content | default('', true)).replace('/think', '').replace('/no_think', '').strip() + '
67
+ ' }}
68
+ {%- elif message['role'] == 'tool' -%}
69
+ {%- if loop.first or (messages[loop.index0 - 1].role != 'tool') -%}
70
+ {{- '<SPECIAL_11>User
71
+ ' + '<TOOL_RESPONSE>[' }}
72
+ {%- endif -%}
73
+ {{- message['content'] -}}
74
+ {{- ', ' if not loop.last and (messages[loop.index0 + 1].role == 'tool') else '' -}}
75
+ {%- if loop.last or (messages[loop.index0 + 1].role != 'tool') -%}
76
+ {{- ']</TOOL_RESPONSE>' -}}
77
+ {%- endif -%}
78
+ {%- elif message['role'] == 'assistant' -%}
79
+ {%- if content and '</think>' in content -%}
80
+ {%- set content = (content.split('</think>')[1] | default('', true)).strip() %}
81
+ {%- endif -%}
82
+ {{- '<SPECIAL_11>Assistant
83
+ ' + ((content | default('', true)).strip() if content is not none else '') }}
84
+ {%- if message.tool_calls -%}
85
+ {%- if (content | default('', true)).strip() != '' -%}
86
+ {{- '
87
+ ' -}}
88
+ {%- endif -%}
89
+ {{- '<TOOLCALL>[' -}}
90
+ {%- for call in message.tool_calls -%}
91
+ {%- set fn = call.function if call.function is defined else call -%}
92
+ {{- '{"name": "' + fn.name + '", "arguments": ' -}}
93
+ {%- if fn.arguments is string -%}
94
+ {{- fn.arguments -}}
95
+ {%- else -%}
96
+ {{- fn.arguments | tojson -}}
97
+ {%- endif -%}
98
+ {{- '}' + (', ' if not loop.last else '') -}}
99
+ {%- endfor -%}
100
+ {{- ']</TOOLCALL>' -}}
101
+ {%- endif -%}
102
+ {{- '
103
+ <SPECIAL_12>
104
+ ' -}}
105
+ {%- endif -%}
106
+ {%- endfor -%}
107
+
108
+ {%- if add_generation_prompt -%}
109
+ {{- '<SPECIAL_11>Assistant
110
+ ' -}}
111
+ {%- if ns.enable_thinking is defined and ns.enable_thinking is false -%}
112
+ {{- '<think></think>' -}}
113
+ {%- else -%}
114
+ {{- '<think>
115
+ ' -}}
116
+ {%- endif -%}
117
+ {%- if ns.last_turn_assistant_content is defined and ns.last_turn_assistant_content != '' -%}
118
+ {{- ns.last_turn_assistant_content -}}
119
+ {%- endif -%}
120
+ {%- else -%}
121
+ {%- if ns.last_turn_assistant_content is defined and ns.last_turn_assistant_content != '' -%}
122
+ {{- '<SPECIAL_11>Assistant
123
+ ' -}}
124
+ {%- if ns.enable_thinking is defined and ns.enable_thinking is false -%}
125
+ {{- '<think></think>' -}}
126
+ {%- else -%}
127
+ {{- '<think>
128
+ ' -}}
129
+ {%- endif -%}
130
+ {{- ns.last_turn_assistant_content -}}
131
+ {%- if continue_final_message is defined -%}
132
+ {%- if continue_final_message is false -%}
133
+ {{- '
134
+ <SPECIAL_12>
135
+ ' -}}
136
+ {%- endif -%}
137
+ {%- else -%}
138
+ {{- '
139
+ <SPECIAL_12>
140
+ ' -}}
141
+ {%- endif -%}
142
+ {%- endif -%}
143
+ {%- if ns.last_turn_assistant_tool_calls is defined and ns.last_turn_assistant_tool_calls | length > 0 -%}
144
+ {{- '<SPECIAL_11>Assistant
145
+ ' -}}
146
+ {{- '<TOOLCALL>[' -}}
147
+ {%- for call in ns.last_turn_assistant_tool_calls -%}
148
+ {%- set fn = call.function if call.function is defined else call -%}
149
+ {{- '{"name": "' + fn.name + '", "arguments": ' -}}
150
+ {%- if fn.arguments is string -%}
151
+ {{- fn.arguments -}}
152
+ {%- else -%}
153
+ {{- fn.arguments | tojson -}}
154
+ {%- endif -%}
155
+ {{- '}' + (', ' if not loop.last else '') -}}
156
+ {%- endfor -%}
157
+ {{- ']</TOOLCALL>' -}}
158
+ {{- '<SPECIAL_12>
159
+
160
+ ' -}}
161
+ {%- endif -%}
162
+ {%- endif -%}
models/templates/NousResearch-Hermes-2-Pro-Llama-3-8B-tool_use.jinja ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- macro json_to_python_type(json_spec) %}
2
+ {%- set basic_type_map = {
3
+ "string": "str",
4
+ "number": "float",
5
+ "integer": "int",
6
+ "boolean": "bool"
7
+ } %}
8
+
9
+ {%- if basic_type_map[json_spec.type] is defined %}
10
+ {{- basic_type_map[json_spec.type] }}
11
+ {%- elif json_spec.type == "array" %}
12
+ {{- "list[" + json_to_python_type(json_spec|items) + "]"}}
13
+ {%- elif json_spec.type == "object" %}
14
+ {%- if json_spec.additionalProperties is defined %}
15
+ {{- "dict[str, " + json_to_python_type(json_spec.additionalProperties) + ']'}}
16
+ {%- else %}
17
+ {{- "dict" }}
18
+ {%- endif %}
19
+ {%- elif json_spec.type is iterable %}
20
+ {{- "Union[" }}
21
+ {%- for t in json_spec.type %}
22
+ {{- json_to_python_type({"type": t}) }}
23
+ {%- if not loop.last %}
24
+ {{- "," }}
25
+ {%- endif %}
26
+ {%- endfor %}
27
+ {{- "]" }}
28
+ {%- else %}
29
+ {{- "Any" }}
30
+ {%- endif %}
31
+ {%- endmacro %}
32
+
33
+
34
+ {{- bos_token }}
35
+ {{- '<|im_start|>system
36
+ ' }}
37
+ {{- "You are a function calling AI model. You are provided with function signatures within <tools></tools> XML tags. You may call one or more functions to assist with the user query. Don't make assumptions about what values to plug into functions. Here are the available tools: <tools> " }}
38
+ {%- for tool in tools %}
39
+ {%- if tool.function is defined %}
40
+ {%- set tool = tool.function %}
41
+ {%- endif %}
42
+ {{- '{"type": "function", "function": ' }}
43
+ {{- '{"name": "' + tool.name + '", ' }}
44
+ {{- '"description": "' + tool.name + '(' }}
45
+ {%- for param_name, param_fields in tool.parameters.properties|items %}
46
+ {{- param_name + ": " + json_to_python_type(param_fields) }}
47
+ {%- if not loop.last %}
48
+ {{- ", " }}
49
+ {%- endif %}
50
+ {%- endfor %}
51
+ {{- ")" }}
52
+ {%- if tool.return is defined %}
53
+ {{- " -> " + json_to_python_type(tool.return) }}
54
+ {%- endif %}
55
+ {{- " - " + tool.description + "
56
+
57
+ " }}
58
+ {%- for param_name, param_fields in tool.parameters.properties|items %}
59
+ {%- if loop.first %}
60
+ {{- " Args:
61
+ " }}
62
+ {%- endif %}
63
+ {{- " " + param_name + "(" + json_to_python_type(param_fields) + "): " + param_fields.description|trim }}
64
+ {%- endfor %}
65
+ {%- if tool.return is defined and tool.return.description is defined %}
66
+ {{- "
67
+ Returns:
68
+ " + tool.return.description }}
69
+ {%- endif %}
70
+ {{- '"' }}
71
+ {{- ', "parameters": ' }}
72
+ {%- if tool.parameters.properties | length == 0 %}
73
+ {{- "{}" }}
74
+ {%- else %}
75
+ {{- tool.parameters|tojson }}
76
+ {%- endif %}
77
+ {{- "}" }}
78
+ {%- if not loop.last %}
79
+ {{- "
80
+ " }}
81
+ {%- endif %}
82
+ {%- endfor %}
83
+ {{- " </tools>" }}
84
+ {{- 'Use the following pydantic model json schema for each tool call you will make: {"properties": {"name": {"title": "Name", "type": "string"}, "arguments": {"title": "Arguments", "type": "object"}}, "required": ["name", "arguments"], "title": "FunctionCall", "type": "object"}}
85
+ ' }}
86
+ {{- "For each function call return a json object with function name and arguments within <tool_call></tool_call> XML tags as follows:
87
+ " }}
88
+ {{- "<tool_call>
89
+ " }}
90
+ {{- '{"name": <function-name>, "arguments": <args-dict>}
91
+ ' }}
92
+ {{- '</tool_call><|im_end|>
93
+ ' }}
94
+ {%- for message in messages %}
95
+ {%- if message.role == "user" or message.role == "system" or (message.role == "assistant" and message.tool_calls is not defined) %}
96
+ {{- '<|im_start|>' + message.role + '
97
+ ' + message.content + '<|im_end|>' + '
98
+ ' }}
99
+ {%- elif message.role == "assistant" %}
100
+ {{- '<|im_start|>' + message.role }}
101
+ {%- for tool_call in message.tool_calls %}
102
+ {{- '
103
+ <tool_call>
104
+ ' }} {%- if tool_call.function is defined %}
105
+ {%- set tool_call = tool_call.function %}
106
+ {%- endif %}
107
+ {{- '{' }}
108
+ {{- '"name": "' }}
109
+ {{- tool_call.name }}
110
+ {{- '"' }}
111
+ {{- ', '}}
112
+ {%- if tool_call.arguments is defined %}
113
+ {{- '"arguments": ' }}
114
+ {%- if tool_call.arguments is string %}
115
+ {{- tool_call.arguments }}
116
+ {%- else %}
117
+ {{- tool_call.arguments|tojson }}
118
+ {%- endif %}
119
+ {%- endif %}
120
+ {{- '}' }}
121
+ {{- '
122
+ </tool_call>' }}
123
+ {%- endfor %}
124
+ {{- '<|im_end|>
125
+ ' }}
126
+ {%- elif message.role == "tool" %}
127
+ {%- if loop.previtem and loop.previtem.role != "tool" %}
128
+ {{- '<|im_start|>tool
129
+ ' }}
130
+ {%- endif %}
131
+ {{- '<tool_response>
132
+ ' }}
133
+ {{- message.content }}
134
+ {%- if not loop.last %}
135
+ {{- '
136
+ </tool_response>
137
+ ' }}
138
+ {%- else %}
139
+ {{- '
140
+ </tool_response>' }}
141
+ {%- endif %}
142
+ {%- if not loop.last and loop.nextitem.role != "tool" %}
143
+ {{- '<|im_end|>' }}
144
+ {%- elif loop.last %}
145
+ {{- '<|im_end|>' }}
146
+ {%- endif %}
147
+ {%- endif %}
148
+ {%- endfor %}
149
+ {%- if add_generation_prompt %}
150
+ {{- '<|im_start|>assistant
151
+ ' }}
152
+ {%- endif %}
models/templates/NousResearch-Hermes-3-Llama-3.1-8B-tool_use.jinja ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- macro json_to_python_type(json_spec) %}
2
+ {%- set basic_type_map = {
3
+ "string": "str",
4
+ "number": "float",
5
+ "integer": "int",
6
+ "boolean": "bool"
7
+ } %}
8
+
9
+ {%- if basic_type_map[json_spec.type] is defined %}
10
+ {{- basic_type_map[json_spec.type] }}
11
+ {%- elif json_spec.type == "array" %}
12
+ {{- "list[" + json_to_python_type(json_spec|items) + "]"}}
13
+ {%- elif json_spec.type == "object" %}
14
+ {%- if json_spec.additionalProperties is defined %}
15
+ {{- "dict[str, " + json_to_python_type(json_spec.additionalProperties) + ']'}}
16
+ {%- else %}
17
+ {{- "dict" }}
18
+ {%- endif %}
19
+ {%- elif json_spec.type is iterable %}
20
+ {{- "Union[" }}
21
+ {%- for t in json_spec.type %}
22
+ {{- json_to_python_type({"type": t}) }}
23
+ {%- if not loop.last %}
24
+ {{- "," }}
25
+ {%- endif %}
26
+ {%- endfor %}
27
+ {{- "]" }}
28
+ {%- else %}
29
+ {{- "Any" }}
30
+ {%- endif %}
31
+ {%- endmacro %}
32
+
33
+
34
+ {{- bos_token }}
35
+ {{- '<|im_start|>system
36
+ ' }}
37
+ {{- "You are a function calling AI model. You are provided with function signatures within <tools></tools> XML tags. You may call one or more functions to assist with the user query. Don't make assumptions about what values to plug into functions. Here are the available tools: <tools> " }}
38
+ {%- for tool in tools %}
39
+ {%- if tool.function is defined %}
40
+ {%- set tool = tool.function %}
41
+ {%- endif %}
42
+ {{- '{"type": "function", "function": ' }}
43
+ {{- '{"name": "' + tool.name + '", ' }}
44
+ {{- '"description": "' + tool.name + '(' }}
45
+ {%- for param_name, param_fields in tool.parameters.properties|items %}
46
+ {{- param_name + ": " + json_to_python_type(param_fields) }}
47
+ {%- if not loop.last %}
48
+ {{- ", " }}
49
+ {%- endif %}
50
+ {%- endfor %}
51
+ {{- ")" }}
52
+ {%- if tool.return is defined %}
53
+ {{- " -> " + json_to_python_type(tool.return) }}
54
+ {%- endif %}
55
+ {{- " - " + tool.description + "
56
+
57
+ " }}
58
+ {%- for param_name, param_fields in tool.parameters.properties|items %}
59
+ {%- if loop.first %}
60
+ {{- " Args:
61
+ " }}
62
+ {%- endif %}
63
+ {{- " " + param_name + "(" + json_to_python_type(param_fields) + "): " + param_fields.description|trim }}
64
+ {%- endfor %}
65
+ {%- if tool.return is defined and tool.return.description is defined %}
66
+ {{- "
67
+ Returns:
68
+ " + tool.return.description }}
69
+ {%- endif %}
70
+ {{- '"' }}
71
+ {{- ', "parameters": ' }}
72
+ {%- if tool.parameters.properties | length == 0 %}
73
+ {{- "{}" }}
74
+ {%- else %}
75
+ {{- tool.parameters|tojson }}
76
+ {%- endif %}
77
+ {{- "}" }}
78
+ {%- if not loop.last %}
79
+ {{- "
80
+ " }}
81
+ {%- endif %}
82
+ {%- endfor %}
83
+ {{- " </tools>" }}
84
+ {{- 'Use the following pydantic model json schema for each tool call you will make: {"properties": {"name": {"title": "Name", "type": "string"}, "arguments": {"title": "Arguments", "type": "object"}}, "required": ["name", "arguments"], "title": "FunctionCall", "type": "object"}}
85
+ ' }}
86
+ {{- "For each function call return a json object with function name and arguments within <tool_call></tool_call> XML tags as follows:
87
+ " }}
88
+ {{- "<tool_call>
89
+ " }}
90
+ {{- '{"name": <function-name>, "arguments": <args-dict>}
91
+ ' }}
92
+ {{- '</tool_call><|im_end|>
93
+ ' }}
94
+ {%- for message in messages %}
95
+ {%- if message.role == "user" or message.role == "system" or (message.role == "assistant" and message.tool_calls is not defined) %}
96
+ {{- '<|im_start|>' + message.role + '
97
+ ' + message.content + '<|im_end|>' + '
98
+ ' }}
99
+ {%- elif message.role == "assistant" %}
100
+ {{- '<|im_start|>' + message.role }}
101
+ {%- for tool_call in message.tool_calls %}
102
+ {{- '
103
+ <tool_call>
104
+ ' }} {%- if tool_call.function is defined %}
105
+ {%- set tool_call = tool_call.function %}
106
+ {%- endif %}
107
+ {{- '{' }}
108
+ {{- '"name": "' }}
109
+ {{- tool_call.name }}
110
+ {{- '"' }}
111
+ {{- ', '}}
112
+ {%- if tool_call.arguments is defined %}
113
+ {{- '"arguments": ' }}
114
+ {%- if tool_call.arguments is string %}
115
+ {{- tool_call.arguments }}
116
+ {%- else %}
117
+ {{- tool_call.arguments|tojson }}
118
+ {%- endif %}
119
+ {%- endif %}
120
+ {{- '}' }}
121
+ {{- '
122
+ </tool_call>' }}
123
+ {%- endfor %}
124
+ {{- '<|im_end|>
125
+ ' }}
126
+ {%- elif message.role == "tool" %}
127
+ {%- if loop.previtem and loop.previtem.role != "tool" %}
128
+ {{- '<|im_start|>tool
129
+ ' }}
130
+ {%- endif %}
131
+ {{- '<tool_response>
132
+ ' }}
133
+ {{- message.content }}
134
+ {%- if not loop.last %}
135
+ {{- '
136
+ </tool_response>
137
+ ' }}
138
+ {%- else %}
139
+ {{- '
140
+ </tool_response>' }}
141
+ {%- endif %}
142
+ {%- if not loop.last and loop.nextitem.role != "tool" %}
143
+ {{- '<|im_end|>' }}
144
+ {%- elif loop.last %}
145
+ {{- '<|im_end|>' }}
146
+ {%- endif %}
147
+ {%- endif %}
148
+ {%- endfor %}
149
+ {%- if add_generation_prompt %}
150
+ {{- '<|im_start|>assistant
151
+ ' }}
152
+ {%- endif %}
models/templates/Qwen-QwQ-32B.jinja ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0]['role'] == 'system' %}
4
+ {{- messages[0]['content'] }}
5
+ {%- else %}
6
+ {{- '' }}
7
+ {%- endif %}
8
+ {{- "\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>" }}
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
+ {%- for message in messages %}
20
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
21
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
22
+ {%- elif message.role == "assistant" and not message.tool_calls %}
23
+ {%- set content = message.content %}
24
+ {%- if not loop.last %}
25
+ {%- set content = message.content.split('</think>')[-1].lstrip('\n') %}
26
+ {%- endif %}
27
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
28
+ {%- elif message.role == "assistant" %}
29
+ {%- set content = message.content %}
30
+ {%- if not loop.last %}
31
+ {%- set content = message.content.split('</think>')[-1].lstrip('\n') %}
32
+ {%- endif %}
33
+ {{- '<|im_start|>' + message.role }}
34
+ {%- if message.content %}
35
+ {{- '\n' + content }}
36
+ {%- endif %}
37
+ {%- for tool_call in message.tool_calls %}
38
+ {%- if tool_call.function is defined %}
39
+ {%- set tool_call = tool_call.function %}
40
+ {%- endif %}
41
+ {{- '\n<tool_call>\n{"name": "' }}
42
+ {{- tool_call.name }}
43
+ {{- '", "arguments": ' }}
44
+ {{- tool_call.arguments | tojson }}
45
+ {{- '}\n</tool_call>' }}
46
+ {%- endfor %}
47
+ {{- '<|im_end|>\n' }}
48
+ {%- elif message.role == "tool" %}
49
+ {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
50
+ {{- '<|im_start|>user' }}
51
+ {%- endif %}
52
+ {{- '\n<tool_response>\n' }}
53
+ {{- message.content }}
54
+ {{- '\n</tool_response>' }}
55
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
56
+ {{- '<|im_end|>\n' }}
57
+ {%- endif %}
58
+ {%- endif %}
59
+ {%- endfor %}
60
+ {%- if add_generation_prompt %}
61
+ {{- '<|im_start|>assistant\n<think>\n' }}
62
+ {%- if not enable_thinking -%}{{- '</think>' -}}{%- endif -%}
63
+ {%- endif %}
models/templates/Qwen-Qwen2.5-7B-Instruct.jinja ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0]['role'] == 'system' %}
4
+ {{- messages[0]['content'] }}
5
+ {%- else %}
6
+ {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}
7
+ {%- endif %}
8
+ {{- "\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>" }}
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
+ {%- else %}
18
+ {{- '<|im_start|>system\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\n' }}
19
+ {%- endif %}
20
+ {%- endif %}
21
+ {%- for message in messages %}
22
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
23
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
24
+ {%- elif message.role == "assistant" %}
25
+ {{- '<|im_start|>' + message.role }}
26
+ {%- if message.content %}
27
+ {{- '\n' + message.content }}
28
+ {%- endif %}
29
+ {%- for tool_call in message.tool_calls %}
30
+ {%- if tool_call.function is defined %}
31
+ {%- set tool_call = tool_call.function %}
32
+ {%- endif %}
33
+ {{- '\n<tool_call>\n{"name": "' }}
34
+ {{- tool_call.name }}
35
+ {{- '", "arguments": ' }}
36
+ {{- tool_call.arguments | tojson }}
37
+ {{- '}\n</tool_call>' }}
38
+ {%- endfor %}
39
+ {{- '<|im_end|>\n' }}
40
+ {%- elif message.role == "tool" %}
41
+ {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
42
+ {{- '<|im_start|>user' }}
43
+ {%- endif %}
44
+ {{- '\n<tool_response>\n' }}
45
+ {{- message.content }}
46
+ {{- '\n</tool_response>' }}
47
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
48
+ {{- '<|im_end|>\n' }}
49
+ {%- endif %}
50
+ {%- endif %}
51
+ {%- endfor %}
52
+ {%- if add_generation_prompt %}
53
+ {{- '<|im_start|>assistant\n' }}
54
+ {%- endif %}
models/templates/Qwen-Qwen3-0.6B.jinja ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0].role == 'system' %}
4
+ {{- messages[0].content + '\n\n' }}
5
+ {%- endif %}
6
+ {{- "# 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>" }}
7
+ {%- for tool in tools %}
8
+ {{- "\n" }}
9
+ {{- tool | tojson }}
10
+ {%- endfor %}
11
+ {{- "\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" }}
12
+ {%- else %}
13
+ {%- if messages[0].role == 'system' %}
14
+ {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
15
+ {%- endif %}
16
+ {%- endif %}
17
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
18
+ {%- for message in messages[::-1] %}
19
+ {%- set index = (messages|length - 1) - loop.index0 %}
20
+ {%- if ns.multi_step_tool and message.role == "user" and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
21
+ {%- set ns.multi_step_tool = false %}
22
+ {%- set ns.last_query_index = index %}
23
+ {%- endif %}
24
+ {%- endfor %}
25
+ {%- for message in messages %}
26
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
27
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
28
+ {%- elif message.role == "assistant" %}
29
+ {%- set content = message.content %}
30
+ {%- set reasoning_content = '' %}
31
+ {%- if message.reasoning_content is defined and message.reasoning_content is not none %}
32
+ {%- set reasoning_content = message.reasoning_content %}
33
+ {%- else %}
34
+ {%- if '</think>' in message.content %}
35
+ {%- set content = message.content.split('</think>')[-1].lstrip('\n') %}
36
+ {%- set reasoning_content = message.content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
37
+ {%- endif %}
38
+ {%- endif %}
39
+ {%- if loop.index0 > ns.last_query_index %}
40
+ {%- if loop.last or (not loop.last and reasoning_content) %}
41
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
42
+ {%- else %}
43
+ {{- '<|im_start|>' + message.role + '\n' + content }}
44
+ {%- endif %}
45
+ {%- else %}
46
+ {{- '<|im_start|>' + message.role + '\n' + content }}
47
+ {%- endif %}
48
+ {%- if message.tool_calls %}
49
+ {%- for tool_call in message.tool_calls %}
50
+ {%- if (loop.first and content) or (not loop.first) %}
51
+ {{- '\n' }}
52
+ {%- endif %}
53
+ {%- if tool_call.function %}
54
+ {%- set tool_call = tool_call.function %}
55
+ {%- endif %}
56
+ {{- '<tool_call>\n{"name": "' }}
57
+ {{- tool_call.name }}
58
+ {{- '", "arguments": ' }}
59
+ {%- if tool_call.arguments is string %}
60
+ {{- tool_call.arguments }}
61
+ {%- else %}
62
+ {{- tool_call.arguments | tojson }}
63
+ {%- endif %}
64
+ {{- '}\n</tool_call>' }}
65
+ {%- endfor %}
66
+ {%- endif %}
67
+ {{- '<|im_end|>\n' }}
68
+ {%- elif message.role == "tool" %}
69
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
70
+ {{- '<|im_start|>user' }}
71
+ {%- endif %}
72
+ {{- '\n<tool_response>\n' }}
73
+ {{- message.content }}
74
+ {{- '\n</tool_response>' }}
75
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
76
+ {{- '<|im_end|>\n' }}
77
+ {%- endif %}
78
+ {%- endif %}
79
+ {%- endfor %}
80
+ {%- if add_generation_prompt %}
81
+ {{- '<|im_start|>assistant\n' }}
82
+ {%- if enable_thinking is defined and enable_thinking is false %}
83
+ {{- '<think>\n\n</think>\n\n' }}
84
+ {%- endif %}
85
+ {%- endif %}
models/templates/Qwen3-Coder.jinja ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% macro render_extra_keys(json_dict, handled_keys) %}
2
+ {%- if json_dict is mapping %}
3
+ {%- for json_key in json_dict if json_key not in handled_keys %}
4
+ {%- if json_dict[json_key] is mapping or (json_dict[json_key] is sequence and json_dict[json_key] is not string) %}
5
+ {{- '\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | tojson | safe) ~ '</' ~ json_key ~ '>' }}
6
+ {%- else %}
7
+ {{-'\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | string) ~ '</' ~ json_key ~ '>' }}
8
+ {%- endif %}
9
+ {%- endfor %}
10
+ {%- endif %}
11
+ {% endmacro %}
12
+
13
+ {%- if messages[0]["role"] == "system" %}
14
+ {%- set system_message = messages[0]["content"] %}
15
+ {%- set loop_messages = messages[1:] %}
16
+ {%- else %}
17
+ {%- set loop_messages = messages %}
18
+ {%- endif %}
19
+
20
+ {%- if not tools is defined %}
21
+ {%- set tools = [] %}
22
+ {%- endif %}
23
+
24
+ {%- if system_message is defined %}
25
+ {{- "<|im_start|>system\n" + system_message }}
26
+ {%- else %}
27
+ {%- if tools is iterable and tools | length > 0 %}
28
+ {{- "<|im_start|>system\nYou are Qwen, a helpful AI assistant that can interact with a computer to solve tasks." }}
29
+ {%- endif %}
30
+ {%- endif %}
31
+ {%- if tools is iterable and tools | length > 0 %}
32
+ {{- "\n\n# Tools\n\nYou have access to the following tools:\n\n" }}
33
+ {{- "<tools>" }}
34
+ {%- for tool in tools %}
35
+ {%- if tool.function is defined %}
36
+ {%- set tool = tool.function %}
37
+ {%- endif %}
38
+ {{- "\n<function>\n<name>" ~ tool.name ~ "</name>" }}
39
+ {%- if tool.description is defined %}
40
+ {{- '\n<description>' ~ (tool.description | trim) ~ '</description>' }}
41
+ {%- endif %}
42
+ {{- '\n<parameters>' }}
43
+ {%- if tool.parameters is defined and tool.parameters is mapping and tool.parameters.properties is defined and tool.parameters.properties is mapping %}
44
+ {%- for param_name, param_fields in tool.parameters.properties|items %}
45
+ {{- '\n<parameter>' }}
46
+ {{- '\n<name>' ~ param_name ~ '</name>' }}
47
+ {%- if param_fields.type is defined %}
48
+ {{- '\n<type>' ~ (param_fields.type | string) ~ '</type>' }}
49
+ {%- endif %}
50
+ {%- if param_fields.description is defined %}
51
+ {{- '\n<description>' ~ (param_fields.description | trim) ~ '</description>' }}
52
+ {%- endif %}
53
+ {%- set handled_keys = ['name', 'type', 'description'] %}
54
+ {{- render_extra_keys(param_fields, handled_keys) }}
55
+ {{- '\n</parameter>' }}
56
+ {%- endfor %}
57
+ {%- endif %}
58
+ {% set handled_keys = ['type', 'properties'] %}
59
+ {{- render_extra_keys(tool.parameters, handled_keys) }}
60
+ {{- '\n</parameters>' }}
61
+ {%- set handled_keys = ['type', 'name', 'description', 'parameters'] %}
62
+ {{- render_extra_keys(tool, handled_keys) }}
63
+ {{- '\n</function>' }}
64
+ {%- endfor %}
65
+ {{- "\n</tools>" }}
66
+ {{- '\n\nIf you choose to call a tool ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nvalue_2\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: the tool calling block MUST begin with an opening <tool_call> tag and end with a closing </tool_call> tag.\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
67
+ {%- endif %}
68
+ {%- if system_message is defined %}
69
+ {{- '<|im_end|>\n' }}
70
+ {%- else %}
71
+ {%- if tools is iterable and tools | length > 0 %}
72
+ {{- '<|im_end|>\n' }}
73
+ {%- endif %}
74
+ {%- endif %}
75
+ {%- for message in loop_messages %}
76
+ {%- if message.role == "assistant" and message.tool_calls is defined and message.tool_calls is iterable and message.tool_calls | length > 0 %}
77
+ {{- '<|im_start|>' + message.role }}
78
+ {%- if message.content is defined and message.content is string and message.content | trim | length > 0 %}
79
+ {{- '\n' + message.content | trim + '\n' }}
80
+ {%- endif %}
81
+ {%- for tool_call in message.tool_calls %}
82
+ {%- if tool_call.function is defined %}
83
+ {%- set tool_call = tool_call.function %}
84
+ {%- endif %}
85
+ {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
86
+ {%- if tool_call.arguments is defined %}
87
+ {%- for args_name, args_value in tool_call.arguments|items %}
88
+ {{- '<parameter=' + args_name + '>\n' }}
89
+ {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
90
+ {{- args_value }}
91
+ {{- '\n</parameter>\n' }}
92
+ {%- endfor %}
93
+ {%- endif %}
94
+ {{- '</function>\n</tool_call>' }}
95
+ {%- endfor %}
96
+ {{- '<|im_end|>\n' }}
97
+ {%- elif message.role == "user" or message.role == "system" or message.role == "assistant" %}
98
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
99
+ {%- elif message.role == "tool" %}
100
+ {%- if loop.previtem and loop.previtem.role != "tool" %}
101
+ {{- '<|im_start|>user\n' }}
102
+ {%- endif %}
103
+ {{- '<tool_response>\n' }}
104
+ {{- message.content }}
105
+ {{- '\n</tool_response>\n' }}
106
+ {%- if not loop.last and loop.nextitem.role != "tool" %}
107
+ {{- '<|im_end|>\n' }}
108
+ {%- elif loop.last %}
109
+ {{- '<|im_end|>\n' }}
110
+ {%- endif %}
111
+ {%- else %}
112
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>\n' }}
113
+ {%- endif %}
114
+ {%- endfor %}
115
+ {%- if add_generation_prompt %}
116
+ {{- '<|im_start|>assistant\n' }}
117
+ {%- endif %}
models/templates/Qwen3.5-4B.jinja ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set image_count = namespace(value=0) %}
2
+ {%- set video_count = namespace(value=0) %}
3
+ {%- macro render_content(content, do_vision_count, is_system_content=false) %}
4
+ {%- if content is string %}
5
+ {{- content }}
6
+ {%- elif content is iterable and content is not mapping %}
7
+ {%- for item in content %}
8
+ {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
9
+ {%- if is_system_content %}
10
+ {{- raise_exception('System message cannot contain images.') }}
11
+ {%- endif %}
12
+ {%- if do_vision_count %}
13
+ {%- set image_count.value = image_count.value + 1 %}
14
+ {%- endif %}
15
+ {%- if add_vision_id %}
16
+ {{- 'Picture ' ~ image_count.value ~ ': ' }}
17
+ {%- endif %}
18
+ {{- '<|vision_start|><|image_pad|><|vision_end|>' }}
19
+ {%- elif 'video' in item or item.type == 'video' %}
20
+ {%- if is_system_content %}
21
+ {{- raise_exception('System message cannot contain videos.') }}
22
+ {%- endif %}
23
+ {%- if do_vision_count %}
24
+ {%- set video_count.value = video_count.value + 1 %}
25
+ {%- endif %}
26
+ {%- if add_vision_id %}
27
+ {{- 'Video ' ~ video_count.value ~ ': ' }}
28
+ {%- endif %}
29
+ {{- '<|vision_start|><|video_pad|><|vision_end|>' }}
30
+ {%- elif 'text' in item %}
31
+ {{- item.text }}
32
+ {%- else %}
33
+ {{- raise_exception('Unexpected item type in content.') }}
34
+ {%- endif %}
35
+ {%- endfor %}
36
+ {%- elif content is none or content is undefined %}
37
+ {{- '' }}
38
+ {%- else %}
39
+ {{- raise_exception('Unexpected content type.') }}
40
+ {%- endif %}
41
+ {%- endmacro %}
42
+ {%- if not messages %}
43
+ {{- raise_exception('No messages provided.') }}
44
+ {%- endif %}
45
+ {%- if tools and tools is iterable and tools is not mapping %}
46
+ {{- '<|im_start|>system\n' }}
47
+ {{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
48
+ {%- for tool in tools %}
49
+ {{- "\n" }}
50
+ {{- tool | tojson }}
51
+ {%- endfor %}
52
+ {{- "\n</tools>" }}
53
+ {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
54
+ {%- if messages[0].role == 'system' %}
55
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
56
+ {%- if content %}
57
+ {{- '\n\n' + content }}
58
+ {%- endif %}
59
+ {%- endif %}
60
+ {{- '<|im_end|>\n' }}
61
+ {%- else %}
62
+ {%- if messages[0].role == 'system' %}
63
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
64
+ {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
65
+ {%- endif %}
66
+ {%- endif %}
67
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
68
+ {%- for message in messages[::-1] %}
69
+ {%- set index = (messages|length - 1) - loop.index0 %}
70
+ {%- if ns.multi_step_tool and message.role == "user" %}
71
+ {%- set content = render_content(message.content, false)|trim %}
72
+ {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
73
+ {%- set ns.multi_step_tool = false %}
74
+ {%- set ns.last_query_index = index %}
75
+ {%- endif %}
76
+ {%- endif %}
77
+ {%- endfor %}
78
+ {%- if ns.multi_step_tool %}
79
+ {{- raise_exception('No user query found in messages.') }}
80
+ {%- endif %}
81
+ {%- for message in messages %}
82
+ {%- set content = render_content(message.content, true)|trim %}
83
+ {%- if message.role == "system" %}
84
+ {%- if not loop.first %}
85
+ {{- raise_exception('System message must be at the beginning.') }}
86
+ {%- endif %}
87
+ {%- elif message.role == "user" %}
88
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
89
+ {%- elif message.role == "assistant" %}
90
+ {%- set reasoning_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].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
96
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
97
+ {%- endif %}
98
+ {%- endif %}
99
+ {%- set reasoning_content = reasoning_content|trim %}
100
+ {%- if loop.index0 > ns.last_query_index %}
101
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
102
+ {%- else %}
103
+ {{- '<|im_start|>' + message.role + '\n' + content }}
104
+ {%- endif %}
105
+ {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
106
+ {%- for tool_call in message.tool_calls %}
107
+ {%- if tool_call.function is defined %}
108
+ {%- set tool_call = tool_call.function %}
109
+ {%- endif %}
110
+ {%- if loop.first %}
111
+ {%- if content|trim %}
112
+ {{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
113
+ {%- else %}
114
+ {{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
115
+ {%- endif %}
116
+ {%- else %}
117
+ {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
118
+ {%- endif %}
119
+ {%- if tool_call.arguments is defined %}
120
+ {%- for args_name, args_value in tool_call.arguments|items %}
121
+ {{- '<parameter=' + args_name + '>\n' }}
122
+ {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
123
+ {{- args_value }}
124
+ {{- '\n</parameter>\n' }}
125
+ {%- endfor %}
126
+ {%- endif %}
127
+ {{- '</function>\n</tool_call>' }}
128
+ {%- endfor %}
129
+ {%- endif %}
130
+ {{- '<|im_end|>\n' }}
131
+ {%- elif message.role == "tool" %}
132
+ {%- if loop.previtem and loop.previtem.role != "tool" %}
133
+ {{- '<|im_start|>user' }}
134
+ {%- endif %}
135
+ {{- '\n<tool_response>\n' }}
136
+ {{- content }}
137
+ {{- '\n</tool_response>' }}
138
+ {%- if not loop.last and loop.nextitem.role != "tool" %}
139
+ {{- '<|im_end|>\n' }}
140
+ {%- elif loop.last %}
141
+ {{- '<|im_end|>\n' }}
142
+ {%- endif %}
143
+ {%- else %}
144
+ {{- raise_exception('Unexpected message role.') }}
145
+ {%- endif %}
146
+ {%- endfor %}
147
+ {%- if add_generation_prompt %}
148
+ {{- '<|im_start|>assistant\n' }}
149
+ {%- if enable_thinking is defined and enable_thinking is false %}
150
+ {{- '<think>\n\n</think>\n\n' }}
151
+ {%- else %}
152
+ {{- '<think>\n' }}
153
+ {%- endif %}
154
+ {%- endif %}
models/templates/README.md ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ These templates can be updated with the following commands:
2
+
3
+ ```bash
4
+ ./scripts/get_chat_template.py CohereForAI/c4ai-command-r-plus tool_use > models/templates/CohereForAI-c4ai-command-r-plus-tool_use.jinja
5
+ ./scripts/get_chat_template.py CohereForAI/c4ai-command-r7b-12-2024 default > models/templates/CohereForAI-c4ai-command-r7b-12-2024-default.jinja
6
+ ./scripts/get_chat_template.py CohereForAI/c4ai-command-r7b-12-2024 rag > models/templates/CohereForAI-c4ai-command-r7b-12-2024-rag.jinja
7
+ ./scripts/get_chat_template.py CohereForAI/c4ai-command-r7b-12-2024 tool_use > models/templates/CohereForAI-c4ai-command-r7b-12-2024-tool_use.jinja
8
+ ./scripts/get_chat_template.py deepseek-ai/DeepSeek-R1-Distill-Llama-8B > models/templates/deepseek-ai-DeepSeek-R1-Distill-Llama-8B.jinja
9
+ ./scripts/get_chat_template.py deepseek-ai/DeepSeek-R1-Distill-Qwen-32B > models/templates/deepseek-ai-DeepSeek-R1-Distill-Qwen-32B.jinja
10
+ ./scripts/get_chat_template.py fireworks-ai/llama-3-firefunction-v2 > models/templates/fireworks-ai-llama-3-firefunction-v2.jinja
11
+ ./scripts/get_chat_template.py google/gemma-2-2b-it > models/templates/google-gemma-2-2b-it.jinja
12
+ ./scripts/get_chat_template.py meetkai/functionary-medium-v3.1 > models/templates/meetkai-functionary-medium-v3.1.jinja
13
+ ./scripts/get_chat_template.py meetkai/functionary-medium-v3.2 > models/templates/meetkai-functionary-medium-v3.2.jinja
14
+ ./scripts/get_chat_template.py meta-llama/Llama-3.1-8B-Instruct > models/templates/meta-llama-Llama-3.1-8B-Instruct.jinja
15
+ ./scripts/get_chat_template.py meta-llama/Llama-3.2-3B-Instruct > models/templates/meta-llama-Llama-3.2-3B-Instruct.jinja
16
+ ./scripts/get_chat_template.py meta-llama/Llama-3.3-70B-Instruct > models/templates/meta-llama-Llama-3.3-70B-Instruct.jinja
17
+ ./scripts/get_chat_template.py microsoft/Phi-3.5-mini-instruct > models/templates/microsoft-Phi-3.5-mini-instruct.jinja
18
+ ./scripts/get_chat_template.py mistralai/Mistral-Nemo-Instruct-2407 > models/templates/mistralai-Mistral-Nemo-Instruct-2407.jinja
19
+ ./scripts/get_chat_template.py NousResearch/Hermes-2-Pro-Llama-3-8B tool_use > models/templates/NousResearch-Hermes-2-Pro-Llama-3-8B-tool_use.jinja
20
+ ./scripts/get_chat_template.py NousResearch/Hermes-3-Llama-3.1-8B tool_use > models/templates/NousResearch-Hermes-3-Llama-3.1-8B-tool_use.jinja
21
+ ./scripts/get_chat_template.py Qwen/Qwen2.5-7B-Instruct > models/templates/Qwen-Qwen2.5-7B-Instruct.jinja
22
+ ./scripts/get_chat_template.py Qwen/QwQ-32B > models/templates/Qwen-QwQ-32B.jinja
23
+ ./scripts/get_chat_template.py Qwen/Qwen3-0.6B > models/templates/Qwen-Qwen3-0.6B.jinja
24
+ ./scripts/get_chat_template.py zai-org/GLM-4.5 > models/templates/zai-org-GLM-4.5.jinja
25
+ ./scripts/get_chat_template.py deepseek-ai/DeepSeek-V3.1 > models/templates/deepseek-ai-DeepSeek-V3.1.jinja
26
+ ```
models/templates/Reka-Edge.jinja ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- macro render_content(content, num_img_tokens, num_video_frames) -%}
2
+ {%- if content is string -%}
3
+ {{- content -}}
4
+ {%- elif content is sequence -%}
5
+ {%- set ns = namespace(out="", prev_was_text=false) -%}
6
+ {%- for item in content -%}
7
+ {%- set item_type = item.get("type") -%}
8
+ {%- if item_type == "text" or item.get("text") is not none -%}
9
+ {%- set text = item.get("text", "") -%}
10
+ {%- if text -%}
11
+ {%- if ns.prev_was_text -%}
12
+ {%- set ns.out = ns.out ~ " " -%}
13
+ {%- endif -%}
14
+ {%- set ns.out = ns.out ~ text -%}
15
+ {%- endif -%}
16
+ {%- set ns.prev_was_text = text != "" -%}
17
+ {%- elif item_type in ["image", "image_url"] or item.get("image") is not none or item.get("image_url") is not none -%}
18
+ {%- set ns.out = ns.out ~ "<image>" ~ ("<REKA_IMG_TOKEN>" * num_img_tokens) ~ "</image>" -%}
19
+ {%- set ns.prev_was_text = false -%}
20
+ {%- elif item_type in ["video", "video_url"] or item.get("video") is not none or item.get("video_url") is not none -%}
21
+ {%- set repeat_tokens = num_img_tokens * num_video_frames -%}
22
+ {%- set ns.out = ns.out ~ "<video>" ~ ("<REKA_IMG_TOKEN>" * repeat_tokens) ~ "</video>" -%}
23
+ {%- set ns.prev_was_text = false -%}
24
+ {%- endif -%}
25
+ {%- endfor -%}
26
+ {{- ns.out -}}
27
+ {%- endif -%}
28
+ {%- endmacro -%}
29
+ {%- set ns = namespace(out="", last_query_index=messages|length - 1) -%}
30
+ {%- for msg in messages[::-1] -%}
31
+ {%- set idx = messages|length - 1 - loop.index0 -%}
32
+ {%- if msg.get("role") == "user" -%}
33
+ {%- set content = msg.get("content", "") -%}
34
+ {%- if not (content is string and content.startswith("<tool_response>") and content.endswith("</tool_response>")) -%}
35
+ {%- set ns.last_query_index = idx -%}
36
+ {%- break -%}
37
+ {%- endif -%}
38
+ {%- endif -%}
39
+ {%- endfor -%}
40
+ {%- set last_query_index = ns.last_query_index -%}
41
+ {%- set num_img_tokens = num_img_tokens | default(64, true) | int -%}
42
+ {%- set num_video_frames = num_video_frames | default(6, true) | int -%}
43
+ {%- set start_idx = 0 -%}
44
+ {%- set system_text = "" -%}
45
+ {%- if messages|length > 0 and messages[0].get("role") in ["system", "developer"] -%}
46
+ {%- set system_text = render_content(messages[0].get("content", ""), num_img_tokens, num_video_frames) -%}
47
+ {%- set start_idx = 1 -%}
48
+ {%- endif -%}
49
+ {%- if tools or system_text -%}
50
+ {%- set preamble_ns = namespace(text="") -%}
51
+ {%- if system_text -%}
52
+ {%- set preamble_ns.text = "system: " ~ system_text -%}
53
+ {%- endif -%}
54
+ {%- if tools -%}
55
+ {%- if preamble_ns.text -%}
56
+ {%- set preamble_ns.text = preamble_ns.text ~ "\n\n" -%}
57
+ {%- else -%}
58
+ {%- set preamble_ns.text = "system: " -%}
59
+ {%- endif -%}
60
+ {%- set preamble_ns.text = preamble_ns.text
61
+ ~ "# Tools\n\n"
62
+ ~ "You may call one or more functions to assist with the user query.\n\n"
63
+ ~ "You are provided with function signatures within <tools></tools> XML tags:\n"
64
+ ~ "<tools>" -%}
65
+ {%- for tool in tools -%}
66
+ {%- set preamble_ns.text = preamble_ns.text ~ "\n" ~ (tool | tojson(ensure_ascii=True)) -%}
67
+ {%- endfor -%}
68
+ {%- set preamble_ns.text = preamble_ns.text
69
+ ~ "\n</tools>\n\n"
70
+ ~ "For each function call, return a json object with function name and arguments "
71
+ ~ "within <tool_call></tool_call> XML tags:\n"
72
+ ~ "<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call>" -%}
73
+ {%- endif -%}
74
+ {%- set ns.out = ns.out ~ preamble_ns.text ~ "\n\n<sep>" -%}
75
+ {%- endif -%}
76
+ {%- for idx in range(start_idx, messages|length) -%}
77
+ {%- set message = messages[idx] -%}
78
+ {%- set role = message.get("role") -%}
79
+ {%- set content = message.get("content") -%}
80
+ {%- if role == "user" -%}
81
+ {%- set prefix_ns = namespace(value="human: ") -%}
82
+ {%- if content is sequence and content is not string -%}
83
+ {%- for item in content -%}
84
+ {%- if item.get("type") == "text" or item.get("text") is not none -%}
85
+ {%- set text = item.get("text", "") -%}
86
+ {%- if text -%}
87
+ {%- break -%}
88
+ {%- endif -%}
89
+ {%- elif item.get("type") in ["image", "image_url", "video", "video_url"] -%}
90
+ {%- set prefix_ns.value = "human:" -%}
91
+ {%- break -%}
92
+ {%- endif -%}
93
+ {%- endfor -%}
94
+ {%- endif -%}
95
+ {%- set ns.out = ns.out ~ prefix_ns.value ~ render_content(content, num_img_tokens, num_video_frames) ~ "<sep>" -%}
96
+ {%- elif role == "assistant" -%}
97
+ {%- set tool_calls = message.get("tool_calls") -%}
98
+ {%- set content_text = render_content(content, num_img_tokens, num_video_frames) -%}
99
+ {%- set reasoning_text = "" -%}
100
+ {%- if message.get("reasoning_content") is string -%}
101
+ {%- set reasoning_text = message.get("reasoning_content") -%}
102
+ {%- elif "</think>" in content_text -%}
103
+ {%- set reasoning_text = content_text.split("</think>", 1)[0].rstrip("\n").split("<think>")[-1].lstrip("\n") -%}
104
+ {%- set content_text = content_text.split("</think>", 1)[1].lstrip("\n") -%}
105
+ {%- endif -%}
106
+ {%- set ns.out = ns.out ~ "assistant: " -%}
107
+ {%- set include_thinking = enable_thinking is true
108
+ and idx > last_query_index
109
+ and (idx == messages|length - 1 or reasoning_text)
110
+ -%}
111
+ {%- if include_thinking -%}
112
+ {%- set ns.out = ns.out ~ "<think>\n" ~ (reasoning_text.strip() ) ~ "\n</think>\n\n" -%}
113
+ {%- endif -%}
114
+ {%- set ns.out = ns.out ~ content_text -%}
115
+ {%- if tool_calls -%}
116
+ {%- if content_text and not ns.out.endswith("\n") -%}
117
+ {%- set ns.out = ns.out ~ "\n" -%}
118
+ {%- endif -%}
119
+ {%- for tool_call in tool_calls -%}
120
+ {%- if tool_call.get("function") is not none -%}
121
+ {%- set tool_call = tool_call.get("function") -%}
122
+ {%- endif -%}
123
+ {%- set arguments = tool_call.get("arguments", {}) -%}
124
+ {%- if arguments is string -%}
125
+ {%- set arguments_json = arguments -%}
126
+ {%- elif arguments is mapping -%}
127
+ {%- set arguments_json = arguments | tojson(ensure_ascii=True) -%}
128
+ {%- else -%}
129
+ {%- set arguments_json = arguments | tojson(ensure_ascii=True) -%}
130
+ {%- endif -%}
131
+ {%- set ns.out = ns.out
132
+ ~ "<tool_call>\n"
133
+ ~ "{\"name\": \"" ~ tool_call.get("name", "") ~ "\", \"arguments\": "
134
+ ~ arguments_json
135
+ ~ "}\n</tool_call>" -%}
136
+ {%- endfor -%}
137
+ {%- endif -%}
138
+ {%- if not (continue_final_message and idx == messages|length - 1) -%}
139
+ {%- set ns.out = ns.out ~ "\n\n<sep>" -%}
140
+ {%- endif -%}
141
+ {%- elif role == "tool" -%}
142
+ {%- if idx == start_idx or messages[idx - 1].get("role") != "tool" -%}
143
+ {%- set ns.out = ns.out ~ "human: " -%}
144
+ {%- endif -%}
145
+ {%- set response_text = render_content(content, num_img_tokens, num_video_frames) -%}
146
+ {%- set ns.out = ns.out ~ "<tool_response>\n" ~ response_text ~ "\n</tool_response>" -%}
147
+ {%- if idx == messages|length - 1 or messages[idx + 1].get("role") != "tool" -%}
148
+ {%- set ns.out = ns.out ~ "<sep>" -%}
149
+ {%- endif -%}
150
+ {%- endif -%}
151
+ {%- endfor -%}
152
+ {%- if add_generation_prompt
153
+ and (messages|length == 0 or messages[-1].get("role") != "assistant")
154
+ -%}
155
+ {%- if enable_thinking is true -%}
156
+ {%- set ns.out = ns.out ~ "assistant: <think>\n" -%}
157
+ {%- else -%}
158
+ {%- set ns.out = ns.out ~ "assistant:" -%}
159
+ {%- endif -%}
160
+ {%- endif -%}
161
+ {{- ns.out -}}
models/templates/StepFun3.5-Flash.jinja ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% macro render_content(content) %}{% if content is none %}{{- '' }}{% elif content is string %}{{- content }}{% elif content is mapping %}{{- content['value'] if 'value' in content else content['text'] }}{% elif content is iterable %}{% for item in content %}{% if item.type == 'text' %}{{- item['value'] if 'value' in item else item['text'] }}{% elif item.type == 'image' %}<im_patch>{% endif %}{% endfor %}{% endif %}{% endmacro %}
2
+ {{bos_token}}{%- if tools %}
3
+ {{- '<|im_start|>system\n' }}
4
+ {%- if messages[0].role == 'system' %}
5
+ {{- render_content(messages[0].content) + '\n\n' }}
6
+ {%- endif %}
7
+ {{- "# Tools\n\nYou have access to the following functions in JSONSchema format:\n\n<tools>" }}
8
+ {%- for tool in tools %}
9
+ {{- "\n" }}
10
+ {{- tool | tojson(ensure_ascii=False) }}
11
+ {%- endfor %}
12
+ {{- "\n</tools>\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...>\n...\n</function> block must be nested within <tool_call>\n...\n</tool_call> XML tags\n- Required parameters MUST be specified\n</IMPORTANT><|im_end|>\n" }}
13
+ {%- else %}
14
+ {%- if messages[0].role == 'system' %}
15
+ {{- '<|im_start|>system\n' + render_content(messages[0].content) + '<|im_end|>\n' }}
16
+ {%- endif %}
17
+ {%- endif %}
18
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
19
+ {%- for message in messages[::-1] %}
20
+ {%- set index = (messages|length - 1) - loop.index0 %}
21
+ {%- if ns.multi_step_tool and message.role == "user" and render_content(message.content) is string and not(render_content(message.content).startswith('<tool_response>') and render_content(message.content).endswith('</tool_response>')) %}
22
+ {%- set ns.multi_step_tool = false %}
23
+ {%- set ns.last_query_index = index %}
24
+ {%- endif %}
25
+ {%- endfor %}
26
+ {%- for message in messages %}
27
+ {%- set content = render_content(message.content) %}
28
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
29
+ {%- set role_name = 'observation' if (message.role == "system" and not loop.first and message.name == 'observation') else message.role %}
30
+ {{- '<|im_start|>' + role_name + '\n' + content + '<|im_end|>' + '\n' }}
31
+ {%- elif message.role == "assistant" %}
32
+ {%- if message.reasoning_content is string %}
33
+ {%- set reasoning_content = render_content(message.reasoning_content) %}
34
+ {%- else %}
35
+ {%- if '</think>' in content %}
36
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
37
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
38
+ {%- else %}
39
+ {%- set reasoning_content = '' %}
40
+ {%- endif %}
41
+ {%- endif %}
42
+ {%- if loop.index0 > ns.last_query_index %}
43
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n' + content }}
44
+ {%- else %}
45
+ {{- '<|im_start|>' + message.role + '\n' + content }}
46
+ {%- endif %}
47
+ {%- if message.tool_calls %}
48
+ {%- for tool_call in message.tool_calls %}
49
+ {%- if tool_call.function is defined %}
50
+ {%- set tool_call = tool_call.function %}
51
+ {%- endif %}
52
+ {{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
53
+ {%- if tool_call.arguments is defined %}
54
+ {%- set arguments = tool_call.arguments %}
55
+ {%- for args_name, args_value in arguments|items %}
56
+ {{- '<parameter=' + args_name + '>\n' }}
57
+ {%- set args_value = args_value | tojson(ensure_ascii=False) | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
58
+ {{- args_value }}
59
+ {{- '\n</parameter>\n' }}
60
+ {%- endfor %}
61
+ {%- endif %}
62
+ {{- '</function>\n</tool_call>' }}
63
+ {%- endfor %}
64
+ {%- endif %}
65
+ {{- '<|im_end|>\n' }}
66
+ {%- elif message.role == "tool" %}
67
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
68
+ {{- '<|im_start|>tool_response\n' }}
69
+ {%- endif %}
70
+ {{- '<tool_response>' }}
71
+ {{- content }}
72
+ {{- '</tool_response>' }}
73
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
74
+ {{- '<|im_end|>\n' }}
75
+ {%- endif %}
76
+ {%- endif %}
77
+ {%- endfor %}
78
+ {%- if add_generation_prompt %}
79
+ {{- '<|im_start|>assistant\n<think>\n' }}
80
+ {%- endif %}
models/templates/deepseek-ai-DeepSeek-R1-Distill-Llama-8B.jinja ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% if not add_generation_prompt is defined -%}
2
+ {%- set add_generation_prompt = false -%}
3
+ {%- endif -%}
4
+ {%- set ns = namespace(is_first=false, is_tool=false, is_output_first=true, system_prompt='') -%}
5
+ {%- for message in messages -%}
6
+ {%- if message['role'] == 'system' -%}
7
+ {%- set ns.system_prompt = message['content'] -%}
8
+ {%- endif -%}
9
+ {%- endfor -%}{{bos_token}}{{ns.system_prompt}}
10
+ {%- for message in messages -%}
11
+ {%- if message['role'] == 'user' -%}
12
+ {%- set ns.is_tool = false -%}{{'<|User|>' + message['content']}}
13
+ {%- endif -%}
14
+ {%- if message['role'] == 'assistant' and message['content'] is none -%}
15
+ {%- set ns.is_tool = false -%}
16
+ {%- for tool in message['tool_calls']-%}
17
+ {%- if not ns.is_first -%}{{'<|Assistant|><|tool▁calls▁begin|><|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\n' + '```json' + '\n' + tool['function']['arguments'] + '\n' + '```' + '<|tool▁call▁end|>'}}
18
+ {%- set ns.is_first = true -%}
19
+ {%- else -%}{{'\n' + '<|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\n' + '```json' + '\n' + tool['function']['arguments'] + '\n' + '```' + '<|tool▁call▁end|>'}}{{'<|tool▁calls▁end|><|end▁of▁sentence|>'}}
20
+ {%- endif -%}
21
+ {%- endfor -%}
22
+ {%- endif -%}
23
+ {%- if message['role'] == 'assistant' and message['content'] is not none -%}
24
+ {%- if ns.is_tool -%}{{'<|tool▁outputs▁end|>' + message['content'] + '<|end▁of▁sentence|>'}}
25
+ {%- set ns.is_tool = false -%}
26
+ {%- else -%}
27
+ {%- set content = message['content'] -%}
28
+ {%- if '</think>' in content -%}
29
+ {%- set content = content.split('</think>')[-1] -%}
30
+ {%- endif -%}{{'<|Assistant|>' + content + '<|end▁of▁sentence|>'}}
31
+ {%- endif -%}
32
+ {%- endif -%}
33
+ {%- if message['role'] == 'tool' -%}
34
+ {%- set ns.is_tool = true -%}
35
+ {%- if ns.is_output_first -%}{{'<|tool▁outputs▁begin|><|tool▁output▁begin|>' + message['content'] + '<|tool▁output▁end|>'}}
36
+ {%- set ns.is_output_first = false -%}
37
+ {%- else -%}{{'\n<|tool▁output▁begin|>' + message['content'] + '<|tool▁output▁end|>'}}
38
+ {%- endif -%}
39
+ {%- endif -%}
40
+ {%- endfor -%}
41
+ {%- if ns.is_tool -%}{{'<|tool▁outputs▁end|>'}}
42
+ {%- endif -%}
43
+ {%- if add_generation_prompt and not ns.is_tool -%}{{'<|Assistant|><think>\n'}}
44
+ {%- endif %}