Skip to content

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

Open
Procyon-Nan wants to merge 2 commits into
ChatLunaLab:v1-devfrom
Procyon-Nan:fix/model-capability-metadata
Open

[Fix] filter tool call capability for non-LLM models#882
Procyon-Nan wants to merge 2 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: f0aeef44-6ba4-4956-afb7-31399d58689e

📥 Commits

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

📒 Files selected for processing (6)
  • packages/adapter-deepseek/src/client.ts
  • packages/adapter-doubao/src/client.ts
  • packages/adapter-hunyuan/src/client.ts
  • packages/adapter-openai-like/src/client.ts
  • packages/adapter-openai/src/client.ts
  • packages/adapter-qwen/src/client.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/adapter-doubao/src/client.ts

Walkthrough

Six adapter packages (Deepseek, Doubao, Hunyuan, OpenAI, OpenAI-like, and Qwen) now compute model type during refreshModels() and conditionally assign ToolCall capability only to LLM models, filtering it from embedding and reranker models.

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 === llm 时才包含 ToolCall;非 LLM 模型的能力列表为空或不包含 ToolCall
OpenAI-like 适配器:additionalModels 和 rawModels 的双源过滤
packages/adapter-openai-like/src/client.ts
additionalModels 映射新增显式的 type 推导分支(embeddings/reranker/llm),根据 type 调整 capabilities;rawModels 的格式化仅当类型为 llm 时才注入 supportToolCalling() 的能力,否则置为空数组。
Qwen 适配器:additionalModels 和 expandedModels 的双源过滤
packages/adapter-qwen/src/client.ts
additionalModels 按 modelType 计算 type,在非 LLM 时过滤移除 ToolCall;expandedModels 改写 capabilities 构造逻辑,条件性地根据模型类型包含 ToolCallImageInput 能力。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • ChatLunaLab/chatluna#865: 同样修改 packages/adapter-openai/src/client.tspackages/adapter-openai-like/src/client.ts 中的 refreshModels() 与模型能力构造逻辑(本 PR 使 ToolCall 能力对 LLM vs embeddings 条件化;该 PR 新增 AudioInput 能力并为支持音频的模型注入文件处理配置),两者在代码层级相关。

Suggested reviewers

  • dingyi222666

Poem

🐰 模型各有其能力真,
大言未必通工具,
嵌入无需工具呼,
类型分明逻辑清,
六处适配齐步翻!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确地总结了本次变更的核心内容:为非LLM模型(嵌入和重排序模型)过滤ToolCall能力。
Description check ✅ Passed 描述与变更集相关,阐述了修复目的、动机和验证步骤,清楚地说明了为什么需要在多个适配器中过滤非LLM模型的ToolCall能力。
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 暴露错误能力
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