[V1] Fix json_object support with xgrammar (#15488)

Signed-off-by: Russell Bryant <rbryant@redhat.com>
This commit is contained in:
Russell Bryant
2025-04-02 02:00:08 -07:00
committed by GitHub
parent ddb94c2605
commit 14e53ed11f
5 changed files with 10 additions and 19 deletions
@@ -320,7 +320,10 @@ class XGrammarLogitsProcessor:
elif self.config.grammar_str is not None:
self.ctx = compiler.compile_grammar(self.config.grammar_str)
elif self.config.json_object:
self.ctx = compiler.compile_builtin_json_grammar()
any_whitespace = self.config.any_whitespace
self.ctx = compiler\
.compile_json_schema('{"type": "object"}',
any_whitespace=any_whitespace)
else:
raise ValueError(
"Invalid configuration for xgrammar logits processor")