Spaces:
Running
Running
github-actions[bot]
Sync from GitHub Viciy2023/Qwen2API-A@b372de2fdb435c7fa78fc69c146257a58c842fba
4289eb1 | const dotenv = require('dotenv') | |
| dotenv.config() | |
| const paths = require('../utils/paths') | |
| /** | |
| * 解析API_KEY环境变量,支持逗号分隔的多个key | |
| * @returns {Object} 包含apiKeys数组和adminKey的对象 | |
| */ | |
| const parseApiKeys = () => { | |
| const apiKeyEnv = process.env.API_KEY | |
| if (!apiKeyEnv) { | |
| return { apiKeys: [], adminKey: null } | |
| } | |
| const keys = apiKeyEnv.split(',').map(key => key.trim()).filter(key => key.length > 0) | |
| return { | |
| apiKeys: keys, | |
| adminKey: keys.length > 0 ? keys[0] : null | |
| } | |
| } | |
| const { apiKeys, adminKey } = parseApiKeys() | |
| const config = { | |
| dataSaveMode: process.env.DATA_SAVE_MODE || "none", | |
| apiKeys: apiKeys, | |
| adminKey: adminKey, | |
| simpleModelMap: process.env.SIMPLE_MODEL_MAP === 'true' ? true : false, | |
| listenAddress: process.env.LISTEN_ADDRESS || null, | |
| listenPort: process.env.SERVICE_PORT || 3000, | |
| searchInfoMode: process.env.SEARCH_INFO_MODE === 'table' ? "table" : "text", | |
| outThink: process.env.OUTPUT_THINK === 'true' ? true : false, | |
| redisURL: process.env.REDIS_URL || null, | |
| autoRefresh: true, | |
| autoRefreshInterval: 6 * 60 * 60, | |
| cacheMode: process.env.CACHE_MODE || "default", | |
| logLevel: process.env.LOG_LEVEL || "INFO", | |
| enableFileLog: process.env.ENABLE_FILE_LOG === 'true', | |
| logDir: paths.logDir, | |
| maxLogFileSize: parseInt(process.env.MAX_LOG_FILE_SIZE) || 10, | |
| maxLogFiles: parseInt(process.env.MAX_LOG_FILES) || 5, | |
| dataDir: paths.dataDir, | |
| cacheDir: paths.cacheDir, | |
| dataFilePath: paths.dataFilePath, | |
| usageStatsFilePath: paths.usageStatsFilePath, | |
| // 自定义反代URL配置 | |
| qwenChatProxyUrl: process.env.QWEN_CHAT_PROXY_URL || "https://chat.qwen.ai", | |
| qwenCliProxyUrl: process.env.QWEN_CLI_PROXY_URL || "https://portal.qwen.ai", | |
| // 代理配置 | |
| proxyUrl: process.env.PROXY_URL || null | |
| } | |
| module.exports = config | |