feat: OCR 并发识别控制,支持多用户同时上传

- config.py: 新增 OCR_CONCURRENCY 参数(默认1,范围1-10)
- images.py: 用 asyncio.Semaphore 控制 OCR 并发,4个上传端点统一受控
- settings API: 新增 ocr_concurrency 字段读写
- 前端设置页: 新增 OCR 并发数量输入框
- .env / .env.example: 新增 OCR_CONCURRENCY 配置项
- Semaphore 动态重建:修改配置后立即生效,无需重启
This commit is contained in:
EduBrain Dev
2026-04-14 14:11:18 +08:00
parent 8152494fdc
commit f60b45358d
5 changed files with 44 additions and 4 deletions

View File

@@ -153,6 +153,9 @@ class Settings(BaseSettings):
SEARCH_LIMIT: int = Field(default=3, description="图片搜索默认返回数量(1-10)")
JUDGE_BATCH_SIZE: int = Field(default=10, description="每次LLM判断的文章数量(1-50)")
# ──────────────────────────── OCR ────────────────────────────
OCR_CONCURRENCY: int = Field(default=1, ge=1, le=10, description="OCR 并发识别数量(1-10),多用户同时上传时控制并发")
# ──────────────────────────── CORS ────────────────────────────
CORS_ORIGINS: list[str] = Field(
default=["*"],