Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

1.4 KB
Raw Blame
import { describe, it } from "node:test";
import assert from "node:assert/strict";
import { formatReport } from "../../../open-sse/services/compression/eval/report.ts";
import type { EvalReport } from "../../../open-sse/services/compression/eval/types.ts";

const report: EvalReport = {
  stamps: { answerModel: "gpt-x", judgeModel: "judge-y", corpusHash: "deadbeef", sampleSize: 5 },
  partial: true,
  totalCostUsd: 0.42,
  overall: { casesScored: 4, casesErrored: 1, fidelityPreservedPct: 75, goldAccuracyDeltaPct: -25, meanRatio: 0.5 },
  perKind: [{ kind: "prose", casesScored: 2, fidelityPreservedPct: 50, goldAccuracyDeltaPct: -50, meanRatio: 0.45 }],
};

describe("eval report writer", () => {
  it("stamps the answer model, judge model and corpus hash in the header", () => {
    const md = formatReport(report);
    assert.match(md, /gpt-x/);
    assert.match(md, /judge-y/);
    assert.match(md, /deadbeef/);
  });

  it("flags a partial run prominently (never silent)", () => {
    assert.match(formatReport(report), /PARTIAL/i);
  });

  it("renders a per-kind table row and the overall fidelity %", () => {
    const md = formatReport(report);
    assert.match(md, /prose/);
    assert.match(md, /75/);
  });

  it("a complete run is not labelled partial", () => {
    const md = formatReport({ ...report, partial: false });
    assert.doesNotMatch(md, /PARTIAL/i);
  });
});