refactor: Use default centralized Flash & Pro models everywhere (#994)
This commit is contained in:
parent
f8a31f29aa
commit
7bcc60e996
|
@ -15,6 +15,8 @@ import {
|
||||||
ApprovalMode,
|
ApprovalMode,
|
||||||
ContentGeneratorConfig,
|
ContentGeneratorConfig,
|
||||||
GEMINI_CONFIG_DIR as GEMINI_DIR,
|
GEMINI_CONFIG_DIR as GEMINI_DIR,
|
||||||
|
DEFAULT_GEMINI_MODEL,
|
||||||
|
DEFAULT_GEMINI_EMBEDDING_MODEL,
|
||||||
} from '@gemini-cli/core';
|
} from '@gemini-cli/core';
|
||||||
import { Settings } from './settings.js';
|
import { Settings } from './settings.js';
|
||||||
import { getEffectiveModel } from '../utils/modelCheck.js';
|
import { getEffectiveModel } from '../utils/modelCheck.js';
|
||||||
|
@ -34,10 +36,6 @@ const logger = {
|
||||||
error: (...args: any[]) => console.error('[ERROR]', ...args),
|
error: (...args: any[]) => console.error('[ERROR]', ...args),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DEFAULT_GEMINI_MODEL = 'gemini-2.5-pro-preview-06-05';
|
|
||||||
export const DEFAULT_GEMINI_FLASH_MODEL = 'gemini-2.5-flash-preview-05-20';
|
|
||||||
export const DEFAULT_GEMINI_EMBEDDING_MODEL = 'gemini-embedding-001';
|
|
||||||
|
|
||||||
interface CliArgs {
|
interface CliArgs {
|
||||||
model: string | undefined;
|
model: string | undefined;
|
||||||
sandbox: boolean | string | undefined;
|
sandbox: boolean | string | undefined;
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { getEffectiveModel } from './modelCheck.js';
|
||||||
import {
|
import {
|
||||||
DEFAULT_GEMINI_MODEL,
|
DEFAULT_GEMINI_MODEL,
|
||||||
DEFAULT_GEMINI_FLASH_MODEL,
|
DEFAULT_GEMINI_FLASH_MODEL,
|
||||||
} from '../config/config.js';
|
} from '@gemini-cli/core';
|
||||||
|
|
||||||
// Mock global fetch
|
// Mock global fetch
|
||||||
global.fetch = vi.fn();
|
global.fetch = vi.fn();
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
import {
|
import {
|
||||||
DEFAULT_GEMINI_MODEL,
|
DEFAULT_GEMINI_MODEL,
|
||||||
DEFAULT_GEMINI_FLASH_MODEL,
|
DEFAULT_GEMINI_FLASH_MODEL,
|
||||||
} from '../config/config.js';
|
} from '@gemini-cli/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the default "pro" model is rate-limited and returns a fallback "flash"
|
* Checks if the default "pro" model is rate-limited and returns a fallback "flash"
|
||||||
|
|
|
@ -5,3 +5,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export * from './src/index.js';
|
export * from './src/index.js';
|
||||||
|
export {
|
||||||
|
DEFAULT_GEMINI_MODEL,
|
||||||
|
DEFAULT_GEMINI_FLASH_MODEL,
|
||||||
|
DEFAULT_GEMINI_EMBEDDING_MODEL,
|
||||||
|
} from './src/config/models.js';
|
||||||
|
|
|
@ -24,6 +24,7 @@ import { GEMINI_CONFIG_DIR as GEMINI_DIR } from '../tools/memoryTool.js';
|
||||||
import { FileDiscoveryService } from '../services/fileDiscoveryService.js';
|
import { FileDiscoveryService } from '../services/fileDiscoveryService.js';
|
||||||
import { GitService } from '../services/gitService.js';
|
import { GitService } from '../services/gitService.js';
|
||||||
import { initializeTelemetry } from '../telemetry/index.js';
|
import { initializeTelemetry } from '../telemetry/index.js';
|
||||||
|
import { DEFAULT_GEMINI_EMBEDDING_MODEL } from './models.js';
|
||||||
|
|
||||||
export enum ApprovalMode {
|
export enum ApprovalMode {
|
||||||
DEFAULT = 'default',
|
DEFAULT = 'default',
|
||||||
|
@ -55,7 +56,7 @@ export class MCPServerConfig {
|
||||||
export interface ConfigParameters {
|
export interface ConfigParameters {
|
||||||
sessionId: string;
|
sessionId: string;
|
||||||
contentGeneratorConfig: ContentGeneratorConfig;
|
contentGeneratorConfig: ContentGeneratorConfig;
|
||||||
embeddingModel: string;
|
embeddingModel?: string;
|
||||||
sandbox?: boolean | string;
|
sandbox?: boolean | string;
|
||||||
targetDir: string;
|
targetDir: string;
|
||||||
debugMode: boolean;
|
debugMode: boolean;
|
||||||
|
@ -121,7 +122,8 @@ export class Config {
|
||||||
constructor(params: ConfigParameters) {
|
constructor(params: ConfigParameters) {
|
||||||
this.sessionId = params.sessionId;
|
this.sessionId = params.sessionId;
|
||||||
this.contentGeneratorConfig = params.contentGeneratorConfig;
|
this.contentGeneratorConfig = params.contentGeneratorConfig;
|
||||||
this.embeddingModel = params.embeddingModel;
|
this.embeddingModel =
|
||||||
|
params.embeddingModel ?? DEFAULT_GEMINI_EMBEDDING_MODEL;
|
||||||
this.sandbox = params.sandbox;
|
this.sandbox = params.sandbox;
|
||||||
this.targetDir = path.resolve(params.targetDir);
|
this.targetDir = path.resolve(params.targetDir);
|
||||||
this.debugMode = params.debugMode;
|
this.debugMode = params.debugMode;
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2025 Google LLC
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const DEFAULT_GEMINI_MODEL = 'gemini-2.5-pro-preview-06-05';
|
||||||
|
export const DEFAULT_GEMINI_FLASH_MODEL = 'gemini-2.5-flash-preview-05-20';
|
||||||
|
export const DEFAULT_GEMINI_EMBEDDING_MODEL = 'gemini-embedding-001';
|
|
@ -18,6 +18,7 @@ import { GeminiChat } from './geminiChat.js';
|
||||||
import { Config } from '../config/config.js';
|
import { Config } from '../config/config.js';
|
||||||
import { Turn } from './turn.js';
|
import { Turn } from './turn.js';
|
||||||
import { getCoreSystemPrompt } from './prompts.js';
|
import { getCoreSystemPrompt } from './prompts.js';
|
||||||
|
import { DEFAULT_GEMINI_FLASH_MODEL } from '../config/models.js';
|
||||||
|
|
||||||
// --- Mocks ---
|
// --- Mocks ---
|
||||||
const mockChatCreateFn = vi.fn();
|
const mockChatCreateFn = vi.fn();
|
||||||
|
@ -295,7 +296,7 @@ describe('Gemini Client (client.ts)', () => {
|
||||||
await client.generateJson(contents, schema, abortSignal);
|
await client.generateJson(contents, schema, abortSignal);
|
||||||
|
|
||||||
expect(mockGenerateContentFn).toHaveBeenCalledWith({
|
expect(mockGenerateContentFn).toHaveBeenCalledWith({
|
||||||
model: 'gemini-2.0-flash',
|
model: DEFAULT_GEMINI_FLASH_MODEL,
|
||||||
config: {
|
config: {
|
||||||
abortSignal,
|
abortSignal,
|
||||||
systemInstruction: getCoreSystemPrompt(''),
|
systemInstruction: getCoreSystemPrompt(''),
|
||||||
|
|
|
@ -31,6 +31,7 @@ import {
|
||||||
createContentGenerator,
|
createContentGenerator,
|
||||||
} from './contentGenerator.js';
|
} from './contentGenerator.js';
|
||||||
import { ProxyAgent, setGlobalDispatcher } from 'undici';
|
import { ProxyAgent, setGlobalDispatcher } from 'undici';
|
||||||
|
import { DEFAULT_GEMINI_FLASH_MODEL } from '../config/models.js';
|
||||||
|
|
||||||
export class GeminiClient {
|
export class GeminiClient {
|
||||||
private chat: Promise<GeminiChat>;
|
private chat: Promise<GeminiChat>;
|
||||||
|
@ -215,7 +216,7 @@ export class GeminiClient {
|
||||||
contents: Content[],
|
contents: Content[],
|
||||||
schema: SchemaUnion,
|
schema: SchemaUnion,
|
||||||
abortSignal: AbortSignal,
|
abortSignal: AbortSignal,
|
||||||
model: string = 'gemini-2.0-flash',
|
model: string = DEFAULT_GEMINI_FLASH_MODEL,
|
||||||
config: GenerateContentConfig = {},
|
config: GenerateContentConfig = {},
|
||||||
): Promise<Record<string, unknown>> {
|
): Promise<Record<string, unknown>> {
|
||||||
const cg = await this.contentGenerator;
|
const cg = await this.contentGenerator;
|
||||||
|
|
|
@ -13,8 +13,9 @@ import {
|
||||||
import { GeminiClient } from '../core/client.js';
|
import { GeminiClient } from '../core/client.js';
|
||||||
import { EditToolParams } from '../tools/edit.js';
|
import { EditToolParams } from '../tools/edit.js';
|
||||||
import { LruCache } from './LruCache.js';
|
import { LruCache } from './LruCache.js';
|
||||||
|
import { DEFAULT_GEMINI_FLASH_MODEL } from '../config/models.js';
|
||||||
|
|
||||||
const EditModel = 'gemini-2.5-flash-preview-04-17';
|
const EditModel = DEFAULT_GEMINI_FLASH_MODEL;
|
||||||
const EditConfig: GenerateContentConfig = {
|
const EditConfig: GenerateContentConfig = {
|
||||||
thinkingConfig: {
|
thinkingConfig: {
|
||||||
thinkingBudget: 0,
|
thinkingBudget: 0,
|
||||||
|
|
Loading…
Reference in New Issue