This repository was archived by the owner on May 15, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathvertex.ts
More file actions
66 lines (56 loc) · 2.12 KB
/
Copy pathvertex.ts
File metadata and controls
66 lines (56 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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 modelId = this.options.apiModelId
let id: string
let info: ModelInfo
if (modelId && modelId in vertexModels) {
// Known Vertex model -- use its curated ModelInfo.
id = modelId as VertexModelId
info = vertexModels[id as VertexModelId]
} else if (modelId) {
// Custom / third-party MaaS model.
// Users may supply either a bare model name (e.g. "gpt-oss-120b-maas")
// or a fully-qualified publisher path
// (e.g. "publishers/openai/models/gpt-oss-120b-maas").
// Both forms are passed through as-is; the @google/genai SDK and
// Vertex AI API accept full resource names directly.
id = modelId
info = {
maxTokens: 8192,
contextWindow: 128_000,
supportsImages: true,
supportsPromptCache: false,
}
} else {
// No model specified -- fall back to the default.
id = vertexDefaultModelId
info = 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 }
}
}