mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-05 23:42:03 +00:00
fix: update contextWindowSize and maxOutputTokens when switching models
- Fix handleModelChange to update contextWindowSize and maxOutputTokens during hot-update - Fix dashscope.ts to use contentGeneratorConfig.maxOutputTokens instead of tokenLimit() - Fix acpAgent.ts to use model-specific contextLimit for each model - Add comprehensive tests for model switching scenarios - Fix all TypeScript type errors (index signature and ConfigSource types) - Fix all ESLint errors (remove 'any' types)
This commit is contained in:
parent
8725b91e11
commit
8538f12689
4 changed files with 217 additions and 14 deletions
|
|
@ -15,6 +15,7 @@ import {
|
|||
qwenOAuth2Events,
|
||||
MCPServerConfig,
|
||||
SessionService,
|
||||
tokenLimit,
|
||||
type Config,
|
||||
type ConversationRecord,
|
||||
type DeviceAuthorizationData,
|
||||
|
|
@ -373,17 +374,14 @@ class GeminiAgent {
|
|||
).trim();
|
||||
const availableModels = config.getAvailableModels();
|
||||
|
||||
// Get the contentGeneratorConfig which contains contextWindowSize
|
||||
// This value is either user-configured or auto-detected during config initialization
|
||||
const contentGeneratorConfig = config.getContentGeneratorConfig();
|
||||
|
||||
const mappedAvailableModels = availableModels.map((model) => ({
|
||||
modelId: model.id,
|
||||
name: model.label,
|
||||
description: model.description ?? null,
|
||||
_meta: {
|
||||
// Use the contextWindowSize from config, which is always set during initialization
|
||||
contextLimit: contentGeneratorConfig?.contextWindowSize,
|
||||
// Each model should have its own context window size based on its capabilities
|
||||
// Use tokenLimit to get the model-specific context window size
|
||||
contextLimit: tokenLimit(model.id, 'input'),
|
||||
},
|
||||
}));
|
||||
|
||||
|
|
@ -396,7 +394,8 @@ class GeminiAgent {
|
|||
name: currentModelId,
|
||||
description: null,
|
||||
_meta: {
|
||||
contextLimit: contentGeneratorConfig?.contextWindowSize,
|
||||
// Get context window size specific to the current model
|
||||
contextLimit: tokenLimit(currentModelId, 'input'),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue