feat(context): 根据模型动态设置 contextLimit
- AgentConfig 添加 contextWindow 字段 - ProviderRegistry 添加 getModelInfo() 方法查询模型信息 - loadConfig() 从 ProviderRegistry 获取模型的 contextWindow - Agent 构造函数使用 contextWindow 初始化压缩管理器 效果: - Anthropic Claude: 168k (200k - 32k 输出预留) - DeepSeek: 32k (64k - 32k 输出预留) - 未知模型回退到默认 200k
This commit is contained in:
@@ -121,6 +121,10 @@ export function loadConfig(): AgentConfig {
|
||||
// 确定 baseUrl
|
||||
const finalBaseUrl = storedConfig.baseUrl || providerConfig?.baseUrl;
|
||||
|
||||
// 获取模型的 contextWindow(从 ProviderRegistry 查询)
|
||||
const modelInfo = providerRegistry.getModelInfo(finalProvider, finalModel);
|
||||
const contextWindow = modelInfo?.contextWindow;
|
||||
|
||||
return {
|
||||
provider: finalProvider,
|
||||
apiKey: finalApiKey,
|
||||
@@ -128,6 +132,7 @@ export function loadConfig(): AgentConfig {
|
||||
maxTokens: storedConfig.maxTokens || 4096,
|
||||
systemPrompt: DEFAULT_SYSTEM_PROMPT,
|
||||
baseUrl: finalBaseUrl,
|
||||
contextWindow,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user