]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commit
jinja : support ensure_ascii=true, string repetition and int/float self-filtering...
authorKwa Jie Hao <redacted>
Thu, 9 Apr 2026 09:28:33 +0000 (17:28 +0800)
committerGitHub <redacted>
Thu, 9 Apr 2026 09:28:33 +0000 (11:28 +0200)
commit243532e5568704ced8b08136e70247f9ceecdbf7
tree4456facba70a52db61ff9e2e845015b47bd303f9
parent5e9c6354638858f4c9aa0a70fd4a41a73f894dcc
jinja : support ensure_ascii=true, string repetition and int/float self-filtering (#21623)

* feat: jinja engine improvements for reka-edge

Port three Jinja engine improvements needed for the reka-edge model:
1. Python-style string repetition ("ab" * 3 → "ababab")
2. ensure_ascii=true support for tojson filter (escapes non-ASCII to \uXXXX)
3. int() builtin on value_int_t (identity, needed for Reka Edge template)

* fix: escape invalid utf8 bytes when ensure_ascii=true

The json_ensure_ascii_preserving_format function does not correctly
handle an edge case where if UTF-8 parsing fails, it adds the non-ascii
character back to the output as a raw byte.

This commit fixes that by adding the unicode standard replacement
character \\ufffd to the output instead. This is the standard behavior
for various programming languages like Python, Rust, Go, etc.

* chore: address PR comments

1. Add todo comment for supporting string repetition for array/tuples
2. Add support for float identity operation
3. Move invalid ascii test case to test_fuzzing

* chore: accept suggestion for common/jinja/value.cpp

Co-authored-by: Sigbjørn Skjæret <redacted>
---------

Co-authored-by: Sigbjørn Skjæret <redacted>
common/jinja/runtime.cpp
common/jinja/value.cpp
tests/test-jinja.cpp