mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-03 00:14:28 -07:00
fix: add flash lite with respect to api defaults (#4652)
Co-authored-by: Gal Zahavi <38544478+galz10@users.noreply.github.com>
This commit is contained in:
@@ -9,3 +9,6 @@ export const DEFAULT_GEMINI_FLASH_MODEL = 'gemini-2.5-flash';
|
|||||||
export const DEFAULT_GEMINI_FLASH_LITE_MODEL = 'gemini-2.5-flash-lite';
|
export const DEFAULT_GEMINI_FLASH_LITE_MODEL = 'gemini-2.5-flash-lite';
|
||||||
|
|
||||||
export const DEFAULT_GEMINI_EMBEDDING_MODEL = 'gemini-embedding-001';
|
export const DEFAULT_GEMINI_EMBEDDING_MODEL = 'gemini-embedding-001';
|
||||||
|
|
||||||
|
// Some thinking models do not default to dynamic thinking which is done by a value of -1
|
||||||
|
export const DEFAULT_THINKING_MODE = -1;
|
||||||
|
|||||||
@@ -22,7 +22,12 @@ import type {
|
|||||||
Part,
|
Part,
|
||||||
} from '@google/genai';
|
} from '@google/genai';
|
||||||
import { GoogleGenAI } from '@google/genai';
|
import { GoogleGenAI } from '@google/genai';
|
||||||
import { findIndexAfterFraction, GeminiClient } from './client.js';
|
import {
|
||||||
|
findIndexAfterFraction,
|
||||||
|
isThinkingDefault,
|
||||||
|
isThinkingSupported,
|
||||||
|
GeminiClient,
|
||||||
|
} from './client.js';
|
||||||
import {
|
import {
|
||||||
AuthType,
|
AuthType,
|
||||||
type ContentGenerator,
|
type ContentGenerator,
|
||||||
@@ -162,6 +167,40 @@ describe('findIndexAfterFraction', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('isThinkingSupported', () => {
|
||||||
|
it('should return true for gemini-2.5', () => {
|
||||||
|
expect(isThinkingSupported('gemini-2.5')).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return true for gemini-2.5-pro', () => {
|
||||||
|
expect(isThinkingSupported('gemini-2.5-pro')).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false for other models', () => {
|
||||||
|
expect(isThinkingSupported('gemini-1.5-flash')).toBe(false);
|
||||||
|
expect(isThinkingSupported('some-other-model')).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('isThinkingDefault', () => {
|
||||||
|
it('should return false for gemini-2.5-flash-lite', () => {
|
||||||
|
expect(isThinkingDefault('gemini-2.5-flash-lite')).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return true for gemini-2.5', () => {
|
||||||
|
expect(isThinkingDefault('gemini-2.5')).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return true for gemini-2.5-pro', () => {
|
||||||
|
expect(isThinkingDefault('gemini-2.5-pro')).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false for other models', () => {
|
||||||
|
expect(isThinkingDefault('gemini-1.5-flash')).toBe(false);
|
||||||
|
expect(isThinkingDefault('some-other-model')).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('Gemini Client (client.ts)', () => {
|
describe('Gemini Client (client.ts)', () => {
|
||||||
let client: GeminiClient;
|
let client: GeminiClient;
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
|||||||
@@ -36,7 +36,10 @@ import type {
|
|||||||
} from './contentGenerator.js';
|
} from './contentGenerator.js';
|
||||||
import { AuthType, createContentGenerator } from './contentGenerator.js';
|
import { AuthType, createContentGenerator } from './contentGenerator.js';
|
||||||
import { ProxyAgent, setGlobalDispatcher } from 'undici';
|
import { ProxyAgent, setGlobalDispatcher } from 'undici';
|
||||||
import { DEFAULT_GEMINI_FLASH_MODEL } from '../config/models.js';
|
import {
|
||||||
|
DEFAULT_GEMINI_FLASH_MODEL,
|
||||||
|
DEFAULT_THINKING_MODE,
|
||||||
|
} from '../config/models.js';
|
||||||
import { LoopDetectionService } from '../services/loopDetectionService.js';
|
import { LoopDetectionService } from '../services/loopDetectionService.js';
|
||||||
import { ideContext } from '../ide/ideContext.js';
|
import { ideContext } from '../ide/ideContext.js';
|
||||||
import {
|
import {
|
||||||
@@ -51,7 +54,13 @@ import {
|
|||||||
} from '../telemetry/types.js';
|
} from '../telemetry/types.js';
|
||||||
import type { IdeContext, File } from '../ide/ideContext.js';
|
import type { IdeContext, File } from '../ide/ideContext.js';
|
||||||
|
|
||||||
function isThinkingSupported(model: string) {
|
export function isThinkingSupported(model: string) {
|
||||||
|
if (model.startsWith('gemini-2.5')) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isThinkingDefault(model: string) {
|
||||||
|
if (model.startsWith('gemini-2.5-flash-lite')) return false;
|
||||||
if (model.startsWith('gemini-2.5')) return true;
|
if (model.startsWith('gemini-2.5')) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -245,14 +254,16 @@ export class GeminiClient {
|
|||||||
try {
|
try {
|
||||||
const userMemory = this.config.getUserMemory();
|
const userMemory = this.config.getUserMemory();
|
||||||
const systemInstruction = getCoreSystemPrompt(userMemory);
|
const systemInstruction = getCoreSystemPrompt(userMemory);
|
||||||
const generateContentConfigWithThinking = isThinkingSupported(
|
const model = this.config.getModel();
|
||||||
this.config.getModel(),
|
const generateContentConfigWithThinking = isThinkingSupported(model)
|
||||||
)
|
|
||||||
? {
|
? {
|
||||||
...this.generateContentConfig,
|
...this.generateContentConfig,
|
||||||
thinkingConfig: {
|
thinkingConfig: {
|
||||||
thinkingBudget: -1,
|
thinkingBudget: -1,
|
||||||
includeThoughts: true,
|
includeThoughts: true,
|
||||||
|
...(!isThinkingDefault(model)
|
||||||
|
? { thinkingBudget: DEFAULT_THINKING_MODE }
|
||||||
|
: {}),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
: this.generateContentConfig;
|
: this.generateContentConfig;
|
||||||
|
|||||||
Reference in New Issue
Block a user