建立 OCR 引擎配置中心#843
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 48d2c7be4b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| @system.get("/ocr/health") | ||
| async def get_ocr_health( | ||
| current_user: User = Depends(get_required_user), |
There was a problem hiding this comment.
Keep OCR health details admin-only
With this dependency change, any authenticated non-admin can call /api/system/ocr/health. That handler runs all health checks and returns parser details such as configured server_url/api_url values and connection errors for MinerU, PP-Structure, DeepSeek, and PaddleOCR; before this diff the same route required get_admin_user. In deployments with internal OCR services or cloud endpoints, this leaks configuration and lets ordinary users trigger server-side health probes, so either keep this endpoint admin-only or return a redacted user-safe status.
Useful? React with 👍 / 👎.
| <OCRSelector | ||
| :model-value="item.selectedParseMethod" | ||
| :allowed-engines="item.parseMethods" | ||
| :disabled="item.status === 'parsing' || confirming" | ||
| placeholder="选择 OCR" | ||
| @update:model-value="handleParseMethodChange(item.localId, $event)" | ||
| /> |
There was a problem hiding this comment.
Restore the PDF text-only parse option
For PDF temporary attachments, the backend returns parse_methods including disable, but OCRSelector only adds that synthetic option when includeDisable is true and this call never sets it. As a result, users cannot choose the backend-supported text-layer extraction path for PDFs when the default OCR engine is an OCR service, forcing unnecessary OCR calls for ordinary searchable PDFs. Pass includeDisable here when allowedEngines can contain disable.
Useful? React with 👍 / 👎.
| except Exception as e: | ||
| return {"status": "error", "message": f"健康检查失败: {str(e)}", "details": {"error": str(e)}} | ||
| return { | ||
| "status": "configured", |
There was a problem hiding this comment.
Accept configured health before parsing MinerU Official
When MinerU Official has a configured API key, check_health() now returns configured, but process_file() still rejects every status other than healthy before uploading the file. This means every real mineru_official parse fails immediately with “API 不可用” even though the UI marks the engine usable; either skip that preflight or treat configured as acceptable for this parser.
Useful? React with 👍 / 👎.
| const saveOption = async (option) => { | ||
| savingOption.value = option.key | ||
| try { | ||
| const data = await configOptionsApi.updateOption(option.key, draftValue.value) |
There was a problem hiding this comment.
Preserve existing secret fields when saving other values
When editing the PaddleOCR card to change only api_url, draftValue also contains api_token: '' because sensitive values are intentionally blanked in the serialized option. Sending the whole draft here makes the backend overwrite the stored token with an empty string, so changing the URL silently deletes an existing database token. Omit unchanged sensitive fields or send an explicit clear action only when the user intends to remove the secret.
Useful? React with 👍 / 👎.
| if ( | ||
| !ocrEngineOptions.value.some((option) => option.value === processingParams.value.ocr_engine) | ||
| ) { |
There was a problem hiding this comment.
Don't block non-OCR uploads on OCR option loading
This validation runs for every non-URL upload whenever the selected OCR engine is not disable, even if the selected files are plain text or Office documents that never use OCR. If /ocr/options is still loading or fails, users are blocked from adding those non-OCR files with “OCR 引擎选项尚未加载”; gate this check on files that actually need OCR instead of all uploads.
Useful? React with 👍 / 👎.
| <OCRSelector | ||
| :model-value="configStore.config?.default_ocr_engine" | ||
| @update:model-value="configStore.setConfigValue('default_ocr_engine', $event)" | ||
| /> |
There was a problem hiding this comment.
Expose the disable choice in default OCR settings
The backend still accepts default_ocr_engine: 'disable', and the previous settings UI offered that option, but this new default-OCR selector does not pass includeDisable, so OCRSelector filters the synthetic disable option out. When the current default is an OCR engine, admins can no longer set the global default back to text-only/no-OCR from the settings page; enable the disable option for this settings use case.
Useful? React with 👍 / 👎.
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
变更描述
建立 OCR 引擎配置中心,统一管理 OCR 引擎注册信息、默认参数、启停状态、默认引擎、服务端点和凭证来源。
后端新增 PostgreSQL 持久化配置、加密数据库密钥、脱敏 Redis 快照和跨进程运行时同步;前端新增管理员 OCR 配置页面,并移除上传弹窗中不可达的 OCR 不可用分支。
本次同时按项目维护性要求补齐新增代码的中文 docstring、关键约束注释,并清理 E2E 测试创建的线程、附件和临时对象。
变更类型
设计与影响范围
siliconflow-cn模型供应商凭证。测试
实际执行结果:
docker exec api-dev uv run pytest -q test/unit/services/test_ocr_config_service.py test/unit/services/test_ocr_config_cache.py test/unit/knowledge/test_ocr_config_runtime.py test/unit/knowledge/test_parser_facade.py test/unit/services/test_conversation_service_attachment_state.py test/unit/storage/test_postgres_manager_schema.py test/unit/plugins/test_ragflow_like_chunking.pydocker exec api-dev uv run pytest -q test/integration/api/test_system_router.pydocker exec api-dev uv run pytest -q test/e2e/test_ocr_config_center_e2e.pygit diff --checkdocker exec web-dev pnpm build已知但未在本 PR 中扩大的项目既有警告:前端
:deep、大 chunk 和 Rolldown 依赖注释警告;unified.py中既有_process_file_to_markdown_coreC901 复杂度为 22。Human Review
说明
无关联 Issue。当前 PR 按要求创建为 Draft,来源分支为
Yuchuan925/Yuxi:feat/ocr-config-center,目标为xerrors/Yuxi:main。