-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Change JSON serialization to custom json.dumps #31100
Change JSON serialization to custom json.dumps #31100
Conversation
… "<", ">", "&", "'"
Yes, this makes sense, didn't catch the escaping of HTML characters. May I suggest also removing the |
@Rocketknight1 |
Sorry for the delay! This makes sense to me, however there is a risk of affecting other Jinja implementations. @xenova how does |
@Rocketknight1 AFAICT |
No, not yet, but it should be really easy to implement! |
Okay! In that case, pinging @amyeroberts for core maintainer review. Brief summary: We often want to flatten lists/dicts into a string in a chat template, especially when it deals with tools. Jinja was originally designed for templating in webpages, and as a result it escapes special HTML characters by default, but this is not what we want in a chat template. This PR swaps the default |
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM - thanks for updating!
@junrae6454 Thanks for the PR! I made one small change - I moved the lambda function out into a proper function, and exposed a couple of the other arguments, as I feel like they might be useful later for rendering JSON. Will merge once tests pass |
* Change JSON serialization to custom json.dumps to prevent escaping of "<", ">", "&", "'" * caller has control over the order, remove sort_key=True * Move tojson into a proper function and expose a couple of other args --------- Co-authored-by: jun.4 <jun.4@kakaobrain.com> Co-authored-by: Matt <rocketknight1@gmail.com>
* Change JSON serialization to custom json.dumps to prevent escaping of "<", ">", "&", "'" * caller has control over the order, remove sort_key=True * Move tojson into a proper function and expose a couple of other args --------- Co-authored-by: jun.4 <jun.4@kakaobrain.com> Co-authored-by: Matt <rocketknight1@gmail.com>
* Change JSON serialization to custom json.dumps to prevent escaping of "<", ">", "&", "'" * caller has control over the order, remove sort_key=True * Move tojson into a proper function and expose a couple of other args --------- Co-authored-by: jun.4 <jun.4@kakaobrain.com> Co-authored-by: Matt <rocketknight1@gmail.com>
* Change JSON serialization to custom json.dumps to prevent escaping of "<", ">", "&", "'" * caller has control over the order, remove sort_key=True * Move tojson into a proper function and expose a couple of other args --------- Co-authored-by: jun.4 <jun.4@kakaobrain.com> Co-authored-by: Matt <rocketknight1@gmail.com>
* Change JSON serialization to custom json.dumps to prevent escaping of "<", ">", "&", "'" * caller has control over the order, remove sort_key=True * Move tojson into a proper function and expose a couple of other args --------- Co-authored-by: jun.4 <jun.4@kakaobrain.com> Co-authored-by: Matt <rocketknight1@gmail.com>
* Change JSON serialization to custom json.dumps to prevent escaping of "<", ">", "&", "'" * caller has control over the order, remove sort_key=True * Move tojson into a proper function and expose a couple of other args --------- Co-authored-by: jun.4 <jun.4@kakaobrain.com> Co-authored-by: Matt <rocketknight1@gmail.com>
What does this PR do?
jinja2 default tojson
relative issue
#31041
#31079
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.