DeepInfer/tests/engine/test_sampling_params_golden_so.py

29 lines
761 B
Python

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