-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix: handle global region correctly for Vertex AI Claude models #8573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -34,10 +34,16 @@ export class AnthropicVertexHandler extends BaseProvider implements SingleComple | |||||||||
| const projectId = this.options.vertexProjectId ?? "not-provided" | ||||||||||
| const region = this.options.vertexRegion ?? "us-east5" | ||||||||||
|
|
||||||||||
| // For the "global" region, we need to use a custom base URL | ||||||||||
| // The default would be "global-aiplatform.googleapis.com" which is incorrect | ||||||||||
| // The correct endpoint for global is "aiplatform.googleapis.com" | ||||||||||
| const baseURL = region === "global" ? `https://aiplatform.googleapis.com/v1` : undefined // Let the SDK use its default for other regions | ||||||||||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Region comparison is exact-match; a user-provided value like "Global" or trailing whitespace would miss this branch. Consider normalizing before compare.
Suggested change
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Verify SDK behavior regarding baseURL path: if the Vertex SDK appends "/v1" internally, this string may yield a double "/v1/v1". If so, prefer host-only.
Suggested change
|
||||||||||
|
|
||||||||||
| if (this.options.vertexJsonCredentials) { | ||||||||||
| this.client = new AnthropicVertex({ | ||||||||||
| projectId, | ||||||||||
| region, | ||||||||||
| baseURL, | ||||||||||
| googleAuth: new GoogleAuth({ | ||||||||||
| scopes: ["https://www.googleapis.com/auth/cloud-platform"], | ||||||||||
| credentials: safeJsonParse<JWTInput>(this.options.vertexJsonCredentials, undefined), | ||||||||||
|
|
@@ -47,13 +53,14 @@ export class AnthropicVertexHandler extends BaseProvider implements SingleComple | |||||||||
| this.client = new AnthropicVertex({ | ||||||||||
| projectId, | ||||||||||
| region, | ||||||||||
| baseURL, | ||||||||||
| googleAuth: new GoogleAuth({ | ||||||||||
| scopes: ["https://www.googleapis.com/auth/cloud-platform"], | ||||||||||
| keyFile: this.options.vertexKeyFile, | ||||||||||
| }), | ||||||||||
| }) | ||||||||||
| } else { | ||||||||||
| this.client = new AnthropicVertex({ projectId, region }) | ||||||||||
| this.client = new AnthropicVertex({ projectId, region, baseURL }) | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P3] Consider complementary tests for non-global regions with JSON credentials and with key files to assert baseURL remains undefined. This guards against regressions in the credential branches.