litellm/tests/unit/google_genai
mika-lt 6058bb03d2
fix(google_genai): honor snake_case generation_config on generateContent (#51139)
* fix(google_genai): honor snake_case generation_config on generateContent

Read the request config from generationConfig or generation_config in the shared setup step, and map maxOutputTokens, topP and stopSequences from either spelling on the non-Gemini adapter path, so a snake_case output cap is no longer dropped.

* fix(google_genai): read snake_case generation_config in the rate limiter

* test(google_genai): cover the limiter's Google config precedence

Covers an empty config next to a filled generationConfig and both config spellings in one request, for the cap check and the injected cap, and types the new test params as Mapping.

* fix(google_genai): give a custom generateContent hook an empty config as {} again

* fix(google_genai): read quoted generationConfig numbers and answer 400 for an invalid config

The adapter now reads temperature, the output cap, topP and the stop
sequences as Google types them, so a quoted number like "16" reaches
non-Gemini models as a number. A config that is not an object, or a
field value Google refuses, answers 400 in either spelling before any
provider call, where camelCase answered 500 and snake_case was dropped

* fix(google_genai): read numbers the way the Gemini API types them and accept a typed GenerateContentConfig

* fix(google_genai): read signed and leading-dot number strings and refuse non-finite floats as the Gemini API does

* fix(google_genai): match number strings without backtracking so a long malformed value cannot stall the event loop

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-18 03:47:08 +00:00
..
__init__.py test: move tests/test_litellm root and small trees into tests/unit (#43186) 2026-09-25 11:30:43 -07:00
test_google_genai_adapter.py fix(google_genai): honor snake_case generation_config on generateContent (#51139) 2026-11-18 03:47:08 +00:00
test_google_genai_adapter_fixes.py test: move tests/test_litellm root and small trees into tests/unit (#43186) 2026-09-25 11:30:43 -07:00
test_google_genai_handler.py fix(vertex_ai): route Model Garden models through the generateContent adapter (#41836) 2026-10-15 08:06:49 -07:00
test_google_genai_main.py fix(google_genai): honor snake_case generation_config on generateContent (#51139) 2026-11-18 03:47:08 +00:00
test_google_genai_streaming_iterator.py fix(logging): retain streaming success logging tasks until they finish (#52067) 2026-11-16 11:21:05 -08:00
test_google_genai_transformation.py refactor(llms): expose public names for private provider helpers (#45037) 2026-10-07 08:49:25 -07:00