update model categories' match rules - #2239
Conversation
WalkthroughThe changes expand and refine model category filtering logic across multiple AI vendors to classify additional model variants, new model series, and broader prefix patterns. This includes updated classifications for OpenAI, Gemini, Moonshot, Zhipu, MiniMax, Cohere, Mistral, and restored support for Yi category filtering. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Areas requiring extra attention:
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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: 0
🧹 Nitpick comments (2)
web/src/helpers/render.jsx (2)
164-176: Gemini filter: confirmembedding-prefix won’t match non‑Gemini modelsThe expanded conditions (gemini/gemma/learnlm/text-embedding-004/imagen-4/veo-/aqa) look aligned with Google’s current model families. The one potential risk is
startsWith('embedding-'), which will classify any model named likeembedding-*as Gemini; this is fine only if your catalog guarantees that prefix is unique to Gemini embeddings.If you do have non‑Gemini models whose names start with
embedding-, consider tightening this to a more vendor-specific pattern (e.g. a known full prefix) or switching to an explicit allowlist of Gemini embedding model IDs.
278-282: Yi category:includes('yi')may be too broad; consider tighteningIntroducing a dedicated Yi category is useful, but
model.model_name.toLowerCase().includes('yi')is very short and may accidentally match unrelated models if any happen to containyiin the middle of their IDs (e.g., custom names or future vendors).If your catalog allows, consider tightening this match—e.g. restricting to a prefix like
name.startsWith('yi-')or another known Yi-specific pattern—so you don’t reintroduce vendor misclassification issues.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
web/src/helpers/render.jsx(6 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-27T02:15:25.448Z
Learnt from: AAEE86
Repo: QuantumNous/new-api PR: 1658
File: web/src/components/table/channels/modals/EditChannelModal.jsx:555-569
Timestamp: 2025-08-27T02:15:25.448Z
Learning: In EditChannelModal.jsx, the applyModelMapping function transforms the models list by replacing original model names (mapping values) with display names (mapping keys). The database stores this transformed list containing mapped keys. On channel load, data.models contains these mapped display names, making the initialization filter if (data.models.includes(key)) correct.
Applied to files:
web/src/helpers/render.jsx
🔇 Additional comments (6)
web/src/helpers/render.jsx (6)
141-158: OpenAI filter: narrower match patterns look correctSwitching from generic
tts/text-style checks to specifictts-1,text-embedding-3, andtext-moderationstrings is consistent with current OpenAI model naming and should significantly reduce false OpenAI matches. No issues spotted with this logic.
177-183: Moonshot filter: Kimi inclusion is reasonableIncluding both
moonshotandkimiin the same filter matches how Moonshot brands its Kimi models and should help surface them under the expected category. Logic and syntax look fine.
184-192: Zhipu filter: extended coverage for GLM / CogView / CogVideoAdding matches for
glm-,cogview, andcogvideoalongsidechatglmappropriately expands Zhipu coverage to their newer chat and multimodal series. The conditions remain specific enough that they’re unlikely to capture unrelated vendors.
203-209: MiniMax filter: explicitminimaxmatch improves robustnessCombining the existing
ababcheck with an explicitminimaxsubstring is a sensible way to catch both legacy and clearly branded MiniMax models. No obvious risk of over-matching here.
230-237: Cohere filter: expanded patterns align with Cohere model namingThe added checks for
c4ai-(Cohere for AI / Aya) andembed-align with Cohere’s public model IDs (e.g.embed-english-*,embed-multilingual-*). Given OpenAI and others don’t typically use anembed-prefix, this looks like a safe and accurate broadening.
253-262: Mistral filter: future‑proofing for new seriesCovering
mistral,codestral,pixtral,voxtral, andmagistralgives good forward compatibility with Mistral’s current and announced series, and the substrings are niche enough that accidental matches should be rare. Implementation looks correct.
update model categories' match rules
update model categories' match rules
更新部分模型的供应商匹配规则,减少误匹配情况,如下图:
Summary by CodeRabbit