mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-23 03:24:42 -07:00
Add ModelChain support to ModelConfigService and make ModelDialog dynamic (#22914)
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
import type { GenerateContentConfig } from '@google/genai';
|
||||
import type { ModelPolicy } from '../availability/modelPolicy.js';
|
||||
|
||||
// The primary key for the ModelConfig is the model string. However, we also
|
||||
// support a secondary key to limit the override scope, typically an agent name.
|
||||
@@ -111,6 +112,7 @@ export interface ModelConfigServiceConfig {
|
||||
modelDefinitions?: Record<string, ModelDefinition>;
|
||||
modelIdResolutions?: Record<string, ModelResolution>;
|
||||
classifierIdResolutions?: Record<string, ModelResolution>;
|
||||
modelChains?: Record<string, ModelPolicy[]>;
|
||||
}
|
||||
|
||||
const MAX_ALIAS_CHAIN_DEPTH = 100;
|
||||
@@ -221,6 +223,29 @@ export class ModelConfigService {
|
||||
return resolution.default;
|
||||
}
|
||||
|
||||
getModelChain(chainName: string): ModelPolicy[] | undefined {
|
||||
return this.config.modelChains?.[chainName];
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a chain template and resolves all model IDs within it
|
||||
* based on the provided context.
|
||||
*/
|
||||
resolveChain(
|
||||
chainName: string,
|
||||
context: ResolutionContext = {},
|
||||
): ModelPolicy[] | undefined {
|
||||
const template = this.config.modelChains?.[chainName];
|
||||
if (!template) {
|
||||
return undefined;
|
||||
}
|
||||
// Map through the template and resolve each model ID
|
||||
return template.map((policy) => ({
|
||||
...policy,
|
||||
model: this.resolveModelId(policy.model, context),
|
||||
}));
|
||||
}
|
||||
|
||||
registerRuntimeModelConfig(aliasName: string, alias: ModelConfigAlias): void {
|
||||
this.runtimeAliases[aliasName] = alias;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user