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 GitHub
parent 61248c561d
commit e13abf2034
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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 "") for api_model in sorted(api_models, key=lambda x: x.display_name or "")
if ( if (
api_model.name != "models/gemini-1.0-pro" # duplicate of gemini-pro api_model.display_name
and api_model.display_name
and api_model.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 "vision" not in api_model.name
and api_model.supported_actions
and "generateContent" in 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())) tools.append(Tool(google_search=GoogleSearch()))
model_name = self.entry.options.get(CONF_CHAT_MODEL, RECOMMENDED_CHAT_MODEL) model_name = self.entry.options.get(CONF_CHAT_MODEL, RECOMMENDED_CHAT_MODEL)
# Gemini 1.0 doesn't support system_instruction while 1.5 does. # Avoid INVALID_ARGUMENT Developer instruction is not enabled for <model>
# Assume future versions will support it (if not, the request fails with a
# clear message at which point we can fix).
supports_system_instruction = ( 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( prompt_content = cast(