Skip to content

feat(go-models): add PPIO provider driver - #15099

Merged
JinHai-CN merged 4 commits into
infiniflow:mainfrom
JSONbored:codex/ppio-go-driver-15089-current
May 22, 2026
Merged

JinHai-CN merged 4 commits into
infiniflow:mainfrom
JSONbored:codex/ppio-go-driver-15089-current

Conversation

@JSONbored

@JSONbored JSONbored commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Closes #15089.

Adds PPIO support to the Go model-provider layer so PPIO instances can be routed through the Go API server with the same OpenAI-compatible chat, streaming, model listing, and connection-check flow used by other SaaS providers.

Type of change

  • New Feature (non-breaking change which adds functionality)

Summary

  • Added a PPIO Go model driver.
  • Added the PPIO provider catalog and default OpenAI-compatible API URL.
  • Registered PPIO in the model factory.
  • Added focused provider and provider-manager tests.

What changed

  • Implemented chat completions, SSE streaming, ListModels, and CheckConnection for PPIO.
  • Covered request shape, stream termination, reasoning fallback, model listing, custom base URLs, safe transport setup, unsupported methods, and provider config loading.
  • Kept the provider catalog aligned with the existing RAGFlow PPIO factory model set.
  • Cleaned up pre-existing Go model package validation blockers so the scoped provider tests can run normally with vet enabled.

Why

The existing Python/provider catalog path includes PPIO, but the Go model-provider layer did not have a PPIO driver, so the Go API server could not instantiate or use PPIO as requested in #15089.

Validation

  • go test ./internal/entity/models -run PPIO -count=1
  • go test ./internal/entity/models -count=1
  • go test ./internal/entity/... -count=1
  • jq empty conf/models/ppio.json
  • git diff --check

Also attempted go test ./internal/... -count=1; it is currently blocked locally by pre-existing non-provider issues: missing native tokenizer artifacts/libraries, an existing service-layer vet issue, an Infinity API test mismatch, and MinIO-backed storage tests requiring local MinIO.

Notes

The default PPIO base URL follows the existing RAGFlow Python provider default and can still be overridden by user configuration.

Add a PPIO Go model driver, provider catalog, factory registration, and focused coverage for chat, streaming, model listing, connection checks, custom base URLs, and provider config loading.

Repair existing model-package validation blockers so the scoped Go model/provider tests can run with vet enabled.
@coderabbitai

coderabbitai Bot commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a PPIO provider: config file, factory wiring, PPIOModel driver (chat non-stream/stream, ListModels, CheckConnection), comprehensive tests, and standardizes "no such method" / HTTP error messages across several existing drivers and tests.

Changes

PPIO Provider Implementation and Error Standardization

Layer / File(s) Summary
PPIO configuration and factory registration
conf/models/ppio.json, internal/entity/models/factory.go
Add PPIO provider config (base URLs, suffixes, model list) and register "ppio" in CreateModelDriver.
PPIO model driver implementation
internal/entity/models/ppio.go
Add PPIOModel with HTTP client/transport setup, region-aware endpoint building, ChatWithMessages, ChatStreamlyWithSender (SSE parsing), ListModels, CheckConnection, and unsupported-method stubs.
PPIO driver tests
internal/entity/models/ppio_test.go
Tests for model naming/factory, transport injection, chat parsing and reasoning fallback, streaming SSE handling and sender callback behavior, ListModels/CheckConnection, endpoint URL selection, and unsupported-method errors.
Provider manager integration test
internal/entity/model_test.go
Load ppio.json into ProviderManager and verify provider metadata, model count (21), model metadata fields, and search/list behavior.
Error message standardization across drivers
internal/entity/models/baidu.go, cohere.go, fishaudio.go, mistral.go, paddleocr.go, openrouter.go, xunfei.go
Normalize "no such method" and HTTP error formatting to consistently include model names and use fmt.Errorf formatting.
Test suite consistency updates
internal/entity/models/replicate_test.go, togetherai_test.go, xinference_test.go
Align tests with updated unsupported-method expectations and minor struct-literal formatting changes.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant PPIOModel
  participant PPIOEndpoint
  Client->>PPIOModel: ChatWithMessages / ChatStreamlyWithSender
  PPIOModel->>PPIOModel: validate API key, model, messages
  PPIOModel->>PPIOModel: build endpoint URL (region-aware)
  PPIOModel->>PPIOEndpoint: POST /chat/completions (Bearer auth)
  alt Non-streaming
    PPIOEndpoint-->>PPIOModel: JSON response (choices, reasoning_content)
    PPIOModel-->>Client: ChatResponse (Answer, ReasonContent)
  else Streaming
    PPIOEndpoint-->>PPIOModel: SSE stream (data: events)
    PPIOModel->>PPIOModel: parse delta events (reasoning/content)
    PPIOModel-->>Client: incremental sender callbacks
    PPIOModel->>PPIOModel: detect [DONE] / finish reason
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

  • #14604 — Both add new model drivers and modify CreateModelDriver provider dispatch; related at provider-dispatch level.

Possibly related PRs

  • infiniflow/ragflow#15045: Adds another OpenAI-compatible provider driver and updates CreateModelDriver dispatch.
  • infiniflow/ragflow#14605: Modifies CreateModelDriver to route a provider to its driver; similar factory-dispatch edits.
  • infiniflow/ragflow#15064: Adds an OpenAI-compatible provider driver and factory registration; overlaps on factory-dispatch pattern.

Suggested labels

💞 feature

Poem

🐰 I hopped through configs, code, and test,
PPIO joins the provider nest,
Streams and chats now hum in tune,
Errors polished like a moon,
A rabbit cheers this tidy quest!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding a PPIO provider driver to the Go models package.
Linked Issues check ✅ Passed The PR successfully addresses issue #15089 by implementing PPIOModel driver, conf/models/ppio.json, factory registration, and comprehensive tests for chat, streaming, model listing, and connection checks.
Out of Scope Changes check ✅ Passed Minor formatting/validation improvements to existing model drivers (Baidu, Cohere, FishAudio, Mistral, OpenRouter, PaddleOCR, Xunfei) use consistent error message patterns; test cleanup in Replicate, TogetherAI, Xinference aligns with broader validation effort and is in scope.
Description check ✅ Passed The PR description follows the template structure with all required sections completed: problem statement, type of change, and detailed context.

✏️ 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.

@JSONbored
JSONbored marked this pull request as ready for review May 21, 2026 07:51
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 21, 2026
@JSONbored

Copy link
Copy Markdown
Contributor Author

This one is done as well, @JinHai-CN - in case you're around to review/merge. Thanks a bunch in advance! 🙌🏻

@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 @JSONbored, I get some wired problem: two url is right
I suggest my adivce.

All other tests are passed, thank you for your contribution.

Comment thread conf/models/ppio.json Resolved
Comment thread conf/models/ppio.json Resolved
@Haruko386 Haruko386 added the ci Continue Integration label May 21, 2026
Switch the default PPIO endpoint to the api.ppio.com v1 path, retain the ppinfra endpoint as us, and add DeepSeek v4 flash/pro catalog coverage with tests.
@JSONbored

Copy link
Copy Markdown
Contributor Author

Hi @JSONbored, I get some wired problem: two url is right I suggest my adivce.

All other tests are passed, thank you for your contribution.

Thanks, addressed both review requests:

  • default endpoint now uses https://api.ppio.com/openai/v1
  • us region keeps https://api.ppinfra.com/v3/openai
  • added deepseek/deepseek-v4-flash and deepseek/deepseek-v4-pro
  • updated tests covering model count/lookup and default/US endpoint resolution

Validation:

  • jq empty conf/models/ppio.json
  • go test ./internal/entity/models -run 'PPIO' -count=1
  • go test ./internal/entity -run 'PPIO' -count=1
  • go test ./internal/entity/models -count=1
  • go test ./internal/entity/... -count=1
  • git diff --check
  • CodeRabbit review on the final diff: 0 issues

@JSONbored
JSONbored requested a review from Haruko386 May 21, 2026 10:12
@codecov

codecov Bot commented May 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.12%. Comparing base (440153c) to head (6160cd2).
⚠️ Report is 26 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15099   +/-   ##
=======================================
  Coverage   93.12%   93.12%           
=======================================
  Files          10       10           
  Lines         713      713           
  Branches      116      116           
=======================================
  Hits          664      664           
  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.

@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.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Implement provider: PPIO in Go driver

3 participants