feat: add GreenPT model provider - #17447
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughAdds GreenPT as a supported provider across configuration, Go and Python model drivers, speech-to-text handling, automated tests, documentation, and frontend provider metadata. ChangesGreenPT provider integration
Estimated code review effort: 3 (Moderate) | ~30 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant GreenPTModel
participant GreenPTAPI
Client->>GreenPTModel: Submit audio transcription request
GreenPTModel->>GreenPTAPI: POST /v1/listen with audio and Token authorization
GreenPTAPI-->>GreenPTModel: Return transcript JSON
GreenPTModel-->>Client: Return transcript response
Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
rag/llm/model_meta.py (1)
464-477: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winResolve Ruff RUF012 on mutable class attributes.
Mark these mappings as
ClassVaror make them immutable so shared mutable configuration is explicit and lint-clean.🤖 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 `@rag/llm/model_meta.py` around lines 464 - 477, Update the _MODEL_TYPES and _MAX_TOKENS class attributes to explicitly use ClassVar with their existing mapping types, or convert them to immutable mappings while preserving current lookup behavior, so Ruff RUF012 is satisfied.Source: Linters/SAST tools
🤖 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.
Inline comments:
In `@internal/entity/models/greenpt_test.go`:
- Around line 30-31: The httptest handler goroutines in
internal/entity/models/greenpt_test.go at lines 30-31 and 60-71 must not call
Fatal methods. Replace each t.Fatalf/t.Fatal with t.Errorf, and return
immediately from the handler after each failed assertion or read so execution
stops safely without terminating the test process.
- Around line 34-55: Update the ListModels test fixture and expectations to
include the native model green-s-pro. Before validating ModelTypes, assert that
the returned model set or count contains every expected model, so omitted
entries cannot pass silently; keep the existing classification checks for all
returned models.
In `@rag/llm/sequence2txt_model.py`:
- Around line 135-152: Update transcription to add redacted logging around the
GreenPT request and response outcome, recording safe metadata such as status or
transcript availability while excluding the API key, audio contents, and local
audio_path. Use the module’s existing logger if available, and ensure request
failures are logged before being propagated.
In `@web/src/components/svg-icon.tsx`:
- Line 112: Update the GreenPT handling in LlmIcon to match available assets:
add the themed greenpt-dark and greenpt-bright SVG assets under the LLM SVG
assets, ensuring both dark- and light-mode requests resolve, or remove the
themed mapping and use the existing normal greenpt.svg asset instead.
---
Nitpick comments:
In `@rag/llm/model_meta.py`:
- Around line 464-477: Update the _MODEL_TYPES and _MAX_TOKENS class attributes
to explicitly use ClassVar with their existing mapping types, or convert them to
immutable mappings while preserving current lookup behavior, so Ruff RUF012 is
satisfied.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 30566798-0bfc-477d-b343-bb923daad225
⛔ Files ignored due to path filters (1)
web/src/assets/svg/llm/greenpt.svgis excluded by!**/*.svg
📒 Files selected for processing (14)
conf/llm_factories.jsonconf/models/greenpt.jsondocs/guides/models/supported_models.mdxinternal/entity/models/factory.gointernal/entity/models/greenpt.gointernal/entity/models/greenpt_test.gorag/llm/chat_model.pyrag/llm/embedding_model.pyrag/llm/model_meta.pyrag/llm/rerank_model.pyrag/llm/sequence2txt_model.pytest/unit_test/rag/llm/test_greenpt.pyweb/src/components/svg-icon.tsxweb/src/constants/llm.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@rag/llm/sequence2txt_model.py`:
- Around line 139-168: Update transcription’s successful-response parsing after
response.raise_for_status() to validate that the JSON root, results object,
channel entries, and alternatives are mappings/sequences before accessing them.
Keep malformed-response handling inside a try block, log only safe metadata such
as model and HTTP status, and raise the controlled ValueError from the original
validation exception.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2ec8e90d-602c-45fe-bf12-011d59c01ced
📒 Files selected for processing (7)
internal/entity/models/greenpt_test.gorag/llm/chat_model.pyrag/llm/embedding_model.pyrag/llm/model_meta.pyrag/llm/rerank_model.pyrag/llm/sequence2txt_model.pytest/unit_test/rag/llm/test_greenpt.py
🚧 Files skipped from review as they are similar to previous changes (5)
- rag/llm/embedding_model.py
- test/unit_test/rag/llm/test_greenpt.py
- internal/entity/models/greenpt_test.go
- rag/llm/model_meta.py
- rag/llm/chat_model.py
Haruko386
left a comment
There was a problem hiding this comment.
Hi @robertkeus , there is a small suggestion for you.
| @@ -0,0 +1,69 @@ | |||
| { | |||
| "name": "GreenPT", | |||
| "rank": 50, | |||
There was a problem hiding this comment.
About the rank, I suggest set it as 500 or remove it, since:
ragflow/internal/service/model_service.go
Lines 1538 to 1544 in cc0fbd3
If you set it as 50, It will always let GreenPT in the end of the model provider list
| "rank": 50, |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #17447 +/- ##
=======================================
Coverage 90.65% 90.65%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 650 650
Misses 39 39
Partials 28 28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
GreenPT is a European AI provider with an OpenAI-compatible API, optimized infrastructure, and datacenters powered by 100% renewable energy.
This adds native GreenPT support across RAGFlow’s Go-first provider system and its Python compatibility layer:
GET /v1/modelsglm-5.2andkimi-k2.7-codefor chat and codinggreen-embeddingthrough/v1/embeddingsgreen-rerankthrough/v1/rerankgreen-sandgreen-s-prospeech-to-text through/v1/listenThe dedicated adapters preserve RAGFlow’s normal OpenAI-compatible flows while handling GreenPT’s native reranking and Deepgram-compatible speech protocol correctly.
Verification
gofmtandgit diff --check: passedThe targeted Go test package reaches the linker locally but this sparse checkout does not contain RAGFlow’s prebuilt
librag_tokenizer_c_api.a; upstream CI’s full build environment should exercise those tests.References