mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-05 02:41:56 +00:00
fix(gemini): extend low minimum thinking mapping to Gemini 3.8 Flash
This commit is contained in:
parent
17cd787414
commit
fe9fcddfee
2 changed files with 10 additions and 6 deletions
|
|
@ -862,10 +862,12 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig):
|
|||
# Covers gemini-3-flash, gemini-3-flash-preview, gemini-3.1-flash, gemini-3.1-flash-lite-preview,
|
||||
# gemini-3.5-flash, and any future 3.x-flash variants.
|
||||
is_gemini3flash: Final = model and ("flash" in model.lower() and "gemini-3" in model.lower())
|
||||
is_gemini37flash: Final = model and "gemini-3.7-flash" in model.lower()
|
||||
requires_low_minimum_thinking: Final = model and (
|
||||
"gemini-3.7-flash" in model.lower() or "gemini-3.8-flash" in model.lower()
|
||||
)
|
||||
is_gemini31pro: Final = model and ("gemini-3.1-pro-preview" in model.lower())
|
||||
if reasoning_effort == "minimal":
|
||||
if is_gemini3flash and not is_gemini37flash:
|
||||
if is_gemini3flash and not requires_low_minimum_thinking:
|
||||
return {"thinkingLevel": "minimal", "includeThoughts": True}
|
||||
else:
|
||||
return {"thinkingLevel": "low", "includeThoughts": True}
|
||||
|
|
@ -880,13 +882,13 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig):
|
|||
return {"thinkingLevel": "high", "includeThoughts": True}
|
||||
elif reasoning_effort == "disable":
|
||||
# Gemini 3 cannot fully disable thinking, so we use "minimal" for gemini-3-flash-preview, "low" for others
|
||||
if is_gemini3flash and not is_gemini37flash:
|
||||
if is_gemini3flash and not requires_low_minimum_thinking:
|
||||
return {"thinkingLevel": "minimal", "includeThoughts": False}
|
||||
else:
|
||||
return {"thinkingLevel": "low", "includeThoughts": False}
|
||||
elif reasoning_effort == "none":
|
||||
# For gemini-3-flash-preview, use "minimal" instead of "low"
|
||||
if is_gemini3flash and not is_gemini37flash:
|
||||
if is_gemini3flash and not requires_low_minimum_thinking:
|
||||
return {"thinkingLevel": "minimal", "includeThoughts": False}
|
||||
else:
|
||||
return {"thinkingLevel": "low", "includeThoughts": False}
|
||||
|
|
|
|||
|
|
@ -2666,16 +2666,18 @@ def test_reasoning_effort_maps_to_thinking_level_gemini_3():
|
|||
assert result["thinkingConfig"]["includeThoughts"] is False
|
||||
|
||||
|
||||
@pytest.mark.parametrize("model", ["vertex_ai/gemini-3.7-flash", "vertex_ai/gemini-3.8-flash"])
|
||||
@pytest.mark.parametrize("reasoning_effort", ["minimal", "disable", "none"])
|
||||
def test_gemini_37_flash_uses_low_minimum_thinking_level(reasoning_effort: str):
|
||||
def test_gemini_flash_uses_low_minimum_thinking_level(model: str, reasoning_effort: str):
|
||||
result = VertexGeminiConfig().map_openai_params(
|
||||
non_default_params={"reasoning_effort": reasoning_effort},
|
||||
optional_params={},
|
||||
model="vertex_ai/gemini-3.7-flash",
|
||||
model=model,
|
||||
drop_params=False,
|
||||
)
|
||||
|
||||
assert result["thinkingConfig"]["thinkingLevel"] == "low"
|
||||
assert result["thinkingConfig"]["includeThoughts"] is (reasoning_effort == "minimal")
|
||||
|
||||
|
||||
def test_reasoning_effort_dict_format_gemini_3():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue