(modelName: string)
| 55 | const warnedModels = new Set<string>(); |
| 56 | |
| 57 | function normalizeModelKey(modelName: string): ModelName | null { |
| 58 | assert( |
| 59 | typeof modelName === "string" && modelName.length > 0, |
| 60 | "Model name must be a non-empty string" |
| 61 | ); |
| 62 | |
| 63 | const override = TOKENIZER_MODEL_OVERRIDES[modelName]; |
| 64 | const normalized = |
| 65 | override ?? (modelName.includes(":") ? modelName.replace(":", "/") : modelName); |
| 66 | |
| 67 | if (!(normalized in models)) { |
| 68 | // Return null for unknown models - caller can decide to fallback or error |
| 69 | return null; |
| 70 | } |
| 71 | return normalized as ModelName; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Resolves a model string to a ModelName, falling back to a similar model if unknown. |
no test coverage detected