Skip to content

Commit 751a18c

Browse files
hannesrudolphPeterDaveHello
authored andcommitted
feat(providers): add native tool calling support to LM Studio and Qwen-Code (RooCodeInc#10208)
1 parent 7416328 commit 751a18c

4 files changed

Lines changed: 14 additions & 0 deletions

File tree

packages/types/src/providers/lm-studio.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export const lMStudioDefaultModelInfo: ModelInfo = {
1010
contextWindow: 200_000,
1111
supportsImages: true,
1212
supportsPromptCache: true,
13+
supportsNativeTools: true,
14+
defaultToolProtocol: "native",
1315
inputPrice: 0,
1416
outputPrice: 0,
1517
cacheWritesPrice: 0,

packages/types/src/providers/qwen-code.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export const qwenCodeModels = {
1010
contextWindow: 1_000_000,
1111
supportsImages: false,
1212
supportsPromptCache: false,
13+
supportsNativeTools: true,
14+
defaultToolProtocol: "native",
1315
inputPrice: 0,
1416
outputPrice: 0,
1517
cacheWritesPrice: 0,
@@ -21,6 +23,8 @@ export const qwenCodeModels = {
2123
contextWindow: 1_000_000,
2224
supportsImages: false,
2325
supportsPromptCache: false,
26+
supportsNativeTools: true,
27+
defaultToolProtocol: "native",
2428
inputPrice: 0,
2529
outputPrice: 0,
2630
cacheWritesPrice: 0,

src/api/providers/lm-studio.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ export class LmStudioHandler extends BaseProvider implements SingleCompletionHan
4747
...convertToOpenAiMessages(messages),
4848
]
4949

50+
// LM Studio always supports native tools (https://lmstudio.ai/docs/developer/core/tools)
51+
const useNativeTools = metadata?.tools && metadata.tools.length > 0 && metadata?.toolProtocol !== "xml"
52+
5053
// -------------------------
5154
// Track token usage
5255
// -------------------------

src/api/providers/qwen-code.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ export class QwenCodeHandler extends BaseProvider implements SingleCompletionHan
212212
const client = this.ensureClient()
213213
const model = this.getModel()
214214

215+
// Check if model supports native tools and tools are provided with native protocol
216+
const supportsNativeTools = model.info.supportsNativeTools ?? false
217+
const useNativeTools =
218+
supportsNativeTools && metadata?.tools && metadata.tools.length > 0 && metadata?.toolProtocol !== "xml"
219+
215220
const systemMessage: OpenAI.Chat.ChatCompletionSystemMessageParam = {
216221
role: "system",
217222
content: systemPrompt,

0 commit comments

Comments
 (0)