[bugfix] catch xgrammar unsupported array constraints (#12210)

Signed-off-by: Jason Cheng <jasoncky96@gmail.com>
This commit is contained in:
Cheng Kuan Yong Jason
2025-01-21 08:42:02 +08:00
committed by GitHub
parent da7512215f
commit 06a760d6e8

View File

@ -20,6 +20,13 @@ def has_xgrammar_unsupported_json_features(schema: dict) -> bool:
]):
return True
# Check for array unsupported keywords
if obj.get("type") == "array" and any(key in obj for key in [
"uniqueItems", "contains", "minContains", "maxContains",
"minItems", "maxItems"
]):
return True
# Recursively check all nested objects and arrays
for value in obj.values():
if isinstance(value, dict):