fix(sampling): reject conflicting structural tag constraints (#32525)

This commit is contained in:
Mark
2026-08-02 20:24:55 -07:00
committed by GitHub
parent dd6ddc053b
commit 741e33db81
2 changed files with 27 additions and 14 deletions
@@ -196,9 +196,12 @@ class SamplingParams(msgspec.Struct, kw_only=True, array_like=True):
self.json_schema,
self.regex,
self.ebnf,
self.structural_tag,
] # since mutually exclusive, only one can be set
if sum(x is not None for x in grammars) > 1:
raise ValueError("Only one of regex, json_schema, or ebnf can be set.")
raise ValueError(
"Only one of json_schema, regex, ebnf, or structural_tag can be set."
)
def normalize(self, tokenizer):
# Process stop strings