File size: 3,534 Bytes
4bf0fdd cda8be4 4bf0fdd f076c2a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | /**
* 应用常量定义
* @module constants
*/
// ==================== 缓存相关常量 ====================
/**
* 文件缓存有效期(毫秒)
* @type {number}
*/
export const FILE_CACHE_TTL = 5000;
/**
* 文件保存延迟(毫秒)- 用于 debounce
* @type {number}
*/
export const FILE_SAVE_DELAY = 1000;
/**
* 额度缓存有效期(毫秒)- 5分钟
* @type {number}
*/
export const QUOTA_CACHE_TTL = 5 * 60 * 1000;
/**
* 额度清理间隔(毫秒)- 1小时
* @type {number}
*/
export const QUOTA_CLEANUP_INTERVAL = 60 * 60 * 1000;
/**
* 模型列表缓存默认有效期(毫秒)- 1小时
* @type {number}
*/
export const MODEL_LIST_CACHE_TTL = 60 * 60 * 1000;
// ==================== 内存管理常量 ====================
// 注意:内存压力阈值现在由 memoryManager 根据用户配置的 memoryThreshold 动态计算
// 用户配置的 memoryThreshold(MB)即为高压力阈值,其他阈值按比例计算:
// - LOW: 30% 阈值
// - MEDIUM: 60% 阈值
// - HIGH: 100% 阈值(用户配置值)
// - TARGET: 50% 阈值
/**
* GC 冷却时间(毫秒)
* @type {number}
*/
export const GC_COOLDOWN = 10000;
/**
* 默认内存检查间隔(毫秒)
* @type {number}
*/
export const MEMORY_CHECK_INTERVAL = 30000;
// ==================== 服务器相关常量 ====================
/**
* 默认心跳间隔(毫秒)
* @type {number}
*/
export const DEFAULT_HEARTBEAT_INTERVAL = 15000;
/**
* 默认服务器端口
* @type {number}
*/
export const DEFAULT_SERVER_PORT = 8045;
/**
* 默认服务器主机
* @type {string}
*/
export const DEFAULT_SERVER_HOST = '0.0.0.0';
/**
* 默认请求超时(毫秒)
* @type {number}
*/
export const DEFAULT_TIMEOUT = 300000;
/**
* 默认重试次数
* @type {number}
*/
export const DEFAULT_RETRY_TIMES = 3;
/**
* 默认最大请求体大小
* @type {string}
*/
export const DEFAULT_MAX_REQUEST_SIZE = '50mb';
// ==================== Token 轮询相关常量 ====================
/**
* 默认每个 Token 请求次数后切换
* @type {number}
*/
export const DEFAULT_REQUEST_COUNT_PER_TOKEN = 50;
/**
* Token 过期提前刷新时间(毫秒)- 5分钟
* @type {number}
*/
export const TOKEN_REFRESH_BUFFER = 300000;
// ==================== 生成参数默认值 ====================
/**
* 默认生成参数
*/
export const DEFAULT_GENERATION_PARAMS = {
temperature: 1,
top_p: 0.85,
top_k: 50,
max_tokens: 32000,
thinking_budget: 1024
};
/**
* reasoning_effort 到 thinkingBudget 的映射
*/
export const REASONING_EFFORT_MAP = {
low: 1024,
medium: 16000,
high: 32000
};
// ==================== 图片相关常量 ====================
/**
* 默认最大保留图片数量
* @type {number}
*/
export const DEFAULT_MAX_IMAGES = 10;
/**
* MIME 类型到文件扩展名映射
*/
export const MIME_TO_EXT = {
'image/jpeg': 'jpg',
'image/png': 'png',
'image/gif': 'gif',
'image/webp': 'webp'
};
// ==================== 停止序列 ====================
/**
* 默认停止序列
* @type {string[]}
*/
export const DEFAULT_STOP_SEQUENCES = [
'<|user|>',
'<|bot|>',
'<|context_request|>',
'<|endoftext|>',
'<|end_of_turn|>'
];
// ==================== 管理员默认配置 ====================
// 注意:管理员凭据(用户名、密码、JWT密钥)现在由 config.js 自动生成随机值
// 如果用户未配置,启动时会在控制台显示生成的凭据
// 不再使用硬编码的默认值,提高安全性 |