fix(ai): support gemini-3.1 flash-lite and thinking matching

closes #1785
This commit is contained in:
Mario Zechner 2026-03-04 20:17:58 +01:00
parent e64cd15c25
commit 2af0c98b5f
5 changed files with 54 additions and 8 deletions

View file

@ -2,6 +2,14 @@
## [Unreleased]
### Added
- Added `gemini-3.1-flash-lite-preview` fallback model entry for the `google` provider so it remains selectable until upstream model catalogs include it ([#1785](https://github.com/badlogic/pi-mono/issues/1785), thanks [@n-WN](https://github.com/n-WN)).
### Fixed
- Fixed Gemini 3.1 thinking-level detection in `google` and `google-vertex` providers so `gemini-3.1-*` models use Gemini 3 level-based thinking config instead of budget fallback ([#1785](https://github.com/badlogic/pi-mono/issues/1785), thanks [@n-WN](https://github.com/n-WN)).
## [0.55.4] - 2026-03-02
## [0.55.3] - 2026-02-27

View file

@ -742,6 +742,27 @@ async function generateModels() {
});
}
// Add missing Gemini 3.1 Flash Lite Preview until models.dev includes it.
if (!allModels.some((m) => m.provider === "google" && m.id === "gemini-3.1-flash-lite-preview")) {
allModels.push({
id: "gemini-3.1-flash-lite-preview",
name: "Gemini 3.1 Flash Lite Preview",
api: "google-generative-ai",
baseUrl: "https://generativelanguage.googleapis.com/v1beta",
provider: "google",
reasoning: true,
input: ["text", "image"],
cost: {
input: 0,
output: 0,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 1048576,
maxTokens: 65536,
});
}
// Add missing gpt models
if (!allModels.some(m => m.provider === "openai" && m.id === "gpt-5-chat-latest")) {
allModels.push({

View file

@ -3171,6 +3171,23 @@ export const MODELS = {
contextWindow: 1000000,
maxTokens: 64000,
} satisfies Model<"google-generative-ai">,
"gemini-3.1-flash-lite-preview": {
id: "gemini-3.1-flash-lite-preview",
name: "Gemini 3.1 Flash Lite Preview",
api: "google-generative-ai",
provider: "google",
baseUrl: "https://generativelanguage.googleapis.com/v1beta",
reasoning: true,
input: ["text", "image"],
cost: {
input: 0,
output: 0,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 1048576,
maxTokens: 65536,
} satisfies Model<"google-generative-ai">,
"gemini-3.1-pro-preview": {
id: "gemini-3.1-pro-preview",
name: "Gemini 3.1 Pro Preview",
@ -10162,13 +10179,13 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
input: 0.35,
output: 1.71,
input: 0.39,
output: 1.9,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 202752,
maxTokens: 131072,
contextWindow: 204800,
maxTokens: 204800,
} satisfies Model<"openai-completions">,
"z-ai/glm-4.6:exacto": {
id: "z-ai/glm-4.6:exacto",

View file

@ -416,11 +416,11 @@ function buildParams(
type ClampedThinkingLevel = Exclude<PiThinkingLevel, "xhigh">;
function isGemini3ProModel(model: Model<"google-generative-ai">): boolean {
return model.id.includes("3-pro");
return /gemini-3(?:\.\d+)?-pro/.test(model.id.toLowerCase());
}
function isGemini3FlashModel(model: Model<"google-generative-ai">): boolean {
return model.id.includes("3-flash");
return /gemini-3(?:\.\d+)?-flash/.test(model.id.toLowerCase());
}
function getGemini3ThinkingLevel(

View file

@ -386,11 +386,11 @@ function buildParams(
type ClampedThinkingLevel = Exclude<ThinkingLevel, "xhigh">;
function isGemini3ProModel(model: Model<"google-generative-ai">): boolean {
return model.id.includes("3-pro");
return /gemini-3(?:\.\d+)?-pro/.test(model.id.toLowerCase());
}
function isGemini3FlashModel(model: Model<"google-generative-ai">): boolean {
return model.id.includes("3-flash");
return /gemini-3(?:\.\d+)?-flash/.test(model.id.toLowerCase());
}
function getGemini3ThinkingLevel(