feat: 接入 DeepSeek 官方 OCR API
Convert PDFs into various formats and translate them in one go
Brought to you by:
alic-zhang,
aliczhang-oomol
Originally posted by: coderabbitai[bot]
<picture>
</picture>
No actionable comments were generated in the recent review.
Walkthrough
The change adds a `deepseek-ocr-official` mode, configures the official DeepSeek OCR endpoint, and routes matching vendor requests through a multipart API path. It also adds CLI and smoke configuration, response validation, retry handling, documentation, and tests. **Changes: Official DeepSeek OCR** |Layer / File(s)|Summary| |:---|:---| |**Mode configuration and CLI wiring**
`.env.template`, `pdf_craft/ocr_config.py`, `pdf_craft_tool/cli.py`, `pdf_craft_tool/runtime.py`, `pdf_craft_tool/smoke/ocr.py`, `tests/test_tool.py`, `pdf_craft_tool/README.md`|The OCR configuration adds `DeepSeekOCRVendorConfig.official()` and the new mode. The CLI and smoke configuration load the official API key and create the config. Tests check that both paths produce the same config.| |**Official endpoint request and response handling**
`pdf_craft/pdf/vendor_ocr.py`, `tests/test_vendor_ocr_image_url.py`, `docs/en/OCR_BACKENDS.md`, `docs/zh-CN/OCR_BACKENDS.md`|The runtime sends matching configurations to the official endpoint as multipart requests. It validates page results, records token usage, and retries designated transient errors. Tests cover requests, responses, and retries. The documentation describes the API setup and image URL requirement.| **Estimated code review effort:** 3 (Moderate) | ~25 minutes **Change:** Feature ### Sequence Diagram(s) :::mermaid sequenceDiagram participant ImageURLResolver participant VendorOCRRuntime participant DeepSeekOCRAPI participant EPUBConversion ImageURLResolver->>VendorOCRRuntime: Base64 image Data URL VendorOCRRuntime->>DeepSeekOCRAPI: Authenticated multipart OCR request DeepSeekOCRAPI-->>VendorOCRRuntime: Page result and token counts VendorOCRRuntime->>EPUBConversion: Validated OCR text **Suggested reviewers:** `moskize91`, `caldalis`
Merge Risk: <picture>
</picture> Minimal · up to
9d860This change adds an opt-in `deepseek-ocr-official` mode with configuration, CLI support, documentation and tests. Existing OCR modes keep their current request path. No concrete defect was found in the supplied evidence, so the merge risk is minimal.
Pre-merge checks: <picture>
</picture> 4
| Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Description Check |  | Check skipped - CodeRabbit’s high-level summary is enabled. | | Title check |  | The title "feat: 接入 DeepSeek 官方 OCR API" (added DeepSeek official OCR API) matches the main change. The changeset adds DeepSeekOCRVendorConfig.official(), a deepseek-ocr-official mode in the CLI, env … | | Linked Issues check |  | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check |  | Check skipped because no linked issues were found for this pull request. |
Full details: Title check
**Explanation** The title "feat: 接入 DeepSeek 官方 OCR API" (added DeepSeek official OCR API) matches the main change. The changeset adds DeepSeekOCRVendorConfig.official(), a deepseek-ocr-official mode in the CLI, env and smoke config wiring, and a dedicated official OCR request path in vendor_ocr.py with response validation and retries. The title is in Chinese, which is acceptable for this project. It does not cover every detail, such as EPUB output or retry handling, but that is expected for a short title.
Finishing Touches
Generate unit tests (beta)
- [ ] Create a new PR
<picture>
</picture> Recent review info
<picture>
</picture> Run configuration
- **Source mode**: Auto - **Repository**: [oomol-lab/pdf-craft](<https: github.com="" oomol-lab="" pdf-craft="">) - **Branch**: [main](<https: github.com="" oomol-lab="" pdf-craft="" tree="" main="">) - **File**: [.coderabbit.yaml](<https: github.com="" oomol-lab="" pdf-craft="" blob="" 56acd2887ef78b12e2fe50abcbd5147ce14ce7e1="" .coderabbit.yaml="">) - **Commit**: [56acd28](<https: github.com="" oomol-lab="" pdf-craft="" commit="" 56acd2887ef78b12e2fe50abcbd5147ce14ce7e1="">) - **Layers**: Repository YAML; Enforced overrides: Organization - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `d296a3ad-dc83-4ba9-b240-1571515834ea` </https:></https:></https:></https:>
<picture>
</picture> Commits
Reviewing files that changed from the base of the PR and between [56acd2] and 9d860363ff02435f22e4d195f4ad30f3d514c491.
<picture>
</picture> Files selected for processing: 11
* `.env.template` * `docs/en/OCR_BACKENDS.md` * `docs/zh-CN/OCR_BACKENDS.md` * `pdf_craft/ocr_config.py` * `pdf_craft/pdf/vendor_ocr.py` * `pdf_craft_tool/README.md` * `pdf_craft_tool/cli.py` * `pdf_craft_tool/runtime.py` * `pdf_craft_tool/smoke/ocr.py` * `tests/test_tool.py` * `tests/test_vendor_ocr_image_url.py`