From 6a960f5ca232214b272a009aba6bf9009f77fb06 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Thu, 7 Nov 2024 16:14:10 -0800 Subject: [PATCH] fix(js): Export more evaluator types --- js/src/evaluation/_runner.ts | 10 +++++----- js/src/evaluation/index.ts | 10 +++++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/js/src/evaluation/_runner.ts b/js/src/evaluation/_runner.ts index cdd5b3ccf..93896aaf1 100644 --- a/js/src/evaluation/_runner.ts +++ b/js/src/evaluation/_runner.ts @@ -18,18 +18,18 @@ import { LangSmithConflictError } from "../utils/error.js"; import { v4 as uuidv4 } from "uuid"; // eslint-disable-next-line @typescript-eslint/no-explicit-any -type TargetT = +export type TargetT = | ((input: TInput, config?: KVMap) => Promise) | ((input: TInput, config?: KVMap) => TOutput) | { invoke: (input: TInput, config?: KVMap) => TOutput } | { invoke: (input: TInput, config?: KVMap) => Promise }; // Data format: dataset-name, dataset_id, or examples -type DataT = string | AsyncIterable | Example[]; +export type DataT = string | AsyncIterable | Example[]; // Summary evaluator runs over the whole dataset // and reports aggregate metric(s) -type SummaryEvaluatorT = +export type SummaryEvaluatorT = | (( runs: Array, examples: Array @@ -40,7 +40,7 @@ type SummaryEvaluatorT = ) => EvaluationResult | EvaluationResults); // Row-level evaluator -type EvaluatorT = +export type EvaluatorT = | RunEvaluator | ((run: Run, example?: Example) => EvaluationResult | EvaluationResults) | (( @@ -128,7 +128,7 @@ export function evaluate( return _evaluate(target, options); } -interface ExperimentResultRow { +export interface ExperimentResultRow { run: Run; example: Example; evaluationResults: EvaluationResults; diff --git a/js/src/evaluation/index.ts b/js/src/evaluation/index.ts index e72b94854..3e4a72381 100644 --- a/js/src/evaluation/index.ts +++ b/js/src/evaluation/index.ts @@ -5,5 +5,13 @@ export { GradingFunctionParams, GradingFunctionResult, } from "./string_evaluator.js"; -export { evaluate, type EvaluateOptions } from "./_runner.js"; +export { + evaluate, + type EvaluateOptions, + type TargetT, + type DataT, + type SummaryEvaluatorT, + type EvaluatorT, + type ExperimentResultRow, +} from "./_runner.js"; export { evaluateComparative } from "./evaluate_comparative.js";