mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix: enable native tool calls for Requesty provider (ROO-235) (#10211)
This commit is contained in:
parent
aabee0fb0b
commit
bade9326c6
5 changed files with 37 additions and 13 deletions
|
|
@ -71,6 +71,16 @@ export const TOOL_PROTOCOL = {
|
|||
*/
|
||||
export type ToolProtocol = (typeof TOOL_PROTOCOL)[keyof typeof TOOL_PROTOCOL]
|
||||
|
||||
/**
|
||||
* Default model info properties for native tool support.
|
||||
* Used to merge with cached model info that may lack these fields.
|
||||
* Router providers (Requesty, Unbound, LiteLLM) assume all models support native tools.
|
||||
*/
|
||||
export const NATIVE_TOOL_DEFAULTS = {
|
||||
supportsNativeTools: true,
|
||||
defaultToolProtocol: TOOL_PROTOCOL.NATIVE,
|
||||
} as const
|
||||
|
||||
/**
|
||||
* Checks if the protocol is native (non-XML).
|
||||
*
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ export async function getRequestyModels(baseUrl?: string, apiKey?: string): Prom
|
|||
supportsImages: rawModel.supports_vision,
|
||||
supportsReasoningBudget: reasoningBudget,
|
||||
supportsReasoningEffort: reasoningEffort,
|
||||
supportsNativeTools: true,
|
||||
defaultToolProtocol: "native",
|
||||
inputPrice: parseApiPrice(rawModel.input_price),
|
||||
outputPrice: parseApiPrice(rawModel.output_price),
|
||||
description: rawModel.description,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,13 @@
|
|||
import { Anthropic } from "@anthropic-ai/sdk"
|
||||
import OpenAI from "openai"
|
||||
|
||||
import { type ModelInfo, requestyDefaultModelId, requestyDefaultModelInfo, TOOL_PROTOCOL } from "@roo-code/types"
|
||||
import {
|
||||
type ModelInfo,
|
||||
requestyDefaultModelId,
|
||||
requestyDefaultModelInfo,
|
||||
TOOL_PROTOCOL,
|
||||
NATIVE_TOOL_DEFAULTS,
|
||||
} from "@roo-code/types"
|
||||
|
||||
import type { ApiHandlerOptions, ModelRecord } from "../../shared/api"
|
||||
import { resolveToolProtocol } from "../../utils/resolveToolProtocol"
|
||||
|
|
@ -79,7 +85,11 @@ export class RequestyHandler extends BaseProvider implements SingleCompletionHan
|
|||
|
||||
override getModel() {
|
||||
const id = this.options.requestyModelId ?? requestyDefaultModelId
|
||||
let info = this.models[id] ?? requestyDefaultModelInfo
|
||||
const cachedInfo = this.models[id] ?? requestyDefaultModelInfo
|
||||
|
||||
// Merge native tool defaults for cached models that may lack these fields
|
||||
// The order ensures that cached values (if present) override the defaults
|
||||
let info: ModelInfo = { ...NATIVE_TOOL_DEFAULTS, ...cachedInfo }
|
||||
|
||||
// Apply tool preferences for models accessed through routers (OpenAI, Gemini)
|
||||
info = applyRouterToolPreferences(id, info)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import OpenAI from "openai"
|
||||
|
||||
import type { ModelInfo } from "@roo-code/types"
|
||||
import { type ModelInfo, NATIVE_TOOL_DEFAULTS } from "@roo-code/types"
|
||||
|
||||
import { ApiHandlerOptions, RouterName, ModelRecord } from "../../shared/api"
|
||||
|
||||
|
|
@ -64,8 +64,9 @@ export abstract class RouterProvider extends BaseProvider {
|
|||
const id = this.modelId ?? this.defaultModelId
|
||||
|
||||
// First check instance models (populated by fetchModel)
|
||||
// Merge native tool defaults for cached models that may lack these fields
|
||||
if (this.models[id]) {
|
||||
return { id, info: this.models[id] }
|
||||
return { id, info: { ...NATIVE_TOOL_DEFAULTS, ...this.models[id] } }
|
||||
}
|
||||
|
||||
// Fall back to global cache (synchronous disk/memory cache)
|
||||
|
|
@ -74,7 +75,7 @@ export abstract class RouterProvider extends BaseProvider {
|
|||
if (cachedModels?.[id]) {
|
||||
// Also populate instance models for future calls
|
||||
this.models = cachedModels
|
||||
return { id, info: cachedModels[id] }
|
||||
return { id, info: { ...NATIVE_TOOL_DEFAULTS, ...cachedModels[id] } }
|
||||
}
|
||||
|
||||
// Last resort: return default model
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import {
|
|||
BEDROCK_1M_CONTEXT_MODEL_IDS,
|
||||
isDynamicProvider,
|
||||
getProviderDefaultModelId,
|
||||
NATIVE_TOOL_DEFAULTS,
|
||||
} from "@roo-code/types"
|
||||
|
||||
import type { ModelRecord, RouterModels } from "@roo/api"
|
||||
|
|
@ -157,23 +158,23 @@ function getSelectedModel({
|
|||
}
|
||||
case "requesty": {
|
||||
const id = getValidatedModelId(apiConfiguration.requestyModelId, routerModels.requesty, defaultModelId)
|
||||
const info = routerModels.requesty?.[id]
|
||||
const routerInfo = routerModels.requesty?.[id]
|
||||
// Merge native tool defaults for cached models that may lack these fields
|
||||
const info = routerInfo ? { ...NATIVE_TOOL_DEFAULTS, ...routerInfo } : undefined
|
||||
return { id, info }
|
||||
}
|
||||
case "unbound": {
|
||||
const id = getValidatedModelId(apiConfiguration.unboundModelId, routerModels.unbound, defaultModelId)
|
||||
const info = routerModels.unbound?.[id]
|
||||
const routerInfo = routerModels.unbound?.[id]
|
||||
// Merge native tool defaults for cached models that may lack these fields
|
||||
const info = routerInfo ? { ...NATIVE_TOOL_DEFAULTS, ...routerInfo } : undefined
|
||||
return { id, info }
|
||||
}
|
||||
case "litellm": {
|
||||
const id = getValidatedModelId(apiConfiguration.litellmModelId, routerModels.litellm, defaultModelId)
|
||||
const routerInfo = routerModels.litellm?.[id]
|
||||
// Only merge native tool call defaults, not prices or other model-specific info
|
||||
const nativeToolDefaults = {
|
||||
supportsNativeTools: litellmDefaultModelInfo.supportsNativeTools,
|
||||
defaultToolProtocol: litellmDefaultModelInfo.defaultToolProtocol,
|
||||
}
|
||||
const info = routerInfo ? { ...nativeToolDefaults, ...routerInfo } : litellmDefaultModelInfo
|
||||
// Merge native tool defaults for cached models that may lack these fields
|
||||
const info = routerInfo ? { ...NATIVE_TOOL_DEFAULTS, ...routerInfo } : litellmDefaultModelInfo
|
||||
return { id, info }
|
||||
}
|
||||
case "xai": {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue