From aab392774bb9f50e4248cb590690dc34d8595b5a Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Tue, 25 Feb 2025 03:21:25 -0500 Subject: [PATCH] [Core] xgrammar: Expand list of unsupported jsonschema keywords (#13783) Signed-off-by: Russell Bryant --- vllm/model_executor/guided_decoding/utils.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/vllm/model_executor/guided_decoding/utils.py b/vllm/model_executor/guided_decoding/utils.py index c3c0378ea9520..10981776e768c 100644 --- a/vllm/model_executor/guided_decoding/utils.py +++ b/vllm/model_executor/guided_decoding/utils.py @@ -33,6 +33,18 @@ def has_xgrammar_unsupported_json_features(schema: dict) -> bool: ]): return True + # Unsupported keywords for strings + if obj.get("type") == "string" and any( + key in obj for key in ["minLength", "maxLength", "format"]): + return True + + # Unsupported keywords for objects + if obj.get("type") == "object" and any(key in obj for key in [ + "minProperties", "maxProperties", "propertyNames", + "patternProperties" + ]): + return True + # Recursively check all nested objects and arrays for value in obj.values(): if isinstance(value, dict):