Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

js[patch]: fix evaluateComparative #1283

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions js/src/evaluation/evaluate_comparative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ export type _ComparativeEvaluatorLegacy = (
) => ComparisonEvaluationResultRow | Promise<ComparisonEvaluationResultRow>;

export type _ComparativeEvaluator = (args: {
runs?: Run[];
example?: Example;
inputs?: Record<string, any>;
runs: Run[];
example: Example;
inputs: Record<string, any>;
outputs?: Record<string, any>[];
referenceOutputs?: Record<string, any>;
}) => ComparisonEvaluationResultRow | Promise<ComparisonEvaluationResultRow>;
Expand Down Expand Up @@ -357,7 +357,16 @@ export async function evaluateComparative(
example: Example
): Promise<ComparisonEvaluationResultRow> => {
const evaluatorRun = getCurrentRunTree();
const result = await evaluator(runs, example);
const result =
evaluator.length === 1
? await (evaluator as _ComparativeEvaluator)({
runs: options.randomizeOrder ? shuffle(runs) : runs,
example,
inputs: example.inputs,
outputs: runs.map((run) => run.outputs || {}),
referenceOutputs: example.outputs || {},
})
: await (evaluator as _ComparativeEvaluatorLegacy)(runs, example);

// sanitise the payload before sending to LangSmith
evaluatorRun.inputs = { runs: runs, example: example };
Expand Down
Loading