SPB Git

spb/llmindex Public

The discriminative, contamination-resistant, fully transparent LLM ranking — updated live.

TypeScript 77.9% TeX 15.2% Python 3.7% SQL 1.4% JavaScript 1.1% Shell 0.5%
1.5 KB · 62 lines typescript
Raw Blame History
1/**2 * llmindex.io — live benchmark progress writer (Redis, read by /api/v1/benchmark/progress)3 * Author:  Simon-Pierre Boucher4 * Contact: contact@spboucher.ai5 * License: Proprietary — © Simon-Pierre Boucher, all rights reserved6 */7import IORedis from 'ioredis';8import { redisUrl } from './env';910export const PROGRESS_KEY = 'llmindex:benchmark:progress';1112export interface BenchmarkCurrent {13  model: string;14  domain: string;15  domain_index: number;16  domains_total: number;17  calls_done: number;18  calls_total: number;19}2021export interface BenchmarkProgress {22  active: boolean;23  started_at: string;24  models: string[];25  completed: string[];26  failed: string[];27  /** First active lane (kept for backward compatibility). */28  current: BenchmarkCurrent | null;29  /** All active lanes (parallel evaluation). */30  currents?: BenchmarkCurrent[];31  last_refit_run_id?: string | null;32  note?: string;33}3435let redis: IORedis | null = null;3637function client(): IORedis {38  if (!redis) {39    redis = new IORedis(redisUrl(), { maxRetriesPerRequest: 1, enableOfflineQueue: false });40    redis.on('error', () => {41      /* progress is best-effort; never crash the benchmark on Redis hiccups */42    });43  }44  return redis;45}4647export async function writeProgress(p: BenchmarkProgress): Promise<void> {48  try {49    await client().set(PROGRESS_KEY, JSON.stringify({ ...p, updated_at: new Date().toISOString() }));50  } catch {51    /* best-effort */52  }53}5455export async function closeProgress(): Promise<void> {56  try {57    await redis?.quit();58  } catch {59    /* ignore */60  }61}62