@lov3kaizen/agentsea-evaluate 0.5.1
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/LICENSE +21 -0
- package/README.md +339 -0
- package/dist/annotation/index.d.mts +3 -0
- package/dist/annotation/index.d.ts +3 -0
- package/dist/annotation/index.js +630 -0
- package/dist/annotation/index.mjs +22 -0
- package/dist/chunk-5JRYKRSE.mjs +2791 -0
- package/dist/chunk-EUXXIZK3.mjs +676 -0
- package/dist/chunk-NBMUSATK.mjs +596 -0
- package/dist/chunk-PAQ2TTJJ.mjs +1105 -0
- package/dist/chunk-TUMNJN2S.mjs +416 -0
- package/dist/continuous/index.d.mts +2 -0
- package/dist/continuous/index.d.ts +2 -0
- package/dist/continuous/index.js +707 -0
- package/dist/continuous/index.mjs +16 -0
- package/dist/datasets/index.d.mts +1 -0
- package/dist/datasets/index.d.ts +1 -0
- package/dist/datasets/index.js +456 -0
- package/dist/datasets/index.mjs +14 -0
- package/dist/evaluation/index.d.mts +1 -0
- package/dist/evaluation/index.d.ts +1 -0
- package/dist/evaluation/index.js +2853 -0
- package/dist/evaluation/index.mjs +78 -0
- package/dist/feedback/index.d.mts +2 -0
- package/dist/feedback/index.d.ts +2 -0
- package/dist/feedback/index.js +1158 -0
- package/dist/feedback/index.mjs +40 -0
- package/dist/index-6Pbiq7ny.d.mts +234 -0
- package/dist/index-6Pbiq7ny.d.ts +234 -0
- package/dist/index-BNTycFEA.d.mts +479 -0
- package/dist/index-BNTycFEA.d.ts +479 -0
- package/dist/index-CTYCfWfH.d.mts +543 -0
- package/dist/index-CTYCfWfH.d.ts +543 -0
- package/dist/index-Cq5LwG_3.d.mts +322 -0
- package/dist/index-Cq5LwG_3.d.ts +322 -0
- package/dist/index-bPghFsfP.d.mts +315 -0
- package/dist/index-bPghFsfP.d.ts +315 -0
- package/dist/index.d.mts +81 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.js +5962 -0
- package/dist/index.mjs +429 -0
- package/package.json +102 -0
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { EventEmitter } from 'eventemitter3';
|
|
3
|
+
|
|
4
|
+
type AnnotationTaskStatus = 'draft' | 'active' | 'paused' | 'completed' | 'cancelled';
|
|
5
|
+
type AnnotationItemStatus = 'pending' | 'assigned' | 'in_progress' | 'completed' | 'flagged' | 'skipped';
|
|
6
|
+
interface AnnotationTaskConfig {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
instructions: string;
|
|
10
|
+
schema: z.ZodSchema;
|
|
11
|
+
itemsPerAnnotator?: number;
|
|
12
|
+
annotatorsPerItem?: number;
|
|
13
|
+
deadline?: Date;
|
|
14
|
+
allowSkip?: boolean;
|
|
15
|
+
requireExplanation?: boolean;
|
|
16
|
+
metadata?: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
interface IAnnotationTask {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
instructions: string;
|
|
23
|
+
schema: z.ZodSchema;
|
|
24
|
+
status: AnnotationTaskStatus;
|
|
25
|
+
itemsPerAnnotator: number;
|
|
26
|
+
annotatorsPerItem: number;
|
|
27
|
+
deadline?: Date;
|
|
28
|
+
createdAt: number;
|
|
29
|
+
updatedAt: number;
|
|
30
|
+
completedAt?: number;
|
|
31
|
+
metadata?: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
interface AnnotationItem {
|
|
34
|
+
id: string;
|
|
35
|
+
taskId: string;
|
|
36
|
+
data: Record<string, unknown>;
|
|
37
|
+
status: AnnotationItemStatus;
|
|
38
|
+
priority: number;
|
|
39
|
+
assignedTo?: string[];
|
|
40
|
+
annotations: Annotation[];
|
|
41
|
+
consensus?: ConsensusResult;
|
|
42
|
+
createdAt: number;
|
|
43
|
+
updatedAt: number;
|
|
44
|
+
metadata?: Record<string, unknown>;
|
|
45
|
+
}
|
|
46
|
+
interface Annotation {
|
|
47
|
+
id: string;
|
|
48
|
+
itemId: string;
|
|
49
|
+
annotatorId: string;
|
|
50
|
+
value: Record<string, unknown>;
|
|
51
|
+
explanation?: string;
|
|
52
|
+
confidence?: number;
|
|
53
|
+
duration: number;
|
|
54
|
+
createdAt: number;
|
|
55
|
+
isGold?: boolean;
|
|
56
|
+
quality?: AnnotationQuality;
|
|
57
|
+
}
|
|
58
|
+
interface AnnotationQuality {
|
|
59
|
+
score: number;
|
|
60
|
+
agreementWithConsensus?: number;
|
|
61
|
+
flagged?: boolean;
|
|
62
|
+
flagReason?: string;
|
|
63
|
+
}
|
|
64
|
+
interface Annotator {
|
|
65
|
+
id: string;
|
|
66
|
+
name: string;
|
|
67
|
+
email?: string;
|
|
68
|
+
role: 'annotator' | 'reviewer' | 'expert' | 'admin';
|
|
69
|
+
accuracy?: number;
|
|
70
|
+
completedCount: number;
|
|
71
|
+
activeTaskIds: string[];
|
|
72
|
+
metadata?: Record<string, unknown>;
|
|
73
|
+
}
|
|
74
|
+
interface AnnotatorStats {
|
|
75
|
+
annotatorId: string;
|
|
76
|
+
totalAnnotations: number;
|
|
77
|
+
averageDuration: number;
|
|
78
|
+
accuracy: number;
|
|
79
|
+
agreementRate: number;
|
|
80
|
+
flaggedRate: number;
|
|
81
|
+
byTask: Record<string, {
|
|
82
|
+
annotations: number;
|
|
83
|
+
accuracy: number;
|
|
84
|
+
avgDuration: number;
|
|
85
|
+
}>;
|
|
86
|
+
}
|
|
87
|
+
interface AnnotationQueueConfig {
|
|
88
|
+
task: IAnnotationTask;
|
|
89
|
+
items: AnnotationItem[];
|
|
90
|
+
prioritization?: PrioritizationType;
|
|
91
|
+
assignment?: AssignmentStrategy;
|
|
92
|
+
qualityControl?: QualityControlConfig;
|
|
93
|
+
}
|
|
94
|
+
type PrioritizationType = 'fifo' | 'uncertainty' | 'diversity' | 'importance' | 'custom';
|
|
95
|
+
type AssignmentStrategy = 'round-robin' | 'expertise' | 'load-balanced' | 'random';
|
|
96
|
+
interface QualityControlConfig {
|
|
97
|
+
goldStandard?: GoldStandardItem[];
|
|
98
|
+
goldRatio?: number;
|
|
99
|
+
agreementThreshold?: number;
|
|
100
|
+
minAnnotatorAccuracy?: number;
|
|
101
|
+
autoReject?: boolean;
|
|
102
|
+
expertReviewThreshold?: number;
|
|
103
|
+
}
|
|
104
|
+
interface GoldStandardItem {
|
|
105
|
+
itemId: string;
|
|
106
|
+
expectedAnnotation: Record<string, unknown>;
|
|
107
|
+
tolerance?: Record<string, number>;
|
|
108
|
+
}
|
|
109
|
+
type ConsensusMethod = 'majority' | 'unanimous' | 'weighted' | 'dawid-skene' | 'expert';
|
|
110
|
+
interface ConsensusConfig {
|
|
111
|
+
method: ConsensusMethod;
|
|
112
|
+
minAgreement?: number;
|
|
113
|
+
weights?: Record<string, number>;
|
|
114
|
+
expertAnnotatorId?: string;
|
|
115
|
+
tieBreaker?: 'expert' | 'random' | 'none';
|
|
116
|
+
}
|
|
117
|
+
interface ConsensusResult {
|
|
118
|
+
value: Record<string, unknown>;
|
|
119
|
+
method: ConsensusMethod;
|
|
120
|
+
agreement: number;
|
|
121
|
+
confidence: number;
|
|
122
|
+
contributingAnnotations: string[];
|
|
123
|
+
disagreements?: Disagreement[];
|
|
124
|
+
}
|
|
125
|
+
interface Disagreement {
|
|
126
|
+
field: string;
|
|
127
|
+
values: Array<{
|
|
128
|
+
value: unknown;
|
|
129
|
+
annotatorIds: string[];
|
|
130
|
+
count: number;
|
|
131
|
+
}>;
|
|
132
|
+
resolved: boolean;
|
|
133
|
+
resolution?: unknown;
|
|
134
|
+
}
|
|
135
|
+
interface QueueStats {
|
|
136
|
+
taskId: string;
|
|
137
|
+
totalItems: number;
|
|
138
|
+
pendingItems: number;
|
|
139
|
+
assignedItems: number;
|
|
140
|
+
completedItems: number;
|
|
141
|
+
flaggedItems: number;
|
|
142
|
+
averageAnnotationsPerItem: number;
|
|
143
|
+
averageAgreement: number;
|
|
144
|
+
estimatedCompletion?: Date;
|
|
145
|
+
}
|
|
146
|
+
interface AnnotationResults {
|
|
147
|
+
taskId: string;
|
|
148
|
+
items: Array<{
|
|
149
|
+
itemId: string;
|
|
150
|
+
data: Record<string, unknown>;
|
|
151
|
+
consensus: ConsensusResult;
|
|
152
|
+
annotations: Annotation[];
|
|
153
|
+
}>;
|
|
154
|
+
stats: {
|
|
155
|
+
total: number;
|
|
156
|
+
completed: number;
|
|
157
|
+
agreementRate: number;
|
|
158
|
+
flaggedCount: number;
|
|
159
|
+
avgAnnotationsPerItem: number;
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
interface BatchAssignment {
|
|
163
|
+
annotatorId: string;
|
|
164
|
+
itemIds: string[];
|
|
165
|
+
deadline?: Date;
|
|
166
|
+
instructions?: string;
|
|
167
|
+
}
|
|
168
|
+
type AnnotationEventType = 'task:created' | 'task:started' | 'task:paused' | 'task:completed' | 'item:assigned' | 'item:annotated' | 'item:flagged' | 'item:consensus_reached' | 'annotator:joined' | 'annotator:warning' | 'quality:alert';
|
|
169
|
+
interface AnnotationEvent {
|
|
170
|
+
type: AnnotationEventType;
|
|
171
|
+
taskId: string;
|
|
172
|
+
itemId?: string;
|
|
173
|
+
annotatorId?: string;
|
|
174
|
+
data?: Record<string, unknown>;
|
|
175
|
+
timestamp: number;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
declare class AnnotationTask implements IAnnotationTask {
|
|
179
|
+
readonly id: string;
|
|
180
|
+
readonly name: string;
|
|
181
|
+
readonly description: string;
|
|
182
|
+
readonly instructions: string;
|
|
183
|
+
readonly schema: z.ZodSchema;
|
|
184
|
+
status: AnnotationTaskStatus;
|
|
185
|
+
readonly itemsPerAnnotator: number;
|
|
186
|
+
readonly annotatorsPerItem: number;
|
|
187
|
+
readonly deadline?: Date;
|
|
188
|
+
readonly createdAt: number;
|
|
189
|
+
updatedAt: number;
|
|
190
|
+
completedAt?: number;
|
|
191
|
+
readonly metadata?: Record<string, unknown>;
|
|
192
|
+
constructor(config: AnnotationTaskConfig);
|
|
193
|
+
start(): void;
|
|
194
|
+
pause(): void;
|
|
195
|
+
resume(): void;
|
|
196
|
+
complete(): void;
|
|
197
|
+
cancel(): void;
|
|
198
|
+
validateAnnotation(value: unknown): {
|
|
199
|
+
valid: boolean;
|
|
200
|
+
error?: string;
|
|
201
|
+
};
|
|
202
|
+
isPastDeadline(): boolean;
|
|
203
|
+
toConfig(): AnnotationTaskConfig;
|
|
204
|
+
}
|
|
205
|
+
declare function createAnnotationTask(config: AnnotationTaskConfig): AnnotationTask;
|
|
206
|
+
declare const BinaryClassificationSchema: z.ZodObject<{
|
|
207
|
+
label: z.ZodEnum<["positive", "negative"]>;
|
|
208
|
+
confidence: z.ZodOptional<z.ZodNumber>;
|
|
209
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
210
|
+
}, "strip", z.ZodTypeAny, {
|
|
211
|
+
label: "positive" | "negative";
|
|
212
|
+
confidence?: number | undefined;
|
|
213
|
+
notes?: string | undefined;
|
|
214
|
+
}, {
|
|
215
|
+
label: "positive" | "negative";
|
|
216
|
+
confidence?: number | undefined;
|
|
217
|
+
notes?: string | undefined;
|
|
218
|
+
}>;
|
|
219
|
+
declare const QualityRatingSchema: z.ZodObject<{
|
|
220
|
+
accuracy: z.ZodNumber;
|
|
221
|
+
helpfulness: z.ZodNumber;
|
|
222
|
+
safety: z.ZodEnum<["pass", "fail"]>;
|
|
223
|
+
corrections: z.ZodOptional<z.ZodString>;
|
|
224
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
225
|
+
}, "strip", z.ZodTypeAny, {
|
|
226
|
+
accuracy: number;
|
|
227
|
+
helpfulness: number;
|
|
228
|
+
safety: "pass" | "fail";
|
|
229
|
+
notes?: string | undefined;
|
|
230
|
+
corrections?: string | undefined;
|
|
231
|
+
}, {
|
|
232
|
+
accuracy: number;
|
|
233
|
+
helpfulness: number;
|
|
234
|
+
safety: "pass" | "fail";
|
|
235
|
+
notes?: string | undefined;
|
|
236
|
+
corrections?: string | undefined;
|
|
237
|
+
}>;
|
|
238
|
+
declare const TextSpanSchema: z.ZodObject<{
|
|
239
|
+
spans: z.ZodArray<z.ZodObject<{
|
|
240
|
+
start: z.ZodNumber;
|
|
241
|
+
end: z.ZodNumber;
|
|
242
|
+
label: z.ZodString;
|
|
243
|
+
text: z.ZodOptional<z.ZodString>;
|
|
244
|
+
}, "strip", z.ZodTypeAny, {
|
|
245
|
+
start: number;
|
|
246
|
+
label: string;
|
|
247
|
+
end: number;
|
|
248
|
+
text?: string | undefined;
|
|
249
|
+
}, {
|
|
250
|
+
start: number;
|
|
251
|
+
label: string;
|
|
252
|
+
end: number;
|
|
253
|
+
text?: string | undefined;
|
|
254
|
+
}>, "many">;
|
|
255
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
256
|
+
}, "strip", z.ZodTypeAny, {
|
|
257
|
+
spans: {
|
|
258
|
+
start: number;
|
|
259
|
+
label: string;
|
|
260
|
+
end: number;
|
|
261
|
+
text?: string | undefined;
|
|
262
|
+
}[];
|
|
263
|
+
notes?: string | undefined;
|
|
264
|
+
}, {
|
|
265
|
+
spans: {
|
|
266
|
+
start: number;
|
|
267
|
+
label: string;
|
|
268
|
+
end: number;
|
|
269
|
+
text?: string | undefined;
|
|
270
|
+
}[];
|
|
271
|
+
notes?: string | undefined;
|
|
272
|
+
}>;
|
|
273
|
+
|
|
274
|
+
interface QueueEvents {
|
|
275
|
+
'item:assigned': (itemId: string, annotatorId: string) => void;
|
|
276
|
+
'item:annotated': (itemId: string, annotation: Annotation) => void;
|
|
277
|
+
'item:consensus': (itemId: string, consensus: ConsensusResult) => void;
|
|
278
|
+
'item:flagged': (itemId: string, reason: string) => void;
|
|
279
|
+
}
|
|
280
|
+
declare class AnnotationQueue extends EventEmitter<QueueEvents> {
|
|
281
|
+
readonly task: AnnotationTask;
|
|
282
|
+
private items;
|
|
283
|
+
private annotatorAssignments;
|
|
284
|
+
private annotatorCounts;
|
|
285
|
+
constructor(config: AnnotationQueueConfig);
|
|
286
|
+
getNextItem(annotatorId: string): AnnotationItem | null;
|
|
287
|
+
assignItem(itemId: string, annotatorId: string): void;
|
|
288
|
+
submitAnnotation(itemId: string, annotatorId: string, value: Record<string, unknown>, duration: number): Annotation;
|
|
289
|
+
flagItem(itemId: string, reason: string): void;
|
|
290
|
+
skipItem(itemId: string, annotatorId: string): void;
|
|
291
|
+
getBatchAssignment(annotatorId: string, count: number): BatchAssignment;
|
|
292
|
+
getStats(): QueueStats;
|
|
293
|
+
getItem(itemId: string): AnnotationItem | undefined;
|
|
294
|
+
getItems(): AnnotationItem[];
|
|
295
|
+
getItemsByStatus(status: AnnotationItemStatus): AnnotationItem[];
|
|
296
|
+
getAnnotatorCount(annotatorId: string): number;
|
|
297
|
+
}
|
|
298
|
+
declare function createAnnotationQueue(config: AnnotationQueueConfig): AnnotationQueue;
|
|
299
|
+
|
|
300
|
+
declare class ConsensusManager {
|
|
301
|
+
private method;
|
|
302
|
+
private weights?;
|
|
303
|
+
private expertAnnotatorId?;
|
|
304
|
+
constructor(config: ConsensusConfig);
|
|
305
|
+
calculateConsensus(annotations: Annotation[]): ConsensusResult;
|
|
306
|
+
private majorityConsensus;
|
|
307
|
+
private findMajority;
|
|
308
|
+
private unanimousConsensus;
|
|
309
|
+
private weightedConsensus;
|
|
310
|
+
private expertConsensus;
|
|
311
|
+
calculateAgreement(annotations: Annotation[]): number;
|
|
312
|
+
}
|
|
313
|
+
declare function createConsensusManager(config: ConsensusConfig): ConsensusManager;
|
|
314
|
+
|
|
315
|
+
export { type AnnotationTaskStatus as A, type BatchAssignment as B, type ConsensusMethod as C, type Disagreement as D, type GoldStandardItem as G, type IAnnotationTask as I, type PrioritizationType as P, type QualityControlConfig as Q, TextSpanSchema as T, type AnnotationItemStatus as a, type AnnotationTaskConfig as b, type AnnotationItem as c, type Annotation as d, type AnnotationQuality as e, type Annotator as f, type AnnotatorStats as g, type AnnotationQueueConfig as h, type AssignmentStrategy as i, type ConsensusConfig as j, type ConsensusResult as k, type QueueStats as l, type AnnotationResults as m, type AnnotationEventType as n, type AnnotationEvent as o, AnnotationTask as p, createAnnotationTask as q, BinaryClassificationSchema as r, QualityRatingSchema as s, AnnotationQueue as t, createAnnotationQueue as u, ConsensusManager as v, createConsensusManager as w };
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { EventEmitter } from 'eventemitter3';
|
|
3
|
+
|
|
4
|
+
type AnnotationTaskStatus = 'draft' | 'active' | 'paused' | 'completed' | 'cancelled';
|
|
5
|
+
type AnnotationItemStatus = 'pending' | 'assigned' | 'in_progress' | 'completed' | 'flagged' | 'skipped';
|
|
6
|
+
interface AnnotationTaskConfig {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
instructions: string;
|
|
10
|
+
schema: z.ZodSchema;
|
|
11
|
+
itemsPerAnnotator?: number;
|
|
12
|
+
annotatorsPerItem?: number;
|
|
13
|
+
deadline?: Date;
|
|
14
|
+
allowSkip?: boolean;
|
|
15
|
+
requireExplanation?: boolean;
|
|
16
|
+
metadata?: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
interface IAnnotationTask {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
instructions: string;
|
|
23
|
+
schema: z.ZodSchema;
|
|
24
|
+
status: AnnotationTaskStatus;
|
|
25
|
+
itemsPerAnnotator: number;
|
|
26
|
+
annotatorsPerItem: number;
|
|
27
|
+
deadline?: Date;
|
|
28
|
+
createdAt: number;
|
|
29
|
+
updatedAt: number;
|
|
30
|
+
completedAt?: number;
|
|
31
|
+
metadata?: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
interface AnnotationItem {
|
|
34
|
+
id: string;
|
|
35
|
+
taskId: string;
|
|
36
|
+
data: Record<string, unknown>;
|
|
37
|
+
status: AnnotationItemStatus;
|
|
38
|
+
priority: number;
|
|
39
|
+
assignedTo?: string[];
|
|
40
|
+
annotations: Annotation[];
|
|
41
|
+
consensus?: ConsensusResult;
|
|
42
|
+
createdAt: number;
|
|
43
|
+
updatedAt: number;
|
|
44
|
+
metadata?: Record<string, unknown>;
|
|
45
|
+
}
|
|
46
|
+
interface Annotation {
|
|
47
|
+
id: string;
|
|
48
|
+
itemId: string;
|
|
49
|
+
annotatorId: string;
|
|
50
|
+
value: Record<string, unknown>;
|
|
51
|
+
explanation?: string;
|
|
52
|
+
confidence?: number;
|
|
53
|
+
duration: number;
|
|
54
|
+
createdAt: number;
|
|
55
|
+
isGold?: boolean;
|
|
56
|
+
quality?: AnnotationQuality;
|
|
57
|
+
}
|
|
58
|
+
interface AnnotationQuality {
|
|
59
|
+
score: number;
|
|
60
|
+
agreementWithConsensus?: number;
|
|
61
|
+
flagged?: boolean;
|
|
62
|
+
flagReason?: string;
|
|
63
|
+
}
|
|
64
|
+
interface Annotator {
|
|
65
|
+
id: string;
|
|
66
|
+
name: string;
|
|
67
|
+
email?: string;
|
|
68
|
+
role: 'annotator' | 'reviewer' | 'expert' | 'admin';
|
|
69
|
+
accuracy?: number;
|
|
70
|
+
completedCount: number;
|
|
71
|
+
activeTaskIds: string[];
|
|
72
|
+
metadata?: Record<string, unknown>;
|
|
73
|
+
}
|
|
74
|
+
interface AnnotatorStats {
|
|
75
|
+
annotatorId: string;
|
|
76
|
+
totalAnnotations: number;
|
|
77
|
+
averageDuration: number;
|
|
78
|
+
accuracy: number;
|
|
79
|
+
agreementRate: number;
|
|
80
|
+
flaggedRate: number;
|
|
81
|
+
byTask: Record<string, {
|
|
82
|
+
annotations: number;
|
|
83
|
+
accuracy: number;
|
|
84
|
+
avgDuration: number;
|
|
85
|
+
}>;
|
|
86
|
+
}
|
|
87
|
+
interface AnnotationQueueConfig {
|
|
88
|
+
task: IAnnotationTask;
|
|
89
|
+
items: AnnotationItem[];
|
|
90
|
+
prioritization?: PrioritizationType;
|
|
91
|
+
assignment?: AssignmentStrategy;
|
|
92
|
+
qualityControl?: QualityControlConfig;
|
|
93
|
+
}
|
|
94
|
+
type PrioritizationType = 'fifo' | 'uncertainty' | 'diversity' | 'importance' | 'custom';
|
|
95
|
+
type AssignmentStrategy = 'round-robin' | 'expertise' | 'load-balanced' | 'random';
|
|
96
|
+
interface QualityControlConfig {
|
|
97
|
+
goldStandard?: GoldStandardItem[];
|
|
98
|
+
goldRatio?: number;
|
|
99
|
+
agreementThreshold?: number;
|
|
100
|
+
minAnnotatorAccuracy?: number;
|
|
101
|
+
autoReject?: boolean;
|
|
102
|
+
expertReviewThreshold?: number;
|
|
103
|
+
}
|
|
104
|
+
interface GoldStandardItem {
|
|
105
|
+
itemId: string;
|
|
106
|
+
expectedAnnotation: Record<string, unknown>;
|
|
107
|
+
tolerance?: Record<string, number>;
|
|
108
|
+
}
|
|
109
|
+
type ConsensusMethod = 'majority' | 'unanimous' | 'weighted' | 'dawid-skene' | 'expert';
|
|
110
|
+
interface ConsensusConfig {
|
|
111
|
+
method: ConsensusMethod;
|
|
112
|
+
minAgreement?: number;
|
|
113
|
+
weights?: Record<string, number>;
|
|
114
|
+
expertAnnotatorId?: string;
|
|
115
|
+
tieBreaker?: 'expert' | 'random' | 'none';
|
|
116
|
+
}
|
|
117
|
+
interface ConsensusResult {
|
|
118
|
+
value: Record<string, unknown>;
|
|
119
|
+
method: ConsensusMethod;
|
|
120
|
+
agreement: number;
|
|
121
|
+
confidence: number;
|
|
122
|
+
contributingAnnotations: string[];
|
|
123
|
+
disagreements?: Disagreement[];
|
|
124
|
+
}
|
|
125
|
+
interface Disagreement {
|
|
126
|
+
field: string;
|
|
127
|
+
values: Array<{
|
|
128
|
+
value: unknown;
|
|
129
|
+
annotatorIds: string[];
|
|
130
|
+
count: number;
|
|
131
|
+
}>;
|
|
132
|
+
resolved: boolean;
|
|
133
|
+
resolution?: unknown;
|
|
134
|
+
}
|
|
135
|
+
interface QueueStats {
|
|
136
|
+
taskId: string;
|
|
137
|
+
totalItems: number;
|
|
138
|
+
pendingItems: number;
|
|
139
|
+
assignedItems: number;
|
|
140
|
+
completedItems: number;
|
|
141
|
+
flaggedItems: number;
|
|
142
|
+
averageAnnotationsPerItem: number;
|
|
143
|
+
averageAgreement: number;
|
|
144
|
+
estimatedCompletion?: Date;
|
|
145
|
+
}
|
|
146
|
+
interface AnnotationResults {
|
|
147
|
+
taskId: string;
|
|
148
|
+
items: Array<{
|
|
149
|
+
itemId: string;
|
|
150
|
+
data: Record<string, unknown>;
|
|
151
|
+
consensus: ConsensusResult;
|
|
152
|
+
annotations: Annotation[];
|
|
153
|
+
}>;
|
|
154
|
+
stats: {
|
|
155
|
+
total: number;
|
|
156
|
+
completed: number;
|
|
157
|
+
agreementRate: number;
|
|
158
|
+
flaggedCount: number;
|
|
159
|
+
avgAnnotationsPerItem: number;
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
interface BatchAssignment {
|
|
163
|
+
annotatorId: string;
|
|
164
|
+
itemIds: string[];
|
|
165
|
+
deadline?: Date;
|
|
166
|
+
instructions?: string;
|
|
167
|
+
}
|
|
168
|
+
type AnnotationEventType = 'task:created' | 'task:started' | 'task:paused' | 'task:completed' | 'item:assigned' | 'item:annotated' | 'item:flagged' | 'item:consensus_reached' | 'annotator:joined' | 'annotator:warning' | 'quality:alert';
|
|
169
|
+
interface AnnotationEvent {
|
|
170
|
+
type: AnnotationEventType;
|
|
171
|
+
taskId: string;
|
|
172
|
+
itemId?: string;
|
|
173
|
+
annotatorId?: string;
|
|
174
|
+
data?: Record<string, unknown>;
|
|
175
|
+
timestamp: number;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
declare class AnnotationTask implements IAnnotationTask {
|
|
179
|
+
readonly id: string;
|
|
180
|
+
readonly name: string;
|
|
181
|
+
readonly description: string;
|
|
182
|
+
readonly instructions: string;
|
|
183
|
+
readonly schema: z.ZodSchema;
|
|
184
|
+
status: AnnotationTaskStatus;
|
|
185
|
+
readonly itemsPerAnnotator: number;
|
|
186
|
+
readonly annotatorsPerItem: number;
|
|
187
|
+
readonly deadline?: Date;
|
|
188
|
+
readonly createdAt: number;
|
|
189
|
+
updatedAt: number;
|
|
190
|
+
completedAt?: number;
|
|
191
|
+
readonly metadata?: Record<string, unknown>;
|
|
192
|
+
constructor(config: AnnotationTaskConfig);
|
|
193
|
+
start(): void;
|
|
194
|
+
pause(): void;
|
|
195
|
+
resume(): void;
|
|
196
|
+
complete(): void;
|
|
197
|
+
cancel(): void;
|
|
198
|
+
validateAnnotation(value: unknown): {
|
|
199
|
+
valid: boolean;
|
|
200
|
+
error?: string;
|
|
201
|
+
};
|
|
202
|
+
isPastDeadline(): boolean;
|
|
203
|
+
toConfig(): AnnotationTaskConfig;
|
|
204
|
+
}
|
|
205
|
+
declare function createAnnotationTask(config: AnnotationTaskConfig): AnnotationTask;
|
|
206
|
+
declare const BinaryClassificationSchema: z.ZodObject<{
|
|
207
|
+
label: z.ZodEnum<["positive", "negative"]>;
|
|
208
|
+
confidence: z.ZodOptional<z.ZodNumber>;
|
|
209
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
210
|
+
}, "strip", z.ZodTypeAny, {
|
|
211
|
+
label: "positive" | "negative";
|
|
212
|
+
confidence?: number | undefined;
|
|
213
|
+
notes?: string | undefined;
|
|
214
|
+
}, {
|
|
215
|
+
label: "positive" | "negative";
|
|
216
|
+
confidence?: number | undefined;
|
|
217
|
+
notes?: string | undefined;
|
|
218
|
+
}>;
|
|
219
|
+
declare const QualityRatingSchema: z.ZodObject<{
|
|
220
|
+
accuracy: z.ZodNumber;
|
|
221
|
+
helpfulness: z.ZodNumber;
|
|
222
|
+
safety: z.ZodEnum<["pass", "fail"]>;
|
|
223
|
+
corrections: z.ZodOptional<z.ZodString>;
|
|
224
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
225
|
+
}, "strip", z.ZodTypeAny, {
|
|
226
|
+
accuracy: number;
|
|
227
|
+
helpfulness: number;
|
|
228
|
+
safety: "pass" | "fail";
|
|
229
|
+
notes?: string | undefined;
|
|
230
|
+
corrections?: string | undefined;
|
|
231
|
+
}, {
|
|
232
|
+
accuracy: number;
|
|
233
|
+
helpfulness: number;
|
|
234
|
+
safety: "pass" | "fail";
|
|
235
|
+
notes?: string | undefined;
|
|
236
|
+
corrections?: string | undefined;
|
|
237
|
+
}>;
|
|
238
|
+
declare const TextSpanSchema: z.ZodObject<{
|
|
239
|
+
spans: z.ZodArray<z.ZodObject<{
|
|
240
|
+
start: z.ZodNumber;
|
|
241
|
+
end: z.ZodNumber;
|
|
242
|
+
label: z.ZodString;
|
|
243
|
+
text: z.ZodOptional<z.ZodString>;
|
|
244
|
+
}, "strip", z.ZodTypeAny, {
|
|
245
|
+
start: number;
|
|
246
|
+
label: string;
|
|
247
|
+
end: number;
|
|
248
|
+
text?: string | undefined;
|
|
249
|
+
}, {
|
|
250
|
+
start: number;
|
|
251
|
+
label: string;
|
|
252
|
+
end: number;
|
|
253
|
+
text?: string | undefined;
|
|
254
|
+
}>, "many">;
|
|
255
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
256
|
+
}, "strip", z.ZodTypeAny, {
|
|
257
|
+
spans: {
|
|
258
|
+
start: number;
|
|
259
|
+
label: string;
|
|
260
|
+
end: number;
|
|
261
|
+
text?: string | undefined;
|
|
262
|
+
}[];
|
|
263
|
+
notes?: string | undefined;
|
|
264
|
+
}, {
|
|
265
|
+
spans: {
|
|
266
|
+
start: number;
|
|
267
|
+
label: string;
|
|
268
|
+
end: number;
|
|
269
|
+
text?: string | undefined;
|
|
270
|
+
}[];
|
|
271
|
+
notes?: string | undefined;
|
|
272
|
+
}>;
|
|
273
|
+
|
|
274
|
+
interface QueueEvents {
|
|
275
|
+
'item:assigned': (itemId: string, annotatorId: string) => void;
|
|
276
|
+
'item:annotated': (itemId: string, annotation: Annotation) => void;
|
|
277
|
+
'item:consensus': (itemId: string, consensus: ConsensusResult) => void;
|
|
278
|
+
'item:flagged': (itemId: string, reason: string) => void;
|
|
279
|
+
}
|
|
280
|
+
declare class AnnotationQueue extends EventEmitter<QueueEvents> {
|
|
281
|
+
readonly task: AnnotationTask;
|
|
282
|
+
private items;
|
|
283
|
+
private annotatorAssignments;
|
|
284
|
+
private annotatorCounts;
|
|
285
|
+
constructor(config: AnnotationQueueConfig);
|
|
286
|
+
getNextItem(annotatorId: string): AnnotationItem | null;
|
|
287
|
+
assignItem(itemId: string, annotatorId: string): void;
|
|
288
|
+
submitAnnotation(itemId: string, annotatorId: string, value: Record<string, unknown>, duration: number): Annotation;
|
|
289
|
+
flagItem(itemId: string, reason: string): void;
|
|
290
|
+
skipItem(itemId: string, annotatorId: string): void;
|
|
291
|
+
getBatchAssignment(annotatorId: string, count: number): BatchAssignment;
|
|
292
|
+
getStats(): QueueStats;
|
|
293
|
+
getItem(itemId: string): AnnotationItem | undefined;
|
|
294
|
+
getItems(): AnnotationItem[];
|
|
295
|
+
getItemsByStatus(status: AnnotationItemStatus): AnnotationItem[];
|
|
296
|
+
getAnnotatorCount(annotatorId: string): number;
|
|
297
|
+
}
|
|
298
|
+
declare function createAnnotationQueue(config: AnnotationQueueConfig): AnnotationQueue;
|
|
299
|
+
|
|
300
|
+
declare class ConsensusManager {
|
|
301
|
+
private method;
|
|
302
|
+
private weights?;
|
|
303
|
+
private expertAnnotatorId?;
|
|
304
|
+
constructor(config: ConsensusConfig);
|
|
305
|
+
calculateConsensus(annotations: Annotation[]): ConsensusResult;
|
|
306
|
+
private majorityConsensus;
|
|
307
|
+
private findMajority;
|
|
308
|
+
private unanimousConsensus;
|
|
309
|
+
private weightedConsensus;
|
|
310
|
+
private expertConsensus;
|
|
311
|
+
calculateAgreement(annotations: Annotation[]): number;
|
|
312
|
+
}
|
|
313
|
+
declare function createConsensusManager(config: ConsensusConfig): ConsensusManager;
|
|
314
|
+
|
|
315
|
+
export { type AnnotationTaskStatus as A, type BatchAssignment as B, type ConsensusMethod as C, type Disagreement as D, type GoldStandardItem as G, type IAnnotationTask as I, type PrioritizationType as P, type QualityControlConfig as Q, TextSpanSchema as T, type AnnotationItemStatus as a, type AnnotationTaskConfig as b, type AnnotationItem as c, type Annotation as d, type AnnotationQuality as e, type Annotator as f, type AnnotatorStats as g, type AnnotationQueueConfig as h, type AssignmentStrategy as i, type ConsensusConfig as j, type ConsensusResult as k, type QueueStats as l, type AnnotationResults as m, type AnnotationEventType as n, type AnnotationEvent as o, AnnotationTask as p, createAnnotationTask as q, BinaryClassificationSchema as r, QualityRatingSchema as s, AnnotationQueue as t, createAnnotationQueue as u, ConsensusManager as v, createConsensusManager as w };
|