@learning-commons/evaluators 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,146 @@
1
+ import { T as TelemetryOptions } from '../base-DKcAYXfb.cjs';
2
+ import 'zod';
3
+
4
+ /**
5
+ * Batch evaluation types
6
+ */
7
+
8
+ /**
9
+ * Input row from CSV
10
+ */
11
+ interface BatchInput {
12
+ text: string;
13
+ grade: string;
14
+ rowIndex: number;
15
+ originalRow: Record<string, unknown>;
16
+ }
17
+ /**
18
+ * Result from a single evaluation
19
+ */
20
+ interface BatchResult {
21
+ rowIndex: number;
22
+ text: string;
23
+ grade: string;
24
+ evaluatorId: string;
25
+ status: 'success' | 'error';
26
+ score?: string;
27
+ reasoning?: string;
28
+ error?: string;
29
+ processingTimeMs: number;
30
+ originalRow: Record<string, unknown>;
31
+ }
32
+ /**
33
+ * Summary statistics for batch evaluation
34
+ */
35
+ interface BatchSummary {
36
+ totalTasks: number;
37
+ successful: number;
38
+ failed: number;
39
+ durationMs: number;
40
+ resultsPerEvaluator: Record<string, {
41
+ successful: number;
42
+ failed: number;
43
+ }>;
44
+ }
45
+ /**
46
+ * Complete batch evaluation output
47
+ */
48
+ interface BatchOutput {
49
+ results: BatchResult[];
50
+ summary: BatchSummary;
51
+ }
52
+ /**
53
+ * A named group of evaluators that run together and share an HTML report format.
54
+ * This is the unit of selection exposed to users.
55
+ */
56
+ interface EvaluatorGroup {
57
+ id: string;
58
+ name: string;
59
+ description: string;
60
+ /** IDs of the evaluators that belong to this group */
61
+ evaluatorIds: readonly string[];
62
+ requiresGoogleKey: boolean;
63
+ requiresOpenAIKey: boolean;
64
+ /** Maximum number of input rows allowed for this group */
65
+ maxInputRows: number;
66
+ }
67
+ /**
68
+ * Configuration for batch evaluation
69
+ */
70
+ interface BatchConfig {
71
+ googleApiKey?: string;
72
+ openaiApiKey?: string;
73
+ concurrency?: number;
74
+ maxRetries?: number;
75
+ telemetry?: boolean | TelemetryOptions;
76
+ }
77
+
78
+ /**
79
+ * Returns the available evaluator groups.
80
+ */
81
+ declare function getAvailableGroups(): EvaluatorGroup[];
82
+ /**
83
+ * Batch evaluator class
84
+ *
85
+ * Processes multiple texts in parallel using all evaluators in a group.
86
+ */
87
+ declare class BatchEvaluator {
88
+ private config;
89
+ private limit;
90
+ private evaluatorInstances;
91
+ private isCancelled;
92
+ private completedResults;
93
+ constructor(config: BatchConfig);
94
+ /**
95
+ * Cancel ongoing evaluation.
96
+ * Returns partial results collected so far.
97
+ */
98
+ cancel(): BatchResult[];
99
+ /**
100
+ * Initialize evaluator instances for the given IDs
101
+ */
102
+ private initializeEvaluators;
103
+ /**
104
+ * Create tasks from inputs and evaluator IDs
105
+ */
106
+ private createTasks;
107
+ /**
108
+ * Execute a single evaluation task
109
+ */
110
+ private executeTask;
111
+ /**
112
+ * Calculate summary statistics
113
+ */
114
+ private calculateSummary;
115
+ /**
116
+ * Run batch evaluation for an evaluator group.
117
+ *
118
+ * @param inputs - Array of input rows
119
+ * @param groupId - The evaluator group to run (see getAvailableGroups())
120
+ * @param onProgress - Optional callback invoked after each task completes
121
+ * @returns Batch evaluation results and summary
122
+ */
123
+ evaluate(inputs: BatchInput[], groupId: string, onProgress?: (result: BatchResult) => void): Promise<BatchOutput>;
124
+ }
125
+
126
+ /**
127
+ * Parse a CSV file into BatchInput rows.
128
+ *
129
+ * Requires columns named "text" and "grade" (case-insensitive, whitespace-trimmed).
130
+ * Rows missing either value are silently skipped.
131
+ *
132
+ * @throws {Error} If the file does not exist, is empty, or is missing required columns
133
+ */
134
+ declare function parseCSV(csvPath: string): BatchInput[];
135
+
136
+ declare function formatAsCSV(output: BatchOutput): string;
137
+ interface ReportMeta {
138
+ csvPath: string;
139
+ groupId: string;
140
+ reportId: string;
141
+ generatedAt: Date;
142
+ totalInputRows: number;
143
+ }
144
+ declare function formatAsHTML(output: BatchOutput, meta: ReportMeta): string;
145
+
146
+ export { type BatchConfig, BatchEvaluator, type BatchInput, type BatchOutput, type BatchResult, type BatchSummary, type EvaluatorGroup, type ReportMeta, formatAsCSV, formatAsHTML, getAvailableGroups, parseCSV };
@@ -0,0 +1,146 @@
1
+ import { T as TelemetryOptions } from '../base-DKcAYXfb.js';
2
+ import 'zod';
3
+
4
+ /**
5
+ * Batch evaluation types
6
+ */
7
+
8
+ /**
9
+ * Input row from CSV
10
+ */
11
+ interface BatchInput {
12
+ text: string;
13
+ grade: string;
14
+ rowIndex: number;
15
+ originalRow: Record<string, unknown>;
16
+ }
17
+ /**
18
+ * Result from a single evaluation
19
+ */
20
+ interface BatchResult {
21
+ rowIndex: number;
22
+ text: string;
23
+ grade: string;
24
+ evaluatorId: string;
25
+ status: 'success' | 'error';
26
+ score?: string;
27
+ reasoning?: string;
28
+ error?: string;
29
+ processingTimeMs: number;
30
+ originalRow: Record<string, unknown>;
31
+ }
32
+ /**
33
+ * Summary statistics for batch evaluation
34
+ */
35
+ interface BatchSummary {
36
+ totalTasks: number;
37
+ successful: number;
38
+ failed: number;
39
+ durationMs: number;
40
+ resultsPerEvaluator: Record<string, {
41
+ successful: number;
42
+ failed: number;
43
+ }>;
44
+ }
45
+ /**
46
+ * Complete batch evaluation output
47
+ */
48
+ interface BatchOutput {
49
+ results: BatchResult[];
50
+ summary: BatchSummary;
51
+ }
52
+ /**
53
+ * A named group of evaluators that run together and share an HTML report format.
54
+ * This is the unit of selection exposed to users.
55
+ */
56
+ interface EvaluatorGroup {
57
+ id: string;
58
+ name: string;
59
+ description: string;
60
+ /** IDs of the evaluators that belong to this group */
61
+ evaluatorIds: readonly string[];
62
+ requiresGoogleKey: boolean;
63
+ requiresOpenAIKey: boolean;
64
+ /** Maximum number of input rows allowed for this group */
65
+ maxInputRows: number;
66
+ }
67
+ /**
68
+ * Configuration for batch evaluation
69
+ */
70
+ interface BatchConfig {
71
+ googleApiKey?: string;
72
+ openaiApiKey?: string;
73
+ concurrency?: number;
74
+ maxRetries?: number;
75
+ telemetry?: boolean | TelemetryOptions;
76
+ }
77
+
78
+ /**
79
+ * Returns the available evaluator groups.
80
+ */
81
+ declare function getAvailableGroups(): EvaluatorGroup[];
82
+ /**
83
+ * Batch evaluator class
84
+ *
85
+ * Processes multiple texts in parallel using all evaluators in a group.
86
+ */
87
+ declare class BatchEvaluator {
88
+ private config;
89
+ private limit;
90
+ private evaluatorInstances;
91
+ private isCancelled;
92
+ private completedResults;
93
+ constructor(config: BatchConfig);
94
+ /**
95
+ * Cancel ongoing evaluation.
96
+ * Returns partial results collected so far.
97
+ */
98
+ cancel(): BatchResult[];
99
+ /**
100
+ * Initialize evaluator instances for the given IDs
101
+ */
102
+ private initializeEvaluators;
103
+ /**
104
+ * Create tasks from inputs and evaluator IDs
105
+ */
106
+ private createTasks;
107
+ /**
108
+ * Execute a single evaluation task
109
+ */
110
+ private executeTask;
111
+ /**
112
+ * Calculate summary statistics
113
+ */
114
+ private calculateSummary;
115
+ /**
116
+ * Run batch evaluation for an evaluator group.
117
+ *
118
+ * @param inputs - Array of input rows
119
+ * @param groupId - The evaluator group to run (see getAvailableGroups())
120
+ * @param onProgress - Optional callback invoked after each task completes
121
+ * @returns Batch evaluation results and summary
122
+ */
123
+ evaluate(inputs: BatchInput[], groupId: string, onProgress?: (result: BatchResult) => void): Promise<BatchOutput>;
124
+ }
125
+
126
+ /**
127
+ * Parse a CSV file into BatchInput rows.
128
+ *
129
+ * Requires columns named "text" and "grade" (case-insensitive, whitespace-trimmed).
130
+ * Rows missing either value are silently skipped.
131
+ *
132
+ * @throws {Error} If the file does not exist, is empty, or is missing required columns
133
+ */
134
+ declare function parseCSV(csvPath: string): BatchInput[];
135
+
136
+ declare function formatAsCSV(output: BatchOutput): string;
137
+ interface ReportMeta {
138
+ csvPath: string;
139
+ groupId: string;
140
+ reportId: string;
141
+ generatedAt: Date;
142
+ totalInputRows: number;
143
+ }
144
+ declare function formatAsHTML(output: BatchOutput, meta: ReportMeta): string;
145
+
146
+ export { type BatchConfig, BatchEvaluator, type BatchInput, type BatchOutput, type BatchResult, type BatchSummary, type EvaluatorGroup, type ReportMeta, formatAsCSV, formatAsHTML, getAvailableGroups, parseCSV };