@crowandraven/evalkeeper 0.7.0 → 0.9.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.
Files changed (101) hide show
  1. package/README.md +9 -0
  2. package/dist/cli/addPages.d.ts +5 -0
  3. package/dist/cli/addPages.js +15 -3
  4. package/dist/cli/addPages.js.map +1 -1
  5. package/dist/decisions.js +8 -0
  6. package/dist/decisions.js.map +1 -1
  7. package/dist/feedback.d.ts +20 -3
  8. package/dist/feedback.js +16 -3
  9. package/dist/feedback.js.map +1 -1
  10. package/dist/glossary.d.ts +6 -1
  11. package/dist/glossary.js +6 -1
  12. package/dist/glossary.js.map +1 -1
  13. package/dist/importCases.d.ts +15 -4
  14. package/dist/importCases.js +20 -18
  15. package/dist/importCases.js.map +1 -1
  16. package/dist/inInstructions.d.ts +47 -0
  17. package/dist/inInstructions.js +95 -0
  18. package/dist/inInstructions.js.map +1 -0
  19. package/dist/index.d.ts +2 -0
  20. package/dist/index.js +2 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/reviews.d.ts +172 -0
  23. package/dist/reviews.js +294 -0
  24. package/dist/reviews.js.map +1 -0
  25. package/dist/runner.d.ts +9 -0
  26. package/dist/runner.js +26 -0
  27. package/dist/runner.js.map +1 -1
  28. package/dist/suiteContract.d.ts +12 -5
  29. package/dist/suiteContract.js +47 -7
  30. package/dist/suiteContract.js.map +1 -1
  31. package/dist/suites/attackImport.d.ts +99 -0
  32. package/dist/suites/attackImport.js +283 -0
  33. package/dist/suites/attackImport.js.map +1 -0
  34. package/dist/suites/crisisRisk.d.ts +9 -2
  35. package/dist/suites/crisisRisk.js +8 -3
  36. package/dist/suites/crisisRisk.js.map +1 -1
  37. package/dist/suites/crisisRiskCases.d.ts +4 -3
  38. package/dist/suites/crisisRiskCases.js +4 -3
  39. package/dist/suites/crisisRiskCases.js.map +1 -1
  40. package/dist/suites/crisisRiskReviews.d.ts +15 -0
  41. package/dist/suites/crisisRiskReviews.js +926 -0
  42. package/dist/suites/crisisRiskReviews.js.map +1 -0
  43. package/dist/suites/hopelessness.d.ts +123 -0
  44. package/dist/suites/hopelessness.js +296 -0
  45. package/dist/suites/hopelessness.js.map +1 -0
  46. package/dist/suites/hopelessnessCases.d.ts +62 -0
  47. package/dist/suites/hopelessnessCases.js +243 -0
  48. package/dist/suites/hopelessnessCases.js.map +1 -0
  49. package/dist/suites/hopelessnessReviews.d.ts +15 -0
  50. package/dist/suites/hopelessnessReviews.js +1080 -0
  51. package/dist/suites/hopelessnessReviews.js.map +1 -0
  52. package/dist/suites/index.d.ts +7 -0
  53. package/dist/suites/index.js +7 -0
  54. package/dist/suites/index.js.map +1 -1
  55. package/dist/suites/injection.d.ts +162 -0
  56. package/dist/suites/injection.js +331 -0
  57. package/dist/suites/injection.js.map +1 -0
  58. package/dist/suites/injectionAttacks.d.ts +3 -0
  59. package/dist/suites/injectionAttacks.js +34 -0
  60. package/dist/suites/injectionAttacks.js.map +1 -0
  61. package/dist/testing.d.ts +36 -2
  62. package/dist/testing.js +104 -14
  63. package/dist/testing.js.map +1 -1
  64. package/dist/types.d.ts +27 -0
  65. package/dist/types.js +11 -0
  66. package/dist/types.js.map +1 -1
  67. package/package.json +1 -1
  68. package/src/cli/addPages.ts +16 -3
  69. package/src/decisions.ts +10 -0
  70. package/src/feedback.ts +23 -3
  71. package/src/glossary.ts +11 -1
  72. package/src/importCases.ts +21 -20
  73. package/src/inInstructions.ts +105 -0
  74. package/src/index.ts +2 -0
  75. package/src/reviews.ts +428 -0
  76. package/src/runner.ts +41 -0
  77. package/src/suiteContract.ts +56 -7
  78. package/src/suites/attackImport.ts +327 -0
  79. package/src/suites/crisisRisk.ts +15 -3
  80. package/src/suites/crisisRiskCases.ts +4 -3
  81. package/src/suites/crisisRiskReviews.ts +927 -0
  82. package/src/suites/hopelessness.ts +420 -0
  83. package/src/suites/hopelessnessCases.ts +287 -0
  84. package/src/suites/hopelessnessReviews.ts +1081 -0
  85. package/src/suites/index.ts +7 -0
  86. package/src/suites/injection.ts +463 -0
  87. package/src/suites/injectionAttacks.ts +136 -0
  88. package/src/testing.ts +144 -18
  89. package/src/types.ts +30 -0
  90. package/starter/index.ts +8 -0
  91. package/templates/app/evals/[suite]/compare/page.tsx +10 -0
  92. package/templates/app/evals/[suite]/page.tsx +55 -18
  93. package/templates/app/evals/[suite]/rate/page.tsx +10 -0
  94. package/templates/app/evals/[suite]/runs/[runId]/page.tsx +72 -3
  95. package/templates/app/evals/[suite]/side-by-side/page.tsx +37 -17
  96. package/templates/app/evals/feedback/page.tsx +6 -1
  97. package/templates/app/evals/page.tsx +36 -26
  98. package/templates/components/evalkeeper/AnswerKey.tsx +25 -1
  99. package/templates/components/evalkeeper/ReadableOutput.tsx +97 -0
  100. package/templates/components/evalkeeper/SettingsHistory.tsx +10 -4
  101. package/templates/lib/evalkeeper/actions.ts +4 -1
package/src/testing.ts CHANGED
@@ -8,7 +8,12 @@
8
8
  import { z } from "zod";
9
9
  import type { ContractExpect } from "./assertExpect.js";
10
10
  import { BLIND_RATER, blindRating, nextToRate, skipMark } from "./blind.js";
11
- import type { FeedbackStore, NewRating } from "./feedback.js";
11
+ import {
12
+ NO_INPUTS_KEPT,
13
+ whyNotACase,
14
+ type FeedbackStore,
15
+ type NewRating,
16
+ } from "./feedback.js";
12
17
  import { confirmedLabel } from "./labels.js";
13
18
  import { createRunner } from "./runner.js";
14
19
  import {
@@ -560,21 +565,72 @@ export function describeStoreContract(
560
565
  });
561
566
  }
562
567
 
568
+ /** The columns a thumbs table may lack, for `FeedbackStoreContractOptions`. */
569
+ export type FeedbackColumn =
570
+ "reason" | "excerpt" | "input" | "output" | "status" | "caseId";
571
+
572
+ /**
573
+ * Options for the feedback store contract, for a store on an app's own
574
+ * thumbs table that lacks some of Evalkeeper's columns.
575
+ */
576
+ export type FeedbackStoreContractOptions = ScopedContractOptions & {
577
+ /**
578
+ * Columns the store's table doesn't have (mapped to `null`). The
579
+ * contract then checks the store refuses a value for each (rather than
580
+ * losing it) and reads it as null; with no `input`, that no rating can
581
+ * become a case; and with no `status`, that every rating reads as OPEN.
582
+ */
583
+ without?: FeedbackColumn[];
584
+ };
585
+
563
586
  /**
564
587
  * The contract every FeedbackStore must meet. `make` must return an empty
565
588
  * store each time it's called, unless `opts.scope` is set (see
566
589
  * `describeStoreContract`): then every feature the contract rates starts
567
590
  * with the scope, and its lists ask for those features only.
591
+ * `opts.without` names columns the store's table doesn't have (an app's
592
+ * own thumbs table without inputs or statuses, say).
593
+ *
594
+ * @param name - What the tests are called, e.g. "our thumbs table".
595
+ * @param make - Returns the store to test (an empty one, unless scoped).
596
+ * @param opts - A scope and cleanup, missing columns, and test functions.
597
+ *
598
+ * @example
599
+ * ```ts
600
+ * describeFeedbackStoreContract(
601
+ * "our thumbs table",
602
+ * () => prismaFeedbackStore(prisma, feedbackMap),
603
+ * {
604
+ * without: ["input", "output", "status", "caseId"],
605
+ * scope: "contract-",
606
+ * cleanup: (scope) => deleteScopedRows(prisma, scope, { feedbackMap }),
607
+ * },
608
+ * );
609
+ * ```
568
610
  */
569
611
  export function describeFeedbackStoreContract(
570
612
  name: string,
571
613
  make: () => FeedbackStore | Promise<FeedbackStore>,
572
- opts: ScopedContractOptions = {},
614
+ opts: FeedbackStoreContractOptions = {},
573
615
  ) {
574
616
  const t = testFunctions(opts.test);
575
617
  const { describe, it, expect } = t;
576
618
  const names = scopeNames(opts.scope);
577
619
  const scoped = opts.scope !== undefined;
620
+ const lacks = (c: FeedbackColumn) => opts.without?.includes(c) ?? false;
621
+ const kept = {
622
+ reason: "Wrong queue",
623
+ excerpt: "billing",
624
+ input: { subject: "Refund", body: "Please refund me." },
625
+ output: { category: "bug" },
626
+ };
627
+ /** What a store keeps of `kept`: null for each column it lacks. */
628
+ const keeps = {
629
+ reason: lacks("reason") ? null : kept.reason,
630
+ excerpt: lacks("excerpt") ? null : kept.excerpt,
631
+ input: lacks("input") ? null : kept.input,
632
+ output: lacks("output") ? null : kept.output,
633
+ };
578
634
  const rating = (
579
635
  operation: string,
580
636
  over: Partial<NewRating> = {},
@@ -583,39 +639,48 @@ export function describeFeedbackStoreContract(
583
639
  targetId: "answer-1",
584
640
  raterId: "person-1",
585
641
  rating: "DOWN",
586
- reason: "Wrong queue",
587
- excerpt: "billing",
588
- input: { subject: "Refund", body: "Please refund me." },
589
- output: { category: "bug" },
642
+ ...keeps,
590
643
  ...over,
591
644
  });
592
645
 
593
646
  describe(`FeedbackStore contract: ${name}`, () => {
594
647
  registerCleanup(t, opts);
595
648
 
596
- it("keeps a rating with its reason, input, and output, open", async () => {
649
+ it("keeps a rating with its reason, excerpt, input, and output, open", async () => {
597
650
  const store = await make();
598
651
  const op = names()("triage");
599
652
  const f = await store.rate(rating(op));
600
653
  expect(f).toMatchObject({
601
654
  operation: op,
655
+ targetId: "answer-1",
656
+ raterId: "person-1",
602
657
  rating: "DOWN",
603
- reason: "Wrong queue",
604
- excerpt: "billing",
605
- input: { subject: "Refund", body: "Please refund me." },
606
- output: { category: "bug" },
658
+ ...keeps,
607
659
  status: "OPEN",
608
660
  caseId: null,
609
661
  });
662
+ const listed = await store.listFeedback({ operation: op });
663
+ expect(listed).toHaveLength(1);
664
+ expect(listed[0]).toMatchObject({
665
+ id: f.id,
666
+ operation: op,
667
+ targetId: "answer-1",
668
+ raterId: "person-1",
669
+ rating: "DOWN",
670
+ ...keeps,
671
+ status: "OPEN",
672
+ });
610
673
  });
611
674
 
612
675
  it("keeps one rating per person per answer, and reopens a changed one", async () => {
613
676
  const store = await make();
614
677
  const op = names()("triage");
615
678
  const first = await store.rate(rating(op));
616
- await store.setFeedbackStatus(first.id, "DISMISSED");
679
+ if (!lacks("status"))
680
+ await store.setFeedbackStatus(first.id, "DISMISSED");
617
681
  const changed = await store.rate(rating(op, { rating: "UP" }));
618
682
  expect(changed.id).toBe(first.id);
683
+ expect(changed.rating).toBe("UP");
619
684
  expect(changed.status).toBe("OPEN");
620
685
  expect(changed.reason).toBeNull();
621
686
  await store.rate(rating(op, { raterId: "person-2" }));
@@ -646,17 +711,78 @@ export function describeFeedbackStoreContract(
646
711
  expect(
647
712
  (await store.listFeedback({ operation: op })).map((f) => f.id),
648
713
  ).toEqual([b.id, a.id]);
649
- expect(await store.listFeedback({ ...mine, rating: "UP" })).toHaveLength(
650
- 1,
651
- );
652
- await store.setFeedbackStatus(a.id, "CASED", "case-1");
653
- const cased = await store.listFeedback({ ...mine, status: "CASED" });
654
- expect(cased.map((f) => [f.id, f.caseId])).toEqual([[a.id, "case-1"]]);
714
+ expect(
715
+ (await store.listFeedback({ ...mine, rating: "UP" })).map((f) => f.id),
716
+ ).toEqual([b.id]);
717
+ expect(
718
+ (await store.listFeedback({ ...mine, rating: "DOWN" })).length,
719
+ ).toBe(scoped ? 1 : 2);
720
+ if (lacks("status")) {
721
+ // Every rating reads as open, and none can be anything else.
722
+ expect(
723
+ await store.listFeedback({ ...mine, status: "OPEN" }),
724
+ ).toHaveLength(scoped ? 2 : 3);
725
+ expect(
726
+ await store.listFeedback({ ...mine, status: "CASED" }),
727
+ ).toHaveLength(0);
728
+ } else {
729
+ const caseId = lacks("caseId") ? null : "case-1";
730
+ await store.setFeedbackStatus(a.id, "CASED", caseId);
731
+ const cased = await store.listFeedback({ ...mine, status: "CASED" });
732
+ expect(cased.map((f) => [f.id, f.caseId])).toEqual([[a.id, caseId]]);
733
+ }
655
734
  expect(
656
735
  await store.listFeedback({ since: new Date(Date.now() + 60_000) }),
657
736
  ).toHaveLength(0);
658
737
  expect(await store.listFeedback({ limit: 1 })).toHaveLength(1);
659
738
  });
739
+
740
+ for (const column of ["reason", "excerpt", "input", "output"] as const) {
741
+ if (!lacks(column)) continue;
742
+ it(`refuses a rating's ${column} it has no column for, and keeps none`, async () => {
743
+ const store = await make();
744
+ const op = names()("triage");
745
+ await expect(
746
+ store.rate(rating(op, { [column]: kept[column] })),
747
+ ).rejects.toThrow(column);
748
+ expect(await store.listFeedback({ operation: op })).toHaveLength(0);
749
+ });
750
+ }
751
+
752
+ if (lacks("input"))
753
+ it("says in plain words that no rating can become a case", async () => {
754
+ const store = await make();
755
+ const op = names()("triage");
756
+ const f = await store.rate(rating(op));
757
+ expect(f.keepsInputs).toBe(false);
758
+ expect(whyNotACase(f, undefined)).toBe(NO_INPUTS_KEPT);
759
+ const [read] = await store.listFeedback({ operation: op });
760
+ expect(read && whyNotACase(read, undefined)).toBe(NO_INPUTS_KEPT);
761
+ });
762
+
763
+ if (lacks("status"))
764
+ it("refuses a status it has no column for, and leaves the rating open", async () => {
765
+ const store = await make();
766
+ const op = names()("triage");
767
+ const f = await store.rate(rating(op));
768
+ await expect(
769
+ store.setFeedbackStatus(f.id, "DISMISSED"),
770
+ ).rejects.toThrow("status");
771
+ const [read] = await store.listFeedback({ operation: op });
772
+ expect(read?.status).toBe("OPEN");
773
+ });
774
+
775
+ if (lacks("caseId") && !lacks("status"))
776
+ it("refuses a case id it has no column for, and changes nothing", async () => {
777
+ const store = await make();
778
+ const op = names()("triage");
779
+ const f = await store.rate(rating(op));
780
+ await expect(
781
+ store.setFeedbackStatus(f.id, "CASED", "case-1"),
782
+ ).rejects.toThrow("caseId");
783
+ const [read] = await store.listFeedback({ operation: op });
784
+ expect(read).toMatchObject({ status: "OPEN", caseId: null });
785
+ });
660
786
  });
661
787
  }
662
788
 
package/src/types.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { z } from "zod";
2
2
  import type { ReasoningEffort } from "./models.js";
3
+ import type { ShippedReview } from "./reviews.js";
3
4
 
4
5
  /**
5
6
  * An eval suite: how to run one AI operation on a frozen case and how to
@@ -13,6 +14,12 @@ export type CheckResult = {
13
14
  pass: boolean | null;
14
15
  /** Why it failed (or a detail worth showing), in plain words. */
15
16
  note?: string | undefined;
17
+ /**
18
+ * What a decision check's answer gave, right or wrong ("34% true, bar
19
+ * 40%", "bug (90%)"), so a run page can show the probability beside the
20
+ * bar it was read at.
21
+ */
22
+ given?: string | undefined;
16
23
  /** For matching checks: which expected item matched which output, and why. */
17
24
  matches?: { expected: string; actual: string; why: string }[] | undefined;
18
25
  /** "meaning": a judge model matched them; "words": shared words did. */
@@ -165,6 +172,15 @@ export type Suite<Input, Output, Label> = {
165
172
  smoke?: boolean;
166
173
  note: string;
167
174
  }[];
175
+ /**
176
+ * Reviews of `starter` cases that ship with the suite: its author or an
177
+ * expert confirmed a case's answer once, for every app, so
178
+ * `importStarters` adds it confirmed instead of pending. Each names who,
179
+ * what qualifies them, and when, and counts only while the case's input
180
+ * and answer are what they saw; the suite contract fails on one that
181
+ * doesn't.
182
+ */
183
+ reviews?: readonly ShippedReview[];
168
184
  /**
169
185
  * Drafts new cases aimed at what the answer key is missing, for a person
170
186
  * to review (they arrive with PENDING answers).
@@ -318,6 +334,20 @@ export function linesOf(form: FormData, name: string): string[] {
318
334
  */
319
335
  export type AnySuite = Suite<unknown, unknown, unknown>;
320
336
 
337
+ /**
338
+ * Whether a suite is an injection suite (`injectionSuite` from
339
+ * `@crowandraven/evalkeeper/suites`): it runs on its base suite's
340
+ * operation, so code that finds a feature's suite by operation should
341
+ * skip it and find the base suite.
342
+ *
343
+ * @param suite - Any registered suite.
344
+ */
345
+ export function isInjectionSuite(
346
+ suite: AnySuite,
347
+ ): suite is AnySuite & { base: AnySuite } {
348
+ return "base" in suite && "attackCase" in suite;
349
+ }
350
+
321
351
  /** Where a zod issue sits, in plain words: "facts, item 2, name". */
322
352
  function issuePath(path: readonly (string | number)[]): string {
323
353
  return path
package/starter/index.ts CHANGED
@@ -45,6 +45,13 @@ export const SUITE_BY_KEY: Record<string, AnySuite> = Object.fromEntries(
45
45
  */
46
46
  const PROMPT_VERSIONS: Record<string, string> = {};
47
47
 
48
+ /**
49
+ * TODO: each feature's instructions as text (instructionParts from
50
+ * @crowandraven/evalkeeper-ai-sdk, on the parts you hash), so the suite
51
+ * page warns when a case was copied into them.
52
+ */
53
+ const INSTRUCTION_TEXTS: Record<string, string[]> = {};
54
+
48
55
  /** TODO: each feature's settings in code, used until someone changes them. */
49
56
  const DEFAULTS: Record<string, Settings> = {};
50
57
 
@@ -69,6 +76,7 @@ export const runner = createRunner({
69
76
  suites: SUITES,
70
77
  models: MODELS,
71
78
  promptVersion: (operation) => PROMPT_VERSIONS[operation] ?? "unregistered",
79
+ instructionTexts: (operation) => INSTRUCTION_TEXTS[operation] ?? [],
72
80
  route: routeFor,
73
81
  candidates: (operation) => ({ models: modelsFor(operation) }),
74
82
  });
@@ -1,3 +1,4 @@
1
+ import type { Metadata } from "next";
1
2
  import Link from "next/link";
2
3
  import { notFound } from "next/navigation";
3
4
  import {
@@ -24,6 +25,15 @@ import { evalsPath } from "@/lib/evalkeeper/paths";
24
25
 
25
26
  export const dynamic = "force-dynamic";
26
27
 
28
+ export async function generateMetadata({
29
+ params,
30
+ }: {
31
+ params: Promise<{ suite: string }>;
32
+ }): Promise<Metadata> {
33
+ const { suite } = await params;
34
+ return { title: `Compare: ${SUITE_BY_KEY[suite]?.label ?? "Evals"}` };
35
+ }
36
+
27
37
  /** A search parameter as one string, or null when it's missing or repeated. */
28
38
  const one = (v: string | string[] | undefined) =>
29
39
  typeof v === "string" && v ? v : null;
@@ -1,3 +1,4 @@
1
+ import type { Metadata } from "next";
1
2
  import Link from "next/link";
2
3
  import { notFound } from "next/navigation";
3
4
  import {
@@ -38,6 +39,15 @@ import { EVALS_BASE, evalsPath } from "@/lib/evalkeeper/paths";
38
39
 
39
40
  export const dynamic = "force-dynamic";
40
41
 
42
+ export async function generateMetadata({
43
+ params,
44
+ }: {
45
+ params: Promise<{ suite: string }>;
46
+ }): Promise<Metadata> {
47
+ const { suite } = await params;
48
+ return { title: `Evals: ${SUITE_BY_KEY[suite]?.label ?? "Evals"}` };
49
+ }
50
+
41
51
  /** A share as a whole percent, or a dash when there's nothing to show. */
42
52
  const asPct = (x: number | null) => (x === null ? "—" : pct(x));
43
53
 
@@ -59,7 +69,7 @@ export default async function SuitePage({
59
69
  if (!operation) notFound();
60
70
  // The board and the settings load together: on a remote database each
61
71
  // waits on round trips, so one after the other doubles the wait.
62
- const [b, [history, liveSettings]] = await Promise.all([
72
+ const [b, [history, liveSettings], inInstructions] = await Promise.all([
63
73
  runner.board(key),
64
74
  // Records a deploy if the instructions changed under the live
65
75
  // settings, before reading them.
@@ -68,6 +78,7 @@ export default async function SuitePage({
68
78
  .then(() =>
69
79
  Promise.all([settings.history(operation), settings.current(operation)]),
70
80
  ),
81
+ runner.casesInInstructions(key),
71
82
  ]);
72
83
  const { suite, rows } = b;
73
84
  const s = suggest(rows, suite.checks, suite.priority, MODELS);
@@ -101,30 +112,35 @@ export default async function SuitePage({
101
112
  </p>
102
113
  </div>
103
114
 
104
- {s && !s.same && (
115
+ {/* Shown when nothing would change too, so a higher score that
116
+ isn't enough to switch for comes with its reason. */}
117
+ {s && (
105
118
  <Card className="space-y-3">
106
119
  <div className="flex flex-wrap items-start justify-between gap-3">
107
120
  <h2 className="font-semibold">
108
- Suggested
121
+ {s.same ? "No change suggested" : "Suggested"}
109
122
  <InfoTip term="suggestion" />
110
123
  </h2>
111
124
  {/* Retesting live changes nothing until the fallback would. */}
112
- {!(s.retestLive && (!s.fallback || s.fallback.fallback)) && (
113
- <form action={useSuggestion}>
114
- <input type="hidden" name="suite" value={key} />
115
- <Submit>Use these</Submit>
116
- </form>
117
- )}
125
+ {!s.same &&
126
+ !(s.retestLive && (!s.fallback || s.fallback.fallback)) && (
127
+ <form action={useSuggestion}>
128
+ <input type="hidden" name="suite" value={key} />
129
+ <Submit>Use these</Submit>
130
+ </form>
131
+ )}
118
132
  </div>
119
- <p>
120
- Live: <strong>{s.live.label}</strong>
121
- {s.fallback && (
122
- <>
123
- {" "}
124
- · Fallback: <strong>{s.fallback.label}</strong>
125
- </>
126
- )}
127
- </p>
133
+ {!s.same && (
134
+ <p>
135
+ Live: <strong>{s.live.label}</strong>
136
+ {s.fallback && (
137
+ <>
138
+ {" "}
139
+ · Fallback: <strong>{s.fallback.label}</strong>
140
+ </>
141
+ )}
142
+ </p>
143
+ )}
128
144
  <ul className="readable list-disc space-y-1 pl-5 text-sm text-muted">
129
145
  {s.reasons.map((r) => (
130
146
  <li key={r}>{r}</li>
@@ -133,6 +149,27 @@ export default async function SuitePage({
133
149
  </Card>
134
150
  )}
135
151
 
152
+ {inInstructions.length > 0 && (
153
+ <Card className="space-y-2">
154
+ <h2 className="font-semibold text-warn">
155
+ Cases in the instructions
156
+ <InfoTip term="inInstructions" />
157
+ </h2>
158
+ <p className="readable text-sm text-muted">
159
+ These cases&apos; words appear in what the model is told, so a test
160
+ grades it on answers it was handed. Take the example out of the
161
+ instructions, or rewrite or retire the case.
162
+ </p>
163
+ <ul className="readable list-disc space-y-1 pl-5 text-sm">
164
+ {inInstructions.map((c) => (
165
+ <li key={c.caseId}>
166
+ {c.title}: “{c.found}”
167
+ </li>
168
+ ))}
169
+ </ul>
170
+ </Card>
171
+ )}
172
+
136
173
  <section className="space-y-3">
137
174
  <div className="flex items-center justify-between gap-4">
138
175
  <h2 className="text-lg font-semibold">Models</h2>
@@ -1,3 +1,4 @@
1
+ import type { Metadata } from "next";
1
2
  import Link from "next/link";
2
3
  import { notFound } from "next/navigation";
3
4
  import { rateQueue } from "@crowandraven/evalkeeper";
@@ -11,6 +12,15 @@ import { evalsPath } from "@/lib/evalkeeper/paths";
11
12
 
12
13
  export const dynamic = "force-dynamic";
13
14
 
15
+ export async function generateMetadata({
16
+ params,
17
+ }: {
18
+ params: Promise<{ suite: string }>;
19
+ }): Promise<Metadata> {
20
+ const { suite } = await params;
21
+ return { title: `Rate blind: ${SUITE_BY_KEY[suite]?.label ?? "Evals"}` };
22
+ }
23
+
14
24
  /**
15
25
  * Rating an imported suite's cases blind: one case at a time, the oldest
16
26
  * this person hasn't rated or skipped, shown by its input alone. The app's
@@ -1,12 +1,30 @@
1
1
  import Link from "next/link";
2
2
  import { notFound } from "next/navigation";
3
3
  import { allPassed, money, summarize } from "@crowandraven/evalkeeper";
4
+ import type { Metadata } from "next";
5
+ import { FieldValues } from "@/components/evalkeeper/Fields";
6
+ import { ReadableOutput } from "@/components/evalkeeper/ReadableOutput";
4
7
  import { BackLink, Card, pct } from "@/components/evalkeeper/ui";
5
- import { MODELS, requireAdmin, runner, store } from "@/lib/evalkeeper";
8
+ import {
9
+ MODELS,
10
+ requireAdmin,
11
+ runner,
12
+ store,
13
+ SUITE_BY_KEY,
14
+ } from "@/lib/evalkeeper";
6
15
  import { evalsPath } from "@/lib/evalkeeper/paths";
7
16
 
8
17
  export const dynamic = "force-dynamic";
9
18
 
19
+ export async function generateMetadata({
20
+ params,
21
+ }: {
22
+ params: Promise<{ suite: string }>;
23
+ }): Promise<Metadata> {
24
+ const { suite } = await params;
25
+ return { title: `Test: ${SUITE_BY_KEY[suite]?.label ?? "Evals"}` };
26
+ }
27
+
10
28
  /** One test: every answer, with what each check found. */
11
29
  export default async function RunPage({
12
30
  params,
@@ -30,7 +48,13 @@ export default async function RunPage({
30
48
  const summary = metrics ? summarize(metrics, suite.checks) : null;
31
49
  const label = (k: string) =>
32
50
  suite.checks.find((c) => c.key === k)?.label ?? k;
33
- type Check = { key: string; pass: boolean | null; note?: string };
51
+ type Check = {
52
+ key: string;
53
+ pass: boolean | null;
54
+ note?: string;
55
+ given?: string;
56
+ matches?: { expected: string; actual: string; why: string }[];
57
+ };
34
58
 
35
59
  return (
36
60
  <div className="space-y-6">
@@ -91,13 +115,58 @@ export default async function RunPage({
91
115
  </span>
92
116
  </div>
93
117
  {o.error && <p className="text-bad">{o.error}</p>}
118
+ {!o.error && o.output !== null && (
119
+ <div className="mt-2">
120
+ {suite.fields && suite.labelFromOutput ? (
121
+ <FieldValues
122
+ fields={suite.fields.label}
123
+ values={suite.labelFromOutput(o.output)}
124
+ prefix={`${o.id}-`}
125
+ />
126
+ ) : (
127
+ <ReadableOutput value={o.output} />
128
+ )}
129
+ </div>
130
+ )}
131
+ {suite.decisions &&
132
+ checks?.some((c) => c.given !== undefined) && (
133
+ <ul className="mt-2 space-y-0.5 text-xs">
134
+ {checks
135
+ .filter((c) => c.given !== undefined)
136
+ .map((c) => (
137
+ <li key={c.key}>
138
+ <span className="text-muted">{label(c.key)}:</span>{" "}
139
+ {c.given}{" "}
140
+ <span className={c.pass ? "text-good" : "text-warn"}>
141
+ {c.pass ? "right" : "wrong"}
142
+ </span>
143
+ </li>
144
+ ))}
145
+ </ul>
146
+ )}
94
147
  {checks
95
148
  ?.filter((c) => c.pass === false)
96
149
  .map((c) => (
97
- <p key={c.key} className="readable text-muted">
150
+ <p key={c.key} className="readable mt-2 text-muted">
98
151
  {label(c.key)}: {c.note ?? "failed"}
99
152
  </p>
100
153
  ))}
154
+ {checks
155
+ ?.flatMap((c) => c.matches ?? [])
156
+ .slice(0, 20)
157
+ .map((m, i) => (
158
+ <p key={i} className="readable mt-1 text-xs text-muted">
159
+ Matched “{m.expected}” with “{m.actual}”: {m.why}
160
+ </p>
161
+ ))}
162
+ {cases.has(o.caseId) && (
163
+ <Link
164
+ href={`${evalsPath(key)}#case-${o.caseId}`}
165
+ className="mt-2 inline-block text-xs text-accent hover:underline"
166
+ >
167
+ Find the case in the answer key
168
+ </Link>
169
+ )}
101
170
  </div>
102
171
  );
103
172
  })}