|
|
@@ -1,7 +1,7 @@
|
|
|
import { Tool as AnthropicTool } from "@anthropic-ai/sdk/resources/index"
|
|
|
import { AnthropicVertex } from "@anthropic-ai/vertex-sdk"
|
|
|
import { FunctionDeclaration as GoogleTool } from "@google/genai"
|
|
|
-import { ModelInfo, VertexModelId, vertexDefaultModelId, vertexModels } from "@shared/api"
|
|
|
+import { CLAUDE_SONNET_1M_SUFFIX, ModelInfo, VertexModelId, vertexDefaultModelId, vertexModels } from "@shared/api"
|
|
|
import { buildExternalBasicHeaders } from "@/services/EnvUtils"
|
|
|
import { ClineStorageMessage } from "@/shared/messages/content"
|
|
|
import { ClineTool } from "@/shared/tools"
|
|
|
@@ -73,10 +73,14 @@ export class VertexHandler implements ApiHandler {
|
|
|
@withRetry()
|
|
|
async *createMessage(systemPrompt: string, messages: ClineStorageMessage[], tools?: ClineTool[]): ApiStream {
|
|
|
const model = this.getModel()
|
|
|
- const modelId = model.id
|
|
|
+ const rawModelId = model.id
|
|
|
+ const modelId = rawModelId.endsWith(CLAUDE_SONNET_1M_SUFFIX)
|
|
|
+ ? rawModelId.slice(0, -CLAUDE_SONNET_1M_SUFFIX.length)
|
|
|
+ : rawModelId
|
|
|
+ const enable1mContextWindow = rawModelId.endsWith(CLAUDE_SONNET_1M_SUFFIX)
|
|
|
|
|
|
// For Gemini models, use the GeminiHandler
|
|
|
- if (!modelId.includes("claude")) {
|
|
|
+ if (!rawModelId.includes("claude")) {
|
|
|
const geminiHandler = this.ensureGeminiHandler()
|
|
|
yield* geminiHandler.createMessage(systemPrompt, messages, tools as GoogleTool[])
|
|
|
return
|
|
|
@@ -117,9 +121,13 @@ export class VertexHandler implements ApiHandler {
|
|
|
// NOTE: Forcing tool use when tools are provided will result in error when thinking is also enabled.
|
|
|
tool_choice: nativeToolsOn && !reasoningOn ? { type: "any" } : undefined,
|
|
|
},
|
|
|
- {
|
|
|
- headers: {},
|
|
|
- },
|
|
|
+ enable1mContextWindow
|
|
|
+ ? {
|
|
|
+ headers: {
|
|
|
+ "anthropic-beta": "context-1m-2025-08-07",
|
|
|
+ },
|
|
|
+ }
|
|
|
+ : undefined,
|
|
|
)
|
|
|
|
|
|
const lastStartedToolCall = { id: "", name: "", arguments: "" }
|