fix(gemini): add presence_penalty support for Google AI Studio (#18154)

Fixes #14753

Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>
This commit is contained in:
Cesar Garcia 2026-01-12 08:42:19 -03:00 committed by GitHub
parent 087ddee227
commit f7912990b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View file

@ -87,6 +87,7 @@ class GoogleAIStudioGeminiConfig(VertexGeminiConfig):
"stop",
"logprobs",
"frequency_penalty",
"presence_penalty",
"modalities",
"parallel_tool_calls",
"web_search_options",

View file

@ -14,6 +14,7 @@ from litellm.llms.vertex_ai.common_utils import VertexAIError
from litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini import (
VertexGeminiConfig,
)
from litellm.llms.gemini.chat.transformation import GoogleAIStudioGeminiConfig
from litellm.types.llms.vertex_ai import UsageMetadata
from litellm.types.utils import ChoiceLogprobs, Usage
from litellm.utils import CustomStreamWrapper
@ -2315,6 +2316,17 @@ def test_partial_json_chunk_on_first_chunk():
assert iterator.chunk_type == "accumulated_json", "Should switch to accumulated_json mode"
def test_google_ai_studio_presence_penalty_supported():
"""
Test that presence_penalty is supported for Google AI Studio Gemini.
Regression test for https://github.com/BerriAI/litellm/issues/14753
"""
config = GoogleAIStudioGeminiConfig()
supported_params = config.get_supported_openai_params(model="gemini-2.0-flash")
assert "presence_penalty" in supported_params
# ==================== Tool Type Separation Tests ====================
# These tests verify that each Tool object contains exactly one type per Vertex AI API spec
# Ref: https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1beta1/Tool