mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-29 06:32:42 +00:00
Previously, when a user provided a custom model ID not in the predefined list, many providers would silently replace it with the default model ID. This affected: Anthropic, Anthropic Vertex, Gemini, MiniMax, OpenAI Codex, OpenAI Native, Vertex, xAI, and BaseOpenAiCompatibleProvider (which also affects SambaNova, Baseten, Fireworks, Z.ai). Now, all providers preserve the user's custom model ID and only fall back to the default model's *info* (capabilities/pricing metadata) when the model is not in the predefined list. This matches the pattern already used by DeepSeek, Moonshot, Mistral, and QwenCode. Closes #11964
39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import { type ModelInfo, type VertexModelId, vertexDefaultModelId, vertexModels } from "@roo-code/types"
|
|
|
|
import type { ApiHandlerOptions } from "../../shared/api"
|
|
|
|
import { getModelParams } from "../transform/model-params"
|
|
|
|
import { GeminiHandler } from "./gemini"
|
|
import { SingleCompletionHandler } from "../index"
|
|
|
|
export class VertexHandler extends GeminiHandler implements SingleCompletionHandler {
|
|
constructor(options: ApiHandlerOptions) {
|
|
super({ ...options, isVertex: true })
|
|
}
|
|
|
|
override getModel() {
|
|
const id = this.options.apiModelId ?? vertexDefaultModelId
|
|
let info: ModelInfo = vertexModels[id as VertexModelId] || vertexModels[vertexDefaultModelId]
|
|
const params = getModelParams({
|
|
format: "gemini",
|
|
modelId: id,
|
|
model: info,
|
|
settings: this.options,
|
|
defaultTemperature: info.defaultTemperature ?? 1,
|
|
})
|
|
|
|
// Vertex Gemini models perform better with the edit tool instead of apply_diff.
|
|
info = {
|
|
...info,
|
|
excludedTools: [...new Set([...(info.excludedTools || []), "apply_diff"])],
|
|
includedTools: [...new Set([...(info.includedTools || []), "edit"])],
|
|
}
|
|
|
|
// The `:thinking` suffix indicates that the model is a "Hybrid"
|
|
// reasoning model and that reasoning is required to be enabled.
|
|
// The actual model ID honored by Gemini's API does not have this
|
|
// suffix.
|
|
return { id: id.endsWith(":thinking") ? id.replace(":thinking", "") : id, info, ...params }
|
|
}
|
|
}
|