From bb79a75a89cf0633c673a85ccbb18df500936fed Mon Sep 17 00:00:00 2001 From: tanvithakur <54823948+tanvithakur94@users.noreply.github.com> Date: Thu, 30 Oct 2025 20:02:58 -0700 Subject: [PATCH] Changes to fix frequency_penalty and presence_penalty issue for gemini-2.5-pro model (#16041) * Update vertex_and_google_ai_studio_gemini.py * Fix logic * Fix mypy error * Fix lgic --------- Co-authored-by: tanvi thakur --- .../vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py | 7 ++----- litellm/proxy/utils.py | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py index fdad7851f1..112d378378 100644 --- a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py +++ b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py @@ -220,11 +220,8 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig): def _supports_penalty_parameters(self, model: str) -> bool: unsupported_models = ["gemini-2.5-pro-preview-06-05"] - - for pattern in unsupported_models: - if model in pattern: - return False - + if model in unsupported_models: + return False return True def get_supported_openai_params(self, model: str) -> List[str]: diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index eaf2c6c4ff..dbd795e1b3 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -985,7 +985,7 @@ class ProxyLogging: ) else: _callback = callback # type: ignore - if _callback is not None and isinstance(_callback, CustomGuardrail): + if _callback is not None and isinstance(_callback, CustomGuardrail) and data is not None: result = await self._process_guardrail_callback( callback=_callback, data=data,