Skip to content

Commit 97004e1

Browse files
tronikosfrenck
authored andcommitted
Make Gemma models work in Google AI (home-assistant#145479)
* Make Gemma models work in Google AI * move one line to be improve readability
1 parent f867a0a commit 97004e1

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

homeassistant/components/google_generative_ai_conversation/config_flow.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,11 @@ async def google_generative_ai_config_option_schema(
254254
)
255255
for api_model in sorted(api_models, key=lambda x: x.display_name or "")
256256
if (
257-
api_model.name != "models/gemini-1.0-pro" # duplicate of gemini-pro
258-
and api_model.display_name
257+
api_model.display_name
259258
and api_model.name
260-
and api_model.supported_actions
259+
and "tts" not in api_model.name
261260
and "vision" not in api_model.name
261+
and api_model.supported_actions
262262
and "generateContent" in api_model.supported_actions
263263
)
264264
]

homeassistant/components/google_generative_ai_conversation/conversation.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,10 @@ async def _async_handle_message(
319319
tools.append(Tool(google_search=GoogleSearch()))
320320

321321
model_name = self.entry.options.get(CONF_CHAT_MODEL, RECOMMENDED_CHAT_MODEL)
322-
# Gemini 1.0 doesn't support system_instruction while 1.5 does.
323-
# Assume future versions will support it (if not, the request fails with a
324-
# clear message at which point we can fix).
322+
# Avoid INVALID_ARGUMENT Developer instruction is not enabled for <model>
325323
supports_system_instruction = (
326-
"gemini-1.0" not in model_name and "gemini-pro" not in model_name
324+
"gemma" not in model_name
325+
and "gemini-2.0-flash-preview-image-generation" not in model_name
327326
)
328327

329328
prompt_content = cast(

0 commit comments

Comments
 (0)