@anthusai/papyrus 2.0.0 → 2.0.2
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/amplify/functions/model-attachment-upload/handler.ts +1 -0
- package/components/reference-cyclotron-priming.tsx +12 -13
- package/components/reference-cyclotron-status.tsx +4 -4
- package/components/reference-cyclotron-suggestion.tsx +6 -6
- package/components/reference-live-agreement.tsx +10 -10
- package/components/reference-priming.tsx +1 -1
- package/components/reference-relevance-review.tsx +1 -1
- package/components/reference-section-suggestion.tsx +1 -1
- package/lib/cyclotron-suggestions.ts +9 -9
- package/lib/relevance-status.ts +4 -4
- package/package.json +1 -1
- package/routes.manifest.json +1 -1
|
@@ -6,9 +6,8 @@ import { primingStateText, type PrimingRequestView } from "../lib/relevance-stat
|
|
|
6
6
|
export type PrimingFormInput = { url: string; label: string; explanation: string };
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* A compact form
|
|
10
|
-
*
|
|
11
|
-
* and records the outcome, which this list shows beside each saved request.
|
|
9
|
+
* A compact "Add a reference" form for a pasted URL. The page is read in the
|
|
10
|
+
* background and the outcome is shown beside each added reference.
|
|
12
11
|
*/
|
|
13
12
|
export function ReferenceCyclotronPriming({
|
|
14
13
|
labels,
|
|
@@ -25,19 +24,19 @@ export function ReferenceCyclotronPriming({
|
|
|
25
24
|
const [message, setMessage] = useState<string | null>(null);
|
|
26
25
|
|
|
27
26
|
async function submit() {
|
|
28
|
-
setMessage("
|
|
27
|
+
setMessage("Adding…");
|
|
29
28
|
try {
|
|
30
29
|
await onRequestPriming({ url, label, explanation });
|
|
31
30
|
setUrl("");
|
|
32
31
|
setExplanation("");
|
|
33
|
-
setMessage("
|
|
32
|
+
setMessage("Added. The page will be read shortly.");
|
|
34
33
|
} catch (error) {
|
|
35
34
|
setMessage(error instanceof Error ? error.message : String(error));
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
return (
|
|
40
|
-
<section aria-label="
|
|
39
|
+
<section aria-label="Add a reference" className="space-y-2 text-sm" data-reference-cyclotron-priming>
|
|
41
40
|
<form
|
|
42
41
|
className="flex flex-wrap items-end gap-3"
|
|
43
42
|
onSubmit={(event) => {
|
|
@@ -46,9 +45,9 @@ export function ReferenceCyclotronPriming({
|
|
|
46
45
|
}}
|
|
47
46
|
>
|
|
48
47
|
<label className="flex min-w-64 flex-1 flex-col gap-1">
|
|
49
|
-
<span className="text-xs text-muted-foreground">
|
|
48
|
+
<span className="text-xs text-muted-foreground">Add a reference by URL</span>
|
|
50
49
|
<input
|
|
51
|
-
aria-label="
|
|
50
|
+
aria-label="Reference URL"
|
|
52
51
|
onChange={(event) => setUrl(event.target.value)}
|
|
53
52
|
placeholder="https://"
|
|
54
53
|
required
|
|
@@ -57,8 +56,8 @@ export function ReferenceCyclotronPriming({
|
|
|
57
56
|
/>
|
|
58
57
|
</label>
|
|
59
58
|
<label className="flex flex-col gap-1">
|
|
60
|
-
<span className="text-xs text-muted-foreground">
|
|
61
|
-
<select aria-label="
|
|
59
|
+
<span className="text-xs text-muted-foreground">Include or exclude</span>
|
|
60
|
+
<select aria-label="Include or exclude" onChange={(event) => setLabel(event.target.value)} value={label}>
|
|
62
61
|
{labels.map((choice) => (
|
|
63
62
|
<option key={choice} value={choice}>{choice}</option>
|
|
64
63
|
))}
|
|
@@ -66,13 +65,13 @@ export function ReferenceCyclotronPriming({
|
|
|
66
65
|
</label>
|
|
67
66
|
<label className="flex min-w-48 flex-1 flex-col gap-1">
|
|
68
67
|
<span className="text-xs text-muted-foreground">Why (optional)</span>
|
|
69
|
-
<input aria-label="
|
|
68
|
+
<input aria-label="Reason" onChange={(event) => setExplanation(event.target.value)} type="text" value={explanation} />
|
|
70
69
|
</label>
|
|
71
|
-
<button className="cyclotron-review-secondary" type="submit">
|
|
70
|
+
<button className="cyclotron-review-secondary" type="submit">Add reference</button>
|
|
72
71
|
{message ? <p className="basis-full text-xs" role="status">{message}</p> : null}
|
|
73
72
|
</form>
|
|
74
73
|
{requests.length ? (
|
|
75
|
-
<ul aria-label="
|
|
74
|
+
<ul aria-label="Added references" className="space-y-1 text-xs text-muted-foreground">
|
|
76
75
|
{requests.slice(0, 10).map((view) => (
|
|
77
76
|
<li data-priming-request-state={view.outcome?.state ?? "waiting"} key={view.request.requestId}>
|
|
78
77
|
<span className="font-medium">{view.request.label}</span> {view.request.url} · {primingStateText(view)}
|
|
@@ -38,19 +38,19 @@ export function ReferenceCyclotronStatus({
|
|
|
38
38
|
setMessage("Sending…");
|
|
39
39
|
try {
|
|
40
40
|
await onRequestRate(choice);
|
|
41
|
-
setMessage("The
|
|
41
|
+
setMessage("Saved. The new rate takes effect shortly and the status will show who set it.");
|
|
42
42
|
} catch (error) {
|
|
43
43
|
setMessage(error instanceof Error ? error.message : String(error));
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
return (
|
|
48
|
-
<section aria-label="
|
|
48
|
+
<section aria-label="Suggestion status" className="space-y-2" data-reference-cyclotron-status>
|
|
49
49
|
<CyclotronStatusView status={status} />
|
|
50
50
|
{stale ? (
|
|
51
51
|
<p className="text-xs text-foreground" data-reference-cyclotron-status-stale>
|
|
52
52
|
<span aria-hidden="true">⚠ </span>
|
|
53
|
-
|
|
53
|
+
Status last updated {Math.round(ageHours)} hours ago; it refreshes automatically.
|
|
54
54
|
</p>
|
|
55
55
|
) : null}
|
|
56
56
|
<button
|
|
@@ -59,7 +59,7 @@ export function ReferenceCyclotronStatus({
|
|
|
59
59
|
onClick={() => setOpen((value) => !value)}
|
|
60
60
|
type="button"
|
|
61
61
|
>
|
|
62
|
-
{open ? "Hide
|
|
62
|
+
{open ? "Hide suggestion details" : "Suggestion details"}
|
|
63
63
|
</button>
|
|
64
64
|
{open ? (
|
|
65
65
|
<div className="space-y-3">
|
|
@@ -101,12 +101,12 @@ export function ReferenceSuggestionProvenance({ decision }: { decision: Relevanc
|
|
|
101
101
|
<ul className="mt-2 space-y-1">
|
|
102
102
|
<li>{summary.teachingLabelsSentence}.</li>
|
|
103
103
|
<li>{summary.primingExamplesSentence}.</li>
|
|
104
|
-
<li>
|
|
105
|
-
<li>
|
|
104
|
+
<li>Guidelines code {summary.doctrineShortHash ?? "not recorded"}.</li>
|
|
105
|
+
<li>Suggestion {summary.modelVersion ?? "revision not recorded"}.</li>
|
|
106
106
|
<li>Decided {formatSuggestionTime(summary.decidedAt)}.</li>
|
|
107
107
|
</ul>
|
|
108
108
|
) : (
|
|
109
|
-
<p className="mt-2">This suggestion was made before the
|
|
109
|
+
<p className="mt-2">This suggestion was made before the details were recorded. Only its revision and confidence are known.</p>
|
|
110
110
|
)}
|
|
111
111
|
</details>
|
|
112
112
|
);
|
|
@@ -116,7 +116,7 @@ export function ReferenceSuggestionProvenance({ decision }: { decision: Relevanc
|
|
|
116
116
|
export function CountsAsTrainingLabelNote({ referenceLineageId }: { referenceLineageId: string }) {
|
|
117
117
|
return (
|
|
118
118
|
<p className="border-l-2 border-foreground pl-2 text-xs font-semibold text-foreground" data-reference-training-label={referenceLineageId}>
|
|
119
|
-
|
|
119
|
+
Recorded as an editor’s own decision.
|
|
120
120
|
</p>
|
|
121
121
|
);
|
|
122
122
|
}
|
|
@@ -135,8 +135,8 @@ export function DelegatedCurationNote({ delegated, referenceLineageId }: { deleg
|
|
|
135
135
|
<p className="text-xs">Delegation {delegated.delegationShortId || "id not recorded"}.</p>
|
|
136
136
|
<p className="text-xs font-semibold" data-reference-training-label={referenceLineageId}>
|
|
137
137
|
{delegated.countsAsTrainingLabel
|
|
138
|
-
? `
|
|
139
|
-
: "
|
|
138
|
+
? `Recorded as ${delegated.person ?? "the person"}'s own decision.`
|
|
139
|
+
: "Not recorded as a person's own decision."}
|
|
140
140
|
</p>
|
|
141
141
|
</section>
|
|
142
142
|
);
|
|
@@ -12,10 +12,10 @@ import { formatSuggestionTime } from "./reference-cyclotron-suggestion";
|
|
|
12
12
|
|
|
13
13
|
function MeasurementFigures({ measurement }: { measurement: AgreementStripMeasurement }) {
|
|
14
14
|
const figures: Array<[string, string]> = [
|
|
15
|
-
["
|
|
16
|
-
["
|
|
17
|
-
["
|
|
18
|
-
["
|
|
15
|
+
["Matches editors", formatPercentage(measurement.agreement)],
|
|
16
|
+
["Suggested includes editors kept", formatPercentage(measurement.precision)],
|
|
17
|
+
["Editor includes suggested", formatPercentage(measurement.recall)],
|
|
18
|
+
["Decisions compared", String(measurement.comparisons)],
|
|
19
19
|
];
|
|
20
20
|
return (
|
|
21
21
|
<dl className="flex flex-wrap gap-x-6 gap-y-1">
|
|
@@ -30,19 +30,19 @@ function MeasurementFigures({ measurement }: { measurement: AgreementStripMeasur
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
* Live agreement at the top of References: how often the
|
|
33
|
+
* Live agreement at the top of References: how often the
|
|
34
34
|
* suggestions matched what editors then decided. Hidden without a payload.
|
|
35
35
|
*/
|
|
36
36
|
export function ReferenceLiveAgreement({ agreement }: { agreement: ShadowAgreement | null }) {
|
|
37
37
|
const state = agreementStripState(agreement);
|
|
38
38
|
if (state.kind === "hidden") return null;
|
|
39
39
|
return (
|
|
40
|
-
<section aria-label="
|
|
41
|
-
<h3 className="text-xs font-semibold uppercase tracking-wide text-foreground">
|
|
40
|
+
<section aria-label="Suggestion accuracy" className="shrink-0 space-y-2 border-y border-foreground py-3" data-reference-live-agreement={state.kind}>
|
|
41
|
+
<h3 className="text-xs font-semibold uppercase tracking-wide text-foreground">Suggestion accuracy</h3>
|
|
42
42
|
{state.loop ? (
|
|
43
43
|
<p className="text-sm text-foreground" data-reference-live-agreement-loop>
|
|
44
44
|
<span className="font-semibold">{loopStateWords(state.loop)}</span>
|
|
45
|
-
{" · "}Last
|
|
45
|
+
{" · "}Last checked {formatSuggestionTime(state.loop.lastSweepAt)}
|
|
46
46
|
{" · "}{dailyCapWords(state.loop)}
|
|
47
47
|
</p>
|
|
48
48
|
) : null}
|
|
@@ -51,11 +51,11 @@ export function ReferenceLiveAgreement({ agreement }: { agreement: ShadowAgreeme
|
|
|
51
51
|
) : null}
|
|
52
52
|
{state.kind === "not_enough" ? (
|
|
53
53
|
<p className="text-sm text-foreground" data-reference-live-agreement-not-enough>
|
|
54
|
-
Not enough
|
|
54
|
+
Not enough decisions yet: {state.measurement.comparisons} of {state.needed} editor decisions have followed a suggestion. Figures appear at {state.needed}.
|
|
55
55
|
</p>
|
|
56
56
|
) : <MeasurementFigures measurement={state.measurement} />}
|
|
57
57
|
<p className="text-xs text-foreground">
|
|
58
|
-
Suggestions compared with the decisions editors made afterwards.
|
|
58
|
+
Suggestions compared with the decisions editors made afterwards. Updated {formatSuggestionTime(agreement?.computedAt ?? null)}.
|
|
59
59
|
</p>
|
|
60
60
|
</section>
|
|
61
61
|
);
|
|
@@ -10,7 +10,7 @@ export function ReferencePriming(props: PrimingPanelProps) {
|
|
|
10
10
|
return (
|
|
11
11
|
<section className="shrink-0 space-y-3" aria-label="Representative reference examples">
|
|
12
12
|
<Button aria-expanded={open} onClick={() => setOpen((value) => !value)} variant="outline">
|
|
13
|
-
{open ? "Hide example
|
|
13
|
+
{open ? "Hide example references" : "Add example references (optional)"}
|
|
14
14
|
</Button>
|
|
15
15
|
{open ? <div className="max-h-[55dvh] space-y-3 overflow-y-auto pr-1"><p className="text-sm text-muted-foreground">Corrections to extracted content: describe what needs fixing, then enter the corrected title and abstract or summary. The note is saved with your correction; it does not automatically regenerate the content. Choose Publish / Not publish separately. An explanation of that judgment is optional.</p><PrimingPanel {...props} renderItem={props.renderItem ?? ((item) => <div className="space-y-2"><p className="whitespace-pre-wrap text-sm">{String(item.values.abstract ?? item.values.text ?? "")}</p><p className="break-all text-xs text-muted-foreground">{String(item.values.source_uri ?? "")}</p></div>)} /></div> : null}
|
|
16
16
|
</section>
|
|
@@ -67,7 +67,7 @@ export function ReferenceRelevanceReview({
|
|
|
67
67
|
onChange={(event) => setShareable(event.target.checked)}
|
|
68
68
|
type="checkbox"
|
|
69
69
|
/>
|
|
70
|
-
My explanation may be quoted publicly (
|
|
70
|
+
My explanation may be quoted publicly (on a public example page)
|
|
71
71
|
</label>
|
|
72
72
|
{error ? <p className="text-xs text-destructive" role="alert">{error}</p> : null}
|
|
73
73
|
</section>
|
|
@@ -98,7 +98,7 @@ export function SectionPicker({
|
|
|
98
98
|
</label>
|
|
99
99
|
);
|
|
100
100
|
})}
|
|
101
|
-
<p className="text-xs text-foreground">The Section you choose is
|
|
101
|
+
<p className="text-xs text-foreground">The Section you choose is saved with your decision.</p>
|
|
102
102
|
</fieldset>
|
|
103
103
|
);
|
|
104
104
|
}
|
|
@@ -92,13 +92,13 @@ export function latestShadowAgreement(payloads: Array<{ json: unknown; updatedAt
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
const STOP_REASON_WORDS: Record<string, string> = {
|
|
95
|
-
disabled: "
|
|
96
|
-
"daily decision cap": "The last
|
|
95
|
+
disabled: "Suggestions are switched off in the settings, so none are being made.",
|
|
96
|
+
"daily decision cap": "The last check reached the daily limit, so some references have no suggestion yet.",
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
/** The sentence an editor reads for a stop reason; unknown reasons are shown as given. */
|
|
100
100
|
export function stopReasonSentence(reason: string): string {
|
|
101
|
-
return STOP_REASON_WORDS[reason] ?? `The last
|
|
101
|
+
return STOP_REASON_WORDS[reason] ?? `The last check stopped early: ${reason}.`;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
/**
|
|
@@ -123,14 +123,14 @@ export function agreementStripState(agreement: ShadowAgreement | null): Agreemen
|
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
/** "
|
|
126
|
+
/** "Suggestions on" or "Suggestions off", the words the panel leads with. */
|
|
127
127
|
export function loopStateWords(loop: CyclotronLoopState): string {
|
|
128
|
-
return loop.enabled ? "
|
|
128
|
+
return loop.enabled ? "Suggestions on" : "Suggestions off";
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
/** The daily cap in words; no cap is said plainly. */
|
|
132
132
|
export function dailyCapWords(loop: CyclotronLoopState): string {
|
|
133
|
-
return loop.maxDecisionsPerDay === null ? "No daily
|
|
133
|
+
return loop.maxDecisionsPerDay === null ? "No daily limit" : `Daily limit ${loop.maxDecisionsPerDay} decisions`;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
export function formatPercentage(fraction: number | null): string {
|
|
@@ -202,10 +202,10 @@ export function provenanceSummary(decision: RelevanceDecisionView): ProvenanceSu
|
|
|
202
202
|
if (!provenance) return null;
|
|
203
203
|
const plural = (count: number, singular: string) => `${count} ${singular}${count === 1 ? "" : "s"}`;
|
|
204
204
|
return {
|
|
205
|
-
teachingLabelsSentence: `
|
|
206
|
-
primingExamplesSentence: `${plural(provenance.primingExamples, "
|
|
205
|
+
teachingLabelsSentence: `Based on ${plural(provenance.teachingLabels, "decision")} that editors made themselves`,
|
|
206
|
+
primingExamplesSentence: `${plural(provenance.primingExamples, "example reference")} supplied as starting examples`,
|
|
207
207
|
doctrineShortHash: provenance.doctrineFingerprint ? provenance.doctrineFingerprint.slice(0, SHORT_HASH_LENGTH) : null,
|
|
208
|
-
modelVersion: decision.version === null ? null : `
|
|
208
|
+
modelVersion: decision.version === null ? null : `revision ${decision.version}`,
|
|
209
209
|
decidedAt: decision.decidedAt,
|
|
210
210
|
};
|
|
211
211
|
}
|
package/lib/relevance-status.ts
CHANGED
|
@@ -127,10 +127,10 @@ export function isPrimingOutcome(value: unknown): value is PrimingOutcome {
|
|
|
127
127
|
|| (outcome.state === "failed" && typeof outcome.message === "string");
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
/** In words:
|
|
130
|
+
/** In plain words: Adding, Added, or Couldn't add with the reason. */
|
|
131
131
|
export function primingStateText(view: PrimingRequestView): string {
|
|
132
|
-
if (!view.outcome) return "
|
|
132
|
+
if (!view.outcome) return "Adding";
|
|
133
133
|
return view.outcome.state === "applied"
|
|
134
|
-
?
|
|
135
|
-
: `
|
|
134
|
+
? "Added"
|
|
135
|
+
: `Couldn't add: ${view.outcome.message}`;
|
|
136
136
|
}
|
package/package.json
CHANGED
package/routes.manifest.json
CHANGED