Skip to content

feat(pdf): add mineru-first strategy for MinerU-priority fallback - #4818

Closed
q2000s wants to merge 3 commits into
volcengine:mainfrom
q2000s:feat/iss-4708-mineru-async-api
Closed

q2000s wants to merge 3 commits into
volcengine:mainfrom
q2000s:feat/iss-4708-mineru-async-api

Conversation

@q2000s

@q2000s q2000s commented Sep 8, 2026 •

Copy link
Copy Markdown

Summary

Adds a mineru_first PDF parsing strategy: MinerU is preferred, and any failure
degrades to the local parser instead of failing the import.

strategy MinerU used? On MinerU failure mineru_endpoint required
local no n/a no
mineru always the import fails yes
mineru_first yes, tried first falls back to local yes
auto only if local fails the import fails optional

Because the strategy is defined as recoverable, MinerU problems never become
startup problems: the preflight result is advisory and the fallback happens per
document. The parser records the path actually taken as pdf_strategy_effective
(mineru or local) so operators can audit which converter handled a document.

Naming

Spelled mineru_first rather than mineru-first to match the snake_case
convention used by the other enumerations in ov.conf (e.g. semantic_and_vectors).
This spelling is used in configuration, ov.conf, logs and metadata.

Stacked on #4725

This branch is based on feat/iss-4708-mineru-async-api from #4725, which already
provides the task-based protocols, mineru_api_mode and mineru_token. This PR
only adds the mineru_first strategy on top of them and does not reimplement any
of that machinery.

Tests

Added to the existing tests/parse/test_pdf_mineru.py rather than a new file:

  • test_mineru_first_uses_mineru_when_available
  • test_mineru_first_falls_back_to_local_on_mineru_failure — the fallback path
  • test_mineru_first_records_effective_strategy
  • test_mineru_first_is_a_valid_strategy
  • test_mineru_first_requires_endpoint

19 passed; ruff check and ruff format --check are clean.

Docs

docs/{en,zh}/guides/01-configuration.md: added mineru_first to the strategy
table plus a comparison table covering when to use it and how it differs from
mineru and auto.

The PDF parser assumed the legacy self-hosted contract: a single
POST /file_parse answering inline with md_content. The current
self-hosted /tasks API and the online batch API are task-based
(create -> poll -> zip download), so both made OpenViking fail:
the online service has no /file_parse endpoint at all (404) and no
/health endpoint for the startup preflight.

- add pdf.mineru_api_mode ("auto" | "sync" | "async", default "auto"):
  auto detects the flavor from the first response, so existing v1
  deployments keep working without config changes
- add pdf.mineru_token, sent as Authorization: Bearer on every call
- v2-tasks flow: POST /tasks -> poll status_url (pending/processing/
  completed) -> download the result zip
- online-batch flow: POST /extract/task/batch -> poll
  extract-results/batch/{batch_id} until state=done -> download
  full_zip_url
- unpack the zip via safe_extract_zip, persist images/ into the media
  store and rewrite markdown references (mirrors the v1 image path)
- skip the /health startup preflight for the async flavors (the
  online service has no such endpoint)
- docs (en/zh): protocol table and online example

Fixes volcengine#4708
@q2000s
q2000s force-pushed the feat/iss-4708-mineru-async-api branch from 73c4f40 to 9d9f672 Compare October 2, 2026 03:50
@ZaynJarvis ZaynJarvis added the kernel Core server, runtime, storage, retrieval, SDK, and CLI. label Oct 5, 2026
@q2000s

q2000s commented Oct 10, 2026

Copy link
Copy Markdown
Author

Now, this PR has been compatible with v0.5 of OV. Please take a look.

@r266-tech

r266-tech commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

At current head a2060993, please keep credential-bearing MinerU API requests separate from signed artifact downloads, and add same-origin / different-origin transport controls for that boundary. This is a focused source and synthetic-method review; I have not independently verified live MinerU or complete v0.5 ingestion.

The fallback/async behavior also needs repository tests. This head changes 13 files, including deployment scripts and copied owner modules, while the PR description still presents the small strategy-only change. Splitting that deployment material and updating the description would make the protocol change easier to review. AI-assisted review.

Adds a PDF parsing strategy that prefers MinerU and degrades to the
local parser instead of failing the import. It sits between 'mineru'
(hard dependency) and 'auto' (local first):

  local        never calls MinerU
  mineru       always calls MinerU, failure fails the import
  mineru_first calls MinerU first, failure falls back to local
  auto         calls MinerU only after local fails

Named miner_first rather than miner-first to match the snake_case
convention used by the other enumerations in ov.conf.

Because the strategy is defined as recoverable, MinerU problems never
become startup problems: the preflight result is advisory and the
fallback happens per document. The parser records the path actually
taken in the result metadata as pdf_strategy_effective so operators can
audit which converter handled a document after the fact.

The strategy name is spelled mineru_first in configuration, ov.conf and
all logs and metadata.

Stacks on volcengine#4725, which already provides the task-based protocols,
mineru_api_mode and mineru_token this change builds on.
@q2000s
q2000s force-pushed the feat/iss-4708-mineru-async-api branch from a206099 to 832fc43 Compare October 12, 2026 23:38
main advanced 510 commits while this branch was stacked on volcengine#4725. Resolved a
single import-order conflict in pdf.py (main added \	hreading\ for the PDFium
render lock in volcengine#5952; this branch added \	empfile\), keeping both.

No behavioural change from the resolution.
@q2000s q2000s closed this Oct 13, 2026
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel Core server, runtime, storage, retrieval, SDK, and CLI.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants