mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-09 22:31:08 +00:00
Look for a tag in the Roo provider to default the model to native tool calling (#9735)
This commit is contained in:
parent
d2b274a9af
commit
700fe42669
2 changed files with 109 additions and 1 deletions
|
|
@ -543,4 +543,106 @@ describe("getRooModels", () => {
|
|||
|
||||
expect(models["test/model-no-temp"].defaultTemperature).toBeUndefined()
|
||||
})
|
||||
|
||||
it("should set defaultToolProtocol to native when default-native-tools tag is present", async () => {
|
||||
const mockResponse = {
|
||||
object: "list",
|
||||
data: [
|
||||
{
|
||||
id: "test/native-tools-model",
|
||||
object: "model",
|
||||
created: 1234567890,
|
||||
owned_by: "test",
|
||||
name: "Native Tools Model",
|
||||
description: "Model with native tool calling default",
|
||||
context_window: 128000,
|
||||
max_tokens: 8192,
|
||||
type: "language",
|
||||
tags: ["tool-use", "default-native-tools"],
|
||||
pricing: {
|
||||
input: "0.0001",
|
||||
output: "0.0002",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
mockFetch.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
json: async () => mockResponse,
|
||||
})
|
||||
|
||||
const models = await getRooModels(baseUrl, apiKey)
|
||||
|
||||
expect(models["test/native-tools-model"].supportsNativeTools).toBe(true)
|
||||
expect(models["test/native-tools-model"].defaultToolProtocol).toBe("native")
|
||||
})
|
||||
|
||||
it("should imply supportsNativeTools when default-native-tools tag is present without tool-use tag", async () => {
|
||||
const mockResponse = {
|
||||
object: "list",
|
||||
data: [
|
||||
{
|
||||
id: "test/implicit-native-tools",
|
||||
object: "model",
|
||||
created: 1234567890,
|
||||
owned_by: "test",
|
||||
name: "Implicit Native Tools Model",
|
||||
description: "Model with default-native-tools but no tool-use tag",
|
||||
context_window: 128000,
|
||||
max_tokens: 8192,
|
||||
type: "language",
|
||||
tags: ["default-native-tools"], // Only default-native-tools, no tool-use
|
||||
pricing: {
|
||||
input: "0.0001",
|
||||
output: "0.0002",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
mockFetch.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
json: async () => mockResponse,
|
||||
})
|
||||
|
||||
const models = await getRooModels(baseUrl, apiKey)
|
||||
|
||||
expect(models["test/implicit-native-tools"].supportsNativeTools).toBe(true)
|
||||
expect(models["test/implicit-native-tools"].defaultToolProtocol).toBe("native")
|
||||
})
|
||||
|
||||
it("should not set defaultToolProtocol when default-native-tools tag is not present", async () => {
|
||||
const mockResponse = {
|
||||
object: "list",
|
||||
data: [
|
||||
{
|
||||
id: "test/non-native-model",
|
||||
object: "model",
|
||||
created: 1234567890,
|
||||
owned_by: "test",
|
||||
name: "Non-Native Tools Model",
|
||||
description: "Model without native tool calling default",
|
||||
context_window: 128000,
|
||||
max_tokens: 8192,
|
||||
type: "language",
|
||||
tags: ["tool-use"],
|
||||
pricing: {
|
||||
input: "0.0001",
|
||||
output: "0.0002",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
mockFetch.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
json: async () => mockResponse,
|
||||
})
|
||||
|
||||
const models = await getRooModels(baseUrl, apiKey)
|
||||
|
||||
expect(models["test/non-native-model"].supportsNativeTools).toBe(true)
|
||||
expect(models["test/non-native-model"].defaultToolProtocol).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -107,8 +107,13 @@ export async function getRooModels(baseUrl: string, apiKey?: string): Promise<Mo
|
|||
// Determine if the model requires reasoning effort based on tags
|
||||
const requiredReasoningEffort = tags.includes("reasoning-required")
|
||||
|
||||
// Determine if native tool calling should be the default protocol for this model
|
||||
const hasDefaultNativeTools = tags.includes("default-native-tools")
|
||||
const defaultToolProtocol = hasDefaultNativeTools ? ("native" as const) : undefined
|
||||
|
||||
// Determine if the model supports native tool calling based on tags
|
||||
const supportsNativeTools = tags.includes("tool-use")
|
||||
// default-native-tools implies tool-use support
|
||||
const supportsNativeTools = tags.includes("tool-use") || hasDefaultNativeTools
|
||||
|
||||
// Parse pricing (API returns strings, convert to numbers)
|
||||
const inputPrice = parseApiPrice(pricing.input)
|
||||
|
|
@ -133,6 +138,7 @@ export async function getRooModels(baseUrl: string, apiKey?: string): Promise<Mo
|
|||
deprecated: model.deprecated || false,
|
||||
isFree: tags.includes("free"),
|
||||
defaultTemperature: model.default_temperature,
|
||||
defaultToolProtocol,
|
||||
}
|
||||
|
||||
// Apply model-specific defaults (e.g., defaultToolProtocol)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue