mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-16 09:45:24 -04:00
fix: model cost/info matches first substring key (gpt-4o-mini billed as gpt-4o) (#1439)
* fix: match model name to the longest known key, not the first substring * test: model key matching prefers the longest specific key
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
// static/js/model/matchKey.js
|
||||
//
|
||||
// Pure helper for matching a model name against a set of known keys. No DOM —
|
||||
// safe to import anywhere and to unit-test under node.
|
||||
|
||||
// Return the most specific (longest) key that is a substring of `name`, or null.
|
||||
// Returning the first match instead made "gpt-4o-mini" match the shorter
|
||||
// "gpt-4o" key — billing it at gpt-4o rates (~16x) and showing the wrong
|
||||
// context window.
|
||||
export function matchModelKey(name, keys) {
|
||||
const n = (name || '').toLowerCase();
|
||||
let best = null;
|
||||
for (const key of keys) {
|
||||
if (n.includes(key) && (best === null || key.length > best.length)) {
|
||||
best = key;
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
Reference in New Issue
Block a user