Skip to content

[Fix] filter tool call capability for non-LLM models#882

Merged
dingyi222666 merged 3 commits into
ChatLunaLab:v1-devfrom
Procyon-Nan:fix/model-capability-metadata
May 28, 2026
Merged

[Fix] filter tool call capability for non-LLM models#882
dingyi222666 merged 3 commits into
ChatLunaLab:v1-devfrom
Procyon-Nan:fix/model-capability-metadata

Conversation

@Procyon-Nan
Copy link
Copy Markdown
Contributor

Summary

  • Filter ToolCall from embedding and reranker model capabilities in BasePlatformClient.getModels().
  • Keep the existing ImageGeneration handling and TextInput capability normalization unchanged.
  • Ensure adapter-provided metadata cannot expose non-LLM models as tool-call capable through the platform registry.

Motivation

Some adapters can return embedding or reranker models with ModelCapabilities.ToolCall. Since model metadata is exposed through listAllModels() and listPlatformModels(), downstream UIs and plugins may incorrectly treat non-LLM models as supporting tool calls.

This fixes the issue at the core registry boundary instead of relying on UI-side filtering.

Validation

  • yarn fast-build core
  • yarn lint

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 BasePlatformClient to filter out ToolCall capabilities for models of type embeddings or reranker. A review comment suggests adding a nullish coalescing guard to model.capabilities to prevent potential TypeError exceptions if the capabilities array is undefined or null.

Comment thread packages/core/src/llm-core/platform/client.ts Outdated
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2a015353-13ad-4a81-ac57-9a5ca5f96f78

📥 Commits

Reviewing files that changed from the base of the PR and between 7c4c1ea and dba67c0.

📒 Files selected for processing (2)
  • packages/adapter-doubao/src/client.ts
  • packages/adapter-openai/src/client.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/adapter-doubao/src/client.ts
  • packages/adapter-openai/src/client.ts

Walkthrough

六个适配器包(Deepseek、Doubao、Hunyuan、OpenAI、OpenAI-like、Qwen)在 refreshModels() 中显式推导模型类型(llm/embeddings/reranker),并仅在类型为 LLM 时赋予 ModelCapabilities.ToolCall,非 LLM 类型不再默认包含该能力。

Changes

类型感知的模型能力过滤

Layer / File(s) Summary
单源适配器:类型感知能力过滤
packages/adapter-deepseek/src/client.ts, packages/adapter-doubao/src/client.ts, packages/adapter-hunyuan/src/client.ts, packages/adapter-openai/src/client.ts
Deepseek、Doubao、Hunyuan 和 OpenAI 适配器在 refreshModels() 中显式推导 type(LLM 或 embeddings),并在构造 capabilities 时仅当 type === ModelType.llm 时才包含 ModelCapabilities.ToolCall;非 LLM 模型的能力列表为空或不包含 ToolCall
OpenAI-like 适配器:additionalModels 和 rawModels 的双源过滤
packages/adapter-openai-like/src/client.ts
additionalModels 映射新增显式的 type 分支(embeddings/reranker/llm),并根据 type 调整 capabilities;对拉取到的 rawModels 的格式化改为仅当类型为 llm 时注入 supportToolCalling() 的 capabilities,否则置 capabilities: []
Qwen 适配器:additionalModels 与 expandedModels 的双源过滤
packages/adapter-qwen/src/client.ts
additionalModelsmodelType 推导 type 并在非 llm 时过滤移除 ModelCapabilities.ToolCallexpandedModelstypecapabilities 构造被重写为按类型条件包含 ToolCallImageInput

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • dingyi222666

Poem

🐰 模型各有其能力真,
大言未必能呼唤工具,
嵌入静默不需调用,
类型分明少了误判,
六处适配齐步看春风。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确反映了 PR 的主要变更:过滤非 LLM 模型(嵌入式和重排名器)的工具调用能力。
Description check ✅ Passed 描述清晰阐述了 PR 的目的、动机和验证步骤,与变更集直接相关。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

Comment thread packages/core/src/llm-core/platform/client.ts Outdated
更改内容:
- 撤销 core 层改动
- 调整 OpenAI、OpenAI-like、Hunyuan、DeepSeek、Doubao、Qwen 适配器,先确定模型类型,再声明 ToolCall 能力
- 对 additional models 中的非 LLM 模型过滤 ToolCall,避免 embedding/reranker 暴露错误能力
@dingyi222666 dingyi222666 merged commit 4351694 into ChatLunaLab:v1-dev May 28, 2026
5 checks passed
@Procyon-Nan Procyon-Nan deleted the fix/model-capability-metadata 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