* check if a given model ID fits a specific model name * * @note * Different model providers may use different model IDs for the same model. * For example, openai's `gpt-5.2` may called: * * - `gpt-5.2-version` * - `gpt-5_2-date` * - `GPT-52-version-date` * - `openai/gpt-5.2-chat` * * The
(modelName: string)
| 140 | * Normalize them to `gpt-52` |
| 141 | */ |
| 142 | function normalizeModelName(modelName: string): string { |
| 143 | let normalizedName = modelName.toLowerCase() |
| 144 | |
| 145 | // remove prefix before '/' |
| 146 | if (normalizedName.includes('/')) { |
| 147 | normalizedName = normalizedName.split('/')[1] |
| 148 | } |
| 149 | |
| 150 | // remove '_' |
| 151 | normalizedName = normalizedName.replace(/_/g, '') |
| 152 | |
| 153 | // remove '.' |
| 154 | normalizedName = normalizedName.replace(/\./g, '') |
| 155 | |
| 156 | return normalizedName |
| 157 | } |