@intellectif/lk-core 1.0.0 → 1.2.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 +30 -0
- package/README.md +2 -1
- package/dist/{activity-DgpBJeBc.d.cts → activity-D705CXng.d.cts} +439 -7
- package/dist/{activity-DgpBJeBc.d.ts → activity-D705CXng.d.ts} +439 -7
- package/dist/ai-check.cjs +300 -9
- package/dist/ai-check.cjs.map +1 -1
- package/dist/ai-check.d.cts +18 -3
- package/dist/ai-check.d.ts +18 -3
- package/dist/ai-check.js +295 -4
- package/dist/ai-check.js.map +1 -1
- package/dist/{chunk-TJJFKKH2.cjs → chunk-46BXIGLG.cjs} +4 -4
- package/dist/{chunk-TJJFKKH2.cjs.map → chunk-46BXIGLG.cjs.map} +1 -1
- package/dist/{chunk-VSH7ECQL.cjs → chunk-4YANYTFN.cjs} +43 -43
- package/dist/{chunk-VSH7ECQL.cjs.map → chunk-4YANYTFN.cjs.map} +1 -1
- package/dist/chunk-7KOWU4RO.js +2207 -0
- package/dist/chunk-7KOWU4RO.js.map +1 -0
- package/dist/{chunk-DSDXL3JO.cjs → chunk-7THXD7AN.cjs} +657 -197
- package/dist/chunk-7THXD7AN.cjs.map +1 -0
- package/dist/chunk-CYCTIXUN.cjs +118 -0
- package/dist/chunk-CYCTIXUN.cjs.map +1 -0
- package/dist/chunk-CYPA5BW5.js +118 -0
- package/dist/chunk-CYPA5BW5.js.map +1 -0
- package/dist/{chunk-SJVRUPJT.js → chunk-JTNDIBZO.js} +2 -2
- package/dist/{chunk-XS6U2ARZ.js → chunk-MV2N2WNS.js} +6 -112
- package/dist/chunk-MV2N2WNS.js.map +1 -0
- package/dist/chunk-MXI26H62.cjs +2207 -0
- package/dist/chunk-MXI26H62.cjs.map +1 -0
- package/dist/{chunk-FBKTION6.js → chunk-QS7B42ZR.js} +640 -180
- package/dist/chunk-QS7B42ZR.js.map +1 -0
- package/dist/{chunk-IARLJ5MW.js → chunk-QX2ERL72.js} +2 -2
- package/dist/{chunk-2JT2WUQ2.cjs → chunk-ZWXQSKCX.cjs} +14 -120
- package/dist/chunk-ZWXQSKCX.cjs.map +1 -0
- package/dist/{index-BVNeSCWC.d.ts → index-BChYtrEe.d.ts} +1 -1
- package/dist/{index-BlOLlwOi.d.cts → index-VXt_v3YI.d.cts} +1 -1
- package/dist/index.cjs +76 -593
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +308 -66
- package/dist/index.d.ts +308 -66
- package/dist/index.js +76 -593
- package/dist/index.js.map +1 -1
- package/dist/schemas.cjs +5 -3
- package/dist/schemas.cjs.map +1 -1
- package/dist/schemas.d.cts +2 -2
- package/dist/schemas.d.ts +2 -2
- package/dist/schemas.js +5 -3
- package/dist/scoring.cjs +3 -3
- package/dist/scoring.d.cts +242 -242
- package/dist/scoring.d.ts +242 -242
- package/dist/scoring.js +2 -2
- package/dist/xapi.cjs +3 -3
- package/dist/xapi.d.cts +1 -1
- package/dist/xapi.d.ts +1 -1
- package/dist/xapi.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-2JT2WUQ2.cjs.map +0 -1
- package/dist/chunk-DSDXL3JO.cjs.map +0 -1
- package/dist/chunk-FBKTION6.js.map +0 -1
- package/dist/chunk-RCZCP5OE.js +0 -729
- package/dist/chunk-RCZCP5OE.js.map +0 -1
- package/dist/chunk-W5KB3DNT.cjs +0 -729
- package/dist/chunk-W5KB3DNT.cjs.map +0 -1
- package/dist/chunk-XS6U2ARZ.js.map +0 -1
- /package/dist/{chunk-SJVRUPJT.js.map → chunk-JTNDIBZO.js.map} +0 -0
- /package/dist/{chunk-IARLJ5MW.js.map → chunk-QX2ERL72.js.map} +0 -0
package/dist/ai-check.cjs
CHANGED
|
@@ -5,9 +5,18 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
var _chunkMXI26H62cjs = require('./chunk-MXI26H62.cjs');
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
var _chunk4YANYTFNcjs = require('./chunk-4YANYTFN.cjs');
|
|
18
|
+
require('./chunk-ZWXQSKCX.cjs');
|
|
19
|
+
require('./chunk-7THXD7AN.cjs');
|
|
11
20
|
|
|
12
21
|
// src/ai-check/cases.ts
|
|
13
22
|
var capital = {
|
|
@@ -87,6 +96,68 @@ var weekend = {
|
|
|
87
96
|
]
|
|
88
97
|
}
|
|
89
98
|
};
|
|
99
|
+
var weather = {
|
|
100
|
+
schemaVersion: "1.0",
|
|
101
|
+
type: "read-aloud",
|
|
102
|
+
id: "ai-check-reading",
|
|
103
|
+
title: "Read the forecast aloud",
|
|
104
|
+
referenceText: "The weather is warm in the north.",
|
|
105
|
+
locale: "en-US",
|
|
106
|
+
recording: { maxSeconds: 20 },
|
|
107
|
+
scoring: {
|
|
108
|
+
dimensions: [
|
|
109
|
+
{ name: "accuracy", weight: 2 },
|
|
110
|
+
{ name: "fluency", weight: 1 }
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
var said = (text, over = {}) => ({
|
|
115
|
+
text,
|
|
116
|
+
error: "none",
|
|
117
|
+
accuracy: 92,
|
|
118
|
+
...over
|
|
119
|
+
});
|
|
120
|
+
function forecast(slips) {
|
|
121
|
+
return {
|
|
122
|
+
assessmentVersion: "1.0",
|
|
123
|
+
status: "assessed",
|
|
124
|
+
task: "scripted",
|
|
125
|
+
locale: "en-US",
|
|
126
|
+
referenceText: weather.referenceText,
|
|
127
|
+
recordingKey: "ai-check-take",
|
|
128
|
+
assessor: { kind: "auto", id: "pronunciation-engine" },
|
|
129
|
+
scale: 100,
|
|
130
|
+
scores: slips ? { accuracy: 68, fluency: 81, completeness: 86 } : { accuracy: 94, fluency: 90 },
|
|
131
|
+
miscue: "assessor",
|
|
132
|
+
phonemeAlphabet: "ipa",
|
|
133
|
+
words: [
|
|
134
|
+
said("The"),
|
|
135
|
+
slips ? said("weather", {
|
|
136
|
+
accuracy: 38,
|
|
137
|
+
error: "mispronunciation",
|
|
138
|
+
phonemes: [
|
|
139
|
+
{ symbol: "w", accuracy: 90 },
|
|
140
|
+
{ symbol: "\u025B", accuracy: 85 },
|
|
141
|
+
{
|
|
142
|
+
symbol: "\xF0",
|
|
143
|
+
accuracy: 12,
|
|
144
|
+
heardAs: [
|
|
145
|
+
{ symbol: "d", score: 64 },
|
|
146
|
+
{ symbol: "z", score: 21 },
|
|
147
|
+
{ symbol: "\xF0", score: 12 }
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
{ symbol: "\u025A", accuracy: 80 }
|
|
151
|
+
]
|
|
152
|
+
}) : said("weather"),
|
|
153
|
+
said("is"),
|
|
154
|
+
said("warm"),
|
|
155
|
+
said("in"),
|
|
156
|
+
said("the"),
|
|
157
|
+
slips ? { text: "north", error: "omission" } : said("north")
|
|
158
|
+
]
|
|
159
|
+
};
|
|
160
|
+
}
|
|
90
161
|
var chose = (ids) => ({
|
|
91
162
|
type: "multiple-choice",
|
|
92
163
|
selectedOptionIds: ids
|
|
@@ -105,22 +176,83 @@ var drafted = (text) => ({
|
|
|
105
176
|
text,
|
|
106
177
|
wordCount: 0
|
|
107
178
|
});
|
|
179
|
+
var fruit = {
|
|
180
|
+
schemaVersion: "1.0",
|
|
181
|
+
type: "multiple-choice",
|
|
182
|
+
id: "ai-check-fruit",
|
|
183
|
+
title: "Food words",
|
|
184
|
+
question: "Which of these is a fruit?",
|
|
185
|
+
mode: "single",
|
|
186
|
+
scoringStrategy: "all-or-nothing",
|
|
187
|
+
options: [
|
|
188
|
+
{ id: "f1", text: "Apple", isCorrect: true },
|
|
189
|
+
{ id: "f2", text: "Carrot", isCorrect: false },
|
|
190
|
+
{ id: "f3", text: "Tomato", isCorrect: false }
|
|
191
|
+
]
|
|
192
|
+
};
|
|
193
|
+
var tooHard = {
|
|
194
|
+
schemaVersion: "1.0",
|
|
195
|
+
type: "written-response",
|
|
196
|
+
id: "ai-check-too-hard",
|
|
197
|
+
title: "Cities",
|
|
198
|
+
prompt: "Discuss the socioeconomic ramifications of rapid urbanisation in developing economies.",
|
|
199
|
+
minWords: 40,
|
|
200
|
+
maxWords: 80
|
|
201
|
+
};
|
|
202
|
+
var cleanCloze = {
|
|
203
|
+
schemaVersion: "1.0",
|
|
204
|
+
type: "fill-in-the-blanks",
|
|
205
|
+
id: "ai-check-clean-cloze",
|
|
206
|
+
title: "Daily routine",
|
|
207
|
+
passage: "Every morning I {{1}} up at seven and {{2}} a shower.",
|
|
208
|
+
blanks: [
|
|
209
|
+
{ id: "1", acceptedAnswers: ["get", "wake"] },
|
|
210
|
+
{ id: "2", acceptedAnswers: ["take", "have"] }
|
|
211
|
+
],
|
|
212
|
+
scoringStrategy: "partial"
|
|
213
|
+
};
|
|
214
|
+
function critiqueCase(id, about, type, draft, extra = {}) {
|
|
215
|
+
const request = _chunkMXI26H62cjs.aiCritiqueRequest.call(void 0, { type, draft, ...extra });
|
|
216
|
+
if (request === null) {
|
|
217
|
+
throw new Error(`ai-check: no critique request for "${id}"`);
|
|
218
|
+
}
|
|
219
|
+
return { id, feature: "item-critique", about, request };
|
|
220
|
+
}
|
|
221
|
+
var MARKET = "Maria lives in Seville, in the south of Spain. Every Saturday she walks to the market with her grandmother. They buy oranges, fresh bread and a little cheese. On the way home they stop at a caf\xE9, where Maria drinks hot chocolate and her grandmother reads the newspaper.";
|
|
222
|
+
var MARKET_CAPTIONS = [
|
|
223
|
+
{ start: 0, end: 4.2, text: "Maria lives in Seville, in the south of Spain." },
|
|
224
|
+
{ start: 4.2, end: 8.9, text: "Every Saturday she walks to the market with her grandmother." },
|
|
225
|
+
{ start: 8.9, end: 12.6, text: "They buy oranges, fresh bread and a little cheese." },
|
|
226
|
+
{ start: 12.6, end: 18.1, text: "On the way home they stop at a caf\xE9." }
|
|
227
|
+
];
|
|
228
|
+
function draftsCase(id, about, types, source, extra = {}) {
|
|
229
|
+
const request = _chunkMXI26H62cjs.aiDraftsRequest.call(void 0, { types, source, ...extra });
|
|
230
|
+
if (request === null) {
|
|
231
|
+
throw new Error(`ai-check: no drafts request for "${id}"`);
|
|
232
|
+
}
|
|
233
|
+
return { id, feature: "draft-generation", about, request };
|
|
234
|
+
}
|
|
235
|
+
var READ_ALOUD_SETTINGS = {
|
|
236
|
+
locale: "en-US",
|
|
237
|
+
recording: { maxSeconds: 20 },
|
|
238
|
+
scoring: { dimensions: [{ name: "accuracy", weight: 1 }] }
|
|
239
|
+
};
|
|
108
240
|
function explanationCase(id, about, data, response) {
|
|
109
|
-
const request =
|
|
241
|
+
const request = _chunkMXI26H62cjs.aiExplanationRequest.call(void 0, { data, response });
|
|
110
242
|
if (request === null) {
|
|
111
243
|
throw new Error(`ai-check: no explanation request for "${id}"`);
|
|
112
244
|
}
|
|
113
245
|
return { id, feature: "explanation", about, request };
|
|
114
246
|
}
|
|
115
247
|
function hintCase(id, about, data, response, previousHints = []) {
|
|
116
|
-
const request =
|
|
248
|
+
const request = _chunkMXI26H62cjs.aiHintRequest.call(void 0, { data, response, previousHints });
|
|
117
249
|
if (request === null) {
|
|
118
250
|
throw new Error(`ai-check: no hint request for "${id}"`);
|
|
119
251
|
}
|
|
120
252
|
return { id, feature: "hint", about, request };
|
|
121
253
|
}
|
|
122
254
|
function writingCase(id, about, text, previousFeedback = [], learnerLocale) {
|
|
123
|
-
const request =
|
|
255
|
+
const request = _chunkMXI26H62cjs.aiWritingFeedbackRequest.call(void 0, {
|
|
124
256
|
data: weekend,
|
|
125
257
|
response: drafted(text),
|
|
126
258
|
previousFeedback,
|
|
@@ -131,6 +263,31 @@ function writingCase(id, about, text, previousFeedback = [], learnerLocale) {
|
|
|
131
263
|
}
|
|
132
264
|
return { id, feature: "writing-feedback", about, request };
|
|
133
265
|
}
|
|
266
|
+
function coachingCase(id, about, marks, learnerLocale) {
|
|
267
|
+
const assessment = _nullishCoalesce(marks.assessment, () => ( forecast(true)));
|
|
268
|
+
const grade = _chunk4YANYTFNcjs.gradeReadAloud.call(void 0,
|
|
269
|
+
weather,
|
|
270
|
+
{ type: "read-aloud", recording: { key: "ai-check-take", mimeType: "audio/wav" } },
|
|
271
|
+
assessment,
|
|
272
|
+
{
|
|
273
|
+
measured: { durationMs: 4e3, voicedMs: 3e3 },
|
|
274
|
+
plausibility: { maxWordsPerSecond: 6, minVoicedMs: 500 }
|
|
275
|
+
}
|
|
276
|
+
);
|
|
277
|
+
if ("unscorable" in grade) {
|
|
278
|
+
throw new Error(`ai-check: the reading for "${id}" did not grade: ${grade.reason}`);
|
|
279
|
+
}
|
|
280
|
+
const request = _chunkMXI26H62cjs.aiCoachingRequest.call(void 0, {
|
|
281
|
+
data: weather,
|
|
282
|
+
...marks.fromGradeOnly === true ? {} : { assessment },
|
|
283
|
+
grade,
|
|
284
|
+
...learnerLocale !== void 0 ? { learnerLocale } : {}
|
|
285
|
+
});
|
|
286
|
+
if (request === null) {
|
|
287
|
+
throw new Error(`ai-check: no coaching request for "${id}"`);
|
|
288
|
+
}
|
|
289
|
+
return { id, feature: "pronunciation-coaching", about, request };
|
|
290
|
+
}
|
|
134
291
|
function aiCheckCases() {
|
|
135
292
|
return [
|
|
136
293
|
explanationCase("mc-correct", "Chose the right city", capital, chose(["madrid"])),
|
|
@@ -220,6 +377,100 @@ function aiCheckCases() {
|
|
|
220
377
|
"Last weekend I visit my grandmother. She cook a big lunch and we eat together in the garden.",
|
|
221
378
|
[],
|
|
222
379
|
"es"
|
|
380
|
+
),
|
|
381
|
+
coachingCase("coaching-slips", 'A reading with a mispronounced "th" and a word left out', {
|
|
382
|
+
assessment: forecast(true)
|
|
383
|
+
}),
|
|
384
|
+
coachingCase("coaching-clean", "A reading the engine marked correct throughout", {
|
|
385
|
+
assessment: forecast(false)
|
|
386
|
+
}),
|
|
387
|
+
coachingCase(
|
|
388
|
+
"coaching-from-grade",
|
|
389
|
+
"The same slips, from a stored grade: marks without sounds",
|
|
390
|
+
{ fromGradeOnly: true }
|
|
391
|
+
),
|
|
392
|
+
coachingCase(
|
|
393
|
+
"coaching-in-spanish",
|
|
394
|
+
"The same slips, with coaching asked for in Spanish",
|
|
395
|
+
{ assessment: forecast(true) },
|
|
396
|
+
"es"
|
|
397
|
+
),
|
|
398
|
+
critiqueCase(
|
|
399
|
+
"critique-second-answer",
|
|
400
|
+
'A question whose distractor "Tomato" is botanically a fruit',
|
|
401
|
+
"multiple-choice",
|
|
402
|
+
fruit,
|
|
403
|
+
{ level: "A1" }
|
|
404
|
+
),
|
|
405
|
+
critiqueCase(
|
|
406
|
+
"critique-level",
|
|
407
|
+
"A writing task far above the A1 level it is set for",
|
|
408
|
+
"written-response",
|
|
409
|
+
tooHard,
|
|
410
|
+
{ level: "A1" }
|
|
411
|
+
),
|
|
412
|
+
critiqueCase(
|
|
413
|
+
"critique-clean",
|
|
414
|
+
"A cloze with nothing wrong in it",
|
|
415
|
+
"fill-in-the-blanks",
|
|
416
|
+
cleanCloze,
|
|
417
|
+
{
|
|
418
|
+
level: "A2"
|
|
419
|
+
}
|
|
420
|
+
),
|
|
421
|
+
critiqueCase(
|
|
422
|
+
"critique-in-spanish",
|
|
423
|
+
"The fruit question, reviewed in Spanish for its author",
|
|
424
|
+
"multiple-choice",
|
|
425
|
+
fruit,
|
|
426
|
+
{ level: "A1", authorLocale: "es" }
|
|
427
|
+
),
|
|
428
|
+
draftsCase(
|
|
429
|
+
"drafts-questions",
|
|
430
|
+
"Four multiple-choice questions on a short reading",
|
|
431
|
+
["multiple-choice"],
|
|
432
|
+
{ kind: "passage", text: MARKET },
|
|
433
|
+
{ count: 4, level: "A2", locale: "en" }
|
|
434
|
+
),
|
|
435
|
+
draftsCase(
|
|
436
|
+
"drafts-cloze",
|
|
437
|
+
"A cloze on the same reading, from its transcript",
|
|
438
|
+
["fill-in-the-blanks"],
|
|
439
|
+
{ kind: "transcript", text: MARKET },
|
|
440
|
+
{ count: 1, level: "A2", locale: "en", instructions: "Blank the verbs." }
|
|
441
|
+
),
|
|
442
|
+
draftsCase(
|
|
443
|
+
"drafts-gaps",
|
|
444
|
+
"A choose-the-word item on the same reading",
|
|
445
|
+
["gap-select"],
|
|
446
|
+
{ kind: "passage", text: MARKET },
|
|
447
|
+
{ count: 1, level: "A2", locale: "en" }
|
|
448
|
+
),
|
|
449
|
+
draftsCase(
|
|
450
|
+
"drafts-writing",
|
|
451
|
+
"A writing task that follows on from the reading",
|
|
452
|
+
["written-response"],
|
|
453
|
+
{ kind: "passage", text: MARKET },
|
|
454
|
+
{ count: 1, level: "A2", locale: "en" }
|
|
455
|
+
),
|
|
456
|
+
draftsCase(
|
|
457
|
+
"drafts-video",
|
|
458
|
+
"A video quiz from timed captions: multiple choice, then dictation, then read-aloud, as many as the video is worth",
|
|
459
|
+
["multiple-choice", "dictation", "read-aloud"],
|
|
460
|
+
{ kind: "captions", cues: MARKET_CAPTIONS },
|
|
461
|
+
{ level: "A2", locale: "en", settings: { "read-aloud": READ_ALOUD_SETTINGS } }
|
|
462
|
+
),
|
|
463
|
+
draftsCase(
|
|
464
|
+
"drafts-script",
|
|
465
|
+
"The same video from its script alone, with no times, and what the author asked for",
|
|
466
|
+
["multiple-choice", "dictation", "read-aloud"],
|
|
467
|
+
{ kind: "transcript", text: MARKET },
|
|
468
|
+
{
|
|
469
|
+
level: "A2",
|
|
470
|
+
locale: "en",
|
|
471
|
+
instructions: "Focus on what Maria and her grandmother buy.",
|
|
472
|
+
settings: { "read-aloud": READ_ALOUD_SETTINGS }
|
|
473
|
+
}
|
|
223
474
|
)
|
|
224
475
|
];
|
|
225
476
|
}
|
|
@@ -231,7 +482,9 @@ var REFUSALS = [
|
|
|
231
482
|
"too-long",
|
|
232
483
|
"contradicts-grade",
|
|
233
484
|
"reveals-answer",
|
|
234
|
-
"misquotes-answer"
|
|
485
|
+
"misquotes-answer",
|
|
486
|
+
"contradicts-marks",
|
|
487
|
+
"contradicts-item"
|
|
235
488
|
];
|
|
236
489
|
function portFor(ports, one) {
|
|
237
490
|
switch (one.request.feature) {
|
|
@@ -239,6 +492,12 @@ function portFor(ports, one) {
|
|
|
239
492
|
return ports.explain;
|
|
240
493
|
case "hint":
|
|
241
494
|
return ports.hint;
|
|
495
|
+
case "pronunciation-coaching":
|
|
496
|
+
return ports.pronunciationCoaching;
|
|
497
|
+
case "item-critique":
|
|
498
|
+
return ports.critique;
|
|
499
|
+
case "draft-generation":
|
|
500
|
+
return ports.drafts;
|
|
242
501
|
default:
|
|
243
502
|
return ports.writingFeedback;
|
|
244
503
|
}
|
|
@@ -262,8 +521,40 @@ async function runCase(ports, one) {
|
|
|
262
521
|
};
|
|
263
522
|
}
|
|
264
523
|
const ms = now() - started;
|
|
524
|
+
if (one.request.feature === "draft-generation") {
|
|
525
|
+
let next = 0;
|
|
526
|
+
const checked2 = _chunkMXI26H62cjs.checkAiDrafts.call(void 0, raw, one.request, {
|
|
527
|
+
newId: () => {
|
|
528
|
+
next += 1;
|
|
529
|
+
return `ai-check-${next}`;
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
return checked2.ok ? { case: one, ok: true, drafts: checked2.drafts, ms } : refused(one, raw, checked2.refusal, ms);
|
|
533
|
+
}
|
|
534
|
+
if (one.request.feature === "item-critique") {
|
|
535
|
+
const checked2 = _chunkMXI26H62cjs.checkAiCritique.call(void 0, raw, one.request);
|
|
536
|
+
return checked2.ok ? { case: one, ok: true, critique: checked2.critique, ms } : refused(one, raw, checked2.refusal, ms);
|
|
537
|
+
}
|
|
538
|
+
if (one.request.feature === "pronunciation-coaching") {
|
|
539
|
+
const checked2 = _chunkMXI26H62cjs.checkAiCoaching.call(void 0, raw, one.request);
|
|
540
|
+
if (checked2.ok) {
|
|
541
|
+
const { text, provenance, usage } = checked2.coaching;
|
|
542
|
+
return {
|
|
543
|
+
case: one,
|
|
544
|
+
ok: true,
|
|
545
|
+
result: {
|
|
546
|
+
text,
|
|
547
|
+
...provenance !== void 0 ? { provenance } : {},
|
|
548
|
+
...usage !== void 0 ? { usage } : {}
|
|
549
|
+
},
|
|
550
|
+
coaching: checked2.coaching,
|
|
551
|
+
ms
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
return refused(one, raw, checked2.refusal, ms);
|
|
555
|
+
}
|
|
265
556
|
if (one.request.feature === "writing-feedback") {
|
|
266
|
-
const checked2 =
|
|
557
|
+
const checked2 = _chunkMXI26H62cjs.checkAiWritingFeedback.call(void 0, raw, one.request);
|
|
267
558
|
if (checked2.ok) {
|
|
268
559
|
const { text, provenance, usage } = checked2.feedback;
|
|
269
560
|
return {
|
|
@@ -280,7 +571,7 @@ async function runCase(ports, one) {
|
|
|
280
571
|
}
|
|
281
572
|
return refused(one, raw, checked2.refusal, ms);
|
|
282
573
|
}
|
|
283
|
-
const checked = one.request.feature === "explanation" ?
|
|
574
|
+
const checked = one.request.feature === "explanation" ? _chunkMXI26H62cjs.checkAiExplanation.call(void 0, raw, one.request) : _chunkMXI26H62cjs.checkAiHint.call(void 0, raw, one.request);
|
|
284
575
|
if (checked.ok) {
|
|
285
576
|
return { case: one, ok: true, result: checked.result, ms };
|
|
286
577
|
}
|
package/dist/ai-check.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/learning-kit/learning-kit/packages/lk-core/dist/ai-check.cjs","../src/ai-check/cases.ts","../src/ai-check/index.ts"],"names":["checked","refused"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACA;ACeA,IAAM,QAAA,EAA8B;AAAA,EAClC,aAAA,EAAe,KAAA;AAAA,EACf,IAAA,EAAM,iBAAA;AAAA,EACN,EAAA,EAAI,aAAA;AAAA,EACJ,KAAA,EAAO,gBAAA;AAAA,EACP,QAAA,EAAU,+BAAA;AAAA,EACV,IAAA,EAAM,QAAA;AAAA,EACN,eAAA,EAAiB,gBAAA;AAAA,EACjB,OAAA,EA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AA,KAAA,CAAM,IAAA;AAAA,IACJ,CAAA,UAAA,EAAa,MAAA,CAAO,KAAK,CAAA,CAAA,EAAI,MAAA,CAAO,KAAK,CAAA,QAAA,EAAW,MAAA,CAAO,OAAO,CAAA,UAAA,EAAa,MAAA,CAAO,MAAM,CAAA,OAAA,EACvF,MAAA,CAAO,QAAA,EAAU,EAAA,EAAI,CAAA,EAAA,EAAK,MAAA,CAAO,OAAO,CAAA,kBAAA,EAAA,EAAuB,EAAE,CAAA,gBAAA,EAAc,OAAO,CAAA,GAAA;AAAA,EAC7F,CAAA;AACA,EAAA,IAAA,CAAA,MAAW,OAAA,GAAU,QAAA,EAAU;AAC7B,IAAA,MAAM,MAAA,EAAQ,MAAA,CAAO,SAAA,CAAU,MAAM,CAAA;AACrC,IAAA,GAAA,CAAI,MAAA,EAAQ,CAAA,EAAG;AACb,MAAA,KAAA,CAAM,IAAA,CAAK,CAAA,EAAA,EAAK,MAAM,CAAA,EAAA,EAAK,KAAK,CAAA,CAAA;AAClC,IAAA;AACF,EAAA;AACqC,EAAA;AACpB,IAAA;AACb,MAAA;AACF,IAAA;AAC8B,IAAA;AACA,IAAA;AACG,IAAA;AACJ,MAAA;AAC7B,IAAA;AACF,EAAA;AACsB,EAAA;AACxB;AF2EuC;AACA;AACA;AACA;AACA","file":"/home/runner/work/learning-kit/learning-kit/packages/lk-core/dist/ai-check.cjs","sourcesContent":[null,"import { aiExplanationRequest, aiHintRequest } from '../ai.js';\nimport { aiWritingFeedbackRequest } from '../ai-writing.js';\nimport type {\n DictationData,\n FillInTheBlanksData,\n GapSelectData,\n LearnerResponse,\n MultipleChoiceData,\n WrittenResponseData,\n} from '../types/activity.js';\nimport type { AiExplanationRequest, AiHintRequest, AiWritingFeedbackRequest } from '../types/ai.js';\n\n/**\n * The items the cases are built from. Small, ordinary language-course content\n * — and deliberately awkward in the places a model slips:\n *\n * - an answer a hint can hardly avoid naming (`Madrid`);\n * - an answer of one short word (`is`), which a hint may write as an ordinary\n * word and must not write beside its neighbour in the passage;\n * - an accented answer (`cañón`), so a hint that spells it without the accent\n * is still caught;\n * - a passage with more than one blank, so a hint can be about the wrong one;\n * - a short essay whose mistakes a model must quote exactly as the learner\n * wrote them — straight apostrophes a model likes to curl, a mistake made\n * twice — so a correction of words nobody wrote is caught.\n */\nconst capital: MultipleChoiceData = {\n schemaVersion: '1.0',\n type: 'multiple-choice',\n id: 'ai-check-mc',\n title: 'Capital cities',\n question: 'What is the capital of Spain?',\n mode: 'single',\n scoringStrategy: 'all-or-nothing',\n options: [\n { id: 'madrid', text: 'Madrid', isCorrect: true },\n { id: 'barcelona', text: 'Barcelona', isCorrect: false },\n { id: 'seville', text: 'Seville', isCorrect: false },\n ],\n};\n\nconst introduction: FillInTheBlanksData = {\n schemaVersion: '1.0',\n type: 'fill-in-the-blanks',\n id: 'ai-check-fib',\n title: 'Introducing yourself',\n passage: 'My name {{be}} Rossi and I {{live}} in Madrid.',\n blanks: [\n { id: 'be', acceptedAnswers: ['is'] },\n { id: 'live', acceptedAnswers: ['live'], hint: 'Present simple, first person.' },\n ],\n scoringStrategy: 'partial',\n};\n\nconst landscape: GapSelectData = {\n schemaVersion: '1.0',\n type: 'gap-select',\n id: 'ai-check-gap',\n title: 'Geography',\n locale: 'es-ES',\n passage: 'El río pasa por un {{g1}} muy profundo, y el agua {{g2}} fría.',\n gaps: [\n {\n id: 'g1',\n choices: [\n { id: 'canon', text: 'cañón' },\n { id: 'campo', text: 'campo' },\n ],\n correctChoiceId: 'canon',\n },\n {\n id: 'g2',\n choices: [\n { id: 'esta', text: 'está' },\n { id: 'es', text: 'es' },\n ],\n correctChoiceId: 'esta',\n },\n ],\n scoringStrategy: 'partial',\n};\n\nconst listening: DictationData = {\n schemaVersion: '1.0',\n type: 'dictation',\n id: 'ai-check-dictation',\n title: 'Listen and type',\n transcript: 'The train leaves at half past nine.',\n};\n\nconst weekend: WrittenResponseData = {\n schemaVersion: '1.0',\n type: 'written-response',\n id: 'ai-check-writing',\n title: 'Your weekend',\n prompt: 'Write a few sentences about what you did last weekend.',\n minWords: 15,\n maxWords: 120,\n languageTarget: 'en-A2',\n rubric: {\n criteria: [\n { name: 'Grammar', description: 'Past tenses, articles, agreement', weight: 2 },\n { name: 'Vocabulary', description: 'Everyday words, used correctly', weight: 1 },\n { name: 'Task', description: 'Says what the learner did, in order', weight: 1 },\n ],\n },\n};\n\n/**\n * One call to make against a host's port, and what a learner was looking at\n * when the SDK would have made it.\n */\nexport interface AiCheckCase {\n /** Stable across releases, so a host can name one in an allow-list or a report. */\n id: string;\n /** Which port the case is for. */\n feature: 'explanation' | 'hint' | 'writing-feedback';\n /** What the learner did, in a few words, for a report a person reads. */\n about: string;\n /** The request, built by the SDK exactly as a component builds it. */\n request: AiExplanationRequest | AiHintRequest | AiWritingFeedbackRequest;\n}\n\nconst chose = (ids: string[]): LearnerResponse => ({\n type: 'multiple-choice',\n selectedOptionIds: ids,\n});\nconst typed = (answers: Record<string, string>): LearnerResponse => ({\n type: 'fill-in-the-blanks',\n answers,\n});\nconst picked = (choices: Record<string, string>): LearnerResponse => ({\n type: 'gap-select',\n selections: choices,\n});\nconst wrote = (text: string): LearnerResponse => ({ type: 'dictation', text });\nconst drafted = (text: string): LearnerResponse => ({\n type: 'written-response',\n text,\n wordCount: 0,\n});\n\n/** Builds a case, failing loudly rather than shipping a case with no request. */\nfunction explanationCase(\n id: string,\n about: string,\n data: Parameters<typeof aiExplanationRequest>[0]['data'],\n response: LearnerResponse,\n): AiCheckCase {\n const request = aiExplanationRequest({ data, response });\n if (request === null) {\n throw new Error(`ai-check: no explanation request for \"${id}\"`);\n }\n return { id, feature: 'explanation', about, request };\n}\n\nfunction hintCase(\n id: string,\n about: string,\n data: Parameters<typeof aiHintRequest>[0]['data'],\n response: LearnerResponse,\n previousHints: string[] = [],\n): AiCheckCase {\n const request = aiHintRequest({ data, response, previousHints });\n if (request === null) {\n throw new Error(`ai-check: no hint request for \"${id}\"`);\n }\n return { id, feature: 'hint', about, request };\n}\n\nfunction writingCase(\n id: string,\n about: string,\n text: string,\n previousFeedback: string[] = [],\n learnerLocale?: string,\n): AiCheckCase {\n const request = aiWritingFeedbackRequest({\n data: weekend,\n response: drafted(text),\n previousFeedback,\n ...(learnerLocale !== undefined ? { learnerLocale } : {}),\n });\n if (request === null) {\n throw new Error(`ai-check: no writing feedback request for \"${id}\"`);\n }\n return { id, feature: 'writing-feedback', about, request };\n}\n\n/**\n * The cases {@link runAiCheck} runs: every type the SDK explains, answered\n * right, wrong and — where a type can be — partly right; every type it hints\n * for, before an answer and after a wrong one; and drafts of an essay, with\n * mistakes, without, and revised.\n *\n * They are ordinary calls. What makes them a test is that the SDK knows the\n * answer to each, so it can check what your model writes about it.\n *\n * A fresh array each call, so a caller may filter, slice or add to it without\n * changing what the next caller gets.\n */\nexport function aiCheckCases(): AiCheckCase[] {\n return [\n explanationCase('mc-correct', 'Chose the right city', capital, chose(['madrid'])),\n explanationCase('mc-wrong', 'Chose Barcelona', capital, chose(['barcelona'])),\n explanationCase('mc-blank', 'Chose nothing and submitted', capital, chose([])),\n explanationCase(\n 'fib-correct',\n 'Filled both blanks correctly',\n introduction,\n typed({ be: 'is', live: 'live' }),\n ),\n explanationCase(\n 'fib-partly',\n 'One blank right, one wrong',\n introduction,\n typed({ be: 'is', live: 'lives' }),\n ),\n explanationCase(\n 'fib-wrong',\n 'Both blanks wrong',\n introduction,\n typed({ be: 'are', live: 'living' }),\n ),\n explanationCase(\n 'gap-partly',\n 'One gap right, one wrong, in Spanish',\n landscape,\n picked({ g1: 'canon', g2: 'es' }),\n ),\n explanationCase(\n 'gap-wrong',\n 'Both gaps wrong, in Spanish',\n landscape,\n picked({ g1: 'campo', g2: 'es' }),\n ),\n explanationCase(\n 'dictation-near',\n 'Typed the sentence with two words wrong',\n listening,\n wrote('The train leaves at half past five'),\n ),\n explanationCase(\n 'dictation-correct',\n 'Typed the sentence correctly',\n listening,\n wrote('The train leaves at half past nine.'),\n ),\n hintCase('mc-hint-1', 'Has not answered yet', capital, chose([])),\n hintCase('mc-hint-2', 'Asked again after choosing Seville', capital, chose(['seville']), [\n 'Think about where the government sits.',\n ]),\n hintCase('fib-hint-1', 'Both blanks empty', introduction, typed({})),\n hintCase(\n 'fib-hint-2',\n 'Asked again with one blank wrong',\n introduction,\n typed({ be: 'are', live: '' }),\n ['Look again at the first blank.'],\n ),\n hintCase('gap-hint-1', 'Neither gap chosen, in Spanish', landscape, picked({})),\n hintCase(\n 'gap-hint-2',\n 'Asked again with the first gap wrong',\n landscape,\n picked({ g1: 'campo' }),\n ['Piensa en la forma del terreno.'],\n ),\n writingCase(\n 'writing-mistakes',\n 'A first draft with tense, article and agreement mistakes',\n \"Last weekend I go to the market and buyed a apple. My friends was there too, so we don't go home early. Then I go to the cinema.\",\n ),\n writingCase(\n 'writing-clean',\n 'A first draft with no mistakes to correct',\n 'Last weekend I went to the market and bought an apple. My friends were there too, so we stayed until the evening. Then we went to the cinema.',\n ),\n writingCase(\n 'writing-revised',\n 'A second draft that fixed some mistakes',\n \"Last weekend I went to the market and bought a apple. My friends was there too, so we didn't go home early.\",\n ['Check your past tenses: \"go\" and \"buyed\" should be past forms.'],\n ),\n writingCase(\n 'writing-feedback-in-spanish',\n 'A first draft, with feedback asked for in Spanish',\n 'Last weekend I visit my grandmother. She cook a big lunch and we eat together in the garden.',\n [],\n 'es',\n ),\n ];\n}\n","/**\n * A test kit for the prompts behind your AI ports.\n *\n * The SDK cannot test your model, and will not try. What it can do is make the\n * calls a learner's questions would make — on items whose answers it knows —\n * and run the same checks it runs before a learner sees anything. What comes\n * back is a count of what would have been shown and what would have been\n * refused, and why.\n *\n * Run it where you change a prompt or a model, in your own CI, with your own\n * key. It is a separate entry point (`@intellectif/lk-core/ai-check`) because\n * it is for your test run, not for a learner's browser: nothing here is\n * imported by anything a page renders.\n *\n * ```ts\n * import { aiCheckCases, formatAiCheckReport, runAiCheck } from '@intellectif/lk-core/ai-check';\n *\n * const report = await runAiCheck({\n * explain: (request) => callMyModel(EXPLAIN_PROMPT, request),\n * hint: (request) => callMyModel(HINT_PROMPT, request),\n * writingFeedback: (request) => callMyModel(FEEDBACK_PROMPT, request),\n * });\n * console.log(formatAiCheckReport(report));\n * if (report.refused > 0 || report.errors > 0) {\n * process.exitCode = 1;\n * }\n * ```\n *\n * A refusal is a real failure, not a warning: it is an answer a learner would\n * have asked for and not received. `reveals-answer` on a hint case is the one\n * to take most seriously — that prompt gives answers away — and\n * `misquotes-answer` on a writing case the next: that prompt corrects words the\n * learner never wrote.\n */\nimport { checkAiExplanation, checkAiHint } from '../ai.js';\nimport { checkAiWritingFeedback } from '../ai-writing.js';\nimport type {\n AiExplanationRequest,\n AiHintRequest,\n AiRefusal,\n AiTextResult,\n AiWritingFeedback,\n AiWritingFeedbackRequest,\n} from '../types/ai.js';\nimport { type AiCheckCase, aiCheckCases } from './cases.js';\n\nexport { type AiCheckCase, aiCheckCases } from './cases.js';\n\n/**\n * Your ports, as this kit calls them. The same functions\n * `<LkAiProvider ai={…}>` takes, minus the `AbortSignal` a browser passes —\n * nothing here abandons a call.\n *\n * Leave one out and its cases are skipped rather than failed.\n */\nexport interface AiCheckPorts {\n explain?(request: AiExplanationRequest): Promise<unknown> | unknown;\n hint?(request: AiHintRequest): Promise<unknown> | unknown;\n writingFeedback?(request: AiWritingFeedbackRequest): Promise<unknown> | unknown;\n}\n\n/** What happened on one case. */\nexport interface AiCheckResult {\n case: AiCheckCase;\n /** Whether a learner would have been shown what came back. */\n ok: boolean;\n /** Why it would not have been shown. */\n refusal?: AiRefusal;\n /** The port threw or rejected. Its message, as a string. */\n error?: string;\n /**\n * What came back, once the SDK had read it — so a refusal can be read beside\n * the text that caused it. Absent when the port failed or answered with\n * nothing the SDK could read.\n */\n result?: AiTextResult;\n /** For a writing case a learner would have been shown: the feedback, as the SDK accepted it. */\n feedback?: AiWritingFeedback;\n /** How long the call took, in milliseconds. */\n ms: number;\n}\n\n/** What a run came to. */\nexport interface AiCheckReport {\n /** Cases run: the ones a port was supplied for. */\n total: number;\n /** Cases whose answer a learner would have been shown. */\n shown: number;\n /** Cases whose answer the SDK refused. */\n refused: number;\n /** Cases where the port itself failed. */\n errors: number;\n /** Cases skipped because no port was supplied for that feature. */\n skipped: number;\n /** How many refusals of each reason. */\n byRefusal: Record<AiRefusal, number>;\n results: AiCheckResult[];\n}\n\nexport interface AiCheckOptions {\n /**\n * The cases to run. Defaults to {@link aiCheckCases}. Pass a filtered list to\n * run one type, or your own cases — built with `aiExplanationRequest` and\n * `aiHintRequest` on your own items, which is how you test a prompt against\n * the content your learners actually see.\n */\n cases?: readonly AiCheckCase[];\n /**\n * How many cases to have in flight at once. Default 1: a run in CI hits a\n * rate limit far more often than it runs out of patience.\n */\n concurrency?: number;\n}\n\nconst REFUSALS: AiRefusal[] = [\n 'malformed',\n 'empty',\n 'too-long',\n 'contradicts-grade',\n 'reveals-answer',\n 'misquotes-answer',\n];\n\n/** The port a case is for. */\nfunction portFor(\n ports: AiCheckPorts,\n one: AiCheckCase,\n): ((request: never) => Promise<unknown> | unknown) | undefined {\n switch (one.request.feature) {\n case 'explanation':\n return ports.explain as never;\n case 'hint':\n return ports.hint as never;\n default:\n return ports.writingFeedback as never;\n }\n}\n\n/** Milliseconds, from whichever clock this runtime has. */\nconst now = (): number => Date.now();\n\n/** Runs one case: calls the port, times it, and checks what came back. */\nasync function runCase(ports: AiCheckPorts, one: AiCheckCase): Promise<AiCheckResult> {\n const started = now();\n const port = portFor(ports, one);\n if (port === undefined) {\n throw new Error(`ai-check: no port for \"${one.id}\"`);\n }\n let raw: unknown;\n try {\n raw = await port(one.request as never);\n } catch (error) {\n return {\n case: one,\n ok: false,\n error: error instanceof Error ? error.message : String(error),\n ms: now() - started,\n };\n }\n const ms = now() - started;\n if (one.request.feature === 'writing-feedback') {\n const checked = checkAiWritingFeedback(raw, one.request);\n if (checked.ok) {\n const { text, provenance, usage } = checked.feedback;\n return {\n case: one,\n ok: true,\n result: {\n text,\n ...(provenance !== undefined ? { provenance } : {}),\n ...(usage !== undefined ? { usage } : {}),\n },\n feedback: checked.feedback,\n ms,\n };\n }\n return refused(one, raw, checked.refusal, ms);\n }\n const checked =\n one.request.feature === 'explanation'\n ? checkAiExplanation(raw, one.request)\n : checkAiHint(raw, one.request);\n if (checked.ok) {\n return { case: one, ok: true, result: checked.result, ms };\n }\n return refused(one, raw, checked.refusal, ms);\n}\n\n/** A case whose answer was refused, with the text that came back when there was one to read. */\nfunction refused(one: AiCheckCase, raw: unknown, refusal: AiRefusal, ms: number): AiCheckResult {\n const text =\n typeof (raw as { text?: unknown })?.text === 'string' ? (raw as AiTextResult) : undefined;\n return {\n case: one,\n ok: false,\n refusal,\n ...(text !== undefined ? { result: text } : {}),\n ms,\n };\n}\n\n/**\n * Calls your ports on every case and reports what a learner would have seen.\n *\n * It never throws for a failing case: a port that rejects is an `error` in the\n * report, so one bad call cannot hide the rest.\n */\nexport async function runAiCheck(\n ports: AiCheckPorts,\n options: AiCheckOptions = {},\n): Promise<AiCheckReport> {\n const all = options.cases ?? aiCheckCases();\n const asked = Math.trunc(options.concurrency ?? 1);\n const lanes = Number.isFinite(asked) && asked >= 1 ? Math.min(asked, 16) : 1;\n const runnable = all.filter((one) => portFor(ports, one) !== undefined);\n const results: AiCheckResult[] = new Array(runnable.length);\n let next = 0;\n const lane = async (): Promise<void> => {\n while (next < runnable.length) {\n const mine = next;\n next += 1;\n const one = runnable[mine];\n if (one === undefined) {\n return;\n }\n results[mine] = await runCase(ports, one);\n }\n };\n await Promise.all(Array.from({ length: Math.min(lanes, runnable.length) }, lane));\n\n const byRefusal = Object.fromEntries(REFUSALS.map((reason) => [reason, 0])) as Record<\n AiRefusal,\n number\n >;\n let shown = 0;\n let refused = 0;\n let errors = 0;\n for (const result of results) {\n if (result.ok) {\n shown += 1;\n } else if (result.refusal !== undefined) {\n refused += 1;\n byRefusal[result.refusal] += 1;\n } else {\n errors += 1;\n }\n }\n return {\n total: results.length,\n shown,\n refused,\n errors,\n skipped: all.length - runnable.length,\n byRefusal,\n results,\n };\n}\n\n/**\n * The report as a few lines for a CI log: the counts, then every case that\n * failed, with what came back.\n *\n * The refused text is printed — this is your own test run, not a learner's\n * screen, and a hint that gives the answer away is only fixable if you can\n * read it.\n */\nexport function formatAiCheckReport(report: AiCheckReport): string {\n const lines: string[] = [];\n const slowest = report.results.reduce((worst, one) => Math.max(worst, one.ms), 0);\n lines.push(\n `ai-check: ${report.shown}/${report.total} shown, ${report.refused} refused, ${report.errors} failed` +\n `${report.skipped > 0 ? `, ${report.skipped} skipped (no port)` : ''} — slowest ${slowest} ms`,\n );\n for (const reason of REFUSALS) {\n const count = report.byRefusal[reason];\n if (count > 0) {\n lines.push(` ${reason}: ${count}`);\n }\n }\n for (const result of report.results) {\n if (result.ok) {\n continue;\n }\n const why = result.refusal ?? `port failed (${result.error ?? 'no message'})`;\n lines.push(` ✗ ${result.case.id} [${result.case.feature}] ${result.case.about}: ${why}`);\n if (result.result !== undefined) {\n lines.push(` ${result.result.text.replace(/\\s+/g, ' ').slice(0, 200)}`);\n }\n }\n return lines.join('\\n');\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/learning-kit/learning-kit/packages/lk-core/dist/ai-check.cjs","../src/ai-check/cases.ts","../src/ai-check/index.ts"],"names":["refused"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACA;ACsBA,IAAM,QAAA,EAA8B;AAAA,EAClC,aAAA,EAAe,KAAA;AAAA,EACf,IAAA,EAAM,iBAAA;AAAA,EACN,EAAA,EAAI,aAAA;AAAA,EACJ,KAAA,EAAO,gBAAA;AAAA,EACP,QAAA,EAAU,+BAAA;AAAA,EACV,IAAA,EAAM,QAAA;AAAA,EACN,eAAA,EAAiB,gBAAA;AAAA,EACjB,OAAA,EAAS;AAAA,IACP,EAAE,EAAA,EA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A;AACO,EAAA;AAC0B,EAAA;AACL,EAAA;AACZ,EAAA;AAC/C,EAAA;AAC6B,EAAA;AACP,IAAA;AAChB,MAAA;AACL,MAAA;AACiB,MAAA;AACF,MAAA;AACrB,QAAA;AACF,MAAA;AACwC,MAAA;AAC1C,IAAA;AACF,EAAA;AACgF,EAAA;AAEN,EAAA;AAI9D,EAAA;AACE,EAAA;AACD,EAAA;AACiB,EAAA;AACb,IAAA;AACJ,MAAA;AAC8B,IAAA;AAC5B,MAAA;AACkB,MAAA;AACxB,IAAA;AACK,MAAA;AACZ,IAAA;AACF,EAAA;AACO,EAAA;AACU,IAAA;AACf,IAAA;AACAA,IAAAA;AACA,IAAA;AAC+B,IAAA;AAC/B,IAAA;AACA,IAAA;AACF,EAAA;AACF;AAUmE;AACxC,EAAA;AACuD,EAAA;AAC1E,EAAA;AAC2E,IAAA;AAEjF,EAAA;AAC+B,EAAA;AACQ,IAAA;AACtB,IAAA;AACqB,MAAA;AACpC,IAAA;AACF,EAAA;AACqC,EAAA;AACpB,IAAA;AACb,MAAA;AACF,IAAA;AAC0E,IAAA;AACD,IAAA;AACxC,IAAA;AAC4C,MAAA;AAC7E,IAAA;AACF,EAAA;AACsB,EAAA;AACxB;AFsSqF;AACA;AACA;AACA;AACA","file":"/home/runner/work/learning-kit/learning-kit/packages/lk-core/dist/ai-check.cjs","sourcesContent":[null,"import { aiExplanationRequest, aiHintRequest } from '../ai.js';\nimport { aiCoachingRequest } from '../ai-coaching.js';\nimport { aiCritiqueRequest } from '../ai-critique.js';\nimport { aiDraftsRequest } from '../ai-drafts.js';\nimport { aiWritingFeedbackRequest } from '../ai-writing.js';\nimport { gradeReadAloud } from '../scoring/speech/grade.js';\nimport type {\n ActivityType,\n DictationData,\n FillInTheBlanksData,\n GapSelectData,\n LearnerResponse,\n MultipleChoiceData,\n ReadAloudData,\n WrittenResponseData,\n} from '../types/activity.js';\nimport type {\n AiCoachingRequest,\n AiCritiqueRequest,\n AiDraftSource,\n AiDraftsRequest,\n AiDraftType,\n AiExplanationRequest,\n AiHintRequest,\n AiWritingFeedbackRequest,\n} from '../types/ai.js';\nimport type { SpeechAssessment, SpeechWord } from '../types/speech.js';\n\n/**\n * The items the cases are built from. Small, ordinary language-course content\n * — and deliberately awkward in the places a model slips:\n *\n * - an answer a hint can hardly avoid naming (`Madrid`);\n * - an answer of one short word (`is`), which a hint may write as an ordinary\n * word and must not write beside its neighbour in the passage;\n * - an accented answer (`cañón`), so a hint that spells it without the accent\n * is still caught;\n * - a passage with more than one blank, so a hint can be about the wrong one;\n * - a short essay whose mistakes a model must quote exactly as the learner\n * wrote them — straight apostrophes a model likes to curl, a mistake made\n * twice — so a correction of words nobody wrote is caught.\n */\nconst capital: MultipleChoiceData = {\n schemaVersion: '1.0',\n type: 'multiple-choice',\n id: 'ai-check-mc',\n title: 'Capital cities',\n question: 'What is the capital of Spain?',\n mode: 'single',\n scoringStrategy: 'all-or-nothing',\n options: [\n { id: 'madrid', text: 'Madrid', isCorrect: true },\n { id: 'barcelona', text: 'Barcelona', isCorrect: false },\n { id: 'seville', text: 'Seville', isCorrect: false },\n ],\n};\n\nconst introduction: FillInTheBlanksData = {\n schemaVersion: '1.0',\n type: 'fill-in-the-blanks',\n id: 'ai-check-fib',\n title: 'Introducing yourself',\n passage: 'My name {{be}} Rossi and I {{live}} in Madrid.',\n blanks: [\n { id: 'be', acceptedAnswers: ['is'] },\n { id: 'live', acceptedAnswers: ['live'], hint: 'Present simple, first person.' },\n ],\n scoringStrategy: 'partial',\n};\n\nconst landscape: GapSelectData = {\n schemaVersion: '1.0',\n type: 'gap-select',\n id: 'ai-check-gap',\n title: 'Geography',\n locale: 'es-ES',\n passage: 'El río pasa por un {{g1}} muy profundo, y el agua {{g2}} fría.',\n gaps: [\n {\n id: 'g1',\n choices: [\n { id: 'canon', text: 'cañón' },\n { id: 'campo', text: 'campo' },\n ],\n correctChoiceId: 'canon',\n },\n {\n id: 'g2',\n choices: [\n { id: 'esta', text: 'está' },\n { id: 'es', text: 'es' },\n ],\n correctChoiceId: 'esta',\n },\n ],\n scoringStrategy: 'partial',\n};\n\nconst listening: DictationData = {\n schemaVersion: '1.0',\n type: 'dictation',\n id: 'ai-check-dictation',\n title: 'Listen and type',\n transcript: 'The train leaves at half past nine.',\n};\n\nconst weekend: WrittenResponseData = {\n schemaVersion: '1.0',\n type: 'written-response',\n id: 'ai-check-writing',\n title: 'Your weekend',\n prompt: 'Write a few sentences about what you did last weekend.',\n minWords: 15,\n maxWords: 120,\n languageTarget: 'en-A2',\n rubric: {\n criteria: [\n { name: 'Grammar', description: 'Past tenses, articles, agreement', weight: 2 },\n { name: 'Vocabulary', description: 'Everyday words, used correctly', weight: 1 },\n { name: 'Task', description: 'Says what the learner did, in order', weight: 1 },\n ],\n },\n};\n\nconst weather: ReadAloudData = {\n schemaVersion: '1.0',\n type: 'read-aloud',\n id: 'ai-check-reading',\n title: 'Read the forecast aloud',\n referenceText: 'The weather is warm in the north.',\n locale: 'en-US',\n recording: { maxSeconds: 20 },\n scoring: {\n dimensions: [\n { name: 'accuracy', weight: 2 },\n { name: 'fluency', weight: 1 },\n ],\n },\n};\n\n/** A word of the forecast as an engine reports it. */\nconst said = (text: string, over: Partial<SpeechWord> = {}): SpeechWord => ({\n text,\n error: 'none',\n accuracy: 92,\n ...over,\n});\n\n/**\n * An engine's assessment of the forecast. With `slips`, \"weather\" is\n * mispronounced — its \"th\" heard as /d/ or /z/ — and \"north\" is left out: the\n * marks a model must coach, and no others.\n */\nfunction forecast(slips: boolean): SpeechAssessment {\n return {\n assessmentVersion: '1.0',\n status: 'assessed',\n task: 'scripted',\n locale: 'en-US',\n referenceText: weather.referenceText,\n recordingKey: 'ai-check-take',\n assessor: { kind: 'auto', id: 'pronunciation-engine' },\n scale: 100,\n scores: slips ? { accuracy: 68, fluency: 81, completeness: 86 } : { accuracy: 94, fluency: 90 },\n miscue: 'assessor',\n phonemeAlphabet: 'ipa',\n words: [\n said('The'),\n slips\n ? said('weather', {\n accuracy: 38,\n error: 'mispronunciation',\n phonemes: [\n { symbol: 'w', accuracy: 90 },\n { symbol: 'ɛ', accuracy: 85 },\n {\n symbol: 'ð',\n accuracy: 12,\n heardAs: [\n { symbol: 'd', score: 64 },\n { symbol: 'z', score: 21 },\n { symbol: 'ð', score: 12 },\n ],\n },\n { symbol: 'ɚ', accuracy: 80 },\n ],\n })\n : said('weather'),\n said('is'),\n said('warm'),\n said('in'),\n said('the'),\n slips ? { text: 'north', error: 'omission' } : said('north'),\n ],\n };\n}\n\n/**\n * One call to make against a host's port, and what a learner was looking at\n * when the SDK would have made it.\n */\nexport interface AiCheckCase {\n /** Stable across releases, so a host can name one in an allow-list or a report. */\n id: string;\n /** Which port the case is for. */\n feature:\n | 'explanation'\n | 'hint'\n | 'writing-feedback'\n | 'pronunciation-coaching'\n | 'item-critique'\n | 'draft-generation';\n /** What the learner did, in a few words, for a report a person reads. */\n about: string;\n /** The request, built by the SDK exactly as a component builds it. */\n request:\n | AiExplanationRequest\n | AiHintRequest\n | AiWritingFeedbackRequest\n | AiCoachingRequest\n | AiCritiqueRequest\n | AiDraftsRequest;\n}\n\nconst chose = (ids: string[]): LearnerResponse => ({\n type: 'multiple-choice',\n selectedOptionIds: ids,\n});\nconst typed = (answers: Record<string, string>): LearnerResponse => ({\n type: 'fill-in-the-blanks',\n answers,\n});\nconst picked = (choices: Record<string, string>): LearnerResponse => ({\n type: 'gap-select',\n selections: choices,\n});\nconst wrote = (text: string): LearnerResponse => ({ type: 'dictation', text });\nconst drafted = (text: string): LearnerResponse => ({\n type: 'written-response',\n text,\n wordCount: 0,\n});\n\n/**\n * Items an author asks a model to review. Each is valid, and each but the last\n * has a flaw a rule cannot see: a distractor that is botanically a right\n * answer, and a task far above the level it is set for.\n */\nconst fruit: MultipleChoiceData = {\n schemaVersion: '1.0',\n type: 'multiple-choice',\n id: 'ai-check-fruit',\n title: 'Food words',\n question: 'Which of these is a fruit?',\n mode: 'single',\n scoringStrategy: 'all-or-nothing',\n options: [\n { id: 'f1', text: 'Apple', isCorrect: true },\n { id: 'f2', text: 'Carrot', isCorrect: false },\n { id: 'f3', text: 'Tomato', isCorrect: false },\n ],\n};\n\nconst tooHard: WrittenResponseData = {\n schemaVersion: '1.0',\n type: 'written-response',\n id: 'ai-check-too-hard',\n title: 'Cities',\n prompt: 'Discuss the socioeconomic ramifications of rapid urbanisation in developing economies.',\n minWords: 40,\n maxWords: 80,\n};\n\nconst cleanCloze: FillInTheBlanksData = {\n schemaVersion: '1.0',\n type: 'fill-in-the-blanks',\n id: 'ai-check-clean-cloze',\n title: 'Daily routine',\n passage: 'Every morning I {{1}} up at seven and {{2}} a shower.',\n blanks: [\n { id: '1', acceptedAnswers: ['get', 'wake'] },\n { id: '2', acceptedAnswers: ['take', 'have'] },\n ],\n scoringStrategy: 'partial',\n};\n\nfunction critiqueCase(\n id: string,\n about: string,\n type: ActivityType,\n draft: unknown,\n extra: { level?: string; authorLocale?: string } = {},\n): AiCheckCase {\n const request = aiCritiqueRequest({ type, draft, ...extra });\n if (request === null) {\n throw new Error(`ai-check: no critique request for \"${id}\"`);\n }\n return { id, feature: 'item-critique', about, request };\n}\n\n/** A short reading to draft from: plain, and with facts a question can be asked about. */\nconst MARKET =\n 'Maria lives in Seville, in the south of Spain. Every Saturday she walks to the market with her ' +\n 'grandmother. They buy oranges, fresh bread and a little cheese. On the way home they stop at a ' +\n 'café, where Maria drinks hot chocolate and her grandmother reads the newspaper.';\n\n/** The same reading as a video's captions, with times in seconds. */\nconst MARKET_CAPTIONS = [\n { start: 0, end: 4.2, text: 'Maria lives in Seville, in the south of Spain.' },\n { start: 4.2, end: 8.9, text: 'Every Saturday she walks to the market with her grandmother.' },\n { start: 8.9, end: 12.6, text: 'They buy oranges, fresh bread and a little cheese.' },\n { start: 12.6, end: 18.1, text: 'On the way home they stop at a café.' },\n];\n\nfunction draftsCase(\n id: string,\n about: string,\n types: AiDraftType[],\n source: AiDraftSource,\n extra: Omit<Parameters<typeof aiDraftsRequest>[0], 'types' | 'source'> = {},\n): AiCheckCase {\n const request = aiDraftsRequest({ types, source, ...extra });\n if (request === null) {\n throw new Error(`ai-check: no drafts request for \"${id}\"`);\n }\n return { id, feature: 'draft-generation', about, request };\n}\n\n/**\n * What a host sets on every read-aloud it drafts: the SDK has no default for a\n * recording's length or the dimensions a reading is graded on.\n */\nconst READ_ALOUD_SETTINGS = {\n locale: 'en-US',\n recording: { maxSeconds: 20 },\n scoring: { dimensions: [{ name: 'accuracy', weight: 1 }] },\n};\n\n/** Builds a case, failing loudly rather than shipping a case with no request. */\nfunction explanationCase(\n id: string,\n about: string,\n data: Parameters<typeof aiExplanationRequest>[0]['data'],\n response: LearnerResponse,\n): AiCheckCase {\n const request = aiExplanationRequest({ data, response });\n if (request === null) {\n throw new Error(`ai-check: no explanation request for \"${id}\"`);\n }\n return { id, feature: 'explanation', about, request };\n}\n\nfunction hintCase(\n id: string,\n about: string,\n data: Parameters<typeof aiHintRequest>[0]['data'],\n response: LearnerResponse,\n previousHints: string[] = [],\n): AiCheckCase {\n const request = aiHintRequest({ data, response, previousHints });\n if (request === null) {\n throw new Error(`ai-check: no hint request for \"${id}\"`);\n }\n return { id, feature: 'hint', about, request };\n}\n\nfunction writingCase(\n id: string,\n about: string,\n text: string,\n previousFeedback: string[] = [],\n learnerLocale?: string,\n): AiCheckCase {\n const request = aiWritingFeedbackRequest({\n data: weekend,\n response: drafted(text),\n previousFeedback,\n ...(learnerLocale !== undefined ? { learnerLocale } : {}),\n });\n if (request === null) {\n throw new Error(`ai-check: no writing feedback request for \"${id}\"`);\n }\n return { id, feature: 'writing-feedback', about, request };\n}\n\nfunction coachingCase(\n id: string,\n about: string,\n marks: { assessment?: SpeechAssessment; fromGradeOnly?: boolean },\n learnerLocale?: string,\n): AiCheckCase {\n const assessment = marks.assessment ?? forecast(true);\n const grade = gradeReadAloud(\n weather,\n { type: 'read-aloud', recording: { key: 'ai-check-take', mimeType: 'audio/wav' } },\n assessment,\n {\n measured: { durationMs: 4000, voicedMs: 3000 },\n plausibility: { maxWordsPerSecond: 6, minVoicedMs: 500 },\n },\n );\n if ('unscorable' in grade) {\n throw new Error(`ai-check: the reading for \"${id}\" did not grade: ${grade.reason}`);\n }\n const request = aiCoachingRequest({\n data: weather,\n ...(marks.fromGradeOnly === true ? {} : { assessment }),\n grade,\n ...(learnerLocale !== undefined ? { learnerLocale } : {}),\n });\n if (request === null) {\n throw new Error(`ai-check: no coaching request for \"${id}\"`);\n }\n return { id, feature: 'pronunciation-coaching', about, request };\n}\n\n/**\n * The cases {@link runAiCheck} runs: every type the SDK explains, answered\n * right, wrong and — where a type can be — partly right; every type it hints\n * for, before an answer and after a wrong one; and drafts of an essay, with\n * mistakes, without, and revised.\n *\n * They are ordinary calls. What makes them a test is that the SDK knows the\n * answer to each, so it can check what your model writes about it.\n *\n * A fresh array each call, so a caller may filter, slice or add to it without\n * changing what the next caller gets.\n */\nexport function aiCheckCases(): AiCheckCase[] {\n return [\n explanationCase('mc-correct', 'Chose the right city', capital, chose(['madrid'])),\n explanationCase('mc-wrong', 'Chose Barcelona', capital, chose(['barcelona'])),\n explanationCase('mc-blank', 'Chose nothing and submitted', capital, chose([])),\n explanationCase(\n 'fib-correct',\n 'Filled both blanks correctly',\n introduction,\n typed({ be: 'is', live: 'live' }),\n ),\n explanationCase(\n 'fib-partly',\n 'One blank right, one wrong',\n introduction,\n typed({ be: 'is', live: 'lives' }),\n ),\n explanationCase(\n 'fib-wrong',\n 'Both blanks wrong',\n introduction,\n typed({ be: 'are', live: 'living' }),\n ),\n explanationCase(\n 'gap-partly',\n 'One gap right, one wrong, in Spanish',\n landscape,\n picked({ g1: 'canon', g2: 'es' }),\n ),\n explanationCase(\n 'gap-wrong',\n 'Both gaps wrong, in Spanish',\n landscape,\n picked({ g1: 'campo', g2: 'es' }),\n ),\n explanationCase(\n 'dictation-near',\n 'Typed the sentence with two words wrong',\n listening,\n wrote('The train leaves at half past five'),\n ),\n explanationCase(\n 'dictation-correct',\n 'Typed the sentence correctly',\n listening,\n wrote('The train leaves at half past nine.'),\n ),\n hintCase('mc-hint-1', 'Has not answered yet', capital, chose([])),\n hintCase('mc-hint-2', 'Asked again after choosing Seville', capital, chose(['seville']), [\n 'Think about where the government sits.',\n ]),\n hintCase('fib-hint-1', 'Both blanks empty', introduction, typed({})),\n hintCase(\n 'fib-hint-2',\n 'Asked again with one blank wrong',\n introduction,\n typed({ be: 'are', live: '' }),\n ['Look again at the first blank.'],\n ),\n hintCase('gap-hint-1', 'Neither gap chosen, in Spanish', landscape, picked({})),\n hintCase(\n 'gap-hint-2',\n 'Asked again with the first gap wrong',\n landscape,\n picked({ g1: 'campo' }),\n ['Piensa en la forma del terreno.'],\n ),\n writingCase(\n 'writing-mistakes',\n 'A first draft with tense, article and agreement mistakes',\n \"Last weekend I go to the market and buyed a apple. My friends was there too, so we don't go home early. Then I go to the cinema.\",\n ),\n writingCase(\n 'writing-clean',\n 'A first draft with no mistakes to correct',\n 'Last weekend I went to the market and bought an apple. My friends were there too, so we stayed until the evening. Then we went to the cinema.',\n ),\n writingCase(\n 'writing-revised',\n 'A second draft that fixed some mistakes',\n \"Last weekend I went to the market and bought a apple. My friends was there too, so we didn't go home early.\",\n ['Check your past tenses: \"go\" and \"buyed\" should be past forms.'],\n ),\n writingCase(\n 'writing-feedback-in-spanish',\n 'A first draft, with feedback asked for in Spanish',\n 'Last weekend I visit my grandmother. She cook a big lunch and we eat together in the garden.',\n [],\n 'es',\n ),\n coachingCase('coaching-slips', 'A reading with a mispronounced \"th\" and a word left out', {\n assessment: forecast(true),\n }),\n coachingCase('coaching-clean', 'A reading the engine marked correct throughout', {\n assessment: forecast(false),\n }),\n coachingCase(\n 'coaching-from-grade',\n 'The same slips, from a stored grade: marks without sounds',\n { fromGradeOnly: true },\n ),\n coachingCase(\n 'coaching-in-spanish',\n 'The same slips, with coaching asked for in Spanish',\n { assessment: forecast(true) },\n 'es',\n ),\n critiqueCase(\n 'critique-second-answer',\n 'A question whose distractor \"Tomato\" is botanically a fruit',\n 'multiple-choice',\n fruit,\n { level: 'A1' },\n ),\n critiqueCase(\n 'critique-level',\n 'A writing task far above the A1 level it is set for',\n 'written-response',\n tooHard,\n { level: 'A1' },\n ),\n critiqueCase(\n 'critique-clean',\n 'A cloze with nothing wrong in it',\n 'fill-in-the-blanks',\n cleanCloze,\n {\n level: 'A2',\n },\n ),\n critiqueCase(\n 'critique-in-spanish',\n 'The fruit question, reviewed in Spanish for its author',\n 'multiple-choice',\n fruit,\n { level: 'A1', authorLocale: 'es' },\n ),\n draftsCase(\n 'drafts-questions',\n 'Four multiple-choice questions on a short reading',\n ['multiple-choice'],\n { kind: 'passage', text: MARKET },\n { count: 4, level: 'A2', locale: 'en' },\n ),\n draftsCase(\n 'drafts-cloze',\n 'A cloze on the same reading, from its transcript',\n ['fill-in-the-blanks'],\n { kind: 'transcript', text: MARKET },\n { count: 1, level: 'A2', locale: 'en', instructions: 'Blank the verbs.' },\n ),\n draftsCase(\n 'drafts-gaps',\n 'A choose-the-word item on the same reading',\n ['gap-select'],\n { kind: 'passage', text: MARKET },\n { count: 1, level: 'A2', locale: 'en' },\n ),\n draftsCase(\n 'drafts-writing',\n 'A writing task that follows on from the reading',\n ['written-response'],\n { kind: 'passage', text: MARKET },\n { count: 1, level: 'A2', locale: 'en' },\n ),\n draftsCase(\n 'drafts-video',\n 'A video quiz from timed captions: multiple choice, then dictation, then read-aloud, as many as the video is worth',\n ['multiple-choice', 'dictation', 'read-aloud'],\n { kind: 'captions', cues: MARKET_CAPTIONS },\n { level: 'A2', locale: 'en', settings: { 'read-aloud': READ_ALOUD_SETTINGS } },\n ),\n draftsCase(\n 'drafts-script',\n 'The same video from its script alone, with no times, and what the author asked for',\n ['multiple-choice', 'dictation', 'read-aloud'],\n { kind: 'transcript', text: MARKET },\n {\n level: 'A2',\n locale: 'en',\n instructions: 'Focus on what Maria and her grandmother buy.',\n settings: { 'read-aloud': READ_ALOUD_SETTINGS },\n },\n ),\n ];\n}\n","/**\n * A test kit for the prompts behind your AI ports.\n *\n * The SDK cannot test your model, and will not try. What it can do is make the\n * calls a learner's questions would make — on items whose answers it knows —\n * and run the same checks it runs before a learner sees anything. What comes\n * back is a count of what would have been shown and what would have been\n * refused, and why.\n *\n * Run it where you change a prompt or a model, in your own CI, with your own\n * key. It is a separate entry point (`@intellectif/lk-core/ai-check`) because\n * it is for your test run, not for a learner's browser: nothing here is\n * imported by anything a page renders.\n *\n * ```ts\n * import { aiCheckCases, formatAiCheckReport, runAiCheck } from '@intellectif/lk-core/ai-check';\n *\n * const report = await runAiCheck({\n * explain: (request) => callMyModel(EXPLAIN_PROMPT, request),\n * hint: (request) => callMyModel(HINT_PROMPT, request),\n * writingFeedback: (request) => callMyModel(FEEDBACK_PROMPT, request),\n * pronunciationCoaching: (request) => callMyModel(COACHING_PROMPT, request),\n * critique: (request) => callMyModel(CRITIQUE_PROMPT, request),\n * drafts: (request) => callMyModel(DRAFTS_PROMPT, request),\n * });\n * console.log(formatAiCheckReport(report));\n * if (report.refused > 0 || report.errors > 0) {\n * process.exitCode = 1;\n * }\n * ```\n *\n * A refusal is a real failure, not a warning: it is an answer a learner would\n * have asked for and not received. `reveals-answer` on a hint case is the one\n * to take most seriously — that prompt gives answers away. Next come\n * `misquotes-answer` on a writing case — that prompt corrects words the learner\n * never wrote — and `contradicts-marks` on a coaching case: that prompt coaches\n * words the engine heard as right, or sounds it never reported.\n */\nimport { checkAiExplanation, checkAiHint } from '../ai.js';\nimport { checkAiCoaching } from '../ai-coaching.js';\nimport { checkAiCritique } from '../ai-critique.js';\nimport { checkAiDrafts } from '../ai-drafts.js';\nimport { checkAiWritingFeedback } from '../ai-writing.js';\nimport type {\n AiCoaching,\n AiCoachingRequest,\n AiCritique,\n AiCritiqueRequest,\n AiDrafts,\n AiDraftsRequest,\n AiExplanationRequest,\n AiHintRequest,\n AiRefusal,\n AiTextResult,\n AiWritingFeedback,\n AiWritingFeedbackRequest,\n} from '../types/ai.js';\nimport { type AiCheckCase, aiCheckCases } from './cases.js';\n\nexport { type AiCheckCase, aiCheckCases } from './cases.js';\n\n/**\n * Your ports, as this kit calls them. The same functions\n * `<LkAiProvider ai={…}>` takes, minus the `AbortSignal` a browser passes —\n * nothing here abandons a call.\n *\n * Leave one out and its cases are skipped rather than failed.\n */\nexport interface AiCheckPorts {\n explain?(request: AiExplanationRequest): Promise<unknown> | unknown;\n hint?(request: AiHintRequest): Promise<unknown> | unknown;\n writingFeedback?(request: AiWritingFeedbackRequest): Promise<unknown> | unknown;\n pronunciationCoaching?(request: AiCoachingRequest): Promise<unknown> | unknown;\n /** Reviews an item for its author: the port an editor's \"Review with AI\" calls. */\n critique?(request: AiCritiqueRequest): Promise<unknown> | unknown;\n /** Drafts items from a source, for an author to approve. */\n drafts?(request: AiDraftsRequest): Promise<unknown> | unknown;\n}\n\n/** What happened on one case. */\nexport interface AiCheckResult {\n case: AiCheckCase;\n /** Whether a learner would have been shown what came back. */\n ok: boolean;\n /** Why it would not have been shown. */\n refusal?: AiRefusal;\n /** The port threw or rejected. Its message, as a string. */\n error?: string;\n /**\n * What came back, once the SDK had read it — so a refusal can be read beside\n * the text that caused it. Absent when the port failed or answered with\n * nothing the SDK could read.\n */\n result?: AiTextResult;\n /** For a writing case a learner would have been shown: the feedback, as the SDK accepted it. */\n feedback?: AiWritingFeedback;\n /** For a coaching case a learner would have been shown: the coaching, as the SDK accepted it. */\n coaching?: AiCoaching;\n /** For a critique case an author would have been shown: the findings, as the SDK accepted them. */\n critique?: AiCritique;\n /**\n * For a drafts case the SDK read: the drafts, each with what `validateDraft`\n * and the item critic say of it. A reply read is not a good one — check how\n * many came back `complete` and without warnings.\n */\n drafts?: AiDrafts;\n /** How long the call took, in milliseconds. */\n ms: number;\n}\n\n/** What a run came to. */\nexport interface AiCheckReport {\n /** Cases run: the ones a port was supplied for. */\n total: number;\n /** Cases whose answer a learner would have been shown. */\n shown: number;\n /** Cases whose answer the SDK refused. */\n refused: number;\n /** Cases where the port itself failed. */\n errors: number;\n /** Cases skipped because no port was supplied for that feature. */\n skipped: number;\n /** How many refusals of each reason. */\n byRefusal: Record<AiRefusal, number>;\n results: AiCheckResult[];\n}\n\nexport interface AiCheckOptions {\n /**\n * The cases to run. Defaults to {@link aiCheckCases}. Pass a filtered list to\n * run one type, or your own cases — built with `aiExplanationRequest` and\n * `aiHintRequest` on your own items, which is how you test a prompt against\n * the content your learners actually see.\n */\n cases?: readonly AiCheckCase[];\n /**\n * How many cases to have in flight at once. Default 1: a run in CI hits a\n * rate limit far more often than it runs out of patience.\n */\n concurrency?: number;\n}\n\nconst REFUSALS: AiRefusal[] = [\n 'malformed',\n 'empty',\n 'too-long',\n 'contradicts-grade',\n 'reveals-answer',\n 'misquotes-answer',\n 'contradicts-marks',\n 'contradicts-item',\n];\n\n/** The port a case is for. */\nfunction portFor(\n ports: AiCheckPorts,\n one: AiCheckCase,\n): ((request: never) => Promise<unknown> | unknown) | undefined {\n switch (one.request.feature) {\n case 'explanation':\n return ports.explain as never;\n case 'hint':\n return ports.hint as never;\n case 'pronunciation-coaching':\n return ports.pronunciationCoaching as never;\n case 'item-critique':\n return ports.critique as never;\n case 'draft-generation':\n return ports.drafts as never;\n default:\n return ports.writingFeedback as never;\n }\n}\n\n/** Milliseconds, from whichever clock this runtime has. */\nconst now = (): number => Date.now();\n\n/** Runs one case: calls the port, times it, and checks what came back. */\nasync function runCase(ports: AiCheckPorts, one: AiCheckCase): Promise<AiCheckResult> {\n const started = now();\n const port = portFor(ports, one);\n if (port === undefined) {\n throw new Error(`ai-check: no port for \"${one.id}\"`);\n }\n let raw: unknown;\n try {\n raw = await port(one.request as never);\n } catch (error) {\n return {\n case: one,\n ok: false,\n error: error instanceof Error ? error.message : String(error),\n ms: now() - started,\n };\n }\n const ms = now() - started;\n if (one.request.feature === 'draft-generation') {\n let next = 0;\n const checked = checkAiDrafts(raw, one.request, {\n newId: () => {\n next += 1;\n return `ai-check-${next}`;\n },\n });\n return checked.ok\n ? { case: one, ok: true, drafts: checked.drafts, ms }\n : refused(one, raw, checked.refusal, ms);\n }\n if (one.request.feature === 'item-critique') {\n const checked = checkAiCritique(raw, one.request);\n return checked.ok\n ? { case: one, ok: true, critique: checked.critique, ms }\n : refused(one, raw, checked.refusal, ms);\n }\n if (one.request.feature === 'pronunciation-coaching') {\n const checked = checkAiCoaching(raw, one.request);\n if (checked.ok) {\n const { text, provenance, usage } = checked.coaching;\n return {\n case: one,\n ok: true,\n result: {\n text,\n ...(provenance !== undefined ? { provenance } : {}),\n ...(usage !== undefined ? { usage } : {}),\n },\n coaching: checked.coaching,\n ms,\n };\n }\n return refused(one, raw, checked.refusal, ms);\n }\n if (one.request.feature === 'writing-feedback') {\n const checked = checkAiWritingFeedback(raw, one.request);\n if (checked.ok) {\n const { text, provenance, usage } = checked.feedback;\n return {\n case: one,\n ok: true,\n result: {\n text,\n ...(provenance !== undefined ? { provenance } : {}),\n ...(usage !== undefined ? { usage } : {}),\n },\n feedback: checked.feedback,\n ms,\n };\n }\n return refused(one, raw, checked.refusal, ms);\n }\n const checked =\n one.request.feature === 'explanation'\n ? checkAiExplanation(raw, one.request)\n : checkAiHint(raw, one.request);\n if (checked.ok) {\n return { case: one, ok: true, result: checked.result, ms };\n }\n return refused(one, raw, checked.refusal, ms);\n}\n\n/** A case whose answer was refused, with the text that came back when there was one to read. */\nfunction refused(one: AiCheckCase, raw: unknown, refusal: AiRefusal, ms: number): AiCheckResult {\n const text =\n typeof (raw as { text?: unknown })?.text === 'string' ? (raw as AiTextResult) : undefined;\n return {\n case: one,\n ok: false,\n refusal,\n ...(text !== undefined ? { result: text } : {}),\n ms,\n };\n}\n\n/**\n * Calls your ports on every case and reports what a learner would have seen.\n *\n * It never throws for a failing case: a port that rejects is an `error` in the\n * report, so one bad call cannot hide the rest.\n */\nexport async function runAiCheck(\n ports: AiCheckPorts,\n options: AiCheckOptions = {},\n): Promise<AiCheckReport> {\n const all = options.cases ?? aiCheckCases();\n const asked = Math.trunc(options.concurrency ?? 1);\n const lanes = Number.isFinite(asked) && asked >= 1 ? Math.min(asked, 16) : 1;\n const runnable = all.filter((one) => portFor(ports, one) !== undefined);\n const results: AiCheckResult[] = new Array(runnable.length);\n let next = 0;\n const lane = async (): Promise<void> => {\n while (next < runnable.length) {\n const mine = next;\n next += 1;\n const one = runnable[mine];\n if (one === undefined) {\n return;\n }\n results[mine] = await runCase(ports, one);\n }\n };\n await Promise.all(Array.from({ length: Math.min(lanes, runnable.length) }, lane));\n\n const byRefusal = Object.fromEntries(REFUSALS.map((reason) => [reason, 0])) as Record<\n AiRefusal,\n number\n >;\n let shown = 0;\n let refused = 0;\n let errors = 0;\n for (const result of results) {\n if (result.ok) {\n shown += 1;\n } else if (result.refusal !== undefined) {\n refused += 1;\n byRefusal[result.refusal] += 1;\n } else {\n errors += 1;\n }\n }\n return {\n total: results.length,\n shown,\n refused,\n errors,\n skipped: all.length - runnable.length,\n byRefusal,\n results,\n };\n}\n\n/**\n * The report as a few lines for a CI log: the counts, then every case that\n * failed, with what came back.\n *\n * The refused text is printed — this is your own test run, not a learner's\n * screen, and a hint that gives the answer away is only fixable if you can\n * read it.\n */\nexport function formatAiCheckReport(report: AiCheckReport): string {\n const lines: string[] = [];\n const slowest = report.results.reduce((worst, one) => Math.max(worst, one.ms), 0);\n lines.push(\n `ai-check: ${report.shown}/${report.total} shown, ${report.refused} refused, ${report.errors} failed` +\n `${report.skipped > 0 ? `, ${report.skipped} skipped (no port)` : ''} — slowest ${slowest} ms`,\n );\n for (const reason of REFUSALS) {\n const count = report.byRefusal[reason];\n if (count > 0) {\n lines.push(` ${reason}: ${count}`);\n }\n }\n for (const result of report.results) {\n if (result.ok) {\n continue;\n }\n const why = result.refusal ?? `port failed (${result.error ?? 'no message'})`;\n lines.push(` ✗ ${result.case.id} [${result.case.feature}] ${result.case.about}: ${why}`);\n if (result.result !== undefined) {\n lines.push(` ${result.result.text.replace(/\\s+/g, ' ').slice(0, 200)}`);\n }\n }\n return lines.join('\\n');\n}\n"]}
|
package/dist/ai-check.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as AiExplanationRequest, M as AiHintRequest, a2 as AiWritingFeedbackRequest, j as AiCoachingRequest, s as AiCritiqueRequest, D as AiDraftsRequest, T as AiRefusal, X as AiTextResult, a1 as AiWritingFeedback, i as AiCoaching, n as AiCritique, B as AiDrafts } from './activity-D705CXng.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* One call to make against a host's port, and what a learner was looking at
|
|
@@ -8,11 +8,11 @@ interface AiCheckCase {
|
|
|
8
8
|
/** Stable across releases, so a host can name one in an allow-list or a report. */
|
|
9
9
|
id: string;
|
|
10
10
|
/** Which port the case is for. */
|
|
11
|
-
feature: 'explanation' | 'hint' | 'writing-feedback';
|
|
11
|
+
feature: 'explanation' | 'hint' | 'writing-feedback' | 'pronunciation-coaching' | 'item-critique' | 'draft-generation';
|
|
12
12
|
/** What the learner did, in a few words, for a report a person reads. */
|
|
13
13
|
about: string;
|
|
14
14
|
/** The request, built by the SDK exactly as a component builds it. */
|
|
15
|
-
request: AiExplanationRequest | AiHintRequest | AiWritingFeedbackRequest;
|
|
15
|
+
request: AiExplanationRequest | AiHintRequest | AiWritingFeedbackRequest | AiCoachingRequest | AiCritiqueRequest | AiDraftsRequest;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* The cases {@link runAiCheck} runs: every type the SDK explains, answered
|
|
@@ -39,6 +39,11 @@ interface AiCheckPorts {
|
|
|
39
39
|
explain?(request: AiExplanationRequest): Promise<unknown> | unknown;
|
|
40
40
|
hint?(request: AiHintRequest): Promise<unknown> | unknown;
|
|
41
41
|
writingFeedback?(request: AiWritingFeedbackRequest): Promise<unknown> | unknown;
|
|
42
|
+
pronunciationCoaching?(request: AiCoachingRequest): Promise<unknown> | unknown;
|
|
43
|
+
/** Reviews an item for its author: the port an editor's "Review with AI" calls. */
|
|
44
|
+
critique?(request: AiCritiqueRequest): Promise<unknown> | unknown;
|
|
45
|
+
/** Drafts items from a source, for an author to approve. */
|
|
46
|
+
drafts?(request: AiDraftsRequest): Promise<unknown> | unknown;
|
|
42
47
|
}
|
|
43
48
|
/** What happened on one case. */
|
|
44
49
|
interface AiCheckResult {
|
|
@@ -57,6 +62,16 @@ interface AiCheckResult {
|
|
|
57
62
|
result?: AiTextResult;
|
|
58
63
|
/** For a writing case a learner would have been shown: the feedback, as the SDK accepted it. */
|
|
59
64
|
feedback?: AiWritingFeedback;
|
|
65
|
+
/** For a coaching case a learner would have been shown: the coaching, as the SDK accepted it. */
|
|
66
|
+
coaching?: AiCoaching;
|
|
67
|
+
/** For a critique case an author would have been shown: the findings, as the SDK accepted them. */
|
|
68
|
+
critique?: AiCritique;
|
|
69
|
+
/**
|
|
70
|
+
* For a drafts case the SDK read: the drafts, each with what `validateDraft`
|
|
71
|
+
* and the item critic say of it. A reply read is not a good one — check how
|
|
72
|
+
* many came back `complete` and without warnings.
|
|
73
|
+
*/
|
|
74
|
+
drafts?: AiDrafts;
|
|
60
75
|
/** How long the call took, in milliseconds. */
|
|
61
76
|
ms: number;
|
|
62
77
|
}
|