refactor: update Claude model identifiers to use new naming convention

This commit is contained in:
daniel-lxs 2025-09-29 12:14:10 -05:00
parent 049f239fce
commit 5e018407ac
No known key found for this signature in database
GPG key ID: 21C74479048B3AA6
7 changed files with 13 additions and 16 deletions

View file

@ -6,7 +6,7 @@ export type AnthropicModelId = keyof typeof anthropicModels
export const anthropicDefaultModelId: AnthropicModelId = "claude-sonnet-4-20250514"
export const anthropicModels = {
"claude-sonnet-4-5-20250514": {
"claude-4.5-sonnet": {
maxTokens: 64_000, // Overridden to 8k if `enableReasoningEffort` is false.
contextWindow: 200_000, // Default 200K, extendable to 1M with beta flag 'context-1m-2025-08-07'
supportsImages: true,

View file

@ -67,7 +67,7 @@ export const bedrockModels = {
maxCachePoints: 1,
cachableFields: ["system"],
},
"anthropic.claude-sonnet-4-5-20250514-v1:0": {
"anthropic.claude-4.5-sonnet-v1:0": {
maxTokens: 8192,
contextWindow: 200_000,
supportsImages: true,

View file

@ -40,8 +40,8 @@ export function getClaudeCodeModelId(baseModelId: ClaudeCodeModelId, useVertex =
}
export const claudeCodeModels = {
"claude-sonnet-4-5-20250514": {
...anthropicModels["claude-sonnet-4-5-20250514"],
"claude-4.5-sonnet": {
...anthropicModels["claude-4.5-sonnet"],
supportsImages: false,
supportsPromptCache: true, // Claude Code does report cache tokens
supportsReasoningEffort: false,

View file

@ -163,7 +163,7 @@ export const vertexModels = {
inputPrice: 1.25,
outputPrice: 5,
},
"claude-sonnet-4-5@20250514": {
"claude-4.5-sonnet": {
maxTokens: 8192,
contextWindow: 200_000,
supportsImages: true,

View file

@ -268,10 +268,10 @@ describe("AnthropicHandler", () => {
it("should handle Claude 4.5 Sonnet model correctly", () => {
const handler = new AnthropicHandler({
apiKey: "test-api-key",
apiModelId: "claude-sonnet-4-5-20250514",
apiModelId: "claude-4.5-sonnet",
})
const model = handler.getModel()
expect(model.id).toBe("claude-sonnet-4-5-20250514")
expect(model.id).toBe("claude-4.5-sonnet")
expect(model.info.maxTokens).toBe(64000)
expect(model.info.contextWindow).toBe(200000)
expect(model.info.supportsReasoningBudget).toBe(true)
@ -280,7 +280,7 @@ describe("AnthropicHandler", () => {
it("should enable 1M context for Claude 4.5 Sonnet when beta flag is set", () => {
const handler = new AnthropicHandler({
apiKey: "test-api-key",
apiModelId: "claude-sonnet-4-5-20250514",
apiModelId: "claude-4.5-sonnet",
anthropicBeta1MContext: true,
})
const model = handler.getModel()

View file

@ -47,14 +47,14 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
// Add 1M context beta flag if enabled for Claude Sonnet 4 and 4.5
if (
(modelId === "claude-sonnet-4-20250514" || modelId === "claude-sonnet-4-5-20250514") &&
(modelId === "claude-sonnet-4-20250514" || modelId === "claude-4.5-sonnet") &&
this.options.anthropicBeta1MContext
) {
betas.push("context-1m-2025-08-07")
}
switch (modelId) {
case "claude-sonnet-4-5-20250514":
case "claude-4.5-sonnet":
case "claude-sonnet-4-20250514":
case "claude-opus-4-1-20250805":
case "claude-opus-4-20250514":
@ -114,7 +114,7 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
// Then check for models that support prompt caching
switch (modelId) {
case "claude-sonnet-4-5-20250514":
case "claude-4.5-sonnet":
case "claude-sonnet-4-20250514":
case "claude-opus-4-1-20250805":
case "claude-opus-4-20250514":
@ -249,10 +249,7 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
let info: ModelInfo = anthropicModels[id]
// If 1M context beta is enabled for Claude Sonnet 4 or 4.5, update the model info
if (
(id === "claude-sonnet-4-20250514" || id === "claude-sonnet-4-5-20250514") &&
this.options.anthropicBeta1MContext
) {
if ((id === "claude-sonnet-4-20250514" || id === "claude-4.5-sonnet") && this.options.anthropicBeta1MContext) {
// Use the tier pricing for 1M context
const tier = info.tiers?.[0]
if (tier) {

View file

@ -23,7 +23,7 @@ export const Anthropic = ({ apiConfiguration, setApiConfigurationField }: Anthro
// Check if the current model supports 1M context beta
const supports1MContextBeta =
selectedModel?.id === "claude-sonnet-4-20250514" || selectedModel?.id === "claude-sonnet-4-5-20250514"
selectedModel?.id === "claude-sonnet-4-20250514" || selectedModel?.id === "claude-4.5-sonnet"
const handleInputChange = useCallback(
<K extends keyof ProviderSettings, E>(