mirror of
https://github.com/home-assistant/core.git
synced 2026-09-05 02:25:07 -05:00
Disable thinking for unsupported gemini models (#153415)
This commit is contained in:
@@ -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,
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user