free-coding-models 0.3.79 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/utils.js CHANGED
@@ -235,7 +235,7 @@ export const getStabilityScore = (r) => {
235
235
  // - 'stability' (B key) — stability score (0–100, higher = more stable)
236
236
  //
237
237
  // 📖 sortDirection 'asc' = ascending (smallest first), 'desc' = descending (largest first)
238
- export const sortResults = (results, sortColumn, sortDirection) => {
238
+ export const sortResults = (results, sortColumn, sortDirection, { benchmarkResults = {} } = {}) => {
239
239
  return [...results].sort((a, b) => {
240
240
  let cmp = 0
241
241
 
@@ -317,6 +317,30 @@ export const sortResults = (results, sortColumn, sortDirection) => {
317
317
  // 📖 Models with no data (-1) sort to the bottom
318
318
  cmp = getStabilityScore(a) - getStabilityScore(b)
319
319
  break
320
+ case 'aiLatency': {
321
+ // 📖 Sort by AI benchmark latency (totalMs). Lower = better.
322
+ // 📖 Models without benchmark data sort to the bottom.
323
+ const aKey = `${a.providerKey}/${a.modelId}`
324
+ const bKey = `${b.providerKey}/${b.modelId}`
325
+ const aBench = benchmarkResults[aKey]
326
+ const bBench = benchmarkResults[bKey]
327
+ const aMs = (aBench?.ok && aBench.totalMs != null) ? aBench.totalMs : Infinity
328
+ const bMs = (bBench?.ok && bBench.totalMs != null) ? bBench.totalMs : Infinity
329
+ cmp = aMs - bMs
330
+ break
331
+ }
332
+ case 'tps': {
333
+ // 📖 Sort by benchmark throughput (tokens/second). Higher = better.
334
+ // 📖 Models without benchmark data sort to the bottom.
335
+ const aKey2 = `${a.providerKey}/${a.modelId}`
336
+ const bKey2 = `${b.providerKey}/${b.modelId}`
337
+ const aBench2 = benchmarkResults[aKey2]
338
+ const bBench2 = benchmarkResults[bKey2]
339
+ const aTps = (aBench2?.ok && aBench2.tokensPerSecond != null) ? aBench2.tokensPerSecond : -1
340
+ const bTps = (bBench2?.ok && bBench2.tokensPerSecond != null) ? bBench2.tokensPerSecond : -1
341
+ cmp = aTps - bTps
342
+ break
343
+ }
320
344
  case 'usage':
321
345
  // 📖 Sort by quota usage percent (usagePercent numeric field, 0–100)
322
346
  // 📖 Models with no usage data (undefined/null) are treated as 0 — stable tie-break