[Bugfix] remove fallback in guided_json (int range, patterns) (#16725)
Signed-off-by: csy1204 <josang1204@gmail.com> Co-authored-by: 조상연[플레이스 AI] <sang-yeon.cho@navercorp.com>
This commit is contained in:
co-authored by
조상연[플레이스 AI] <sang-yeon.cho@navercorp.com>
parent
b22980a1dc
commit
6aae216b4e
@@ -65,7 +65,7 @@ def maybe_backend_fallback(
|
||||
fallback_or_error(
|
||||
guided_params,
|
||||
"xgrammar does not support advanced JSON schema features like "
|
||||
"enums, patterns or numeric ranges.", "outlines")
|
||||
"string length, item limits, or property bounds.", "outlines")
|
||||
|
||||
# xgrammar only supports GBNF grammars, so we must convert Lark.
|
||||
# We must check if the grammar is likely Lark and if that
|
||||
|
||||
@@ -10,16 +10,8 @@ def has_xgrammar_unsupported_json_features(schema: dict) -> bool:
|
||||
if not isinstance(obj, dict):
|
||||
return False
|
||||
|
||||
# Check for pattern restrictions
|
||||
if "pattern" in obj:
|
||||
return True
|
||||
|
||||
# Check for numeric ranges
|
||||
if obj.get("type") in ("integer", "number") and any(
|
||||
key in obj for key in [
|
||||
"minimum", "maximum", "exclusiveMinimum",
|
||||
"exclusiveMaximum", "multipleOf"
|
||||
]):
|
||||
if obj.get("type") in ("integer", "number") and ("multipleOf" in obj):
|
||||
return True
|
||||
|
||||
# Check for array unsupported keywords
|
||||
|
||||
Reference in New Issue
Block a user