pi-evals 0.4.1 → 0.5.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/CHANGELOG.md +8 -0
- package/README.md +23 -4
- package/dist/findings.js +4 -0
- package/dist/index.js +9 -4
- package/dist/labels-query.js +35 -0
- package/dist/labels.js +211 -0
- package/dist/live-labels.js +128 -0
- package/dist/model.js +9 -43
- package/dist/observer.js +8 -2
- package/dist/ops.js +2 -1
- package/dist/query.js +5 -1
- package/dist/render.js +1 -0
- package/dist/report/concepts.js +14 -0
- package/dist/report/sections.js +18 -3
- package/dist/work/track.js +10 -4
- package/docs/design.md +19 -1
- package/docs/schema.md +22 -4
- package/package.json +4 -2
- package/skills/analyzing-evals/SKILL.md +3 -1
- package/src/findings.ts +3 -0
- package/src/index.ts +8 -4
- package/src/labels-query.ts +36 -0
- package/src/labels.ts +248 -0
- package/src/live-labels.ts +140 -0
- package/src/model.ts +11 -47
- package/src/observer.ts +13 -3
- package/src/ops.ts +2 -1
- package/src/query.ts +4 -1
- package/src/render.ts +1 -0
- package/src/report/concepts.ts +18 -0
- package/src/report/sections.ts +42 -9
- package/src/work/track.ts +11 -2
package/src/report/sections.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { FAILURE_TYPE_META, type FailureType, ruleLabel } from "../labels.ts";
|
|
2
|
+
import { type ReportModel, SMALL_SAMPLE } from "../model.ts";
|
|
2
3
|
import { type concepts, lesson, selfCheck } from "./concepts.ts";
|
|
3
4
|
import { duration, esc, type Lang, num, pct, table, usd, words } from "./format.ts";
|
|
4
5
|
import { workSection } from "./work.ts";
|
|
@@ -151,21 +152,52 @@ export function sections(m: ReportModel, lang: Lang, cards: ReturnType<typeof co
|
|
|
151
152
|
} bytes</p>`
|
|
152
153
|
: `<p>${L("Coverage not measured; keep cleanup off.", "沒有索引覆蓋資料,請勿開啟清理。")}</p>`,
|
|
153
154
|
);
|
|
155
|
+
const lb = m.labels, rule = (r: string) => ruleLabel(r, lang);
|
|
156
|
+
const pair = (c: { agree: number; n: number }) => (c.n ? `${num(c.agree)} / ${num(c.n)}` : "—");
|
|
154
157
|
const labels = section(
|
|
155
158
|
"labels",
|
|
156
159
|
L("Your labels", "你的標記"),
|
|
157
160
|
meta.agreement.meaning[lang],
|
|
158
|
-
|
|
159
|
-
?
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
lb.needsIndex ? `<p>${L("Run /evals extract to count labels in this period.", "請執行 /evals extract 以計算這段期間的標記。")}</p>` : lb.present && lb.n
|
|
162
|
+
? `<p>${L(`After the fact ${num(lb.bySource.batch)} (${num(lb.sessions.batch)} sessions) / In the moment ${num(lb.bySource.live)} (${num(lb.sessions.live)} sessions)`, `事後標 ${num(lb.bySource.batch)} 筆(${num(lb.sessions.batch)} 段工作) / 當下標 ${num(lb.bySource.live)} 筆(${num(lb.sessions.live)} 段工作)`)}${
|
|
163
|
+
lb.fromWords ? L(`; ${num(lb.fromWords)} of them the agent wrote from your words`, `;其中 ${num(lb.fromWords)} 筆是代理人依你的話整理的`) : ""
|
|
164
|
+
}</p>` +
|
|
165
|
+
T(
|
|
166
|
+
[L("Check", "檢查"), L("Agreement", "一致比例"), L("After the fact: agreed / compared", "事後標:一致 / 比對"), L("In the moment: agreed / compared", "當下標:一致 / 比對"), L("Cannot tell", "看不出來")],
|
|
167
|
+
lb.agreement.map((r) => [rule(r.detector), `${pct(r.rate)}(${num(r.n)})`, pair(r.bySource.batch), pair(r.bySource.live), r.unclear]),
|
|
168
|
+
) +
|
|
169
|
+
`<p class="muted">${L(`Cannot tell ${num(lb.unclear)}: labels marked unclear are left out of the agreement rate.`, `看不出來 ${num(lb.unclear)}:標成「看不出來」的不算進一致比例。`)}${
|
|
170
|
+
lb.noCode ? L(` ${num(lb.noCode)} labels have no code verdict to compare: the session is not extracted yet (run /evals extract), or the rule did not apply to it.`, `另有 ${num(lb.noCode)} 筆沒有程式判斷可比:那段工作還沒整理(執行 /evals extract 後就能比),或這條規則不適用於它。`) : ""
|
|
171
|
+
}${lb.other ? L(` ${num(lb.other)} labels are on "Other", which no code check covers.`, `${num(lb.other)} 筆標在「其他」,沒有程式檢查可比。`) : ""}</p>` + lesson(cards.labelTiming, L)
|
|
163
172
|
: `<p>${
|
|
164
173
|
L(
|
|
165
|
-
"No labels yet.
|
|
166
|
-
"
|
|
174
|
+
"No labels yet. Type /evals label in any session to say, while the work is in front of you, whether the agent followed a rule.",
|
|
175
|
+
"還沒有標記。在任何工作階段輸入 /evals label,就能趁工作還在眼前,標記代理人有沒有照規則做。",
|
|
176
|
+
)
|
|
177
|
+
}</p>` + lesson(cards.labelTiming, L),
|
|
178
|
+
);
|
|
179
|
+
const c = lb.corrections, few = c.n < SMALL_SAMPLE;
|
|
180
|
+
const corrections = section(
|
|
181
|
+
"corrections",
|
|
182
|
+
L("Times the agent was corrected", "被糾正"),
|
|
183
|
+
L(
|
|
184
|
+
"When you correct how the agent worked, it logs one line with evals_label. This counts the corrections it logged, not all its mistakes: a slip nobody caught, or one it forgot to log, is not here.",
|
|
185
|
+
"你糾正代理人的做法時,它會用 evals_label 自己記一筆。這裡數的是它記下的被糾正次數,不是所有錯誤:沒人發現、沒被糾正,或它忘了記的,都不在這裡。",
|
|
186
|
+
),
|
|
187
|
+
c.n
|
|
188
|
+
? `<p class="big">${num(c.n)} <small>${L("corrections", "次")} · ${num(c.sessions)} ${L("sessions", "段工作")}</small></p>${
|
|
189
|
+
few ? `<p class="stale">${L(`Only ${num(c.n)}: too few to show a trend. Read it as a hint of where slips may recur.`, `只有 ${num(c.n)} 次,太少,看不出趨勢;只能當提醒,看哪裡可能常出錯。`)}</p>` : ""
|
|
190
|
+
}<div class="pair"><article class="panel"><h3>${L("By rule", "依規則")}</h3>${T([L("Rule", "規則"), L("Times", "次數")], c.byRule.map((r) => [rule(r.rule), r.n]))}</article><article class="panel"><h3>${L("By kind of slip", "依錯誤類型")}</h3>${
|
|
191
|
+
T([L("Kind", "類型"), L("Times", "次數")], c.byType.map((r) => [FAILURE_TYPE_META[r.type as FailureType]?.[lang] ?? r.type, r.n]))
|
|
192
|
+
}</article></div>` +
|
|
193
|
+
more(
|
|
194
|
+
L("By skill loaded and by anchorloop version", "依載入的技能、anchorloop 版本"),
|
|
195
|
+
`<p class="muted">${L("Skills the session had loaded before the correction. One correction counts for each of them; this does not mean the skill caused it.", "被糾正時這段工作已載入的技能。一次糾正會算進每個已載入的技能,不代表是技能造成的。")}</p>` +
|
|
196
|
+
T([L("Skill", "技能"), L("Times", "次數"), L("Sessions", "工作段數")], c.bySkill.map((r) => [r.skill || L("(none loaded)", "(沒載入技能)"), r.n, r.sessions])) +
|
|
197
|
+
`<p class="muted">${L("The anchorloop version in use when the correction was logged.", "依糾正當時使用的 anchorloop 版本。")}</p>` +
|
|
198
|
+
T([L("Version", "版本"), L("Times", "次數"), L("Sessions", "工作段數")], c.byVersion.map((r) => [r.version === "unknown" ? L("unknown", "不明") : r.version, r.n, r.sessions])),
|
|
167
199
|
)
|
|
168
|
-
}</p>`,
|
|
200
|
+
: `<p>${L("None logged in this period. When you correct the agent, it logs one line here.", "這段期間沒有紀錄。你糾正代理人時,它會在這裡記一筆。")}</p>`,
|
|
169
201
|
);
|
|
170
202
|
return [
|
|
171
203
|
workSection(m, lang, cards, lesson),
|
|
@@ -178,6 +210,7 @@ export function sections(m: ReportModel, lang: Lang, cards: ReturnType<typeof co
|
|
|
178
210
|
cost,
|
|
179
211
|
coverage,
|
|
180
212
|
labels,
|
|
213
|
+
corrections,
|
|
181
214
|
section(
|
|
182
215
|
"concepts",
|
|
183
216
|
L("Concepts", "概念"),
|
package/src/work/track.ts
CHANGED
|
@@ -142,6 +142,15 @@ function liteOf(raw: unknown): TaskLite | undefined {
|
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
/** A task's own key: its uid, else `<origin session>#<id>` for a task handed over from another session. */
|
|
146
|
+
const ownKey = (task: TaskLite) => task.uid ?? (task.origin ? `${task.origin}#${task.id}` : undefined);
|
|
147
|
+
|
|
148
|
+
/** The key of the task in progress in a live todo list, as the back-fill keys it on the session's main branch. */
|
|
149
|
+
export function liveItemKey(tasks: readonly unknown[], session: string): string | undefined {
|
|
150
|
+
const task = tasks.map(liteOf).find((x) => x?.status === "in_progress");
|
|
151
|
+
return task && (ownKey(task) ?? `${session}#${task.id}`);
|
|
152
|
+
}
|
|
153
|
+
|
|
145
154
|
/** The kind of stall a waking entry ends, or undefined when the entry does not start a turn. */
|
|
146
155
|
export function wakeOf(entry: Obj): { kind: StallKind; on?: string } | undefined {
|
|
147
156
|
const type = entry.type;
|
|
@@ -346,8 +355,8 @@ export class WorkTracker {
|
|
|
346
355
|
|
|
347
356
|
private newItem(session: string, nested: boolean, task: TaskLite, snap: Snapshot, si: number, main: Set<number>, reuse: Map<number, number>): ItemRaw {
|
|
348
357
|
let key: string;
|
|
349
|
-
|
|
350
|
-
|
|
358
|
+
const own = ownKey(task);
|
|
359
|
+
if (own) key = own;
|
|
351
360
|
else if (main.has(si)) {
|
|
352
361
|
const count = (reuse.get(task.id) ?? 0) + 1;
|
|
353
362
|
reuse.set(task.id, count);
|