Repository navigation
fix(go-models): route hosted OCR providers through drivers - #15233
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughFactory dispatch recognizes domain-style provider aliases (e.g., ChangesProvider Alias Mapping and Validation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ 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. Comment |
Haruko386
left a comment
There was a problem hiding this comment.
Hi @oktofeesh1
Just change the right name in
ragflow/internal/entity/models/factory.go
Line 140 in 036ed5b
ragflow/internal/entity/models/factory.go
Line 130 in 036ed5b
This has been fixed - thanks for the heads up |
Haruko386
left a comment
There was a problem hiding this comment.
@oktofeesh1 I have tested your code.
Some bugs need to fix.
please chage:
ragflow/conf/models/paddleocr.json
Line 9 in 036ed5b
paddleocr.net and ragflow/conf/models/mineru.json
Line 10 in 036ed5b
mineru.net
Thank you for taking time
Sorry about that, it's fixed |
Haruko386
left a comment
There was a problem hiding this comment.
@oktofeesh1 LGTM
Thank you for your contribution
|
@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.
Fixed |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/entity/models/factory.go (1)
122-147: ⚡ Quick winConsider grouping related OCR provider cases together.
The OCR-related cases are currently scattered:
paddleocr.net(122),mineru.net(128),mineru(134), andpaddleocr(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
📒 Files selected for processing (1)
internal/entity/models/factory.go
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Summary
What changed
Why
The hosted provider configs use display names with
.Net, while model factory dispatch lowercases the provider name. Without aliases, those configs fall through toDummyModelinstead of using the existing MinerU and PaddleOCR drivers.Validation
go test ./internal/entity -run 'TestHostedProviderConfigsLoadSharedDrivers|TestPPIOProviderConfigLoadsIntoProviderManager' -count=1go test ./internal/entity/models -run 'Test.*CreateModelDriver|Test.*Factory|TestPPIO|TestPaddle|TestMiner' -count=1git diff --check