From d02a9cf16ff88ad011e2eb1ce29f4d9400f13cd1 Mon Sep 17 00:00:00 2001 From: Andrei Betlen Date: Fri, 8 Mar 2024 21:10:53 -0500 Subject: [PATCH] Fixed json strings grammar by blacklisting character control set. Closes #1259 --- llama_cpp/llama_grammar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llama_cpp/llama_grammar.py b/llama_cpp/llama_grammar.py index 6a37857..9cc48a9 100644 --- a/llama_cpp/llama_grammar.py +++ b/llama_cpp/llama_grammar.py @@ -1337,7 +1337,7 @@ array ::= string ::= "\"" ( - [^"\\] | + [^"\\\x7F\x00-\x1F] | "\\" (["\\/bfnrt] | "u" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]) # escapes )* "\"" ws @@ -1366,7 +1366,7 @@ array ::= string ::= "\"" ( - [^"\\] | + [^"\\\x7F\x00-\x1F] | "\\" (["\\/bfnrt] | "u" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]) # escapes )* "\"" ws