Skip to content

Commit

Permalink
fix(js): Export more evaluator types (#1190)
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul authored Nov 8, 2024
2 parents a8cab88 + 90f660b commit 9a3e247
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 5 additions & 5 deletions js/src/evaluation/_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<TInput = any, TOutput = KVMap> =
export type TargetT<TInput = any, TOutput = KVMap> =
| ((input: TInput, config?: KVMap) => Promise<TOutput>)
| ((input: TInput, config?: KVMap) => TOutput)
| { invoke: (input: TInput, config?: KVMap) => TOutput }
| { invoke: (input: TInput, config?: KVMap) => Promise<TOutput> };

// Data format: dataset-name, dataset_id, or examples
type DataT = string | AsyncIterable<Example> | Example[];
export type DataT = string | AsyncIterable<Example> | Example[];

// Summary evaluator runs over the whole dataset
// and reports aggregate metric(s)
type SummaryEvaluatorT =
export type SummaryEvaluatorT =
| ((
runs: Array<Run>,
examples: Array<Example>
Expand All @@ -40,7 +40,7 @@ type SummaryEvaluatorT =
) => EvaluationResult | EvaluationResults);

// Row-level evaluator
type EvaluatorT =
export type EvaluatorT =
| RunEvaluator
| ((run: Run, example?: Example) => EvaluationResult | EvaluationResults)
| ((
Expand Down Expand Up @@ -128,7 +128,7 @@ export function evaluate(
return _evaluate(target, options);
}

interface ExperimentResultRow {
export interface ExperimentResultRow {
run: Run;
example: Example;
evaluationResults: EvaluationResults;
Expand Down
10 changes: 9 additions & 1 deletion js/src/evaluation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

0 comments on commit 9a3e247

Please sign in to comment.