Skip to content

fix(go-models): route hosted OCR providers through drivers - #15233

Merged
JinHai-CN merged 5 commits into
infiniflow:mainfrom
oktofeesh1:codex/hosted-provider-class-drivers
May 26, 2026
Merged

JinHai-CN merged 5 commits into
infiniflow:mainfrom
oktofeesh1:codex/hosted-provider-class-drivers

Conversation

@oktofeesh1

@oktofeesh1 oktofeesh1 commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • route hosted MinerU.Net and PaddleOCR.Net provider names to their existing Go drivers
  • add regression coverage for loading the hosted OCR provider configs through ProviderManager

What changed

  • Added canonical provider-name aliases for the hosted OCR provider display names.
  • Covered both bundled configs with a focused provider-manager test.

Why

The hosted provider configs use display names with .Net, while model factory dispatch lowercases the provider name. Without aliases, those configs fall through to DummyModel instead of using the existing MinerU and PaddleOCR drivers.

Validation

  • go test ./internal/entity -run 'TestHostedProviderConfigsLoadSharedDrivers|TestPPIOProviderConfigLoadsIntoProviderManager' -count=1
  • go test ./internal/entity/models -run 'Test.*CreateModelDriver|Test.*Factory|TestPPIO|TestPaddle|TestMiner' -count=1
  • git diff --check

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label May 26, 2026
@coderabbitai

coderabbitai Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Factory dispatch recognizes domain-style provider aliases (e.g., paddleocr.net, mineru.net) and routes to the appropriate constructors. Tests add a shared readProviderConfig helper, refactor readPPIOProviderConfig, add TestHostedProviderConfigsLoadSharedDrivers, and update local provider tests to use the helper.

Changes

Provider Alias Mapping and Validation

Layer / File(s) Summary
Factory provider-name dispatch updates
internal/entity/models/factory.go
CreateModelDriver switch now includes paddleocr.net and mineru.net cases and adjusts which constructors are selected for paddleocr/mineru labels.
Test helper extraction and provider config tests
internal/entity/model_test.go, conf/models/mineru.json, conf/models/paddleocr.json
Add shared readProviderConfig helper, refactor readPPIOProviderConfig to use it, add TestHostedProviderConfigsLoadSharedDrivers (writes hosted configs, initializes NewProviderManager, and asserts driver types and URL suffixes), update local provider test to use the helper, and update model class fields to domain-style identifiers.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • Haruko386

Poem

🐰
I hopped through configs, keen and small,
Mapped domains so drivers call,
A helper sniffed each JSON name,
Tests now prove the drivers came,
Carrot cheers for tidy fame.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description provides comprehensive context (Summary, What changed, Why, Validation) but does not follow the required template structure with explicit 'What problem does this PR solve?' and 'Type of change' sections. Restructure the description to include the required template sections: 'What problem does this PR solve?' and select a 'Type of change' checkbox (Bug Fix or Refactoring appear most appropriate).
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: routing hosted OCR providers through their drivers by adding provider-name aliases.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Haruko386 Haruko386 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @oktofeesh1
Just change the right name in

case "paddleocr_local":
and
case "mineru_local":

@Haruko386 Haruko386 added the ci Continue Integration label May 26, 2026
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels May 26, 2026
@oktofeesh1

oktofeesh1 commented May 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Hi @oktofeesh1 Just change the right name in

case "paddleocr_local":

and

case "mineru_local":

This has been fixed - thanks for the heads up

@oktofeesh1
oktofeesh1 requested a review from Haruko386 May 26, 2026 07:23

@Haruko386 Haruko386 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oktofeesh1 I have tested your code.
Some bugs need to fix.
please chage:

"class": "paddleocr",
to paddleocr.net and
"class": "mineru",
to mineru.net

Thank you for taking time

@oktofeesh1

Copy link
Copy Markdown
Contributor Author

@oktofeesh1 I have tested your code. Some bugs need to fix. please chage:

"class": "paddleocr",

to paddleocr.net and

"class": "mineru",

to mineru.net
Thank you for taking time

Sorry about that, it's fixed

@oktofeesh1
oktofeesh1 requested a review from Haruko386 May 26, 2026 08:15

@Haruko386 Haruko386 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oktofeesh1 LGTM
Thank you for your contribution

@JinHai-CN

Copy link
Copy Markdown
Member

@oktofeesh1 please fix the conflicts.

Resolve the model factory conflict by preserving upstream provider additions while keeping hosted OCR provider names routed to the hosted drivers and local OCR names routed to local drivers.
@oktofeesh1

Copy link
Copy Markdown
Contributor Author

@oktofeesh1 please fix the conflicts.

Fixed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
internal/entity/models/factory.go (1)

122-147: ⚡ Quick win

Consider grouping related OCR provider cases together.

The OCR-related cases are currently scattered: paddleocr.net (122), mineru.net (128), mineru (134), and paddleocr (146), separated by unrelated providers. Grouping them together would improve code readability and maintainability when working with OCR provider routing.

For example:

case "paddleocr.net":
    return NewPaddleOCRModel(baseURL, urlSuffix), nil
case "paddleocr":
    return NewPaddleOCRLocalModel(baseURL, urlSuffix), nil
case "mineru.net":
    return NewMinerUModel(baseURL, urlSuffix), nil
case "mineru":
    return NewMinerLocalUModel(baseURL, urlSuffix), nil
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/entity/models/factory.go` around lines 122 - 147, The switch
handling model providers mixes OCR-related cases with unrelated providers,
hurting readability; reorder the cases so OCR providers are contiguous — move
the "paddleocr.net" -> NewPaddleOCRModel, "paddleocr" -> NewPaddleOCRLocalModel,
"mineru.net" -> NewMinerUModel, and "mineru" -> NewMinerLocalUModel entries next
to each other in the factory switch (identify them by their case strings and
constructor calls) so the OCR routing logic is grouped together for clarity.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/entity/models/factory.go`:
- Around line 122-147: The switch handling model providers mixes OCR-related
cases with unrelated providers, hurting readability; reorder the cases so OCR
providers are contiguous — move the "paddleocr.net" -> NewPaddleOCRModel,
"paddleocr" -> NewPaddleOCRLocalModel, "mineru.net" -> NewMinerUModel, and
"mineru" -> NewMinerLocalUModel entries next to each other in the factory switch
(identify them by their case strings and constructor calls) so the OCR routing
logic is grouped together for clarity.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ccb24e0e-3622-44e3-967c-881dc7791055

📥 Commits

Reviewing files that changed from the base of the PR and between adcd142 and ba35338.

📒 Files selected for processing (1)
  • internal/entity/models/factory.go

@codecov

codecov Bot commented May 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (3619cec) to head (ba35338).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15233   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JinHai-CN
JinHai-CN merged commit 5ae41dc into infiniflow:main May 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants