From 63996e54c1976be14b108e6f178f3f5fe1e801f1 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Mon, 24 Feb 2025 14:32:32 -0500 Subject: [PATCH] [Core] xgrammar: Expand list of unsupported jsonschema keywords While doing some testing with xgrammar, I ran into an supported attribute for a string type. I checked the code and found some things we weren't checking for. Details can be found by searching for `warnUnsupportedKeywords` in this file: https://github.com/mlc-ai/xgrammar/blob/main/cpp/json_schema_converter.cc 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 c3c0378ea952..10981776e768 100644 --- a/vllm/model_executor/guided_decoding/utils.py +++ b/vllm/model_executor/guided_decoding/utils.py @@ -33,6 +33,18 @@ def check_object(obj: 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):