This commit is contained in:
Mateo Wang 2026-11-06 15:51:07 -05:00 • committed by GitHub
commit a41aeedfb3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View file

@ -87,7 +87,9 @@ def _int_or_none(value: object) -> int | None:
def _asks_for_one_candidate(generation_config: Mapping[str, object]) -> bool:
return all(
_int_or_none(generation_config[key] or 1) == 1 for key in _CANDIDATE_COUNT_KEYS if key in generation_config
generation_config[key] is None or _int_or_none(generation_config[key]) in (0, 1)
for key in _CANDIDATE_COUNT_KEYS
if key in generation_config
)

View file

@ -518,7 +518,14 @@ async def test_unary_answer_cut_at_the_callers_cap_is_returned_with_its_token_in
@pytest.mark.parametrize(
"choice_count_request",
[{"max_tokens": 100_000, "n": 2}, {"extra_body": {"generationConfig": {"candidateCount": 2}}}],
[
{"max_tokens": 100_000, "n": 2},
{"extra_body": {"generationConfig": {"candidateCount": 2}}},
{"max_tokens": 100_000, "n": ""},
{"max_tokens": 100_000, "n": []},
{"max_tokens": 100_000, "n": {}},
{"max_tokens": 100_000, "n": "1"},
],
)
@pytest.mark.parametrize("is_async", [True, False])
@pytest.mark.asyncio