mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-30 20:50:34 +00:00
refactor: move contextWindowSize to ContentGeneratorConfig
- Add contextWindowSize field to ContentGeneratorConfig interface - Update tokenLimit function to accept contentGeneratorConfig parameter - Implement priority logic: user config > auto-detection - Update chatCompressionService to use new API via getContentGeneratorConfig() - Add contextWindowSize to MODEL_GENERATION_CONFIG_FIELDS for config resolution - Add contextWindowSize to CLI settings schema (model.generationConfig) - Update UI components (Footer, ContextUsageDisplay) to use new config API - Fix test mocks to include getContentGeneratorConfig method This refactor avoids modifying 71+ test files by moving the config to the generator level instead of the Config class level. Modified files: - packages/core/src/core/contentGenerator.ts - packages/core/src/core/tokenLimits.ts - packages/core/src/services/chatCompressionService.ts - packages/core/src/services/chatCompressionService.test.ts - packages/core/src/models/constants.ts - packages/cli/src/config/settingsSchema.ts - packages/cli/src/ui/components/ContextUsageDisplay.tsx - packages/cli/src/ui/components/Footer.tsx
This commit is contained in:
parent
52d6d1ff13
commit
a684f07ff4
8 changed files with 42 additions and 3 deletions
|
|
@ -6,18 +6,22 @@
|
|||
|
||||
import { Text } from 'ink';
|
||||
import { theme } from '../semantic-colors.js';
|
||||
import { tokenLimit } from '@qwen-code/qwen-code-core';
|
||||
import { tokenLimit, type Config } from '@qwen-code/qwen-code-core';
|
||||
|
||||
export const ContextUsageDisplay = ({
|
||||
promptTokenCount,
|
||||
model,
|
||||
terminalWidth,
|
||||
config,
|
||||
}: {
|
||||
promptTokenCount: number;
|
||||
model: string;
|
||||
terminalWidth: number;
|
||||
config: Config;
|
||||
}) => {
|
||||
const percentage = promptTokenCount / tokenLimit(model);
|
||||
const contentGeneratorConfig = config.getContentGeneratorConfig();
|
||||
const contextLimit = tokenLimit(model, 'input', contentGeneratorConfig);
|
||||
const percentage = promptTokenCount / contextLimit;
|
||||
const percentageLeft = ((1 - percentage) * 100).toFixed(0);
|
||||
|
||||
const label = terminalWidth < 100 ? '%' : '% context left';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue