[V1] Add structural_tag support using xgrammar (#17085)
This commit is contained in:
@@ -38,6 +38,7 @@ class GuidedDecodingParams:
|
||||
"""These are other options that can be set"""
|
||||
backend: Optional[str] = None
|
||||
whitespace_pattern: Optional[str] = None
|
||||
structural_tag: Optional[str] = None
|
||||
|
||||
@staticmethod
|
||||
def from_optional(
|
||||
@@ -48,9 +49,10 @@ class GuidedDecodingParams:
|
||||
json_object: Optional[bool] = None,
|
||||
backend: Optional[str] = None,
|
||||
whitespace_pattern: Optional[str] = None,
|
||||
structural_tag: Optional[str] = None,
|
||||
) -> Optional["GuidedDecodingParams"]:
|
||||
if all(arg is None
|
||||
for arg in (json, regex, choice, grammar, json_object)):
|
||||
if all(arg is None for arg in (json, regex, choice, grammar,
|
||||
json_object, structural_tag)):
|
||||
return None
|
||||
# Extract json schemas from pydantic models
|
||||
if isinstance(json, (BaseModel, type(BaseModel))):
|
||||
@@ -63,6 +65,7 @@ class GuidedDecodingParams:
|
||||
json_object=json_object,
|
||||
backend=backend,
|
||||
whitespace_pattern=whitespace_pattern,
|
||||
structural_tag=structural_tag,
|
||||
)
|
||||
|
||||
@property
|
||||
|
||||
Reference in New Issue
Block a user