[V1] Add structural_tag support using xgrammar (#17085)
This commit is contained in:
@@ -27,14 +27,15 @@ class GuidedDecodingRequest:
|
||||
guided_decoding_backend: Optional[str] = None
|
||||
guided_whitespace_pattern: Optional[str] = None
|
||||
guided_json_object: Optional[bool] = None
|
||||
structural_tag: Optional[str] = None
|
||||
|
||||
def __post_init__(self):
|
||||
"""Validate that some fields are mutually exclusive."""
|
||||
guide_count = sum([
|
||||
self.guided_json is not None, self.guided_regex is not None,
|
||||
self.guided_choice is not None, self.guided_grammar is not None,
|
||||
self.guided_json_object is not None
|
||||
])
|
||||
guide_count = sum(x is not None
|
||||
for x in (self.guided_json, self.guided_regex,
|
||||
self.guided_choice, self.guided_grammar,
|
||||
self.guided_json_object,
|
||||
self.structural_tag))
|
||||
if guide_count > 1:
|
||||
raise ValueError(
|
||||
"You can only use one kind of guided decoding but multiple are "
|
||||
|
||||
Reference in New Issue
Block a user