mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
fix(core): Allow model to be set from settings.json (#5527)
This commit is contained in:
@@ -917,6 +917,68 @@ describe('loadCliConfig extensions', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('loadCliConfig model selection', () => {
|
||||||
|
it('selects a model from settings.json if provided', async () => {
|
||||||
|
process.argv = ['node', 'script.js'];
|
||||||
|
const argv = await parseArguments();
|
||||||
|
const config = await loadCliConfig(
|
||||||
|
{
|
||||||
|
model: 'gemini-9001-ultra',
|
||||||
|
},
|
||||||
|
[],
|
||||||
|
'test-session',
|
||||||
|
argv,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(config.getModel()).toBe('gemini-9001-ultra');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('uses the default gemini model if nothing is set', async () => {
|
||||||
|
process.argv = ['node', 'script.js']; // No model set.
|
||||||
|
const argv = await parseArguments();
|
||||||
|
const config = await loadCliConfig(
|
||||||
|
{
|
||||||
|
// No model set.
|
||||||
|
},
|
||||||
|
[],
|
||||||
|
'test-session',
|
||||||
|
argv,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(config.getModel()).toBe('gemini-2.5-pro');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('always prefers model from argvs', async () => {
|
||||||
|
process.argv = ['node', 'script.js', '--model', 'gemini-8675309-ultra'];
|
||||||
|
const argv = await parseArguments();
|
||||||
|
const config = await loadCliConfig(
|
||||||
|
{
|
||||||
|
model: 'gemini-9001-ultra',
|
||||||
|
},
|
||||||
|
[],
|
||||||
|
'test-session',
|
||||||
|
argv,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(config.getModel()).toBe('gemini-8675309-ultra');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('selects the model from argvs if provided', async () => {
|
||||||
|
process.argv = ['node', 'script.js', '--model', 'gemini-8675309-ultra'];
|
||||||
|
const argv = await parseArguments();
|
||||||
|
const config = await loadCliConfig(
|
||||||
|
{
|
||||||
|
// No model provided via settings.
|
||||||
|
},
|
||||||
|
[],
|
||||||
|
'test-session',
|
||||||
|
argv,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(config.getModel()).toBe('gemini-8675309-ultra');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('loadCliConfig ideModeFeature', () => {
|
describe('loadCliConfig ideModeFeature', () => {
|
||||||
const originalArgv = process.argv;
|
const originalArgv = process.argv;
|
||||||
const originalEnv = { ...process.env };
|
const originalEnv = { ...process.env };
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export async function parseArguments(): Promise<CliArgs> {
|
|||||||
alias: 'm',
|
alias: 'm',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: `Model`,
|
description: `Model`,
|
||||||
default: process.env.GEMINI_MODEL || DEFAULT_GEMINI_MODEL,
|
default: process.env.GEMINI_MODEL,
|
||||||
})
|
})
|
||||||
.option('prompt', {
|
.option('prompt', {
|
||||||
alias: 'p',
|
alias: 'p',
|
||||||
@@ -444,7 +444,7 @@ export async function loadCliConfig(
|
|||||||
cwd: process.cwd(),
|
cwd: process.cwd(),
|
||||||
fileDiscoveryService: fileService,
|
fileDiscoveryService: fileService,
|
||||||
bugCommand: settings.bugCommand,
|
bugCommand: settings.bugCommand,
|
||||||
model: argv.model!,
|
model: argv.model || settings.model || DEFAULT_GEMINI_MODEL,
|
||||||
extensionContextFilePaths,
|
extensionContextFilePaths,
|
||||||
maxSessionTurns: settings.maxSessionTurns ?? -1,
|
maxSessionTurns: settings.maxSessionTurns ?? -1,
|
||||||
experimentalAcp: argv.experimentalAcp || false,
|
experimentalAcp: argv.experimentalAcp || false,
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ export interface Settings {
|
|||||||
bugCommand?: BugCommandSettings;
|
bugCommand?: BugCommandSettings;
|
||||||
checkpointing?: CheckpointingSettings;
|
checkpointing?: CheckpointingSettings;
|
||||||
autoConfigureMaxOldSpaceSize?: boolean;
|
autoConfigureMaxOldSpaceSize?: boolean;
|
||||||
|
/** The model name to use (e.g 'gemini-9.0-pro') */
|
||||||
|
model?: string;
|
||||||
|
|
||||||
// Git-aware file filtering settings
|
// Git-aware file filtering settings
|
||||||
fileFiltering?: {
|
fileFiltering?: {
|
||||||
|
|||||||
Reference in New Issue
Block a user