[Fix] add vision model patterns to image input whitelist#884
Conversation
Walkthrough调整了 glob-matcher 的匹配边界(在分隔符边界内匹配而不是整串匹配),并将图片模型匹配列表中的 变更模型匹配行为更新
代码审查工作量🎯 3 (Moderate) | ⏱️ ~20 minutes 可能相关的拉取请求
建议审查人
庆祝诗
🚥 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. ✨ 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.
Code Review
This pull request updates the list of image model matchers in the shared adapter client to include newer GLM vision models and an OCR model. The reviewer suggested using a more robust wildcard pattern ('glm-v') instead of manually listing individual GLM model versions, which simplifies the code and avoids future manual updates.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/shared-adapter/src/client.ts (1)
185-187: ⚡ Quick win移除冗余的 GLM 模型匹配项。
第 184 行的 glob 模式
'glm-*v'会被转换为正则表达式^glm-.*v$,已经能够匹配glm-4.1v、glm-4.6v、glm-5v等所有符合该模式的字符串。这三个具体的匹配项是冗余的,永远不会被执行到。根据编码规范,应当编写最简单的可工作代码。♻️ 建议移除冗余项
'gpt-4.1', 'gpt-5', 'glm-*v', - 'glm-4.1v', - 'glm-4.6v', - 'glm-5v', 'kimi-k2.5', 'step3',🤖 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 `@packages/shared-adapter/src/client.ts` around lines 185 - 187, 数组中有已包含通配模式 'glm-*v',它会编译为正则 ^glm-.*v$ 并覆盖具体条目 'glm-4.1v'、'glm-4.6v'、'glm-5v',所以请在包含这些字符串的模型匹配列表中移除冗余的具体项 'glm-4.1v'、'glm-4.6v' 和 'glm-5v',只保留通配模式 'glm-*v' 即可,确保相关代码(查找包含这些字符串的数组/常量)不会再包含重复匹配项。
🤖 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.
Nitpick comments:
In `@packages/shared-adapter/src/client.ts`:
- Around line 185-187: 数组中有已包含通配模式 'glm-*v',它会编译为正则 ^glm-.*v$ 并覆盖具体条目
'glm-4.1v'、'glm-4.6v'、'glm-5v',所以请在包含这些字符串的模型匹配列表中移除冗余的具体项 'glm-4.1v'、'glm-4.6v'
和 'glm-5v',只保留通配模式 'glm-*v' 即可,确保相关代码(查找包含这些字符串的数组/常量)不会再包含重复匹配项。
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 9e337cda-eafb-494c-8855-9d2c24d65793
📒 Files selected for processing (1)
packages/shared-adapter/src/client.ts
带 * 的白名单项现在可以匹配模型名中的分隔片段,不再要求完整模型名匹配。同时在转换 glob pattern 前转义正则特殊字符,并增加 kimi-k2.* 以覆盖 kimi-k2.x 系列版本模型。
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/shared-adapter/src/client.ts (1)
156-159: ⚡ Quick win建议补充匹配器边界变更的回归测试。
这里把
*的匹配语义改成了分隔符边界匹配,同时新增了kimi-k2.*与ocr模式。建议补一组正反例测试,锁定新语义,避免后续调整时出现模型能力误判。Also applies to: 188-188
🤖 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 `@packages/shared-adapter/src/client.ts` around lines 156 - 159, Add regression tests that validate the changed matcher boundary semantics implemented where the pattern is escaped into source and compiled into regex (the code that builds source and regex). Specifically, add positive and negative test cases for patterns including "kimi-k2.*" and "ocr" that assert matches only when the wildcard spans token parts separated by separators (characters :, /, _, -) and does not match inside longer tokens; include examples with separators on both sides and cases without separators to lock the new (^|[:/_-])...($|[:/_-]) behavior. Target the module that constructs the regex (the variables pattern -> source -> regex) and assert both matching and non-matching strings to prevent regressions.
🤖 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.
Nitpick comments:
In `@packages/shared-adapter/src/client.ts`:
- Around line 156-159: Add regression tests that validate the changed matcher
boundary semantics implemented where the pattern is escaped into source and
compiled into regex (the code that builds source and regex). Specifically, add
positive and negative test cases for patterns including "kimi-k2.*" and "ocr"
that assert matches only when the wildcard spans token parts separated by
separators (characters :, /, _, -) and does not match inside longer tokens;
include examples with separators on both sides and cases without separators to
lock the new (^|[:/_-])...($|[:/_-]) behavior. Target the module that constructs
the regex (the variables pattern -> source -> regex) and assert both matching
and non-matching strings to prevent regressions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: a1093763-32ea-4bf4-b109-8a2800910095
📒 Files selected for processing (1)
packages/shared-adapter/src/client.ts
|
明天合并吧我待会睡觉了 |
Summary
ImageInput.Motivation
Some models support image input but were not marked with
ModelCapabilities.ImageInputbecause their names did not match the shared image model whitelist.This updates the shared matcher used by OpenAI-compatible adapters so those models can display vision capability correctly.
Validation
yarn fast-build shared-adapteryarn lint