refactor(convert): 使用固定阈值替换环境变量配置
移除对环境变量的依赖,改为使用代码中定义的固定阈值来判断推理努力程度。这简化了配置并提高了代码的可维护性。
This commit is contained in:
parent
917d89bffa
commit
bf573bb8f5
3 changed files with 39 additions and 32 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,5 +1,4 @@
|
|||
node_modules
|
||||
config.json
|
||||
.serena/
|
||||
.claude/
|
||||
CLAUDE.md
|
||||
25
config.json
Normal file
25
config.json
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"REQUIRED_API_KEY": "123456",
|
||||
"SERVER_PORT": 3000,
|
||||
"HOST": "127.0.0.1",
|
||||
"MODEL_PROVIDER": "gemini-cli-oauth",
|
||||
"OPENAI_API_KEY": "xxx",
|
||||
"OPENAI_BASE_URL": "https://openai/v1",
|
||||
"CLAUDE_API_KEY": "xxx",
|
||||
"CLAUDE_BASE_URL": "https://anthropic/v1",
|
||||
"PROJECT_ID": null,
|
||||
"GEMINI_OAUTH_CREDS_BASE64": null,
|
||||
"GEMINI_OAUTH_CREDS_FILE_PATH": null,
|
||||
"KIRO_OAUTH_CREDS_BASE64": null,
|
||||
"KIRO_OAUTH_CREDS_FILE_PATH": null,
|
||||
"QWEN_OAUTH_CREDS_FILE_PATH": null,
|
||||
"SYSTEM_PROMPT_FILE_PATH": "input_system_prompt.txt",
|
||||
"SYSTEM_PROMPT_MODE": "overwrite",
|
||||
"PROMPT_LOG_BASE_NAME": "prompt_log",
|
||||
"PROMPT_LOG_MODE": "none",
|
||||
"REQUEST_MAX_RETRIES": 3,
|
||||
"REQUEST_BASE_DELAY": 1000,
|
||||
"CRON_NEAR_MINUTES": 1,
|
||||
"CRON_REFRESH_TOKEN": false,
|
||||
"PROVIDER_POOLS_FILE_PATH": "provider_pools.json"
|
||||
}
|
||||
|
|
@ -105,40 +105,23 @@ function _determineReasoningEffortFromBudget(budgetTokens) {
|
|||
return "high";
|
||||
}
|
||||
|
||||
// 从环境变量获取阈值配置
|
||||
const lowThresholdStr = process.env.ANTHROPIC_TO_OPENAI_LOW_REASONING_THRESHOLD;
|
||||
const highThresholdStr = process.env.ANTHROPIC_TO_OPENAI_HIGH_REASONING_THRESHOLD;
|
||||
// 使用固定阈值替代环境变量
|
||||
const LOW_THRESHOLD = 50; // 低推理努力的阈值
|
||||
const HIGH_THRESHOLD = 200; // 高推理努力的阈值
|
||||
|
||||
// 检查必需的环境变量
|
||||
if (lowThresholdStr === undefined) {
|
||||
throw new Error("ANTHROPIC_TO_OPENAI_LOW_REASONING_THRESHOLD environment variable is required for intelligent reasoning_effort determination");
|
||||
console.debug(`Threshold configuration: low <= ${LOW_THRESHOLD}, medium <= ${HIGH_THRESHOLD}, high > ${HIGH_THRESHOLD}`);
|
||||
|
||||
let effort;
|
||||
if (budgetTokens <= LOW_THRESHOLD) {
|
||||
effort = "low";
|
||||
} else if (budgetTokens <= HIGH_THRESHOLD) {
|
||||
effort = "medium";
|
||||
} else {
|
||||
effort = "high";
|
||||
}
|
||||
|
||||
if (highThresholdStr === undefined) {
|
||||
throw new Error("ANTHROPIC_TO_OPENAI_HIGH_REASONING_THRESHOLD environment variable is required for intelligent reasoning_effort determination");
|
||||
}
|
||||
|
||||
try {
|
||||
const lowThreshold = parseInt(lowThresholdStr, 10);
|
||||
const highThreshold = parseInt(highThresholdStr, 10);
|
||||
|
||||
console.debug(`Threshold configuration: low <= ${lowThreshold}, medium <= ${highThreshold}, high > ${highThreshold}`);
|
||||
|
||||
let effort;
|
||||
if (budgetTokens <= lowThreshold) {
|
||||
effort = "low";
|
||||
} else if (budgetTokens <= highThreshold) {
|
||||
effort = "medium";
|
||||
} else {
|
||||
effort = "high";
|
||||
}
|
||||
|
||||
console.info(`🎯 Budget tokens ${budgetTokens} -> reasoning_effort '${effort}' (thresholds: low<=${lowThreshold}, high<=${highThreshold})`);
|
||||
return effort;
|
||||
|
||||
} catch (e) {
|
||||
throw new Error(`Invalid threshold values in environment variables: ${e.message}. ANTHROPIC_TO_OPENAI_LOW_REASONING_THRESHOLD and ANTHROPIC_TO_OPENAI_HIGH_REASONING_THRESHOLD must be integers.`);
|
||||
}
|
||||
console.info(`🎯 Budget tokens ${budgetTokens} -> reasoning_effort '${effort}' (thresholds: low<=${LOW_THRESHOLD}, high<=${HIGH_THRESHOLD})`);
|
||||
return effort;
|
||||
}
|
||||
|
||||
// 全局工具状态管理器
|
||||
|
|
|
|||
Loading…
Reference in a new issue