Disable thinking for unsupported gemini models (#153415)

This commit is contained in:
Denis Shulyaka
2025-10-03 17:25:46 +00:00
committed by Franck Nijhof
parent 46a2e21ef0
commit 34640ea735
2 changed files with 10 additions and 3 deletions
@@ -620,6 +620,13 @@ class GoogleGenerativeAILLMBaseEntity(Entity):
def create_generate_content_config(self) -> GenerateContentConfig:
"""Create the GenerateContentConfig for the LLM."""
options = self.subentry.data
model = options.get(CONF_CHAT_MODEL, RECOMMENDED_CHAT_MODEL)
thinking_config: ThinkingConfig | None = None
if model.startswith("models/gemini-2.5") and not model.endswith(
("tts", "image", "image-preview")
):
thinking_config = ThinkingConfig(include_thoughts=True)
return GenerateContentConfig(
temperature=options.get(CONF_TEMPERATURE, RECOMMENDED_TEMPERATURE),
top_k=options.get(CONF_TOP_K, RECOMMENDED_TOP_K),
@@ -652,7 +659,7 @@ class GoogleGenerativeAILLMBaseEntity(Entity):
),
),
],
thinking_config=ThinkingConfig(include_thoughts=True),
thinking_config=thinking_config,
)
@@ -208,7 +208,7 @@ async def test_tts_service_speak(
threshold=RECOMMENDED_HARM_BLOCK_THRESHOLD,
),
],
thinking_config=types.ThinkingConfig(include_thoughts=True),
thinking_config=None,
),
)
@@ -277,6 +277,6 @@ async def test_tts_service_speak_error(
threshold=RECOMMENDED_HARM_BLOCK_THRESHOLD,
),
],
thinking_config=types.ThinkingConfig(include_thoughts=True),
thinking_config=None,
),
)