Skip to content

Commit 821676a

Browse files
authored
Merge pull request #3088 from mcowger/mcowger/vertex
fix(anthropic-vertex): add manual baseURL configuration to fix out of date library
2 parents 69d1e2b + 3343092 commit 821676a

File tree

3 files changed

+29
-21
lines changed

3 files changed

+29
-21
lines changed

.changeset/big-fans-spend.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"kilo-code": minor
3+
---
4+
5+
Update base URL for Vertex Anthropic models to work around outdated library.

src/api/providers/__tests__/anthropic-vertex.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ describe("VertexHandler", () => {
6060
})
6161

6262
expect(AnthropicVertex).toHaveBeenCalledWith({
63+
baseURL: "https://aiplatform.googleapis.com/v1", // kilocode_change
6364
projectId: "test-project",
6465
region: "us-central1",
6566
})

src/api/providers/anthropic-vertex.ts

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,29 @@ export class AnthropicVertexHandler extends BaseProvider implements SingleComple
3434
const projectId = this.options.vertexProjectId ?? "not-provided"
3535
const region = this.options.vertexRegion ?? "us-east5"
3636

37-
if (this.options.vertexJsonCredentials) {
38-
this.client = new AnthropicVertex({
39-
projectId,
40-
region,
41-
googleAuth: new GoogleAuth({
42-
scopes: ["https://www.googleapis.com/auth/cloud-platform"],
43-
credentials: safeJsonParse<JWTInput>(this.options.vertexJsonCredentials, undefined),
44-
}),
45-
})
46-
} else if (this.options.vertexKeyFile) {
47-
this.client = new AnthropicVertex({
48-
projectId,
49-
region,
50-
googleAuth: new GoogleAuth({
51-
scopes: ["https://www.googleapis.com/auth/cloud-platform"],
52-
keyFile: this.options.vertexKeyFile,
53-
}),
54-
})
55-
} else {
56-
this.client = new AnthropicVertex({ projectId, region })
57-
}
37+
//kilocode_change start
38+
// Manually construct the baseURL because the format has changed (there are no longer
39+
// dedicated hosts), but the required updated Anthropic libraries have significant
40+
// breaking changes for other parts of the application.
41+
const updatedBaseUrl = `https://aiplatform.googleapis.com/v1`
42+
43+
const googleAuthConfig =
44+
this.options.vertexJsonCredentials || this.options.vertexKeyFile
45+
? {
46+
scopes: ["https://www.googleapis.com/auth/cloud-platform"],
47+
...(this.options.vertexJsonCredentials
48+
? { credentials: safeJsonParse<JWTInput>(this.options.vertexJsonCredentials, undefined) }
49+
: { keyFile: this.options.vertexKeyFile }),
50+
}
51+
: undefined
52+
53+
this.client = new AnthropicVertex({
54+
baseURL: updatedBaseUrl,
55+
projectId,
56+
region,
57+
...(googleAuthConfig && { googleAuth: new GoogleAuth(googleAuthConfig) }),
58+
})
59+
//kilocode_change end
5860
}
5961

6062
override async *createMessage(

0 commit comments

Comments
 (0)