Allow latest Gemini Models to be accessible - #10
Conversation
|
Thanks for tackling this @pnpninja — the hardcoded One suggestion to make it last longer: the two presets in the current diff ( Could we add a free-text "Custom…" option alongside the dropdown? That way, whenever Google rotates models, users can just type the new ID instead of waiting for an app update. The dropdown stays for convenience; the text field is the safety net. Proposed {
type: "select",
messageKey: "geminiModel",
defaultValue: "gemini-3.1-flash-lite",
label: "Gemini model",
description: "Pick a current model. Choose \u201CCustom\u2026\u201D to type any model ID \u2014 handy when Google retires a model and this list is out of date.",
options: [
{ label: "Gemini 3.1 Flash-Lite (cheapest, recommended)", value: "gemini-3.1-flash-lite" },
{ label: "Gemini 3.5 Flash (balanced)", value: "gemini-3.5-flash" },
{ label: "Custom\u2026", value: "custom" },
],
},
{
type: "input",
messageKey: "geminiModelCustom",
label: "Custom Gemini model ID",
description: "Only used when \u201CCustom\u2026\u201D is selected above. Enter the exact model ID, e.g. gemini-3.1-pro.",
attributes: { placeholder: "gemini-3.1-flash-lite" },
},Small resolver so the call site stays clean (feed it the same way the app already reads // Resolve which Gemini model to call.
// `selected` = value of the "geminiModel" select
// `custom` = value of the "geminiModelCustom" input
function resolveGeminiModel(selected, custom) {
selected = (selected || "").trim();
custom = (custom || "").trim();
// "Custom…" chosen and an ID was typed → use it verbatim.
if (selected === "custom" && custom) return custom;
// A concrete preset was chosen.
if (selected && selected !== "custom") return selected;
// Nothing set yet (e.g. installs from before this change) → safe current default.
return "gemini-3.1-flash-lite";
}And at the request site, build the URL from the resolved model instead of the hardcoded string: var model = resolveGeminiModel(settings.geminiModel, settings.geminiModelCustom);
var url = "https://generativelanguage.googleapis.com/v1beta/models/"
+ encodeURIComponent(model)
+ ":generateContent?key=" + apiKey;Benefits:
Happy to help test on hardware if useful. Thanks again! |
|
I wonder if we can pull this info and populate it dynamically in the dropdown? |
|
That would be the perfect move @pnpninja I see there is the same problem on Claude ai section as well. |
The current code returns an error saying the Gemini 2.0 model is no longer accessible. This fixes it
Tested in Basalt Emulator