主要功能更新: - 新增auto推理级别,完全遵循客户端原始请求参数 - 支持五档推理级别:auto/off/low/medium/high - auto模式零干预:不修改推理字段和anthropic-beta头 - 除gpt-5-codex外,所有模型默认设为auto模式 文档完善: - 更新核心功能说明,突出智能推理级别控制 - 新增auto推理模式详细说明和使用场景 - 添加推理级别对比表格和配置示例 - 增强FAQ部分,分场景解答推理相关问题 - 提供OpenAI和Anthropic模型字段对应关系 技术实现: - 更新getModelReasoning函数支持auto选项 - 完善所有transformer的auto模式处理逻辑 - 优化routes.js中直接转发端点的auto支持 - 确保auto模式下头信息和请求体完全透传
69 lines
1.5 KiB
JavaScript
69 lines
1.5 KiB
JavaScript
import fs from 'fs';
|
|
import path from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
let config = null;
|
|
|
|
export function loadConfig() {
|
|
try {
|
|
const configPath = path.join(__dirname, 'config.json');
|
|
const configData = fs.readFileSync(configPath, 'utf-8');
|
|
config = JSON.parse(configData);
|
|
return config;
|
|
} catch (error) {
|
|
throw new Error(`Failed to load config.json: ${error.message}`);
|
|
}
|
|
}
|
|
|
|
export function getConfig() {
|
|
if (!config) {
|
|
loadConfig();
|
|
}
|
|
return config;
|
|
}
|
|
|
|
export function getModelById(modelId) {
|
|
const cfg = getConfig();
|
|
return cfg.models.find(m => m.id === modelId);
|
|
}
|
|
|
|
export function getEndpointByType(type) {
|
|
const cfg = getConfig();
|
|
return cfg.endpoint.find(e => e.name === type);
|
|
}
|
|
|
|
export function isDevMode() {
|
|
const cfg = getConfig();
|
|
return cfg.dev_mode === true;
|
|
}
|
|
|
|
export function getPort() {
|
|
const cfg = getConfig();
|
|
return cfg.port || 3000;
|
|
}
|
|
|
|
export function getSystemPrompt() {
|
|
const cfg = getConfig();
|
|
return cfg.system_prompt || '';
|
|
}
|
|
|
|
export function getModelReasoning(modelId) {
|
|
const model = getModelById(modelId);
|
|
if (!model || !model.reasoning) {
|
|
return null;
|
|
}
|
|
const reasoningLevel = model.reasoning.toLowerCase();
|
|
if (['low', 'medium', 'high', 'auto'].includes(reasoningLevel)) {
|
|
return reasoningLevel;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
export function getUserAgent() {
|
|
const cfg = getConfig();
|
|
return cfg.user_agent || 'factory-cli/0.19.3';
|
|
}
|