mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-28 15:01:14 -07:00
feat(core): fallback to chat-base when using unrecognized models for chat (#19016)
This commit is contained in:
@@ -729,6 +729,71 @@ describe('ModelConfigService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('fallback behavior', () => {
|
||||
it('should fallback to chat-base if the requested model is completely unknown', () => {
|
||||
const config: ModelConfigServiceConfig = {
|
||||
aliases: {
|
||||
'chat-base': {
|
||||
modelConfig: {
|
||||
model: 'default-fallback-model',
|
||||
generateContentConfig: {
|
||||
temperature: 0.99,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const service = new ModelConfigService(config);
|
||||
const resolved = service.getResolvedConfig({
|
||||
model: 'my-custom-model',
|
||||
isChatModel: true,
|
||||
});
|
||||
|
||||
// It preserves the requested model name, but inherits the config from chat-base
|
||||
expect(resolved.model).toBe('my-custom-model');
|
||||
expect(resolved.generateContentConfig).toEqual({
|
||||
temperature: 0.99,
|
||||
});
|
||||
});
|
||||
|
||||
it('should return empty config if requested model is unknown and chat-base is not defined', () => {
|
||||
const config: ModelConfigServiceConfig = {
|
||||
aliases: {},
|
||||
};
|
||||
const service = new ModelConfigService(config);
|
||||
const resolved = service.getResolvedConfig({
|
||||
model: 'my-custom-model',
|
||||
isChatModel: true,
|
||||
});
|
||||
|
||||
expect(resolved.model).toBe('my-custom-model');
|
||||
expect(resolved.generateContentConfig).toEqual({});
|
||||
});
|
||||
|
||||
it('should NOT fallback to chat-base if the requested model is completely unknown but isChatModel is false', () => {
|
||||
const config: ModelConfigServiceConfig = {
|
||||
aliases: {
|
||||
'chat-base': {
|
||||
modelConfig: {
|
||||
model: 'default-fallback-model',
|
||||
generateContentConfig: {
|
||||
temperature: 0.99,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const service = new ModelConfigService(config);
|
||||
const resolved = service.getResolvedConfig({
|
||||
model: 'my-custom-model',
|
||||
isChatModel: false,
|
||||
});
|
||||
|
||||
expect(resolved.model).toBe('my-custom-model');
|
||||
expect(resolved.generateContentConfig).toEqual({});
|
||||
});
|
||||
});
|
||||
|
||||
describe('unrecognized models', () => {
|
||||
it('should apply overrides to unrecognized model names', () => {
|
||||
const unregisteredModelName = 'my-unregistered-model-v1';
|
||||
|
||||
Reference in New Issue
Block a user