Repository navigation
Addd OpenRouter OpenAI API compatible list models - #15764
Conversation
📝 WalkthroughWalkthroughThis PR extends the LLM model metadata system with three new backend providers. It adds OpenRouter with custom JSON key parsing and modality-based type mapping, introduces an OpenAIAPICompatible base class that infers capability types from model names, and provides VLLM and LMStudio as concrete OpenAI-compatible implementations. ChangesLLM Provider Backends
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
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: 1
🧹 Nitpick comments (1)
rag/llm/model_meta.py (1)
227-230: ⚡ Quick winAdd logging on new parse/fallback branches.
These new flows swallow parse/shape failures and return defaults without emitting diagnostics, which makes provider issues hard to debug in production.
As per coding guidelines, "
**/*.py: Add logging for new flows".Also applies to: 247-249, 342-343
🤖 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 227 - 230, The try/except around json.loads(api_key) currently swallows parse errors and returns the raw api_key without any diagnostics; update that block to log the exception and contextual info (masking secrets) before returning the fallback, and apply the same change to the other two fallback try/excepts referenced (the blocks around lines 247-249 and 342-343) so all parse/shape failures emit a clear log entry; use the module logger (logger or logging.getLogger(__name__)) to log the exception and a short message identifying the operation (e.g., "failed to parse provider API key payload") and include enough context to debug (provider name or masked api_key) while not exposing secrets.Source: Coding guidelines
🤖 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/model_meta.py`:
- Line 308: The raw substring hint "vl" in the vision_hint list is too broad and
causes false positives (e.g., tagging novel-* / evolve-* as IMAGE2TEXT in the
IMAGE2TEXT matching code around the IMAGE2TEXT branch at lines ~336-337). Make
the matching token-aware: either remove the "vl" hint, replace it with a
delimiter-aware token like " vl " or "-vl-" (matching the actual token format
used), or change the matcher to use word-boundary/regex checks when comparing
hints to names in the IMAGE2TEXT selection logic so "vl" no longer matches
inside other words.
---
Nitpick comments:
In `@rag/llm/model_meta.py`:
- Around line 227-230: The try/except around json.loads(api_key) currently
swallows parse errors and returns the raw api_key without any diagnostics;
update that block to log the exception and contextual info (masking secrets)
before returning the fallback, and apply the same change to the other two
fallback try/excepts referenced (the blocks around lines 247-249 and 342-343) so
all parse/shape failures emit a clear log entry; use the module logger (logger
or logging.getLogger(__name__)) to log the exception and a short message
identifying the operation (e.g., "failed to parse provider API key payload") and
include enough context to debug (provider name or masked api_key) while not
exposing secrets.
🪄 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: 5f028279-72ca-4c28-a98a-2b77aa63163e
📒 Files selected for processing (1)
rag/llm/model_meta.py
| _SPEECH2TEXT_HINTS = ("asr", "stt", "transcribe", "transcriber", "whisper") | ||
| _TTS_HINTS = ("tts", "text-to-speech") | ||
| _VISION_HINTS = ( | ||
| "vl", |
There was a problem hiding this comment.
Narrow the "vl" vision hint to avoid false positives.
Line 308 uses "vl" as a raw substring hint, so names like novel-*/evolve-* can be incorrectly tagged as IMAGE2TEXT at Line 336. Use token-aware matching (delimiter/word boundary) or remove this hint.
Proposed fix
class OpenAIAPICompatible(Base):
@@
- _VISION_HINTS = (
- "vl",
+ _VISION_HINTS = (
"vision",
"llava",
"internvl",
"minicpm-v",
"gpt-4o",
"glm-4v",
"qvq",
"qwen-vl",
"pixtral",
)
@@
`@classmethod`
def _contains_hint(cls, model_name, hints):
- return any(hint in model_name for hint in hints)
+ normalized = model_name.replace("_", "-")
+ for hint in hints:
+ if hint in normalized:
+ return True
+ # token-aware fallback for short aliases if added later
+ return FalseAlso applies to: 336-337
🤖 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` at line 308, The raw substring hint "vl" in the
vision_hint list is too broad and causes false positives (e.g., tagging novel-*
/ evolve-* as IMAGE2TEXT in the IMAGE2TEXT matching code around the IMAGE2TEXT
branch at lines ~336-337). Make the matching token-aware: either remove the "vl"
hint, replace it with a delimiter-aware token like " vl " or "-vl-" (matching
the actual token format used), or change the matcher to use word-boundary/regex
checks when comparing hints to names in the IMAGE2TEXT selection logic so "vl"
no longer matches inside other words.
There was a problem hiding this comment.
how can novel-* or evolve-* has vl inside?
There was a problem hiding this comment.
@wangq8, you are absolutely right — I made a mistake. Spelling it out:
"novel"→n-o-v-e-l—'v'is followed by'e', not'l', so"vl"is not a substring."evolve"→e-v-o-l-v-e— neither'v'is immediately followed by'l', so"vl"is not a substring there either.
Those examples were factually wrong and I apologize for the confusion. The hint "vl" will only match model names where v is directly followed by l, such as qwen-vl, internvl, etc., which are precisely the intended vision model names. The concern is not valid as stated.
🐇 hops back into the burrow quietly
🧠 Learnings used
Learnt from: CR
Repo: infiniflow/ragflow PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-06-03T09:19:11.072Z
Learning: Applies to rag/llm/**/*.py : Use factory pattern with runtime class discovery for LLM provider integration in rag/llm/
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15764 +/- ##
=======================================
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 Harness. 🚀 New features to boost your workflow:
|
Addd OpenRouter OpenAI API compatible list models
Open Router

VLLM
