Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# 示例(8080:3000) 则访问 http://localhost:8080
# To change the exposed Docker port, modify the ports parameter
# Example: (8080:3000) then access http://localhost:8080
SERVICE_PORT=3000
SERVICE_PORT=3423


# 监听地址(非必填)
Expand Down Expand Up @@ -164,3 +164,11 @@ PROXY_URL=
# disabled by default to avoid failure spam)
# true: enable; false/unset: disabled (cli endpoints return 503)
ENABLE_CLI=false

# ========== Temporary (Local) Chat Mode ==========

# 启用临时聊天模式(chat_mode=local,上游不创建持久会话)
# 可被单个请求的 chat_mode 字段覆盖(显式 'normal' 优先于本开关)
# Enable temporary local chat mode (chat_mode=local, bypasses persistent session creation)
# Can be overridden per-request via the chat_mode field (explicit 'normal' wins over this flag)
ENABLE_TEMP_CHATS=true
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
node_modules
package-lock.json
.tmp/
mitm_mcp_traffic.db
.env
Expand Down
41 changes: 16 additions & 25 deletions README-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ SERVICE_PORT=3000 # Service port
API_KEY=sk-123456,sk-456789 # API key (required, supports multiple keys)
ACCOUNTS= # Account configuration (format: user1:pass1[|proxy_url],user2:pass2[|proxy_url])

# 🚀 PM2 Multi-process Configuration
PM2_INSTANCES=1 # Number of PM2 processes (1/number/max)
PM2_MAX_MEMORY=1G # PM2 memory limit (100M/1G/2G, etc.)
# Note: All processes in PM2 cluster mode share the same port

# 🔍 Feature Configuration
SEARCH_INFO_MODE=table # Search info display mode (table/text)
OUTPUT_THINK=true # Whether to output thinking process (true/false)
Expand All @@ -115,6 +110,12 @@ BATCH_LOGIN_CONCURRENCY=5 # Login concurrency during batch account addition

# 📸 Cache Configuration
CACHE_MODE=default # Image cache mode (default/file)

# 🌐 Temp Chat Mode
ENABLE_TEMP_CHATS=false # Enable temporary local chat mode (true/false)

# 🌐 Temp Chat Mode
ENABLE_TEMP_CHATS=false # Enable temporary local chat mode (true/false)
```

#### 📋 Configuration Description
Expand All @@ -124,8 +125,6 @@ CACHE_MODE=default # Image cache mode (default/file)
| `LISTEN_ADDRESS` | Service listen address | `localhost` or `0.0.0.0` |
| [SERVICE_PORT](file://d:\Code\Qwen2API\src\start.js#L12-L12) | Service running port | `3000` |
| `API_KEY` | API access key, supports multi-key configuration. The first is the admin key (can access frontend management page), others are regular keys (API calls only). Multiple keys separated by commas | `sk-admin123,sk-user456,sk-user789` |
| [PM2_INSTANCES](file://d:\Code\Qwen2API\src\start.js#L11-L11) | Number of PM2 processes | `1`/`4`/`max` |
| `PM2_MAX_MEMORY` | PM2 memory limit | `100M`/`1G`/`2G` |
| `SEARCH_INFO_MODE` | Search result display format | `table` or [text](file://d:\Code\Qwen2API\src\utils\tool-prompt.js#L206-L206) |
| `OUTPUT_THINK` | Whether to show AI thinking process | `true` or `false` |
| `LEGACY_REASONING_IN_CONTENT` | Reasoning output format. Default `false` = reasoning goes to a separate `reasoning_content` field; `true` = legacy behavior (`<think>` inside `content`) | `true` or `false` |
Expand All @@ -140,6 +139,7 @@ CACHE_MODE=default # Image cache mode (default/file)
| `REDIS_URL` | Redis database connection address, use `rediss://` protocol when using TLS encryption | `redis://localhost:6379` or `rediss://xxx.upstash.io` |
| `BATCH_LOGIN_CONCURRENCY` | Login concurrency during batch account addition, can be adjusted dynamically in frontend system settings | `5` |
| `CACHE_MODE` | Image cache storage method | `default`/`file` |
| `ENABLE_TEMP_CHATS` | Enable temporary local chat mode (bypasses persistent session creation) | `true` or `false` |
| [LOG_LEVEL](file://d:\Code\Qwen2API\backend\core\config.py#L30-L30) | Log level | `DEBUG`/`INFO`/`WARN`/`ERROR` |
| `ENABLE_FILE_LOG` | Enable file logging | `true` or `false` |
| `LOG_DIR` | Log file directory | `./logs` |
Expand Down Expand Up @@ -241,32 +241,22 @@ git clone https://github.com/Rfym21/Qwen2API.git
cd Qwen2API

# Install dependencies
npm install
pnpm install

# Configure environment variables
cp .env.example .env
# Edit .env file

# Smart start (recommended - automatically determines single/multi-process)
npm start
# Start (recommended)
pnpm start

# Development mode
npm run dev
pnpm dev
```

### 🚀 PM2 Multi-Process Deployment

Use PM2 for production environment multi-process deployment, providing better performance and stability.

**Important Note**: In PM2 cluster mode, all processes share the same port, and PM2 automatically performs load balancing.

### 🤖 Smart Start Mode

Using `npm start` can automatically determine the startup method:

- When `PM2_INSTANCES=1`, uses single-process mode
- When `PM2_INSTANCES>1`, uses Node.js cluster mode
- Automatically limits process count to no more than CPU cores
Using `pnpm start` starts the server directly with Node.js:

### ☁️ Hugging Face Deployment

Expand Down Expand Up @@ -300,8 +290,9 @@ DATA_SAVE_MODE=none
Qwen2API/
├── README.md
├── README-en.md
├── ecosystem.config.js # PM2 configuration file
├── package.json
├── pnpm-workspace.yaml # pnpm workspace configuration
├── pnpm-workspace.yaml # pnpm workspace configuration
├── docker/ # Docker configuration directory
│ ├── Dockerfile
Expand All @@ -317,7 +308,7 @@ Qwen2API/
├── src/ # Backend source code directory
│ ├── server.js # Main server file
│ ├── start.js # Smart start script (automatically determines single/multi-process)
│ ├── start.js # Server entry point
│ ├── config/
│ │ └── index.js # Configuration file
│ ├── controllers/ # Controllers directory
Expand Down Expand Up @@ -375,7 +366,7 @@ Qwen2API/
│ ├── dashboard.vue # Dashboard page
│ └── settings.vue # Settings page
├── package.json # Frontend dependency configuration
├── package-lock.json
├── pnpm-lock.yaml
├── index.html # Frontend entry HTML
├── postcss.config.js # PostCSS configuration
├── tailwind.config.js # TailwindCSS configuration
Expand Down
14 changes: 4 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,11 @@
"name": "qwen2api",
"version": "2026.08.26.12.30",
"main": "src/server.js",
"packageManager": "pnpm@11.22.0",
"scripts": {
"start": "node src/start.js",
"dev": "nodemon src/server.js",
"test": "node --test tests/*.test.js",
"pm2": "pm2 start ecosystem.config.js",
"pm2:stop": "pm2 stop qwen2api",
"pm2:restart": "pm2 restart qwen2api",
"pm2:reload": "pm2 reload qwen2api",
"pm2:delete": "pm2 delete qwen2api",
"pm2:logs": "pm2 logs qwen2api",
"pm2:status": "pm2 status",
"pm2:monit": "pm2 monit"
"test": "node --test --test-force-exit tests/*.test.js"
},
"keywords": [],
"author": "",
Expand All @@ -26,14 +19,15 @@
"cors": "^2.8.5",
"csrf": "^3.1.0",
"dotenv": "^16.4.7",
"express": "^4.21.2",
"express": "^4.22.2",
"form-data": "^4.0.2",
"https-proxy-agent": "^7.0.6",
"ioredis": "^5.6.1",
"jwt-decode": "^4.0.0",
"mime-types": "^3.0.1",
"multer": "^1.4.5-lts.1",
"pm2": "^6.0.8",
"qwen2api": "link:/home/shabev/Documents/Code_Projects/Qwen2API",
"tiktoken": "^1.0.21"
},
"devDependencies": {
Expand Down
Loading