Commit c35bd61
Jinja - add missing features for DeepSeek R1 (huggingface#1142)
This PR adds support for the following Jinja features:
* Accessing members of call expression results
* `.split` on strings - the implementation matches [Python's
`str.split(sep=None, maxsplit=-1)` function
behavior](https://docs.python.org/3.13/library/stdtypes.html#str.split)
[DeepSeek R1's chat
template](https://huggingface.co/deepseek-ai/DeepSeek-R1/blob/main/tokenizer_config.json)
used to fail on this expression, which now works in this PR:
```
{%- set content = content.split('</think>')[-1] -%}
```
Fixes huggingface#1141
---------
Co-authored-by: Joshua Lochner <[email protected]>1 parent 12a25f3 commit c35bd61
File tree
5 files changed
+329
-41
lines changed- packages/jinja
- src
- test
5 files changed
+329
-41
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
48 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
346 | | - | |
| 346 | + | |
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
| |||
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
355 | | - | |
356 | | - | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
357 | 359 | | |
358 | 360 | | |
359 | 361 | | |
360 | | - | |
| 362 | + | |
361 | 363 | | |
362 | 364 | | |
363 | | - | |
| 365 | + | |
364 | 366 | | |
365 | 367 | | |
366 | 368 | | |
| |||
433 | 435 | | |
434 | 436 | | |
435 | 437 | | |
436 | | - | |
437 | | - | |
438 | | - | |
| 438 | + | |
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
120 | 162 | | |
121 | 163 | | |
122 | 164 | | |
| |||
543 | 585 | | |
544 | 586 | | |
545 | 587 | | |
| 588 | + | |
| 589 | + | |
546 | 590 | | |
547 | 591 | | |
548 | 592 | | |
| |||
570 | 614 | | |
571 | 615 | | |
572 | 616 | | |
| 617 | + | |
573 | 618 | | |
574 | 619 | | |
575 | 620 | | |
| |||
610 | 655 | | |
611 | 656 | | |
612 | 657 | | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
613 | 676 | | |
614 | 677 | | |
615 | 678 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments