Support thinking level configuration for Gemini 3 Pro models (#176)

* support Google thinking level configuration for Gemini 3 Pro models

* relax model ID check for gemini 3 pro
This commit is contained in:
Markus Ylisiurunen 2025-12-13 03:09:54 +02:00 committed by GitHub
parent 38119ffbb0
commit 6b48fa58d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 44 additions and 9 deletions

View file

@ -6,6 +6,8 @@ import {
type GenerateContentParameters,
GoogleGenAI,
type Part,
type ThinkingConfig,
type ThinkingLevel,
} from "@google/genai";
import { calculateCost } from "../models.js";
import type {
@ -31,6 +33,7 @@ export interface GoogleOptions extends StreamOptions {
thinking?: {
enabled: boolean;
budgetTokens?: number; // -1 for dynamic, 0 to disable
level?: ThinkingLevel;
};
}
@ -293,10 +296,13 @@ function buildParams(
}
if (options.thinking?.enabled && model.reasoning) {
config.thinkingConfig = {
includeThoughts: true,
...(options.thinking.budgetTokens !== undefined && { thinkingBudget: options.thinking.budgetTokens }),
};
const thinkingConfig: ThinkingConfig = { includeThoughts: true };
if (options.thinking.level !== undefined) {
thinkingConfig.thinkingLevel = options.thinking.level;
} else if (options.thinking.budgetTokens !== undefined) {
thinkingConfig.thinkingBudget = options.thinking.budgetTokens;
}
config.thinkingConfig = thinkingConfig;
}
if (options.signal) {