@learning-commons/evaluators 0.1.0 → 0.3.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/README.md +161 -14
- package/dist/index.cjs +471 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +192 -5
- package/dist/index.d.ts +192 -5
- package/dist/index.js +468 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -117,19 +117,18 @@ await evaluator.evaluate(text: string, grade: string)
|
|
|
117
117
|
|
|
118
118
|
---
|
|
119
119
|
|
|
120
|
-
### 3.
|
|
120
|
+
### 3. Subject Matter Knowledge (SMK) Evaluator
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
Evaluates the background knowledge demands of educational texts relative to grade level. Determines how much prior subject knowledge a student needs to comprehend the text, based on the Common Core Qualitative Text Complexity Rubric.
|
|
123
123
|
|
|
124
124
|
**Supported Grades:** 3-12
|
|
125
125
|
|
|
126
|
-
**Uses:** Google Gemini
|
|
126
|
+
**Uses:** Google Gemini 3 Flash Preview
|
|
127
127
|
|
|
128
128
|
**Constructor:**
|
|
129
129
|
```typescript
|
|
130
|
-
const evaluator = new
|
|
130
|
+
const evaluator = new SmkEvaluator({
|
|
131
131
|
googleApiKey?: string; // Google API key (required by this evaluator)
|
|
132
|
-
openaiApiKey?: string; // OpenAI API key (required by this evaluator)
|
|
133
132
|
maxRetries?: number; // Optional - Max retry attempts (default: 2)
|
|
134
133
|
telemetry?: boolean | TelemetryOptions; // Optional (default: true)
|
|
135
134
|
logger?: Logger; // Optional - Custom logger
|
|
@@ -145,23 +144,169 @@ await evaluator.evaluate(text: string, grade: string)
|
|
|
145
144
|
**Returns:**
|
|
146
145
|
```typescript
|
|
147
146
|
{
|
|
148
|
-
score:
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
147
|
+
score: 'Slightly complex' | 'Moderately complex' | 'Very complex' | 'Exceedingly complex';
|
|
148
|
+
reasoning: string;
|
|
149
|
+
metadata: {
|
|
150
|
+
model: string;
|
|
151
|
+
processingTimeMs: number;
|
|
152
152
|
};
|
|
153
|
-
reasoning: string; // Combined reasoning from both evaluators
|
|
154
|
-
metadata: EvaluationMetadata;
|
|
155
153
|
_internal: {
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
identified_topics: string[];
|
|
155
|
+
curriculum_check: string;
|
|
156
|
+
assumptions_and_scaffolding: string;
|
|
157
|
+
friction_analysis: string;
|
|
158
|
+
complexity_score: 'Slightly complex' | 'Moderately complex' | 'Very complex' | 'Exceedingly complex';
|
|
159
|
+
reasoning: string;
|
|
158
160
|
};
|
|
159
161
|
}
|
|
160
162
|
```
|
|
161
163
|
|
|
164
|
+
**Example:**
|
|
165
|
+
```typescript
|
|
166
|
+
import { SmkEvaluator } from '@learning-commons/evaluators';
|
|
167
|
+
|
|
168
|
+
const evaluator = new SmkEvaluator({
|
|
169
|
+
googleApiKey: process.env.GOOGLE_API_KEY,
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const result = await evaluator.evaluate(
|
|
173
|
+
"Hydraulic propulsion works by sucking water at the bow and forcing it sternward.",
|
|
174
|
+
"10"
|
|
175
|
+
);
|
|
176
|
+
console.log(result.score); // "Very complex"
|
|
177
|
+
console.log(result.reasoning);
|
|
178
|
+
console.log(result._internal.identified_topics); // ["hydraulics", "propulsion", "physics"]
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
### 4. Conventionality Evaluator
|
|
184
|
+
|
|
185
|
+
Evaluates how explicit, literal, and straightforward a text's meaning is versus how abstract, ironic, figurative, or archaic it is for the target grade level. Based on the Common Core Qualitative Text Complexity Rubric.
|
|
186
|
+
|
|
187
|
+
**Supported Grades:** 3-12
|
|
188
|
+
|
|
189
|
+
**Uses:** Google Gemini 3 Flash Preview
|
|
190
|
+
|
|
191
|
+
**Constructor:**
|
|
192
|
+
```typescript
|
|
193
|
+
const evaluator = new ConventionalityEvaluator({
|
|
194
|
+
googleApiKey?: string; // Google API key (required by this evaluator)
|
|
195
|
+
maxRetries?: number; // Optional - Max retry attempts (default: 2)
|
|
196
|
+
telemetry?: boolean | TelemetryOptions; // Optional (default: true)
|
|
197
|
+
logger?: Logger; // Optional - Custom logger
|
|
198
|
+
logLevel?: LogLevel; // Optional - Logging verbosity (default: WARN)
|
|
199
|
+
});
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**API:**
|
|
203
|
+
```typescript
|
|
204
|
+
await evaluator.evaluate(text: string, grade: string)
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**Returns:**
|
|
208
|
+
```typescript
|
|
209
|
+
{
|
|
210
|
+
score: 'Slightly complex' | 'Moderately complex' | 'Very complex' | 'Exceedingly complex';
|
|
211
|
+
reasoning: string;
|
|
212
|
+
metadata: {
|
|
213
|
+
model: string;
|
|
214
|
+
processingTimeMs: number;
|
|
215
|
+
};
|
|
216
|
+
_internal: {
|
|
217
|
+
conventionality_features: string[];
|
|
218
|
+
grade_context: string;
|
|
219
|
+
instructional_insights: string;
|
|
220
|
+
complexity_score: 'Slightly complex' | 'Moderately complex' | 'Very complex' | 'Exceedingly complex';
|
|
221
|
+
reasoning: string;
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
**Example:**
|
|
227
|
+
```typescript
|
|
228
|
+
import { ConventionalityEvaluator } from '@learning-commons/evaluators';
|
|
229
|
+
|
|
230
|
+
const evaluator = new ConventionalityEvaluator({
|
|
231
|
+
googleApiKey: process.env.GOOGLE_API_KEY,
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
const result = await evaluator.evaluate(
|
|
235
|
+
"The author uses sustained irony to critique societal norms throughout the passage.",
|
|
236
|
+
"10"
|
|
237
|
+
);
|
|
238
|
+
console.log(result.score); // "Very complex"
|
|
239
|
+
console.log(result.reasoning);
|
|
240
|
+
console.log(result._internal.conventionality_features); // ["sustained irony", ...]
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
### 5. Text Complexity Evaluator
|
|
246
|
+
|
|
247
|
+
Composite evaluator that analyzes vocabulary, sentence structure, subject matter knowledge, and conventionality complexity in parallel.
|
|
248
|
+
|
|
249
|
+
**Supported Grades:** 3-12
|
|
250
|
+
|
|
251
|
+
**Uses:** Google Gemini 2.5 Pro + Google Gemini 3 Flash Preview + OpenAI GPT-4o (composite)
|
|
252
|
+
|
|
253
|
+
**Constructor:**
|
|
254
|
+
```typescript
|
|
255
|
+
const evaluator = new TextComplexityEvaluator({
|
|
256
|
+
googleApiKey?: string; // Google API key (required by this evaluator)
|
|
257
|
+
openaiApiKey?: string; // OpenAI API key (required by this evaluator)
|
|
258
|
+
maxRetries?: number; // Optional - Max retry attempts (default: 2)
|
|
259
|
+
telemetry?: boolean | TelemetryOptions; // Optional (default: true)
|
|
260
|
+
logger?: Logger; // Optional - Custom logger
|
|
261
|
+
logLevel?: LogLevel; // Optional - Logging verbosity (default: WARN)
|
|
262
|
+
});
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
**API:**
|
|
266
|
+
```typescript
|
|
267
|
+
await evaluator.evaluate(text: string, grade: string)
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
**Returns:**
|
|
271
|
+
```typescript
|
|
272
|
+
{
|
|
273
|
+
vocabulary: EvaluationResult<TextComplexityLevel> | { error: Error };
|
|
274
|
+
sentenceStructure: EvaluationResult<TextComplexityLevel> | { error: Error };
|
|
275
|
+
subjectMatterKnowledge: EvaluationResult<TextComplexityLevel> | { error: Error };
|
|
276
|
+
conventionality: EvaluationResult<TextComplexityLevel> | { error: Error };
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Each sub-evaluator result is either a full `EvaluationResult` or `{ error: Error }` if that evaluator failed. An error is only thrown if all four fail.
|
|
281
|
+
|
|
282
|
+
**Example:**
|
|
283
|
+
```typescript
|
|
284
|
+
import { TextComplexityEvaluator } from '@learning-commons/evaluators';
|
|
285
|
+
|
|
286
|
+
const evaluator = new TextComplexityEvaluator({
|
|
287
|
+
googleApiKey: process.env.GOOGLE_API_KEY,
|
|
288
|
+
openaiApiKey: process.env.OPENAI_API_KEY,
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
const result = await evaluator.evaluate("Your text here", "6");
|
|
292
|
+
|
|
293
|
+
if (!('error' in result.vocabulary)) {
|
|
294
|
+
console.log('Vocabulary:', result.vocabulary.score);
|
|
295
|
+
}
|
|
296
|
+
if (!('error' in result.sentenceStructure)) {
|
|
297
|
+
console.log('Sentence structure:', result.sentenceStructure.score);
|
|
298
|
+
}
|
|
299
|
+
if (!('error' in result.subjectMatterKnowledge)) {
|
|
300
|
+
console.log('Subject matter knowledge:', result.subjectMatterKnowledge.score);
|
|
301
|
+
}
|
|
302
|
+
if (!('error' in result.conventionality)) {
|
|
303
|
+
console.log('Conventionality:', result.conventionality.score);
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
162
307
|
---
|
|
163
308
|
|
|
164
|
-
###
|
|
309
|
+
### 6. Grade Level Appropriateness Evaluator
|
|
165
310
|
|
|
166
311
|
Determines appropriate grade level for text.
|
|
167
312
|
|
|
@@ -308,6 +453,8 @@ interface BaseEvaluatorConfig {
|
|
|
308
453
|
**Note:** Which API keys are required depends on the evaluator. The SDK validates required keys at runtime based on the evaluator's metadata:
|
|
309
454
|
- **Vocabulary**: Requires both `googleApiKey` and `openaiApiKey`
|
|
310
455
|
- **Sentence Structure**: Requires `openaiApiKey` only
|
|
456
|
+
- **Subject Matter Knowledge**: Requires `googleApiKey` only
|
|
457
|
+
- **Conventionality**: Requires `googleApiKey` only
|
|
311
458
|
- **Text Complexity**: Requires both `googleApiKey` and `openaiApiKey`
|
|
312
459
|
- **Grade Level Appropriateness**: Requires `googleApiKey` only
|
|
313
460
|
|