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:
@@ -38,6 +38,7 @@ class SettingsResponse(BaseModel):
|
||||
chunk_overlap: int
|
||||
search_limit: int
|
||||
judge_batch_size: int
|
||||
ocr_concurrency: int
|
||||
# API Key 只返回是否已配置(不返回实际值)
|
||||
has_minimax_key: bool
|
||||
has_deepseek_key: bool
|
||||
@@ -71,6 +72,7 @@ async def get_settings():
|
||||
chunk_overlap=settings.CHUNK_OVERLAP,
|
||||
search_limit=settings.SEARCH_LIMIT,
|
||||
judge_batch_size=settings.JUDGE_BATCH_SIZE,
|
||||
ocr_concurrency=settings.OCR_CONCURRENCY,
|
||||
has_minimax_key=bool(settings.MINIMAX_API_KEY),
|
||||
has_deepseek_key=bool(settings.DEEPSEEK_API_KEY),
|
||||
has_openai_key=bool(settings.OPENAI_API_KEY),
|
||||
@@ -110,6 +112,7 @@ class SettingsUpdate(BaseModel):
|
||||
chunk_overlap: int | None = None
|
||||
search_limit: int | None = None
|
||||
judge_batch_size: int | None = None
|
||||
ocr_concurrency: int | None = None
|
||||
# 企业微信机器人
|
||||
wework_bot_enabled: bool | None = None
|
||||
wework_bot_id: str | None = None
|
||||
@@ -159,6 +162,7 @@ async def update_settings(data: SettingsUpdate):
|
||||
"chunk_overlap": "CHUNK_OVERLAP",
|
||||
"search_limit": "SEARCH_LIMIT",
|
||||
"judge_batch_size": "JUDGE_BATCH_SIZE",
|
||||
"ocr_concurrency": "OCR_CONCURRENCY",
|
||||
"wework_bot_enabled": "WEWORK_BOT_ENABLED",
|
||||
"wework_bot_id": "WEWORK_BOT_ID",
|
||||
"wework_bot_secret": "WEWORK_BOT_SECRET",
|
||||
|
||||
Reference in New Issue
Block a user