MCPcopy
hub / github.com/mastra-ai/mastra / stripDateSuffix

Function stripDateSuffix

observability/mastra/src/metrics/pricing-registry.ts:237–249  ·  view source on GitHub ↗

* Strip date suffix from model names. * Handles multiple date formats used by different providers: * - OpenAI: YYYY-MM-DD at end (e.g., "gpt-5-4-mini-2026-03-17" → "gpt-5-4-mini") * - Anthropic: YYYYMMDD with optional suffix (e.g., "claude-sonnet-4-5-20250929-thinking" → "claude-sonnet-4-5-thinki

(model: string)

Source from the content-addressed store, hash-verified

235 * - Cohere/Gemini: MM-YYYY at end (e.g., "command-r-08-2024""command-r")
236 */
237function stripDateSuffix(model: string): string {
238 // OpenAI format: -YYYY-MM-DD at end
239 let stripped = model.replace(/-20\d{2}-\d{2}-\d{2}$/, '');
240 if (stripped !== model) return stripped;
241
242 // Anthropic format: -YYYYMMDD, possibly followed by suffix like -thinking
243 stripped = model.replace(/-20\d{6}(-[a-z]+)?$/, '$1');
244 if (stripped !== model) return stripped;
245
246 // Cohere/Gemini format: -MM-YYYY at end
247 stripped = model.replace(/-\d{2}-20\d{2}$/, '');
248 return stripped;
249}

Callers 1

addFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…