deprecation.ts
utils/model/deprecation.ts
102
Lines
2534
Bytes
1
Exports
1
Imports
10
Keywords
What this is
This page documents one file from the repository and includes its full source so you can read it without leaving the docs site.
Beginner explanation
This file is one piece of the larger system. Its name, directory, imports, and exports show where it fits. Start by reading the exports and related files first.
How it is used
Start from the exports list and related files. Those are the easiest clues for where this file fits into the system.
Expert explanation
Architecturally, this file intersects with modes. It contains 102 lines, 1 detected imports, and 1 detected exports.
Important relationships
Detected exports
getModelDeprecationWarning
Keywords
modelnamemodeldeprecatedisdeprecatedretirementdateproviderretirementdatesinfomodelidjanuary
Detected imports
./providers.js
Source notes
This page embeds the full file contents. Small or leaf files are still indexed honestly instead of being over-explained.
Full source
/**
* Model deprecation utilities
*
* Contains information about deprecated models and their retirement dates.
*/
import { type APIProvider, getAPIProvider } from './providers.js'
type DeprecatedModelInfo = {
isDeprecated: true
modelName: string
retirementDate: string
}
type NotDeprecatedInfo = {
isDeprecated: false
}
type DeprecationInfo = DeprecatedModelInfo | NotDeprecatedInfo
type DeprecationEntry = {
/** Human-readable model name */
modelName: string
/** Retirement dates by provider (null = not deprecated for that provider) */
retirementDates: Record<APIProvider, string | null>
}
/**
* Deprecated models and their retirement dates by provider.
* Keys are substrings to match in model IDs (case-insensitive).
* To add a new deprecated model, add an entry to this object.
*/
const DEPRECATED_MODELS: Record<string, DeprecationEntry> = {
'claude-3-opus': {
modelName: 'Claude 3 Opus',
retirementDates: {
firstParty: 'January 5, 2026',
bedrock: 'January 15, 2026',
vertex: 'January 5, 2026',
foundry: 'January 5, 2026',
},
},
'claude-3-7-sonnet': {
modelName: 'Claude 3.7 Sonnet',
retirementDates: {
firstParty: 'February 19, 2026',
bedrock: 'April 28, 2026',
vertex: 'May 11, 2026',
foundry: 'February 19, 2026',
},
},
'claude-3-5-haiku': {
modelName: 'Claude 3.5 Haiku',
retirementDates: {
firstParty: 'February 19, 2026',
bedrock: null,
vertex: null,
foundry: null,
},
},
}
/**
* Check if a model is deprecated and get its deprecation info
*/
function getDeprecatedModelInfo(modelId: string): DeprecationInfo {
const lowercaseModelId = modelId.toLowerCase()
const provider = getAPIProvider()
for (const [key, value] of Object.entries(DEPRECATED_MODELS)) {
const retirementDate = value.retirementDates[provider]
if (!lowercaseModelId.includes(key) || !retirementDate) {
continue
}
return {
isDeprecated: true,
modelName: value.modelName,
retirementDate,
}
}
return { isDeprecated: false }
}
/**
* Get a deprecation warning message for a model, or null if not deprecated
*/
export function getModelDeprecationWarning(
modelId: string | null,
): string | null {
if (!modelId) {
return null
}
const info = getDeprecatedModelInfo(modelId)
if (!info.isDeprecated) {
return null
}
return `⚠ ${info.modelName} will be retired on ${info.retirementDate}. Consider switching to a newer model.`
}