mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-22 02:54:31 -07:00
[Gemma x Gemini CLI] Add an Experimental Gemma Router that uses a LiteRT-LM shim into the Composite Model Classifier Strategy (#17231)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Allen Hutchison <adh@google.com>
This commit is contained in:
@@ -4,10 +4,12 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { GemmaClassifierStrategy } from './strategies/gemmaClassifierStrategy.js';
|
||||
import type { Config } from '../config/config.js';
|
||||
import type {
|
||||
RoutingContext,
|
||||
RoutingDecision,
|
||||
RoutingStrategy,
|
||||
TerminalStrategy,
|
||||
} from './routingStrategy.js';
|
||||
import { DefaultStrategy } from './strategies/defaultStrategy.js';
|
||||
@@ -35,17 +37,31 @@ export class ModelRouterService {
|
||||
}
|
||||
|
||||
private initializeDefaultStrategy(): TerminalStrategy {
|
||||
// Initialize the composite strategy with the desired priority order.
|
||||
// The strategies are ordered in order of highest priority.
|
||||
const strategies: RoutingStrategy[] = [];
|
||||
|
||||
// Order matters here. Fallback and override are checked first.
|
||||
strategies.push(new FallbackStrategy());
|
||||
strategies.push(new OverrideStrategy());
|
||||
|
||||
// Approval mode is next.
|
||||
strategies.push(new ApprovalModeStrategy());
|
||||
|
||||
// Then, if enabled, the Gemma classifier is used.
|
||||
if (this.config.getGemmaModelRouterSettings()?.enabled) {
|
||||
strategies.push(new GemmaClassifierStrategy());
|
||||
}
|
||||
|
||||
// The generic classifier is next.
|
||||
strategies.push(new ClassifierStrategy());
|
||||
|
||||
// The numerical classifier is next.
|
||||
strategies.push(new NumericalClassifierStrategy());
|
||||
|
||||
// The default strategy is the terminal strategy.
|
||||
const terminalStrategy = new DefaultStrategy();
|
||||
|
||||
return new CompositeStrategy(
|
||||
[
|
||||
new FallbackStrategy(),
|
||||
new OverrideStrategy(),
|
||||
new ApprovalModeStrategy(),
|
||||
new ClassifierStrategy(),
|
||||
new NumericalClassifierStrategy(),
|
||||
new DefaultStrategy(),
|
||||
],
|
||||
[...strategies, terminalStrategy],
|
||||
'agent-router',
|
||||
);
|
||||
}
|
||||
@@ -75,6 +91,7 @@ export class ModelRouterService {
|
||||
context,
|
||||
this.config,
|
||||
this.config.getBaseLlmClient(),
|
||||
this.config.getLocalLiteRtLmClient(),
|
||||
);
|
||||
|
||||
debugLogger.debug(
|
||||
|
||||
Reference in New Issue
Block a user