Make Gemma models work in Google AI (#145479)

* Make Gemma models work in Google AI

* move one line to be improve readability
This commit is contained in:
tronikos 2025-05-22 22:02:30 -07:00 committed by Franck Nijhof
parent f867a0af24
commit 97004e13cb
No known key found for this signature in database
GPG Key ID: AB33ADACE7101952
2 changed files with 6 additions and 7 deletions

View File

@ -254,11 +254,11 @@ async def google_generative_ai_config_option_schema(
)
for api_model in sorted(api_models, key=lambda x: x.display_name or "")
if (
api_model.name != "models/gemini-1.0-pro" # duplicate of gemini-pro
and api_model.display_name
api_model.display_name
and api_model.name
and api_model.supported_actions
and "tts" not in api_model.name
and "vision" not in api_model.name
and api_model.supported_actions
and "generateContent" in api_model.supported_actions
)
]

View File

@ -319,11 +319,10 @@ class GoogleGenerativeAIConversationEntity(
tools.append(Tool(google_search=GoogleSearch()))
model_name = self.entry.options.get(CONF_CHAT_MODEL, RECOMMENDED_CHAT_MODEL)
# Gemini 1.0 doesn't support system_instruction while 1.5 does.
# Assume future versions will support it (if not, the request fails with a
# clear message at which point we can fix).
# Avoid INVALID_ARGUMENT Developer instruction is not enabled for <model>
supports_system_instruction = (
"gemini-1.0" not in model_name and "gemini-pro" not in model_name
"gemma" not in model_name
and "gemini-2.0-flash-preview-image-generation" not in model_name
)
prompt_content = cast(