axiom
Version:
Axiom AI SDK provides - an API to wrap your AI calls with observability instrumentation. - offline evals - online evals
42 lines (41 loc) • 1 kB
JavaScript
import {
normalizeBooleanScore
} from "../chunk-FGLJO4BD.js";
import "../chunk-4TKUTT24.js";
import "../chunk-KEXKKQVW.js";
// src/scorers/scorer.factory.ts
function createScorer(name, fn, options) {
const normalizeScore = (res) => {
if (typeof res === "number") {
return { score: res };
}
if (typeof res === "boolean") {
return normalizeBooleanScore(res);
}
return normalizeBooleanScore(res.score, res.metadata);
};
const scorer = (args) => {
const res = fn(args);
if (res instanceof Promise) {
return res.then(normalizeScore);
}
return normalizeScore(res);
};
Object.defineProperty(scorer, "name", {
value: name,
configurable: true,
enumerable: true
});
if (options?.aggregation) {
Object.defineProperty(scorer, "aggregation", {
value: options.aggregation,
configurable: true,
enumerable: true
});
}
return scorer;
}
export {
createScorer as Scorer
};
//# sourceMappingURL=scorers.js.map