diff --git a/deepinfer/structure_output/so_matcher_builder.py b/deepinfer/structure_output/so_matcher_builder.py index 030d2dc..ab3b867 100644 --- a/deepinfer/structure_output/so_matcher_builder.py +++ b/deepinfer/structure_output/so_matcher_builder.py @@ -61,6 +61,10 @@ class SOMatcherBuilder: raise ValueError("Offline structured output does not accept serialized grammars; provide schema_type and schema") if "bound_token_ids" in so_args: raise ValueError("bound_token_ids is no longer supported; use bound_token_id with a single non-negative integer") + missing = [key for key in ("schema_type", "schema") if key not in so_args] + if missing: + raise ValueError(f"so_args is missing required key(s) {missing}; provide schema_type and schema") + schema_type = so_args["schema_type"] schema = so_args["schema"] trigger_tokens = so_args.get("trigger_token_ids") @@ -76,7 +80,7 @@ class SOMatcherBuilder: return XGrammarMatcherFuture(task=failed) def _build() -> XGrammarMatcher: - ctx = self._compiler.dispatch_and_compile(so_args["schema_type"], schema) + ctx = self._compiler.dispatch_and_compile(schema_type, schema) matcher = XGrammarMatcher.from_compiled( ctx, self._vocab_size,