Skip to content

✨ Add block assignment functionality in jinja package. #1341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 10, 2025

Conversation

pweglik
Copy link
Contributor

@pweglik pweglik commented Apr 8, 2025

This PR implements functionality of block assignments (https://jinja.palletsprojects.com/en/stable/templates/#block-assignments) in lexer, parser and engine=
I felt encouraged by the reply here:
#1087 (comment)

It was necessary to parse some chat_templates e.g. https://huggingface.co/MadeAgents/Hammer2.1-1.5b/blob/main/tokenizer_config.json (nicely formatted chat_template: https://pastebin.com/xBmhbwLi)

Let me know if you have any feedback.

@pweglik pweglik requested a review from xenova as a code owner April 8, 2025 13:11
@pweglik pweglik changed the title feat: Add block assignment functionality. feat: Add block assignment functionality in jinja paxkage. Apr 8, 2025
@pweglik pweglik changed the title feat: Add block assignment functionality in jinja paxkage. ✨ Add block assignment functionality in jinja paxkage. Apr 8, 2025
@pweglik pweglik changed the title ✨ Add block assignment functionality in jinja paxkage. ✨ Add block assignment functionality in jinja package. Apr 8, 2025
@xenova
Copy link
Contributor

xenova commented Apr 9, 2025

Thanks so much! This is very useful and the PR looks clean 👍

Maybe it's worth adding a unit test for a very simple test string that tests just this functionality? To be added in

@pweglik
Copy link
Contributor Author

pweglik commented Apr 10, 2025

Good suggestion @xenova, I've added a simple test 👍

@pweglik
Copy link
Contributor Author

pweglik commented Apr 10, 2025

I've also added a simple test for string array filter.

@xenova
Copy link
Contributor

xenova commented Apr 10, 2025

Flawless PR! Thanks a ton!

Failing lint is unrelated to this PR - could you merge main into your branch? I'll re-run CI and merge when all is green.

@pweglik
Copy link
Contributor Author

pweglik commented Apr 10, 2025

I've already rebased pweglik:main onto huggingface:main
Thanks a lot 😄

Copy link
Contributor

@xenova xenova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes you are right! Fixed by #1348 (& ran pnpm format).

Thanks again.

@xenova xenova merged commit f945dad into huggingface:main Apr 10, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants