Repository navigation
feat: Add Astraflow provider support (global + China endpoints) - #14270
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:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughAdded two new LLM providers, Astraflow and Astraflow-CN: configuration entries, enum and mapping registrations, provider-specific chat and embedding classes with region-default base URLs, and documentation table rows; minor formatting fixes in existing factory JSON. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
rag/llm/sequence2txt_model.py (1)
307-331:⚠️ Potential issue | 🔴 CriticalMove the DeerAPI
__init__method out ofAstraflowCNSeq2txtclass.Lines 327–331 define a second
__init__insideAstraflowCNSeq2txt, overriding the first one (lines 322–325). This causesAstraflowCNSeq2txtto use the DeerAPI endpoint (https://api.deerapi.com/v1) instead of the correct Astraflow-CN endpoint (https://api.modelverse.cn/v1). Additionally,DeerAPISeq2txtlacks its own__init__implementation.Move the second
__init__to belong toDeerAPISeq2txt:Fix
class DeerAPISeq2txt(Base): _FACTORY_NAME = "DeerAPI" + + def __init__(self, key, model_name="whisper-1", base_url="https://api.deerapi.com/v1", **kwargs): + if not base_url: + base_url = "https://api.deerapi.com/v1" + self.client = OpenAI(api_key=key, base_url=base_url) + self.model_name = model_name + class AstraflowSeq2txt(GPTSeq2txt): _FACTORY_NAME = "Astraflow" @@ def __init__(self, key, model_name="whisper-1", base_url="https://api.modelverse.cn/v1", **kwargs): if not base_url: base_url = "https://api.modelverse.cn/v1" super().__init__(key, model_name=model_name, base_url=base_url, **kwargs) - - def __init__(self, key, model_name="whisper-1", base_url="https://api.deerapi.com/v1", **kwargs): - if not base_url: - base_url = "https://api.deerapi.com/v1" - self.client = OpenAI(api_key=key, base_url=base_url) - self.model_name = model_name🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@rag/llm/sequence2txt_model.py` around lines 307 - 331, AstraflowCNSeq2txt currently has two __init__ methods; the second one (which sets base_url to "https://api.deerapi.com/v1" and initializes self.client = OpenAI(...)) should be moved to DeerAPISeq2txt so AstraflowCNSeq2txt keeps its correct Astraflow-CN initialization. Remove the duplicate __init__ from AstraflowCNSeq2txt (leave the one that defaults base_url to "https://api.modelverse.cn/v1" and calls super().__init__) and add the moved __init__ to DeerAPISeq2txt (use the existing signature key, model_name="whisper-1", base_url="https://api.deerapi.com/v1", check/fallback if not base_url, then set self.client = OpenAI(api_key=key, base_url=base_url) and self.model_name = model_name).rag/llm/tts_model.py (1)
444-467:⚠️ Potential issue | 🔴 CriticalMove the DeerAPI initializer to
DeerAPITTS.The class
AstraflowCNTTSdefines two__init__methods (lines 459 and 464), causing the China endpoint initializer to be overwritten by the DeerAPI endpoint. Additionally,DeerAPITTSlacks an explicit__init__, missing its intended default URL configuration. Move lines 464–467 toDeerAPITTSto resolve the endpoint routing.🐛 Proposed fix
class DeerAPITTS(OpenAITTS): _FACTORY_NAME = "DeerAPI" + + def __init__(self, key, model_name, base_url="https://api.deerapi.com/v1", **kwargs): + if not base_url: + base_url = "https://api.deerapi.com/v1" + super().__init__(key, model_name, base_url, **kwargs) + + class AstraflowTTS(OpenAITTS): _FACTORY_NAME = "Astraflow" @@ def __init__(self, key, model_name, base_url="https://api.modelverse.cn/v1", **kwargs): if not base_url: base_url = "https://api.modelverse.cn/v1" super().__init__(key, model_name, base_url, **kwargs) - - def __init__(self, key, model_name, base_url="https://api.deerapi.com/v1", **kwargs): - if not base_url: - base_url = "https://api.deerapi.com/v1" - super().__init__(key, model_name, base_url, **kwargs)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@rag/llm/tts_model.py` around lines 444 - 467, AstraflowCNTTS currently has two __init__ definitions which overwrote the China endpoint initializer; remove the duplicate __init__ that sets base_url="https://api.deerapi.com/v1" from AstraflowCNTTS and instead add that initializer to DeerAPITTS so DeerAPITTS.__init__(key, model_name, base_url="https://api.deerapi.com/v1", **kwargs) sets the default DeerAPI URL and calls super().__init__(...), while AstraflowCNTTS retains its China endpoint __init__ (base_url="https://api.modelverse.cn/v1"); keep the _FACTORY_NAME values as-is.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@conf/llm_factories.json`:
- Around line 6299-6303: The factory entries for "Astraflow" and "Astraflow-CN"
advertise the capability tag "TEXT RE-RANK" but their "llm" arrays lack any
rerank model entries; either add the appropriate Astraflow rerank model objects
into each factory's "llm" list (matching the shape of other models in the file
and using the provider's rerank model names/ids), or remove "TEXT RE-RANK" from
the factory "tags" field for both factories so rerank is not advertised until
models are added; update the same change for both occurrences mentioned in the
comment.
In `@rag/llm/chat_model.py`:
- Around line 39-56: The AstraflowChat and AstraflowCNChat classes currently
inherit from Base before Base is defined, causing a NameError; move the class
definitions for AstraflowChat and AstraflowCNChat so they appear after the Base
class definition (keep their _FACTORY_NAME, __init__ signatures, default
base_url values, and super().__init__ calls unchanged) and ensure any references
to these classes still import or instantiate them after the module-level Base is
available.
---
Outside diff comments:
In `@rag/llm/sequence2txt_model.py`:
- Around line 307-331: AstraflowCNSeq2txt currently has two __init__ methods;
the second one (which sets base_url to "https://api.deerapi.com/v1" and
initializes self.client = OpenAI(...)) should be moved to DeerAPISeq2txt so
AstraflowCNSeq2txt keeps its correct Astraflow-CN initialization. Remove the
duplicate __init__ from AstraflowCNSeq2txt (leave the one that defaults base_url
to "https://api.modelverse.cn/v1" and calls super().__init__) and add the moved
__init__ to DeerAPISeq2txt (use the existing signature key,
model_name="whisper-1", base_url="https://api.deerapi.com/v1", check/fallback if
not base_url, then set self.client = OpenAI(api_key=key, base_url=base_url) and
self.model_name = model_name).
In `@rag/llm/tts_model.py`:
- Around line 444-467: AstraflowCNTTS currently has two __init__ definitions
which overwrote the China endpoint initializer; remove the duplicate __init__
that sets base_url="https://api.deerapi.com/v1" from AstraflowCNTTS and instead
add that initializer to DeerAPITTS so DeerAPITTS.__init__(key, model_name,
base_url="https://api.deerapi.com/v1", **kwargs) sets the default DeerAPI URL
and calls super().__init__(...), while AstraflowCNTTS retains its China endpoint
__init__ (base_url="https://api.modelverse.cn/v1"); keep the _FACTORY_NAME
values as-is.
🪄 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
Run ID: 6e51f37a-7d9d-47b4-9a59-ef496c000290
📒 Files selected for processing (8)
conf/llm_factories.jsonrag/llm/__init__.pyrag/llm/chat_model.pyrag/llm/cv_model.pyrag/llm/embedding_model.pyrag/llm/rerank_model.pyrag/llm/sequence2txt_model.pyrag/llm/tts_model.py
|
@ucloudnb666 would you please fix lint errors? |
- rag/llm/chat_model.py: move AstraflowChat and AstraflowCNChat below the Base class definition (prev location caused NameError at import time); restore from common.misc_utils import thread_pool_exec to its proper position among module imports. - rag/llm/sequence2txt_model.py, tts_model.py: restore DeerAPI __init__ methods that had been merged into the adjacent Astraflow-CN classes, resolving ruff F811 redefinition errors. - conf/llm_factories.json: drop TEXT RE-RANK from Astraflow / Astraflow-CN factory tags since no rerank models are listed. - rag/llm/rerank_model.py: remove AstraflowRerank / AstraflowCNRerank classes to match the factory tag change.
- conf/llm_factories.json: Astraflow / Astraflow-CN tags no longer claim IMAGE2TEXT because the llm list contained no image2text model entries (same inconsistency coderabbit flagged for TEXT RE-RANK). - rag/llm/cv_model.py: remove AstraflowCV / AstraflowCNCV accordingly. - docs/guides/models/supported_models.mdx: add Astraflow and Astraflow-CN rows. rag/llm/__init__.py requires this doc to stay in sync.
… + embedding The previous factory entries listed 23 model names per factory, but 19 of them do not exist on the Astraflow platform (verified via /v1/models). Users selecting those entries would have gotten 404s from the API. - conf/llm_factories.json: rewrite Astraflow and Astraflow-CN llm lists using only models that are currently served by Astraflow (18 chat + 3 embedding, cross-checked against the live /v1/models endpoint at https://api.modelverse.cn/v1/models). - Tags reduced to LLM + TEXT EMBEDDING. Speech2text / TTS were dropped because the platform's speech / tts endpoints are not OpenAI-compatible in a way that RAGFlow's GPTSeq2txt / OpenAITTS subclasses can drive. - rag/llm/tts_model.py, sequence2txt_model.py: remove AstraflowTTS / AstraflowCNTTS / AstraflowSeq2txt / AstraflowCNSeq2txt accordingly. - docs/guides/models/supported_models.mdx: update Astraflow / Astraflow-CN rows to check only LLM and Embedding columns. Verified locally: ruff check (whole repo), AST parse, factory tags vs model_type consistency, and every listed llm_name resolves against the live /v1/models API.
|
Pushed two follow-up commits (a89d08f, 23b9a49) addressing the review: Commit 1 — the three items from coderabbit & @JinHai-CN:
Commit 2 — two additional issues I caught during a full audit:
|
|
Pushed one more commit (6bae7a6) for a deeper audit — the previous entries Rewrote the Astraflow / Astraflow-CN llm lists using only models that the All checks still pass locally (ruff, AST, factory tag/type consistency, |
- Add is_tools: false to embedding entries (matches CometAPI / DeerAPI /
SILICONFLOW convention — all existing embedding entries carry this field).
- Rewrite context-size tag strings to use short forms ("1M" for 1_000_000,
"8K" for 8K embeddings) consistent with other factories, instead of
"1000k" / "8191".
|
Pushed one more alignment commit (eadb3ff) to match the JSON conventions
Full audit re-run locally (14 independent checks): ruff, AST structure, Ready for another round of review whenever you have time. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #14270 +/- ##
==========================================
- Coverage 97.41% 95.97% -1.44%
==========================================
Files 10 10
Lines 695 695
Branches 111 111
==========================================
- Hits 677 667 -10
- Misses 7 11 +4
- Partials 11 17 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
同步 infiniflow/ragflow main(v0.25.0 tag + 后续 commits)。 上游主要变更: - REST API 大重构:user/tenant/stats/plugin/chunk/document/file2document/ connector/langfuse/mcp/system/chat/search 全部迁到 api/apps/restful_apis/ - feat: Agent API (infiniflow#14157) / deepseek v4 (infiniflow#14346) / docling native chunking (infiniflow#14218) / Astraflow provider (infiniflow#14270) / title chunk 优化 (infiniflow#14325) - refactor: doc metadata update / agent webhook → REST / 移除 legacy MCP web API - Go 侧:retrieval_test in GO / stream think chat / zhipu thinking / minimax provider / balance command - 若干 fix:think tags normalization / upload truncation / audio-video pipeline - 7 个 ingestion_pipeline templates 重命名(Book→book 等) 冲突解决(2 处): - CLAUDE.md:保留 fork 专属整块(Fork 信息/端口/macOS 本地/活跃文档/首次运行 记录/Task Executor),追加上游新增的 Working Style 8 条作为独立段 - web/src/pages/dataset/testing/testing-result.tsx:保留 HEAD 版本 (P1.7-C4 设计对齐版已内含 upstream 要加的 RAGFlowPagination + isRuned 空态 文案,upstream 版被 HEAD 超集) 验证: - `pytest test/agent_v2/` → 301 passed / 8 skipped(RAGFLOW_TEST_DB gate) - 其它冲突文件 auto-merge 成功:dialog_service.py / docker/.env / pyproject.toml / uv.lock / locales/en.ts / dataset-table.tsx / testing-form.tsx Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Add Astraflow Provider Support
This PR integrates Astraflow (by UCloud / 优刻得) as a new AI model provider in RAGFlow, with support for both global and China endpoints.
About Astraflow
Astraflow is an OpenAI-compatible AI model aggregation platform supporting 200+ models from major providers including DeepSeek, Qwen, GPT, Claude, Gemini, Llama, Mistral, and more.
Astraflowhttps://api-us-ca.umodelverse.ai/v1ASTRAFLOW_API_KEYAstraflow-CNhttps://api.modelverse.cn/v1ASTRAFLOW_CN_API_KEYFiles Changed
rag/llm/__init__.pyAstraflowandAstraflow-CNinSupportedLiteLLMProviderenum,FACTORY_DEFAULT_BASE_URL, andLITELLM_PROVIDER_PREFIXrag/llm/chat_model.pyAstraflowChatandAstraflowCNChat(OpenAI-compatibleBasesubclass)rag/llm/embedding_model.pyAstraflowEmbedandAstraflowCNEmbed(subclasses ofOpenAIEmbed)rag/llm/rerank_model.pyAstraflowRerankandAstraflowCNRerank(subclasses ofOpenAI_APIRerank)rag/llm/cv_model.pyAstraflowCVandAstraflowCNCV(subclasses ofGptV4)rag/llm/tts_model.pyAstraflowTTSandAstraflowCNTTS(subclasses ofOpenAITTS)rag/llm/sequence2txt_model.pyAstraflowSeq2txtandAstraflowCNSeq2txt(subclasses ofGPTSeq2txt)conf/llm_factories.jsonAstraflowandAstraflow-CNfactories with a curated list of popular modelsSupported Model Types
Implementation Notes
openai/LiteLLM prefix — consistent with other OpenAI-compatible aggregation platforms (SILICONFLOW, DeerAPI, CometAPI, OpenRouter, n1n, Avian, etc.)Astraflow(global, rank 250) andAstraflow-CN(China, rank 249) are separate factory entries, allowing users to choose the optimal endpoint based on their region.Base,OpenAIEmbed,OpenAI_APIRerank,GptV4,OpenAITTS,GPTSeq2txt) with no custom logic needed — the provider is fully OpenAI-compatible.