@@ -219,13 +219,17 @@ type ErrorScoreHandler = (args: {
219219 unhandledScores : string [ ] ;
220220} ) => Record < string , number > | undefined | void ;
221221
222- type EvaluatorBase <
222+ /**
223+ * Defines an evaluator. At least one of `scores` or `classifiers` must be provided;
224+ * a runtime error is raised if neither is present.
225+ */
226+ export interface Evaluator <
223227 Input ,
224228 Output ,
225229 Expected ,
226230 Metadata extends BaseMetadata = DefaultMetadataType ,
227231 Parameters extends EvalParameters = EvalParameters ,
228- > = {
232+ > {
229233 /**
230234 * A function that returns a list of inputs, expected outputs, and metadata.
231235 */
@@ -236,6 +240,19 @@ type EvaluatorBase<
236240 */
237241 task : EvalTask < Input , Output , Expected , Metadata , Parameters > ;
238242
243+ /**
244+ * A set of functions that take an input, output, and expected value and return a {@link Score}.
245+ * At least one of `scores` or `classifiers` must be provided.
246+ */
247+ scores ?: EvalScorer < Input , Output , Expected , Metadata > [ ] ;
248+
249+ /**
250+ * A set of functions that take an input, output, and expected value and return a
251+ * {@link Classification}. Results are recorded under the `classifications` column.
252+ * At least one of `scores` or `classifiers` must be provided.
253+ */
254+ classifiers ?: EvalClassifier < Input , Output , Expected , Metadata > [ ] ;
255+
239256 /**
240257 * A set of parameters that will be passed to the evaluator.
241258 * Can be:
@@ -353,42 +370,7 @@ type EvaluatorBase<
353370 * Flushes spans before calling scoring functions
354371 */
355372 flushBeforeScoring ?: boolean ;
356- } ;
357-
358- /**
359- * Defines an evaluator. At least one of `scores` or `classifiers` must be provided.
360- */
361- export type Evaluator <
362- Input ,
363- Output ,
364- Expected ,
365- Metadata extends BaseMetadata = DefaultMetadataType ,
366- Parameters extends EvalParameters = EvalParameters ,
367- > = EvaluatorBase < Input , Output , Expected , Metadata , Parameters > &
368- (
369- | {
370- /**
371- * A set of functions that take an input, output, and expected value and return a {@link Score}.
372- */
373- scores : EvalScorer < Input , Output , Expected , Metadata > [ ] ;
374- /**
375- * A set of functions that take an input, output, and expected value and return a
376- * {@link Classification}. Results are recorded under the `classifications` column.
377- */
378- classifiers ?: EvalClassifier < Input , Output , Expected , Metadata > [ ] ;
379- }
380- | {
381- /**
382- * A set of functions that take an input, output, and expected value and return a {@link Score}.
383- */
384- scores ?: EvalScorer < Input , Output , Expected , Metadata > [ ] ;
385- /**
386- * A set of functions that take an input, output, and expected value and return a
387- * {@link Classification}. Results are recorded under the `classifications` column.
388- */
389- classifiers : EvalClassifier < Input , Output , Expected , Metadata > [ ] ;
390- }
391- ) ;
373+ }
392374
393375export class EvalResultWithSummary <
394376 Input ,
@@ -1007,7 +989,6 @@ function toClassificationItem(c: Classification): ClassificationItem {
1007989 return {
1008990 id : c . id ,
1009991 label : c . label ?? c . id ,
1010- ...( c . confidence !== undefined ? { confidence : c . confidence } : { } ) ,
1011992 ...( c . metadata !== undefined ? { metadata : c . metadata } : { } ) ,
1012993 } ;
1013994}
0 commit comments