Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
234fc5510d | ||
|
|
6d50969caa | ||
|
|
2141d6fd82 | ||
|
|
b33b149555 | ||
|
|
5d79d653ac | ||
|
|
0cec894ba8 | ||
|
|
dcf7e9006e | ||
|
|
049fb73231 | ||
|
|
77f91fad99 | ||
|
|
cf4e57cf79 | ||
|
|
b30ffda52e | ||
|
|
0bc283dc49 |
No files matched your search
@@ -6,5 +6,6 @@ hf-cache/
|
||||
piper-models/
|
||||
ai-models/
|
||||
waifu2x/
|
||||
face-models/
|
||||
*.log
|
||||
.venv-hf/
|
||||
@@ -7,7 +7,10 @@ RUN apt-get update \
|
||||
# models are pre-downloaded on the host (build env has no internet)
|
||||
RUN pip install --no-cache-dir piper-tts faster-whisper
|
||||
RUN pip install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple "rembg[cpu]"
|
||||
# AI 换脸: insightface(纯Python wheel 免编译) + buffalo_l人脸检测 + inswapper_128换脸模型(宿主已预置)
|
||||
RUN pip install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple insightface
|
||||
COPY hf-cache /root/.cache/huggingface
|
||||
COPY face-models /app/face-models
|
||||
COPY piper-models /app/piper-models
|
||||
# AI 图片: u2net 抠图模型(预下载) + waifu2x-ncnn-vulkan 无损放大(CPU)
|
||||
COPY ai-models/u2net.onnx /root/.u2net/u2net.onnx
|
||||
|
||||
@@ -4,6 +4,10 @@ IT-Tools 的自建后端中继服务(Python 标准库 `http.server`,**监听
|
||||
|
||||
- **翻译代理** `GET /translate` —— 转发 Google Translate(走 `HTTPS_PROXY` 出网,解决国内不通)
|
||||
- **授权校验** `GET /check` —— 供 nginx `auth_request` 调用,卡密授权 / 试用窗口判定(网络故障 fail-open,不锁死付费用户)
|
||||
- **AI 生图额度** `POST /ai/quota`(前端经 `/relay/ai/quota`,带 `model` 返回上游真实配额 `upstream/upstream_daily/upstream_remaining/upstream_note`)—— **两级真实限额**:
|
||||
- 机器级:未授权用内置渠道每日 `DAILY_FREE_LIMIT` 次(默认 10,北京时间 0 点重置,`daily_gen.json` 落盘),**生成成功才扣次**,**自带提供商/KEY 生成不计次**;
|
||||
- 上游共享池(**已授权同样受保护**——内置模型上游是站主免费额度,不存在无限次):`flux*`/`dall-e-3` 走 Cloudflare Workers AI,**官方 10,000 Neurons/天 ÷ 57.6 Neurons/张(1024×1024/4 步)≈ 173 张/天**(`CF_DAILY_LIMIT` 默认 173,北京时间约 08:00 重置,`daily_gen_cf.json` 全站计数);`pollinations-*` 走 Pollinations(API Key 预算制,无固定日限,上游错误透传);
|
||||
- 额度用尽生图返回 403(含官方配额出处文案)并引导配置自己的 KEY
|
||||
- **卡密激活** `POST /activate` —— 代理 CardAuth 验卡,`CARD_AUTH_KEY` 只留在容器内
|
||||
- **授权中心 hub** `GET /hub/announcements`(拉项目公告,服务端双保险过滤 `project_id`)+ `POST /hub/report`(安装登记 + 心跳在线统计,`X-Api-Key`/`X-Project-Id=6` 只存在服务端;**先心跳后 check-update**——实测 CardAuth heartbeat 会清空 `client_version/device_info`,check-update 放最后保证版本号落库)
|
||||
- 另有大量 AI 对话/生图、TTS/ASR、视频、格式转换、网速测速、IP 查询等接口(`server.py`,约 3700 行)
|
||||
@@ -12,6 +16,16 @@ Docker 镜像内置:calibre(`ebook-convert`)、ffmpeg、Piper(本地 TTS
|
||||
|
||||
镜像也可直接拉取:`192.168.68.19:3200/jinghui/it-tools-relay:latest`(Gitea Container Registry,免登录)。
|
||||
|
||||
## 授权功能接口
|
||||
|
||||
| 接口 | 方法 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `/ai/face-swap` | POST | AI 换脸(授权):multipart `source`/`target`(文件)+ `consent=1`(必填授权承诺),需 `X-Machine-Id` 头;多脸取最大,返回站内图片 URL |
|
||||
| `/ai/gen-image` | POST | AI 生图(每日免费额度):JSON `machine`/`prompt`/`model`/`width`/`height`;尺寸需按模型档位传(dall-e-3 仅 1024×1024 / 1792×1024 / 1024×1792) |
|
||||
| `/ai/image-models` | GET | 生图模型列表 |
|
||||
|
||||
`PROTECTED_TOOLS` 集合含 `face-swap`、`poster-maker`(海报前端门控),与前端 `license.ts` 双端同步。
|
||||
|
||||
## 环境变量(`.env`)
|
||||
|
||||
```bash
|
||||
@@ -39,6 +53,11 @@ NEWAPI_URL=https://your-newapi-host/v1/chat/completions
|
||||
NEWAPI_KEY=sk-xxx
|
||||
NEWAPI_MODEL=qwen3.8-flash
|
||||
|
||||
# AI 生图内置免费额度(可选)
|
||||
DAILY_FREE_LIMIT=10 # 未授权机器每日次数(北京 0 点重置)
|
||||
CF_DAILY_LIMIT=173 # Cloudflare 共享池张数/天(官方 10,000 Neurons ÷ 57.6/张)
|
||||
CF_DAILY_FILE=/app/data/daily_gen_cf.json
|
||||
|
||||
# 出网代理(翻译等走 Google 的接口用,可选)
|
||||
HTTPS_PROXY=http://host.docker.internal:7890
|
||||
RELAY_TIMEOUT=25
|
||||
@@ -60,7 +79,9 @@ docker run -d --name it-tools-relay --restart always \
|
||||
-e NO_PROXY=localhost,127.0.0.1,192.168.68.19 \
|
||||
--add-host host.docker.internal:host-gateway \
|
||||
--cap-add NET_ADMIN \
|
||||
-v /:/hostfs \
|
||||
-v /vol3/1000/HD3/docker/it-tools-relay/data:/app/data \
|
||||
-v /vol3/1000/HD3/docker/it-tools-relay/data/config.json:/vol3/1000/HD3/docker/it-tools-relay/data/config.json \
|
||||
it-tools-relay
|
||||
```
|
||||
|
||||
@@ -98,6 +119,11 @@ services:
|
||||
volumes:
|
||||
# 数据持久化:试用记录 / 用量库 / 用户库 / news.json
|
||||
- ./data:/app/data
|
||||
# 宿主全路径(run 段同款):缺失则 DATA_DIR 漂移到容器易失层,重建后用户库/密钥全丢
|
||||
- /:/hostfs
|
||||
# 存储根配置必须持久:不挂载则落在容器易失层,重建容器后 storage_root 丢失
|
||||
# → DATA_DIR 漂移到易失目录 → 用户库/密钥/上传全丢
|
||||
- ./data/config.json:/vol3/1000/HD3/docker/it-tools-relay/data/config.json
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
extra_hosts:
|
||||
@@ -123,6 +149,10 @@ curl -s http://127.0.0.1:8091/auth-status # 返回 JSON 即服务正常
|
||||
|
||||
只重建代码(模型目录已缓存):`docker compose up -d --build it-tools-relay`。
|
||||
|
||||
## 中文提示词自动转英文(2026-11-13)
|
||||
|
||||
`_handle_gen_image` / `_handle_edit_image` 发起生成前经 `_translate_prompt()`:提示词含中文时用 `IMG_PROMPT_MODEL`(默认 `mimo-v2.6-flash`,走 NEWAPI_URL + NEWAPI_KEY)转成高质量英文生图提示词再发上游(Flux/SDXL 系对英文理解最好);进程内缓存 300 条;翻译失败/超时/结果仍含中文一律回退原文,**绝不阻断生图**;纯英文提示词原样透传。实际发送的英文随响应 `prompt_en` 字段返回(前端结果图操作行显示「🌐 已自动转英文发送(悬停查看)」);生成历史仍存用户原文。
|
||||
|
||||
## 其他镜像变体
|
||||
|
||||
| 文件 | 用途 |
|
||||
|
||||
+5
-2
@@ -18,8 +18,11 @@ services:
|
||||
volumes:
|
||||
# 数据持久化:试用记录 / 用量库 / 用户库 / news.json
|
||||
- ./data:/app/data
|
||||
# 存储根配置必须持久:_load_storage_root() 读 DEFAULT_HOST_ROOT 容器路径下的 config.json,
|
||||
# 不挂载则落在容器易失层,重建容器后 storage_root 丢失 → DATA_DIR 漂移到易失目录 → 用户库/密钥全丢
|
||||
# 宿主全路径(canonical run line 同款):_load_storage_root 经 /hostfs 解析 config.json,
|
||||
# 缺失则 DATA_DIR 漂移到容器易失 /vol3/... 层 → 重建容器后用户库/密钥全丢
|
||||
- /:/hostfs
|
||||
# 存储根配置必须持久:不挂载则落在容器易失层,重建容器后 storage_root 丢失
|
||||
# → DATA_DIR 漂移到易失目录 → 用户库/密钥/上传全丢
|
||||
- ./data/config.json:/vol3/1000/HD3/docker/it-tools-relay/data/config.json
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
|
||||
+2
-1
@@ -76,7 +76,8 @@ def mcp_usage_query(days: int = 7) -> dict:
|
||||
conn = sqlite3.connect(_CTX["usage_db"])
|
||||
rows = conn.execute(
|
||||
"SELECT token_tail, machine, tool, ok, err, dur_ms, at FROM mcp_usage "
|
||||
"WHERE at>? ORDER BY at DESC LIMIT 300", (since,)).fetchall()
|
||||
# 铁规则:所有功能历史最多显示 100 条
|
||||
"WHERE at>? ORDER BY at DESC LIMIT 100", (since,)).fetchall()
|
||||
by_tool = conn.execute(
|
||||
"SELECT tool, COUNT(*), SUM(ok) FROM mcp_usage WHERE at>? GROUP BY tool ORDER BY COUNT(*) DESC",
|
||||
(since,)).fetchall()
|
||||
|
||||
Reference in new issue
Block a user