Skip to content

feat: add GreenPT model provider - #17447

Merged
JinHai-CN merged 4 commits into
infiniflow:mainfrom
robertkeus:codex/add-greenpt-provider
Jul 28, 2026
Merged

feat: add GreenPT model provider#17447
JinHai-CN merged 4 commits into
infiniflow:mainfrom
robertkeus:codex/add-greenpt-provider

Conversation

@robertkeus

Copy link
Copy Markdown
Contributor

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:

  • discovers the current catalog from GET /v1/models
  • features glm-5.2 and kimi-k2.7-code for chat and coding
  • supports green-embedding through /v1/embeddings
  • supports green-rerank through /v1/rerank
  • supports green-s and green-s-pro speech-to-text through /v1/listen
  • adds provider configuration, UI icon, and supported-provider documentation

The dedicated adapters preserve RAGFlow’s normal OpenAI-compatible flows while handling GreenPT’s native reranking and Deepgram-compatible speech protocol correctly.

Verification

  • Python provider tests: 3 passed
  • Python compile check: passed
  • JSON configuration validation: passed
  • gofmt and git diff --check: passed
  • focused frontend lint: passed

The 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

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 35c57022-e15b-4f23-9010-4675da28b321

📥 Commits

Reviewing files that changed from the base of the PR and between 5204997 and 3d42258.

📒 Files selected for processing (1)
  • conf/models/greenpt.json
💤 Files with no reviewable changes (1)
  • conf/models/greenpt.json

📝 Walkthrough

Walkthrough

Adds GreenPT as a supported provider across configuration, Go and Python model drivers, speech-to-text handling, automated tests, documentation, and frontend provider metadata.

Changes

GreenPT provider integration

Layer / File(s) Summary
Provider catalog and configuration
conf/llm_factories.json, conf/models/greenpt.json, docs/guides/models/supported_models.mdx
Registers GreenPT metadata, six model types, endpoint settings, and supported-provider documentation.
Go model driver and ASR flow
internal/entity/models/factory.go, internal/entity/models/greenpt.go, internal/entity/models/greenpt_test.go
Adds GreenPT driver construction, speech-model classification, /v1/listen transcription, response parsing, and HTTP integration tests.
Python model adapters and metadata
rag/llm/chat_model.py, rag/llm/embedding_model.py, rag/llm/model_meta.py, rag/llm/rerank_model.py, rag/llm/sequence2txt_model.py
Adds GreenPT adapters for chat, embedding, rerank, model metadata, and speech-to-text requests.
Python integration validation
test/unit_test/rag/llm/test_greenpt.py
Tests model classification, rerank URL normalization, request parameters, authorization, transcript extraction, and logging behavior.
Frontend provider registration
web/src/constants/llm.ts, web/src/components/svg-icon.tsx
Adds the GreenPT provider enum, icon and API mappings, and themed icon support.

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
Loading

Possibly related PRs

  • infiniflow/ragflow#17276: Introduces the OpenAI-compatible provider implementation wrapped by the new GreenPT Go driver.

Suggested labels: 🌈 python, 🧰 typescript

Poem

Green leaves flutter, models align,
Six little engines hum and shine.
Chat and speech now hop the stream,
“/listen!” cries the rabbit bright—
GreenPT joins the burrow tonight! 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.33% 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 is concise and accurately captures the main change: adding GreenPT provider support.
Description check ✅ Passed The description includes the required Summary section with context, goals, implementation details, and verification notes.
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.

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.

@robertkeus
robertkeus marked this pull request as ready for review July 27, 2026 14:30
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. 💞 feature Feature request, pull request that fullfill a new feature. labels Jul 27, 2026

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
rag/llm/model_meta.py (1)

464-477: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Resolve Ruff RUF012 on mutable class attributes.

Mark these mappings as ClassVar or 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

📥 Commits

Reviewing files that changed from the base of the PR and between 76acd49 and c4cc08e.

⛔ Files ignored due to path filters (1)
  • web/src/assets/svg/llm/greenpt.svg is excluded by !**/*.svg
📒 Files selected for processing (14)
  • conf/llm_factories.json
  • conf/models/greenpt.json
  • docs/guides/models/supported_models.mdx
  • internal/entity/models/factory.go
  • internal/entity/models/greenpt.go
  • internal/entity/models/greenpt_test.go
  • rag/llm/chat_model.py
  • rag/llm/embedding_model.py
  • rag/llm/model_meta.py
  • rag/llm/rerank_model.py
  • rag/llm/sequence2txt_model.py
  • test/unit_test/rag/llm/test_greenpt.py
  • web/src/components/svg-icon.tsx
  • web/src/constants/llm.ts

Comment thread internal/entity/models/greenpt_test.go Outdated
Comment thread internal/entity/models/greenpt_test.go Outdated
Comment thread rag/llm/sequence2txt_model.py
Comment thread web/src/components/svg-icon.tsx
Comment thread rag/llm/sequence2txt_model.py

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between c4cc08e and 7b714f8.

📒 Files selected for processing (7)
  • internal/entity/models/greenpt_test.go
  • rag/llm/chat_model.py
  • rag/llm/embedding_model.py
  • rag/llm/model_meta.py
  • rag/llm/rerank_model.py
  • rag/llm/sequence2txt_model.py
  • test/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

Comment thread rag/llm/sequence2txt_model.py
@JinHai-CN
JinHai-CN requested review from Haruko386 and Lynn-Inf July 28, 2026 04:13
@Haruko386
Haruko386 marked this pull request as draft July 28, 2026 05:01
@Haruko386
Haruko386 marked this pull request as ready for review July 28, 2026 05:01
@Haruko386 Haruko386 added the ci Continue Integration label Jul 28, 2026

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

LGTM

@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

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 28, 2026

@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 @robertkeus , there is a small suggestion for you.

Comment thread conf/models/greenpt.json Outdated
@@ -0,0 +1,69 @@
{
"name": "GreenPT",
"rank": 50,

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.

About the rank, I suggest set it as 500 or remove it, since:

factoryRankMapping[factory.Name] = -factory.Rank
for _, llm := range factory.Models {
rank := 500
if llm.Rank != nil {
rank = *llm.Rank
}
modelRankMap[factory.Name+"@"+llm.Name] = rank

If you set it as 50, It will always let GreenPT in the end of the model provider list

Suggested change
"rank": 50,

@Haruko386 Haruko386 removed the ci Continue Integration label Jul 28, 2026
@Haruko386
Haruko386 marked this pull request as draft July 28, 2026 06:37
@Haruko386
Haruko386 marked this pull request as ready for review July 28, 2026 06:37
@Haruko386 Haruko386 added the ci Continue Integration label Jul 28, 2026
@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.65%. Comparing base (1ae1dd1) to head (3d42258).
⚠️ Report is 11 commits behind head on main.

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.
📢 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 7e1ab97 into infiniflow:main Jul 28, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration 💞 feature Feature request, pull request that fullfill a new feature. lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants