Skip to content

Commit 7e34fbc

Browse files
authored
fix: add bedrock to ANTHROPIC_STYLE_PROVIDERS and restore vertex Claude model checking (#6019)
1 parent 8334f08 commit 7e34fbc

File tree

2 files changed

+14
-31
lines changed

2 files changed

+14
-31
lines changed

packages/types/src/__tests__/provider-settings.test.ts

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ describe("getApiProtocol", () => {
1212
expect(getApiProtocol("claude-code")).toBe("anthropic")
1313
expect(getApiProtocol("claude-code", "some-model")).toBe("anthropic")
1414
})
15+
16+
it("should return 'anthropic' for bedrock provider", () => {
17+
expect(getApiProtocol("bedrock")).toBe("anthropic")
18+
expect(getApiProtocol("bedrock", "gpt-4")).toBe("anthropic")
19+
expect(getApiProtocol("bedrock", "claude-3-opus")).toBe("anthropic")
20+
})
1521
})
1622

1723
describe("Vertex provider with Claude models", () => {
@@ -27,25 +33,14 @@ describe("getApiProtocol", () => {
2733
expect(getApiProtocol("vertex", "gemini-pro")).toBe("openai")
2834
expect(getApiProtocol("vertex", "llama-2")).toBe("openai")
2935
})
30-
})
31-
32-
describe("Bedrock provider with Claude models", () => {
33-
it("should return 'anthropic' for bedrock provider with claude models", () => {
34-
expect(getApiProtocol("bedrock", "claude-3-opus")).toBe("anthropic")
35-
expect(getApiProtocol("bedrock", "Claude-3-Sonnet")).toBe("anthropic")
36-
expect(getApiProtocol("bedrock", "CLAUDE-instant")).toBe("anthropic")
37-
expect(getApiProtocol("bedrock", "anthropic.claude-v2")).toBe("anthropic")
38-
})
3936

40-
it("should return 'openai' for bedrock provider with non-claude models", () => {
41-
expect(getApiProtocol("bedrock", "gpt-4")).toBe("openai")
42-
expect(getApiProtocol("bedrock", "titan-text")).toBe("openai")
43-
expect(getApiProtocol("bedrock", "llama-2")).toBe("openai")
37+
it("should return 'openai' for vertex provider without model", () => {
38+
expect(getApiProtocol("vertex")).toBe("openai")
4439
})
4540
})
4641

47-
describe("Other providers with Claude models", () => {
48-
it("should return 'openai' for non-vertex/bedrock providers with claude models", () => {
42+
describe("Other providers", () => {
43+
it("should return 'openai' for non-anthropic providers regardless of model", () => {
4944
expect(getApiProtocol("openrouter", "claude-3-opus")).toBe("openai")
5045
expect(getApiProtocol("openai", "claude-3-sonnet")).toBe("openai")
5146
expect(getApiProtocol("litellm", "claude-instant")).toBe("openai")
@@ -59,20 +54,13 @@ describe("getApiProtocol", () => {
5954
expect(getApiProtocol(undefined, "claude-3-opus")).toBe("openai")
6055
})
6156

62-
it("should return 'openai' when model is undefined", () => {
63-
expect(getApiProtocol("openai")).toBe("openai")
64-
expect(getApiProtocol("vertex")).toBe("openai")
65-
expect(getApiProtocol("bedrock")).toBe("openai")
66-
})
67-
6857
it("should handle empty strings", () => {
6958
expect(getApiProtocol("vertex", "")).toBe("openai")
70-
expect(getApiProtocol("bedrock", "")).toBe("openai")
7159
})
7260

7361
it("should be case-insensitive for claude detection", () => {
7462
expect(getApiProtocol("vertex", "CLAUDE-3-OPUS")).toBe("anthropic")
75-
expect(getApiProtocol("bedrock", "claude-3-opus")).toBe("anthropic")
63+
expect(getApiProtocol("vertex", "claude-3-opus")).toBe("anthropic")
7664
expect(getApiProtocol("vertex", "ClAuDe-InStAnT")).toBe("anthropic")
7765
})
7866
})

packages/types/src/provider-settings.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ export const getModelId = (settings: ProviderSettings): string | undefined => {
301301
}
302302

303303
// Providers that use Anthropic-style API protocol
304-
export const ANTHROPIC_STYLE_PROVIDERS: ProviderName[] = ["anthropic", "claude-code"]
304+
export const ANTHROPIC_STYLE_PROVIDERS: ProviderName[] = ["anthropic", "claude-code", "bedrock"]
305305

306306
// Helper function to determine API protocol for a provider and model
307307
export const getApiProtocol = (provider: ProviderName | undefined, modelId?: string): "anthropic" | "openai" => {
@@ -310,13 +310,8 @@ export const getApiProtocol = (provider: ProviderName | undefined, modelId?: str
310310
return "anthropic"
311311
}
312312

313-
// For vertex and bedrock providers, check if the model ID contains "claude" (case-insensitive)
314-
if (
315-
provider &&
316-
(provider === "vertex" || provider === "bedrock") &&
317-
modelId &&
318-
modelId.toLowerCase().includes("claude")
319-
) {
313+
// For vertex provider, check if the model ID contains "claude" (case-insensitive)
314+
if (provider && provider === "vertex" && modelId && modelId.toLowerCase().includes("claude")) {
320315
return "anthropic"
321316
}
322317

0 commit comments

Comments
 (0)