Merge f97e82bdb61377eaa10b992296ccd45f9e58286f into 553741557a57df44a46fb3ab72b6aafeaf945337

This commit is contained in:
Yuxiao Huang 2026-10-28 20:27:36 -07:00 committed by GitHub
commit 700230447c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 31 additions and 0 deletions

View File

@ -62,6 +62,9 @@ class SamplingParams:
) -> None:
del logprobs
if so_args is not None and golden_token_ids is not None:
raise ValueError("golden_token_ids cannot be combined with structured output constraints (so_args)")
self.temperature = temperature
self.top_p = top_p
self.top_k = top_k

View File

@ -0,0 +1,28 @@
import pytest
from deepinfer.sampling_params import SamplingParams
def test_golden_tokens_conflict_with_structured_output() -> None:
with pytest.raises(ValueError, match="cannot be combined"):
SamplingParams(
golden_token_ids=[2],
so_args={
"schema_type": "regex",
"schema": "[0-9]+",
},
)
def test_golden_tokens_without_structured_output() -> None:
params = SamplingParams(golden_token_ids=[2])
assert params.golden_token_ids == [2]
def test_structured_output_without_golden_tokens() -> None:
so_args = {
"schema_type": "regex",
"schema": "[0-9]+",
}
params = SamplingParams(so_args=so_args)
assert params.so_args == so_args