1// static/js/model/matchKey.js 2// 3// Pure helper for matching a model name against a set of known keys. No DOM â 4// safe to import anywhere and to unit-test under node. 5 6// Return the most specific (longest) key that is a substring of `name`, or null. 7// Returning the first match instead made "gpt-4o-mini" match the shorter 8// "gpt-4o" key â billing it at gpt-4o rates (~16x) and showing the wrong 9// context window. 10export function matchModelKey(name, keys) { 11 const n = (name || '').toLowerCase(); 12 let best = null; 13 for (const key of keys) { 14 if (n.includes(key) && (best === null || key.length > best.length)) { 15 best = key; 16 } 17 } 18 return best; 19}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.