Skip to content

[Fix] add vision model patterns to image input whitelist#884

Merged
dingyi222666 merged 2 commits into
ChatLunaLab:v1-devfrom
Procyon-Nan:fix/image-input-model-whitelist
May 28, 2026
Merged

[Fix] add vision model patterns to image input whitelist#884
dingyi222666 merged 2 commits into
ChatLunaLab:v1-devfrom
Procyon-Nan:fix/image-input-model-whitelist

Conversation

@Procyon-Nan
Copy link
Copy Markdown
Contributor

Summary

  • Add GLM vision model patterns to the shared image-input model matcher.
  • Add OCR model matching so OCR-capable models can be marked with ImageInput.
  • Keep the existing matcher structure unchanged.

Motivation

Some models support image input but were not marked with ModelCapabilities.ImageInput because 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-adapter
  • yarn lint

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

Review Change Stack

Walkthrough

调整了 glob-matcher 的匹配边界(在分隔符边界内匹配而不是整串匹配),并将图片模型匹配列表中的 kimi-k2.5 扩展为 kimi-k2.*,同时新增 ocr 条目,影响对图片输入支持的模型识别。

变更

模型匹配行为更新

层级 / 文件 摘要
调整 createGlobMatcher 正则边界
packages/shared-adapter/src/client.ts
将 glob-to-regex 的匹配从整串匹配改为在 [:/_-] 分隔符边界内命中,保留 * -> .* 转换并对其他特殊字符转义,改变所有使用该 matcher 的模型名匹配行为。
扩展 imageModelMatchers 列表
packages/shared-adapter/src/client.ts
kimi-k2.5 扩展为 kimi-k2.* 并新增 ocr 条目,使 supportImageInput(modelName) 对包含这些片段的模型名返回肯定匹配。

代码审查工作量

🎯 3 (Moderate) | ⏱️ ~20 minutes

可能相关的拉取请求

建议审查人

  • dingyi222666

庆祝诗

🐰 我在代码田间跳跃,
新的星号织出新花边,
kimi-k2.* 与 ocr 登场,
模型名单又宽又暖,
小兔鼓掌为变更欢!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确概括了主要变更:为图像输入白名单添加视觉模型模式,与代码改动完全相关。
Description check ✅ Passed 描述清晰关联到代码变更,说明了添加GLM视觉模型模式和OCR模型匹配的改动。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/shared-adapter/src/client.ts Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/shared-adapter/src/client.ts (1)

185-187: ⚡ Quick win

移除冗余的 GLM 模型匹配项。

第 184 行的 glob 模式 'glm-*v' 会被转换为正则表达式 ^glm-.*v$,已经能够匹配 glm-4.1vglm-4.6vglm-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

📥 Commits

Reviewing files that changed from the base of the PR and between b272a80 and c116865.

📒 Files selected for processing (1)
  • packages/shared-adapter/src/client.ts

Comment thread packages/shared-adapter/src/client.ts Outdated
带 * 的白名单项现在可以匹配模型名中的分隔片段,不再要求完整模型名匹配。同时在转换 glob pattern 前转义正则特殊字符,并增加 kimi-k2.* 以覆盖 kimi-k2.x 系列版本模型。
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between c116865 and a8de4e7.

📒 Files selected for processing (1)
  • packages/shared-adapter/src/client.ts

@dingyi222666
Copy link
Copy Markdown
Member

明天合并吧我待会睡觉了

@dingyi222666 dingyi222666 merged commit f7ddb15 into ChatLunaLab:v1-dev May 28, 2026
5 checks passed
@Procyon-Nan Procyon-Nan deleted the fix/image-input-model-whitelist branch May 28, 2026 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants