From c88791ed04278699c1a94ebe3567b2784933574f Mon Sep 17 00:00:00 2001 From: Peter Ross Date: Tue, 13 May 2025 10:13:32 +1000 Subject: [PATCH] Add tojson.ensure_ascii (Support GLM 4 chat template) https://huggingface.co/THUDM/GLM-4-32B-0414/blob/main/chat_template.jinja --- include/minja/minja.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/minja/minja.hpp b/include/minja/minja.hpp index ec89bc7..9e92b72 100644 --- a/include/minja/minja.hpp +++ b/include/minja/minja.hpp @@ -2589,7 +2589,7 @@ inline std::shared_ptr Context::builtins() { globals.set("raise_exception", simple_function("raise_exception", { "message" }, [](const std::shared_ptr &, Value & args) -> Value { throw std::runtime_error(args.at("message").get()); })); - globals.set("tojson", simple_function("tojson", { "value", "indent" }, [](const std::shared_ptr &, Value & args) { + globals.set("tojson", simple_function("tojson", { "value", "indent", "ensure_ascii" }, [](const std::shared_ptr &, Value & args) { return Value(args.at("value").dump(args.get("indent", -1), /* to_json= */ true)); })); globals.set("items", simple_function("items", { "object" }, [](const std::shared_ptr &, Value & args) {