Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions web/default/src/features/usage-logs/components/model-badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,36 @@ function resolveModelProvider(modelName: string): ModelProvider | null {
if (hasAny(['moonshot-', 'kimi-'])) {
return { icon: 'Moonshot.Color', label: 'Moonshot' }
}
if (hasAny(['minimax', 'abab'])) {
return { icon: 'Minimax.Color', label: 'MiniMax' }
}
if (hasAny(['glm-', 'chatglm', 'cogview', 'cogvideo'])) {
return { icon: 'Zhipu.Color', label: 'Zhipu' }
}
if (hasAny(['mimo-'])) {
return { icon: 'XiaomiMiMo', label: 'MiMo' }
}
if (hasAny(['ernie'])) {
return { icon: 'Wenxin.Color', label: 'Baidu' }
}
if (hasAny(['spark'])) {
return { icon: 'Spark.Color', label: 'iFlyTek' }
Comment on lines +91 to +95

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Avoid ambiguous substring matching for provider detection.

Using plain includes('ernie') / includes('spark') can misclassify unrelated model IDs that merely contain those substrings. Prefer boundary/prefix-aware checks for these tokens.

Suggested tightening
-  if (hasAny(['ernie'])) {
+  if (/\bernie(?:-|$)/.test(model)) {
     return { icon: 'Wenxin.Color', label: 'Baidu' }
   }
-  if (hasAny(['spark'])) {
+  if (/\bspark(?:-|$)/.test(model)) {
     return { icon: 'Spark.Color', label: 'iFlyTek' }
   }
🤖 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 `@web/default/src/features/usage-logs/components/model-badge.tsx` around lines
91 - 95, The provider detection logic in model-badge.tsx uses substring matching
with hasAny() calls that can incorrectly match unrelated model IDs containing
those substrings (e.g., 'ernie' or 'spark'). Replace the simple substring-based
checks in the conditions for Baidu (hasAny(['ernie'])) and iFlyTek
(hasAny(['spark'])) with boundary-aware or prefix-aware matching that checks for
these tokens as complete identifiers or at word boundaries, ensuring only actual
models from these providers are detected correctly.

}
if (hasAny(['hunyuan'])) {
return { icon: 'Hunyuan.Color', label: 'Tencent' }
}
if (hasAny(['baichuan'])) {
return { icon: 'Baichuan.Color', label: 'Baichuan' }
}
if (hasAny(['internlm'])) {
return { icon: 'InternLM.Color', label: 'InternLM' }
}
if (hasAny(['step-'])) {
return { icon: 'StepFun.Color', label: 'StepFun' }
}
if (hasAny(['yi-'])) {
return { icon: 'Yi.Color', label: 'Yi' }
}
if (hasAny(['mistral-', 'mixtral-'])) {
return { icon: 'Mistral.Color', label: 'Mistral' }
}
Expand Down