Skip to content

Commit f38592f

Browse files
committed
Add cache breakpoints for custom vertex models on Unbound
1 parent a9c1dad commit f38592f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/api/providers/fetchers/unbound.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export async function getUnboundModels(apiKey?: string | null): Promise<Record<s
2020
for (const [modelId, model] of Object.entries(rawModels)) {
2121
const modelInfo: ModelInfo = {
2222
maxTokens: model?.maxTokens ? parseInt(model.maxTokens) : undefined,
23-
contextWindow: model?.contextWindow ? parseInt(model.contextWindow) : 0,
23+
contextWindow: model?.contextWindow ? parseInt(model.contextWindow) : 128_000,
2424
supportsImages: model?.supportsImages ?? false,
2525
supportsPromptCache: model?.supportsPromptCaching ?? false,
2626
supportsComputerUse: model?.supportsComputerUse ?? false,

src/api/providers/unbound.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { ApiStream, ApiStreamUsageChunk } from "../transform/stream"
99
import { convertToOpenAiMessages } from "../transform/openai-format"
1010
import { addCacheBreakpoints as addAnthropicCacheBreakpoints } from "../transform/caching/anthropic"
1111
import { addCacheBreakpoints as addGeminiCacheBreakpoints } from "../transform/caching/gemini"
12+
import { addCacheBreakpoints as addVertexCacheBreakpoints } from "../transform/caching/vertex"
1213

1314
import type { SingleCompletionHandler, ApiHandlerCreateMessageMetadata } from "../index"
1415
import { RouterProvider } from "./router-provider"
@@ -70,6 +71,10 @@ export class UnboundHandler extends RouterProvider implements SingleCompletionHa
7071
addAnthropicCacheBreakpoints(systemPrompt, openAiMessages)
7172
}
7273
}
74+
// Custom models from Vertex AI (no configuration) need to be handled differently.
75+
if (modelId.startsWith("vertex-ai/google.") || modelId.startsWith("vertex-ai/anthropic.")) {
76+
addVertexCacheBreakpoints(messages)
77+
}
7378

7479
// Required by Anthropic; other providers default to max tokens allowed.
7580
let maxTokens: number | undefined

0 commit comments

Comments
 (0)