evalite
Version:
Test your LLM-powered apps with a TypeScript-native, Vitest-based eval runner. No API key required.
25 lines • 813 B
JavaScript
export const createScorer = (opts) => {
return async (input) => {
const score = await opts.scorer(input);
if (typeof score === "object") {
if (typeof score.score !== "number") {
throw new Error(`The scorer '${opts.name}' must return a number.`);
}
return {
score: score.score,
metadata: score.metadata,
description: opts.description,
name: opts.name,
};
}
if (typeof score !== "number") {
throw new Error(`The scorer '${opts.name}' must return a number.`);
}
return {
description: opts.description,
name: opts.name,
score,
};
};
};
//# sourceMappingURL=create-scorer.js.map