mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-11 22:51:00 -07:00
log fallback mode (#15817)
This commit is contained in:
@@ -133,8 +133,7 @@ export function useQuotaAndFallback({
|
|||||||
// Set the model to the fallback model for the current session.
|
// Set the model to the fallback model for the current session.
|
||||||
// This ensures the Footer updates and future turns use this model.
|
// This ensures the Footer updates and future turns use this model.
|
||||||
// The change is not persisted, so the original model is restored on restart.
|
// The change is not persisted, so the original model is restored on restart.
|
||||||
config.setModel(proQuotaRequest.fallbackModel, true);
|
config.activateFallbackMode(proQuotaRequest.fallbackModel);
|
||||||
|
|
||||||
historyManager.addItem(
|
historyManager.addItem(
|
||||||
{
|
{
|
||||||
type: MessageType.INFO,
|
type: MessageType.INFO,
|
||||||
|
|||||||
@@ -60,8 +60,11 @@ import { ideContextStore } from '../ide/ideContext.js';
|
|||||||
import { WriteTodosTool } from '../tools/write-todos.js';
|
import { WriteTodosTool } from '../tools/write-todos.js';
|
||||||
import type { FileSystemService } from '../services/fileSystemService.js';
|
import type { FileSystemService } from '../services/fileSystemService.js';
|
||||||
import { StandardFileSystemService } from '../services/fileSystemService.js';
|
import { StandardFileSystemService } from '../services/fileSystemService.js';
|
||||||
import { logRipgrepFallback } from '../telemetry/loggers.js';
|
import { logRipgrepFallback, logFlashFallback } from '../telemetry/loggers.js';
|
||||||
import { RipgrepFallbackEvent } from '../telemetry/types.js';
|
import {
|
||||||
|
RipgrepFallbackEvent,
|
||||||
|
FlashFallbackEvent,
|
||||||
|
} from '../telemetry/types.js';
|
||||||
import type { FallbackModelHandler } from '../fallback/types.js';
|
import type { FallbackModelHandler } from '../fallback/types.js';
|
||||||
import { ModelAvailabilityService } from '../availability/modelAvailabilityService.js';
|
import { ModelAvailabilityService } from '../availability/modelAvailabilityService.js';
|
||||||
import { ModelRouterService } from '../routing/modelRouterService.js';
|
import { ModelRouterService } from '../routing/modelRouterService.js';
|
||||||
@@ -911,6 +914,14 @@ export class Config {
|
|||||||
this.modelAvailabilityService.reset();
|
this.modelAvailabilityService.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
activateFallbackMode(model: string): void {
|
||||||
|
this.setModel(model, true);
|
||||||
|
const authType = this.getContentGeneratorConfig()?.authType;
|
||||||
|
if (authType) {
|
||||||
|
logFlashFallback(this, new FlashFallbackEvent(authType));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getActiveModel(): string {
|
getActiveModel(): string {
|
||||||
return this._activeModel ?? this.model;
|
return this._activeModel ?? this.model;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,16 @@
|
|||||||
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
||||||
import { Config } from './config.js';
|
import { Config } from './config.js';
|
||||||
import { DEFAULT_GEMINI_MODEL, DEFAULT_GEMINI_FLASH_MODEL } from './models.js';
|
import { DEFAULT_GEMINI_MODEL, DEFAULT_GEMINI_FLASH_MODEL } from './models.js';
|
||||||
|
import { logFlashFallback } from '../telemetry/loggers.js';
|
||||||
|
import { FlashFallbackEvent } from '../telemetry/types.js';
|
||||||
|
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
|
|
||||||
vi.mock('node:fs');
|
vi.mock('node:fs');
|
||||||
|
vi.mock('../telemetry/loggers.js', () => ({
|
||||||
|
logFlashFallback: vi.fn(),
|
||||||
|
logRipgrepFallback: vi.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('Flash Model Fallback Configuration', () => {
|
describe('Flash Model Fallback Configuration', () => {
|
||||||
let config: Config;
|
let config: Config;
|
||||||
@@ -57,4 +63,15 @@ describe('Flash Model Fallback Configuration', () => {
|
|||||||
expect(newConfig.getModel()).toBe('custom-model');
|
expect(newConfig.getModel()).toBe('custom-model');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('activateFallbackMode', () => {
|
||||||
|
it('should set model to fallback and log event', () => {
|
||||||
|
config.activateFallbackMode(DEFAULT_GEMINI_FLASH_MODEL);
|
||||||
|
expect(config.getModel()).toBe(DEFAULT_GEMINI_FLASH_MODEL);
|
||||||
|
expect(logFlashFallback).toHaveBeenCalledWith(
|
||||||
|
config,
|
||||||
|
expect.any(FlashFallbackEvent),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user