@memberjunction/testing-engine 6.2.0-edge.0 → 6.2.0-edge.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/decision-eval/corpus.d.ts +94 -0
- package/dist/decision-eval/corpus.d.ts.map +1 -0
- package/dist/decision-eval/corpus.js +144 -0
- package/dist/decision-eval/corpus.js.map +1 -0
- package/dist/decision-eval/discovery-baseline.d.ts +62 -0
- package/dist/decision-eval/discovery-baseline.d.ts.map +1 -0
- package/dist/decision-eval/discovery-baseline.js +90 -0
- package/dist/decision-eval/discovery-baseline.js.map +1 -0
- package/dist/decision-eval/discovery-corpus.d.ts +75 -0
- package/dist/decision-eval/discovery-corpus.d.ts.map +1 -0
- package/dist/decision-eval/discovery-corpus.js +110 -0
- package/dist/decision-eval/discovery-corpus.js.map +1 -0
- package/dist/decision-eval/discovery-mapping.d.ts +18 -0
- package/dist/decision-eval/discovery-mapping.d.ts.map +1 -0
- package/dist/decision-eval/discovery-mapping.js +21 -0
- package/dist/decision-eval/discovery-mapping.js.map +1 -0
- package/dist/decision-eval/discovery-metrics.d.ts +339 -0
- package/dist/decision-eval/discovery-metrics.d.ts.map +1 -0
- package/dist/decision-eval/discovery-metrics.js +401 -0
- package/dist/decision-eval/discovery-metrics.js.map +1 -0
- package/dist/decision-eval/discovery-scorecard.d.ts +96 -0
- package/dist/decision-eval/discovery-scorecard.d.ts.map +1 -0
- package/dist/decision-eval/discovery-scorecard.js +351 -0
- package/dist/decision-eval/discovery-scorecard.js.map +1 -0
- package/dist/decision-eval/discovery-suite.d.ts +201 -0
- package/dist/decision-eval/discovery-suite.d.ts.map +1 -0
- package/dist/decision-eval/discovery-suite.js +180 -0
- package/dist/decision-eval/discovery-suite.js.map +1 -0
- package/dist/decision-eval/discovery-types.d.ts +896 -0
- package/dist/decision-eval/discovery-types.d.ts.map +1 -0
- package/dist/decision-eval/discovery-types.js +211 -0
- package/dist/decision-eval/discovery-types.js.map +1 -0
- package/dist/decision-eval/index.d.ts +18 -0
- package/dist/decision-eval/index.d.ts.map +1 -0
- package/dist/decision-eval/index.js +18 -0
- package/dist/decision-eval/index.js.map +1 -0
- package/dist/decision-eval/metrics.d.ts +330 -0
- package/dist/decision-eval/metrics.d.ts.map +1 -0
- package/dist/decision-eval/metrics.js +574 -0
- package/dist/decision-eval/metrics.js.map +1 -0
- package/dist/decision-eval/output-paths.d.ts +119 -0
- package/dist/decision-eval/output-paths.d.ts.map +1 -0
- package/dist/decision-eval/output-paths.js +258 -0
- package/dist/decision-eval/output-paths.js.map +1 -0
- package/dist/decision-eval/point-mapping.d.ts +50 -0
- package/dist/decision-eval/point-mapping.d.ts.map +1 -0
- package/dist/decision-eval/point-mapping.js +83 -0
- package/dist/decision-eval/point-mapping.js.map +1 -0
- package/dist/decision-eval/scorecard.d.ts +190 -0
- package/dist/decision-eval/scorecard.d.ts.map +1 -0
- package/dist/decision-eval/scorecard.js +384 -0
- package/dist/decision-eval/scorecard.js.map +1 -0
- package/dist/decision-eval/suite.d.ts +244 -0
- package/dist/decision-eval/suite.d.ts.map +1 -0
- package/dist/decision-eval/suite.js +238 -0
- package/dist/decision-eval/suite.js.map +1 -0
- package/dist/decision-eval/types.d.ts +993 -0
- package/dist/decision-eval/types.d.ts.map +1 -0
- package/dist/decision-eval/types.js +227 -0
- package/dist/decision-eval/types.js.map +1 -0
- package/dist/drivers/AgentEvalDriver.d.ts +30 -1
- package/dist/drivers/AgentEvalDriver.d.ts.map +1 -1
- package/dist/drivers/AgentEvalDriver.js +145 -16
- package/dist/drivers/AgentEvalDriver.js.map +1 -1
- package/dist/drivers/DecisionEvalDriver.d.ts +297 -0
- package/dist/drivers/DecisionEvalDriver.d.ts.map +1 -0
- package/dist/drivers/DecisionEvalDriver.js +716 -0
- package/dist/drivers/DecisionEvalDriver.js.map +1 -0
- package/dist/drivers/PinnedDecisionRunner.d.ts +24 -0
- package/dist/drivers/PinnedDecisionRunner.d.ts.map +1 -0
- package/dist/drivers/PinnedDecisionRunner.js +24 -0
- package/dist/drivers/PinnedDecisionRunner.js.map +1 -0
- package/dist/drivers/PromptEvalDriver.d.ts.map +1 -1
- package/dist/drivers/PromptEvalDriver.js +11 -4
- package/dist/drivers/PromptEvalDriver.js.map +1 -1
- package/dist/drivers/RubricCalibrationTestDriver.d.ts +34 -0
- package/dist/drivers/RubricCalibrationTestDriver.d.ts.map +1 -0
- package/dist/drivers/RubricCalibrationTestDriver.js +193 -0
- package/dist/drivers/RubricCalibrationTestDriver.js.map +1 -0
- package/dist/drivers/calibration.d.ts +85 -0
- package/dist/drivers/calibration.d.ts.map +1 -0
- package/dist/drivers/calibration.js +191 -0
- package/dist/drivers/calibration.js.map +1 -0
- package/dist/drivers/index.d.ts +2 -0
- package/dist/drivers/index.d.ts.map +1 -1
- package/dist/drivers/index.js +2 -0
- package/dist/drivers/index.js.map +1 -1
- package/dist/engine/TestEngine.d.ts.map +1 -1
- package/dist/engine/TestEngine.js +21 -11
- package/dist/engine/TestEngine.js.map +1 -1
- package/dist/eval/corpus.d.ts +8 -0
- package/dist/eval/corpus.d.ts.map +1 -1
- package/dist/eval/corpus.js +26 -10
- package/dist/eval/corpus.js.map +1 -1
- package/dist/eval/decision.d.ts +8 -0
- package/dist/eval/decision.d.ts.map +1 -1
- package/dist/eval/decision.js +23 -7
- package/dist/eval/decision.js.map +1 -1
- package/dist/eval/expectation.d.ts +2 -0
- package/dist/eval/expectation.d.ts.map +1 -1
- package/dist/eval/expectation.js +9 -5
- package/dist/eval/expectation.js.map +1 -1
- package/dist/eval/history.d.ts +2 -0
- package/dist/eval/history.d.ts.map +1 -1
- package/dist/eval/history.js +5 -1
- package/dist/eval/history.js.map +1 -1
- package/dist/eval/matchers.d.ts +7 -0
- package/dist/eval/matchers.d.ts.map +1 -1
- package/dist/eval/matchers.js +11 -3
- package/dist/eval/matchers.js.map +1 -1
- package/dist/eval/subAgentTrace.d.ts +8 -6
- package/dist/eval/subAgentTrace.d.ts.map +1 -1
- package/dist/eval/subAgentTrace.js +15 -11
- package/dist/eval/subAgentTrace.js.map +1 -1
- package/dist/eval/wellFormed.d.ts +2 -0
- package/dist/eval/wellFormed.d.ts.map +1 -1
- package/dist/eval/wellFormed.js +5 -1
- package/dist/eval/wellFormed.js.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/oracles/AgentDecisionOracle.js +7 -7
- package/dist/oracles/DecisionJudgeOracle.d.ts +97 -0
- package/dist/oracles/DecisionJudgeOracle.d.ts.map +1 -0
- package/dist/oracles/DecisionJudgeOracle.js +230 -0
- package/dist/oracles/DecisionJudgeOracle.js.map +1 -0
- package/dist/oracles/DecisionLabelMatchOracle.d.ts +38 -0
- package/dist/oracles/DecisionLabelMatchOracle.d.ts.map +1 -0
- package/dist/oracles/DecisionLabelMatchOracle.js +96 -0
- package/dist/oracles/DecisionLabelMatchOracle.js.map +1 -0
- package/dist/oracles/DiscoveryLabelMatchOracle.d.ts +39 -0
- package/dist/oracles/DiscoveryLabelMatchOracle.d.ts.map +1 -0
- package/dist/oracles/DiscoveryLabelMatchOracle.js +88 -0
- package/dist/oracles/DiscoveryLabelMatchOracle.js.map +1 -0
- package/dist/oracles/LLMJudgeOracle.d.ts +2 -47
- package/dist/oracles/LLMJudgeOracle.d.ts.map +1 -1
- package/dist/oracles/LLMJudgeOracle.js +80 -149
- package/dist/oracles/LLMJudgeOracle.js.map +1 -1
- package/dist/oracles/RubricOracle.d.ts +51 -0
- package/dist/oracles/RubricOracle.d.ts.map +1 -0
- package/dist/oracles/RubricOracle.js +66 -0
- package/dist/oracles/RubricOracle.js.map +1 -0
- package/dist/oracles/TraceSubAgentValidatorOracle.js +3 -3
- package/dist/oracles/index.d.ts +5 -0
- package/dist/oracles/index.d.ts.map +1 -1
- package/dist/oracles/index.js +5 -0
- package/dist/oracles/index.js.map +1 -1
- package/dist/oracles/inline-rubric.d.ts +25 -0
- package/dist/oracles/inline-rubric.d.ts.map +1 -0
- package/dist/oracles/inline-rubric.js +82 -0
- package/dist/oracles/inline-rubric.js.map +1 -0
- package/dist/oracles/judge-trace.d.ts +76 -0
- package/dist/oracles/judge-trace.d.ts.map +1 -0
- package/dist/oracles/judge-trace.js +125 -0
- package/dist/oracles/judge-trace.js.map +1 -0
- package/dist/oracles/promote-criteria.d.ts +57 -0
- package/dist/oracles/promote-criteria.d.ts.map +1 -0
- package/dist/oracles/promote-criteria.js +104 -0
- package/dist/oracles/promote-criteria.js.map +1 -0
- package/dist/oracles/rubric-resolution.d.ts +69 -0
- package/dist/oracles/rubric-resolution.d.ts.map +1 -0
- package/dist/oracles/rubric-resolution.js +110 -0
- package/dist/oracles/rubric-resolution.js.map +1 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/cost-calculator.d.ts +34 -0
- package/dist/utils/cost-calculator.d.ts.map +1 -1
- package/dist/utils/cost-calculator.js +40 -8
- package/dist/utils/cost-calculator.js.map +1 -1
- package/dist/utils/execution-context.d.ts +6 -0
- package/dist/utils/execution-context.d.ts.map +1 -1
- package/dist/utils/execution-context.js +15 -3
- package/dist/utils/execution-context.js.map +1 -1
- package/dist/utils/result-formatter.d.ts +38 -0
- package/dist/utils/result-formatter.d.ts.map +1 -1
- package/dist/utils/result-formatter.js +74 -24
- package/dist/utils/result-formatter.js.map +1 -1
- package/dist/utils/scoring.d.ts +20 -0
- package/dist/utils/scoring.d.ts.map +1 -1
- package/dist/utils/scoring.js +35 -7
- package/dist/utils/scoring.js.map +1 -1
- package/dist/utils/variable-resolver.d.ts +20 -1
- package/dist/utils/variable-resolver.d.ts.map +1 -1
- package/dist/utils/variable-resolver.js +58 -20
- package/dist/utils/variable-resolver.js.map +1 -1
- package/package.json +12 -10
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview `decision-label-match`: does a decision's Likelihood agree with the point's label?
|
|
3
|
+
* @module @memberjunction/testing-engine
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { DecisionEvalAnswerSummarySchema, DecisionEvalExpectedSchema, DecisionLabelMatchConfigSchema, DescribeZodError } from '../decision-eval/types.js';
|
|
7
|
+
/** The part of a Decision Eval `ActualOutput` this oracle reads: the summarized answers. */
|
|
8
|
+
const AnswersOnlySchema = z.object({ Answers: z.record(DecisionEvalAnswerSummarySchema) });
|
|
9
|
+
/**
|
|
10
|
+
* `decision-label-match`: reads one Likelihood's probability from a Decision Eval run's answers
|
|
11
|
+
* (by default `continues`) and compares `probability >= threshold` with `label === positiveLabel`.
|
|
12
|
+
*
|
|
13
|
+
* - The result passes, with score 1, when the two agree, and fails with score 0 otherwise.
|
|
14
|
+
* - `details` carry `{ probability, label, positive, correct, brier }`, so the scorecard can
|
|
15
|
+
* aggregate without re-running anything.
|
|
16
|
+
* - An `ambiguous` label is not scored: the result is `advisory`, so it never gates the run.
|
|
17
|
+
* - A run with no such Likelihood fails, naming why.
|
|
18
|
+
*
|
|
19
|
+
* Configuration: `{ question = 'continues', positiveLabel = 'continue', threshold = 0.5 }`.
|
|
20
|
+
*/
|
|
21
|
+
export class DecisionLabelMatchOracle {
|
|
22
|
+
constructor() {
|
|
23
|
+
this.type = 'decision-label-match';
|
|
24
|
+
}
|
|
25
|
+
async evaluate(input, config) {
|
|
26
|
+
const settings = DecisionLabelMatchConfigSchema.safeParse(config ?? {});
|
|
27
|
+
if (!settings.success) {
|
|
28
|
+
return this.failed(`Invalid configuration: ${DescribeZodError(settings.error)}`);
|
|
29
|
+
}
|
|
30
|
+
const expected = DecisionEvalExpectedSchema.safeParse(input.expectedOutput);
|
|
31
|
+
if (!expected.success) {
|
|
32
|
+
return this.failed(`Expected outcome has no usable label: ${DescribeZodError(expected.error)}`);
|
|
33
|
+
}
|
|
34
|
+
const probability = ReadLikelihood(input.actualOutput, settings.data.question);
|
|
35
|
+
if (expected.data.label === 'ambiguous') {
|
|
36
|
+
return this.advisory(probability, settings.data);
|
|
37
|
+
}
|
|
38
|
+
if (probability === null) {
|
|
39
|
+
return this.failed(`No '${settings.data.question}' Likelihood in the answers`, {
|
|
40
|
+
probability: null, label: expected.data.label, positive: this.positiveOf(expected.data.label, settings.data), correct: false, brier: null
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return this.scored(probability, expected.data.label, settings.data);
|
|
44
|
+
}
|
|
45
|
+
/** A scored comparison of the probability with the label. */
|
|
46
|
+
scored(probability, label, settings) {
|
|
47
|
+
const positive = this.positiveOf(label, settings);
|
|
48
|
+
const predictedPositive = probability >= settings.threshold;
|
|
49
|
+
const correct = predictedPositive === (positive === 1);
|
|
50
|
+
const details = { probability, label, positive, correct, brier: (probability - positive) ** 2 };
|
|
51
|
+
return {
|
|
52
|
+
oracleType: this.type,
|
|
53
|
+
passed: correct,
|
|
54
|
+
score: correct ? 1 : 0,
|
|
55
|
+
message: `${settings.question} = ${probability.toFixed(3)} ${predictedPositive ? '>=' : '<'} ${settings.threshold}; `
|
|
56
|
+
+ `label '${label}'${correct ? '' : ' (disagrees)'}`,
|
|
57
|
+
details
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** An unscored result for an ambiguous label: reported, never gating. */
|
|
61
|
+
advisory(probability, settings) {
|
|
62
|
+
const details = { probability, label: 'ambiguous', positive: null, correct: null, brier: null };
|
|
63
|
+
const kept = probability === null ? 'no probability' : probability >= settings.threshold ? 'kept with the previous agent' : 'moved away';
|
|
64
|
+
return {
|
|
65
|
+
oracleType: this.type,
|
|
66
|
+
passed: true,
|
|
67
|
+
score: 0,
|
|
68
|
+
advisory: true,
|
|
69
|
+
message: `Ambiguous label: not scored (${kept})`,
|
|
70
|
+
details
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/** 1 when the label is the positive class, else 0. */
|
|
74
|
+
positiveOf(label, settings) {
|
|
75
|
+
return label === settings.positiveLabel ? 1 : 0;
|
|
76
|
+
}
|
|
77
|
+
failed(message, details) {
|
|
78
|
+
return { oracleType: this.type, passed: false, score: 0, message, details };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A Likelihood's probability from a Decision Eval `ActualOutput`, or null when the output has no
|
|
83
|
+
* readable answers or no Likelihood under that key.
|
|
84
|
+
*
|
|
85
|
+
* @param actualOutput The run's actual output, as the driver recorded it.
|
|
86
|
+
* @param question The Likelihood's key.
|
|
87
|
+
*/
|
|
88
|
+
export function ReadLikelihood(actualOutput, question) {
|
|
89
|
+
const parsed = AnswersOnlySchema.safeParse(actualOutput);
|
|
90
|
+
if (!parsed.success) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
const answer = parsed.data.Answers[question];
|
|
94
|
+
return answer?.Kind === 'Likelihood' && typeof answer.Probability === 'number' ? answer.Probability : null;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=DecisionLabelMatchOracle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DecisionLabelMatchOracle.js","sourceRoot":"","sources":["../../src/oracles/DecisionLabelMatchOracle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EACH,+BAA+B,EAC/B,0BAA0B,EAC1B,8BAA8B,EAC9B,gBAAgB,EAGnB,MAAM,wBAAwB,CAAC;AAEhC,4FAA4F;AAC5F,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,+BAA+B,CAAC,EAAE,CAAC,CAAC;AAE3F;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,wBAAwB;IAArC;QACa,SAAI,GAAG,sBAAsB,CAAC;IA6D3C,CAAC;IA3DG,KAAK,CAAC,QAAQ,CAAC,KAAkB,EAAE,MAAoB;QACnD,MAAM,QAAQ,GAAG,8BAA8B,CAAC,SAAS,CA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AC,YAAY,CAAC;QACzI,OAAO;YACH,UAAU,EAAE,IAAI,CAAC,IAAI;YACrB,MAAM,EAAE,IAAI;YACZ,KAAK,EAAE,CAAC;YACR,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,gCAAgC,IAAI,GAAG;YAChD,OAAO;SACV,CAAC;IACN,CAAC;IAED,sDAAsD;IAC9C,UAAU,CAAC,KAA4B,EAAE,QAAkC;QAC/E,OAAO,KAAK,KAAK,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC;IAEO,MAAM,CAAC,OAAe,EAAE,OAAmC;QAC/D,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IAChF,CAAC;CACJ;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,YAAqB,EAAE,QAAgB;IAClE,MAAM,MAAM,GAAG,iBAAiB,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IACzD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7C,OAAO,MAAM,EAAE,IAAI,KAAK,YAAY,IAAI,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/G,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview `discovery-label-match`: did agent discovery reach the agent the request's label
|
|
3
|
+
* names, or, for a request no specialist should handle, stay out of the way?
|
|
4
|
+
* @module @memberjunction/testing-engine
|
|
5
|
+
*/
|
|
6
|
+
import { IOracle } from './IOracle.js';
|
|
7
|
+
import { OracleInput, OracleConfig, OracleResult } from '../types.js';
|
|
8
|
+
import { type DiscoveryEvalActualOutput, type DiscoveryEvalExpected, type DiscoveryLabelMatchDetails } from '../decision-eval/discovery-types.js';
|
|
9
|
+
/**
|
|
10
|
+
* `discovery-label-match`: scores an agent-discovery run against its label, for either arm.
|
|
11
|
+
*
|
|
12
|
+
* - An `agent` label is correct when the chosen agent is the labelled agent: the Choice's pick for
|
|
13
|
+
* the decision, whatever its confidence, or the first row `Find Candidate Agents` would return
|
|
14
|
+
* for the `semantic-search` baseline.
|
|
15
|
+
* - A `none` label is correct when discovery would not inject a suggestion (the run's `WouldInject`):
|
|
16
|
+
* production's own verdict, `DecisionDiscoveryFromResult`, not confident once the answers are
|
|
17
|
+
* calibrated for the answering model, or that model having no calibration, or the discovery
|
|
18
|
+
* finishing after production's timeout (decision); or no candidate reaching the action's
|
|
19
|
+
* similarity floor (baseline).
|
|
20
|
+
* - A run with no usable answer fails, naming why, with `correct: null`.
|
|
21
|
+
*
|
|
22
|
+
* `details` carry `{ arm, label, kind, expectedAgentId, chosenAgentId, confidence, anyApplies,
|
|
23
|
+
* wouldInject, topScore, correct }`, so the scorecard can aggregate without re-running anything.
|
|
24
|
+
* It takes no configuration.
|
|
25
|
+
*/
|
|
26
|
+
export declare class DiscoveryLabelMatchOracle implements IOracle {
|
|
27
|
+
readonly type = "discovery-label-match";
|
|
28
|
+
evaluate(input: OracleInput, _config: OracleConfig): Promise<OracleResult>;
|
|
29
|
+
private failed;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Scores one discovery run against its label (see {@link DiscoveryLabelMatchOracle}). `correct` is
|
|
33
|
+
* null when the run has no usable answer: `WouldInject` unknown, or, for the decision, no Choice.
|
|
34
|
+
*
|
|
35
|
+
* @param expected The run's label.
|
|
36
|
+
* @param actual The run's actual output.
|
|
37
|
+
*/
|
|
38
|
+
export declare function ScoreDiscoveryRun(expected: DiscoveryEvalExpected, actual: DiscoveryEvalActualOutput): DiscoveryLabelMatchDetails;
|
|
39
|
+
//# sourceMappingURL=DiscoveryLabelMatchOracle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DiscoveryLabelMatchOracle.d.ts","sourceRoot":"","sources":["../../src/oracles/DiscoveryLabelMatchOracle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEnE,OAAO,EAGH,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAClC,MAAM,kCAAkC,CAAC;AAE1C;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,yBAA0B,YAAW,OAAO;IACrD,QAAQ,CAAC,IAAI,2BAA2B;IAElC,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAsBhF,OAAO,CAAC,MAAM;CAGjB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,qBAAqB,EAAE,MAAM,EAAE,yBAAyB,GAAG,0BAA0B,CAiBhI"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview `discovery-label-match`: did agent discovery reach the agent the request's label
|
|
3
|
+
* names, or, for a request no specialist should handle, stay out of the way?
|
|
4
|
+
* @module @memberjunction/testing-engine
|
|
5
|
+
*/
|
|
6
|
+
import { UUIDsEqual } from '@memberjunction/global';
|
|
7
|
+
import { DescribeZodError } from '../decision-eval/types.js';
|
|
8
|
+
import { DiscoveryEvalActualOutputSchema, DiscoveryEvalExpectedSchema } from '../decision-eval/discovery-types.js';
|
|
9
|
+
/**
|
|
10
|
+
* `discovery-label-match`: scores an agent-discovery run against its label, for either arm.
|
|
11
|
+
*
|
|
12
|
+
* - An `agent` label is correct when the chosen agent is the labelled agent: the Choice's pick for
|
|
13
|
+
* the decision, whatever its confidence, or the first row `Find Candidate Agents` would return
|
|
14
|
+
* for the `semantic-search` baseline.
|
|
15
|
+
* - A `none` label is correct when discovery would not inject a suggestion (the run's `WouldInject`):
|
|
16
|
+
* production's own verdict, `DecisionDiscoveryFromResult`, not confident once the answers are
|
|
17
|
+
* calibrated for the answering model, or that model having no calibration, or the discovery
|
|
18
|
+
* finishing after production's timeout (decision); or no candidate reaching the action's
|
|
19
|
+
* similarity floor (baseline).
|
|
20
|
+
* - A run with no usable answer fails, naming why, with `correct: null`.
|
|
21
|
+
*
|
|
22
|
+
* `details` carry `{ arm, label, kind, expectedAgentId, chosenAgentId, confidence, anyApplies,
|
|
23
|
+
* wouldInject, topScore, correct }`, so the scorecard can aggregate without re-running anything.
|
|
24
|
+
* It takes no configuration.
|
|
25
|
+
*/
|
|
26
|
+
export class DiscoveryLabelMatchOracle {
|
|
27
|
+
constructor() {
|
|
28
|
+
this.type = 'discovery-label-match';
|
|
29
|
+
}
|
|
30
|
+
async evaluate(input, _config) {
|
|
31
|
+
const expected = DiscoveryEvalExpectedSchema.safeParse(input.expectedOutput);
|
|
32
|
+
if (!expected.success) {
|
|
33
|
+
return this.failed(`Expected outcome has no usable label: ${DescribeZodError(expected.error)}`);
|
|
34
|
+
}
|
|
35
|
+
const actual = DiscoveryEvalActualOutputSchema.safeParse(input.actualOutput);
|
|
36
|
+
if (!actual.success) {
|
|
37
|
+
return this.failed(`Actual output is not a discovery run's: ${DescribeZodError(actual.error)}`);
|
|
38
|
+
}
|
|
39
|
+
const details = ScoreDiscoveryRun(expected.data, actual.data);
|
|
40
|
+
if (details.correct === null) {
|
|
41
|
+
return this.failed(`No usable answer: ${actual.data.Error ?? actual.data.VerdictReason ?? 'the run chose no agent'}`, details);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
oracleType: this.type,
|
|
45
|
+
passed: details.correct,
|
|
46
|
+
score: details.correct ? 1 : 0,
|
|
47
|
+
message: describe(details),
|
|
48
|
+
details
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
failed(message, details) {
|
|
52
|
+
return { oracleType: this.type, passed: false, score: 0, message, details };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Scores one discovery run against its label (see {@link DiscoveryLabelMatchOracle}). `correct` is
|
|
57
|
+
* null when the run has no usable answer: `WouldInject` unknown, or, for the decision, no Choice.
|
|
58
|
+
*
|
|
59
|
+
* @param expected The run's label.
|
|
60
|
+
* @param actual The run's actual output.
|
|
61
|
+
*/
|
|
62
|
+
export function ScoreDiscoveryRun(expected, actual) {
|
|
63
|
+
const expectedAgentId = expected.label === 'agent' ? expected.agentId : null;
|
|
64
|
+
const answered = actual.WouldInject !== null && (actual.Arm !== 'decision' || actual.ChosenAgentId !== null);
|
|
65
|
+
return {
|
|
66
|
+
arm: actual.Arm,
|
|
67
|
+
label: expected.label,
|
|
68
|
+
kind: expected.label === 'none' ? expected.kind : null,
|
|
69
|
+
expectedAgentId,
|
|
70
|
+
chosenAgentId: actual.ChosenAgentId,
|
|
71
|
+
confidence: actual.Confidence,
|
|
72
|
+
anyApplies: actual.AnyApplies,
|
|
73
|
+
wouldInject: actual.WouldInject,
|
|
74
|
+
topScore: actual.Baseline?.TopMatch?.Score ?? null,
|
|
75
|
+
correct: !answered ? null : expectedAgentId !== null
|
|
76
|
+
? !!actual.ChosenAgentId && UUIDsEqual(actual.ChosenAgentId, expectedAgentId)
|
|
77
|
+
: actual.WouldInject === false
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** The result's message. */
|
|
81
|
+
function describe(details) {
|
|
82
|
+
const verdict = details.correct ? '' : ' (disagrees)';
|
|
83
|
+
if (details.label === 'agent') {
|
|
84
|
+
return `chose ${details.chosenAgentId ?? 'no agent'}; labelled ${details.expectedAgentId}${verdict}`;
|
|
85
|
+
}
|
|
86
|
+
return `${details.wouldInject ? 'would suggest' : 'would not suggest'} ${details.chosenAgentId ?? 'an agent'}; labelled none (${details.kind})${verdict}`;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=DiscoveryLabelMatchOracle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DiscoveryLabelMatchOracle.js","sourceRoot":"","sources":["../../src/oracles/DiscoveryLabelMatchOracle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EACH,+BAA+B,EAC/B,2BAA2B,EAI9B,MAAM,kCAAkC,CAAC;AAE1C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,yBAAyB;IAAtC;QACa,SAAI,GAAG,uBAAuB,CAAC;IA2B5C,CAAC;IAzBG,KAAK,CAAC,QAAQ,CAAC,KAAkB,EAAE,OAAqB;QACpD,MAAM,QAAQ,GAAG,2BAA2B,CAAC,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAC7E,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC,MAAM,CAAC,yCAAyC,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACpG,CAAC;QACD,MAAM,MAAM,GAAG,+BAA+B,CAAC,SAAS,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAC7E,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC,MAAM,CAAC,2CAA2C,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACpG,CAAC;QACD,MAAM,OAAO,GAAG,iBAAiB,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9D,IAAI,OAAO,CAAC,OAAO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AAC,UAAU;QAC7B,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,IAAI,IAAI;QAClD,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,KAAK,IAAI;YAChD,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,IAAI,UAAU,CAAC,MAAM,CAAC,aAAa,EAAE,eAAe,CAAC;YAC7E,CAAC,CAAC,MAAM,CAAC,WAAW,KAAK,KAAK;KACrC,CAAC;AACN,CAAC;AAED,4BAA4B;AAC5B,SAAS,QAAQ,CAAC,OAAmC;IACjD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC;IACtD,IAAI,OAAO,CAAC,KAAK,KAAK,OAAO,EAAE,CAAC;QAC5B,OAAO,SAAS,OAAO,CAAC,aAAa,IAAI,UAAU,cAAc,OAAO,CAAC,eAAe,GAAG,OAAO,EAAE,CAAC;IACzG,CAAC;IACD,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,mBAAmB,IAAI,OAAO,CAAC,aAAa,IAAI,UAAU,oBAAoB,OAAO,CAAC,IAAI,IAAI,OAAO,EAAE,CAAC;AAC9J,CAAC"}
|
|
@@ -4,45 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { IOracle } from './IOracle.js';
|
|
6
6
|
import { OracleInput, OracleConfig, OracleResult } from '../types.js';
|
|
7
|
-
/**
|
|
8
|
-
* LLM Judge Oracle.
|
|
9
|
-
*
|
|
10
|
-
* Uses an LLM to evaluate output quality based on custom criteria.
|
|
11
|
-
* Provides semantic evaluation beyond deterministic checks.
|
|
12
|
-
*
|
|
13
|
-
* Configuration:
|
|
14
|
-
* - criteria: Array of validation criteria (required)
|
|
15
|
-
* - model: Model to use for judging (default: from prompt or default model)
|
|
16
|
-
* - temperature: Temperature for LLM (default: 0.1 for consistency)
|
|
17
|
-
* - promptTemplate: Custom prompt template (optional, uses default if not provided)
|
|
18
|
-
* - strictMode: Require all criteria to pass (default: false, uses weighted scoring)
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* const oracle = new LLMJudgeOracle();
|
|
23
|
-
* const result = await oracle.evaluate({
|
|
24
|
-
* actualOutput: { response: 'Sales by region report created successfully' },
|
|
25
|
-
* expectedOutput: {
|
|
26
|
-
* judgeValidationCriteria: [
|
|
27
|
-
* 'Response accurately answers the user\'s question',
|
|
28
|
-
* 'Response includes actionable information',
|
|
29
|
-
* 'Response is professional and clear'
|
|
30
|
-
* ]
|
|
31
|
-
* },
|
|
32
|
-
* contextUser
|
|
33
|
-
* }, {
|
|
34
|
-
* model: 'claude-sonnet-4',
|
|
35
|
-
* temperature: 0.1
|
|
36
|
-
* });
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
7
|
export declare class LLMJudgeOracle implements IOracle {
|
|
40
8
|
readonly type = "llm-judge";
|
|
41
|
-
/**
|
|
42
|
-
* Default prompt template for LLM judge.
|
|
43
|
-
* @private
|
|
44
|
-
*/
|
|
45
|
-
private readonly defaultPromptTemplate;
|
|
46
9
|
/**
|
|
47
10
|
* Evaluate output using LLM judge.
|
|
48
11
|
*
|
|
@@ -51,15 +14,7 @@ export declare class LLMJudgeOracle implements IOracle {
|
|
|
51
14
|
* @returns Oracle result with LLM judgment
|
|
52
15
|
*/
|
|
53
16
|
evaluate(input: OracleInput, config: OracleConfig): Promise<OracleResult>;
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
* @private
|
|
57
|
-
*/
|
|
58
|
-
private buildPrompt;
|
|
59
|
-
/**
|
|
60
|
-
* Parse LLM judgment response.
|
|
61
|
-
* @private
|
|
62
|
-
*/
|
|
63
|
-
private parseJudgment;
|
|
17
|
+
/** A failed result with this message and a score of 0. */
|
|
18
|
+
private failed;
|
|
64
19
|
}
|
|
65
20
|
//# sourceMappingURL=LLMJudgeOracle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LLMJudgeOracle.d.ts","sourceRoot":"","sources":["../../src/oracles/LLMJudgeOracle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"LLMJudgeOracle.d.ts","sourceRoot":"","sources":["../../src/oracles/LLMJudgeOracle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAoEnE,qBAAa,cAAe,YAAW,OAAO;IAC1C,QAAQ,CAAC,IAAI,eAAe;IAE5B;;;;;;OAMG;IACG,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAiE/E,0DAA0D;IAC1D,OAAO,CAAC,MAAM;CAGjB"}
|
|
@@ -2,21 +2,33 @@
|
|
|
2
2
|
* @fileoverview LLM Judge oracle implementation
|
|
3
3
|
* @module @memberjunction/testing-engine
|
|
4
4
|
*/
|
|
5
|
+
import { BuildJudgeTrace, ReadJudgeCriteria, ReadJudgeTimeoutMS } from './judge-trace.js';
|
|
6
|
+
import { InlineOracleResult, InlineVersion, ScoreInline } from './inline-rubric.js';
|
|
5
7
|
import { AIPromptParams } from '@memberjunction/ai-core-plus';
|
|
6
|
-
import { AIPromptRunner } from '@memberjunction/ai-prompts';
|
|
7
8
|
import { AIEngine } from '@memberjunction/aiengine';
|
|
9
|
+
import { AIPromptRunner } from '@memberjunction/ai-prompts';
|
|
10
|
+
import { RenderRubricEvaluatorPrompt } from '@memberjunction/rubrics';
|
|
11
|
+
/** The prompt whose model selection this judge uses. The rendered rubric text is the user message. */
|
|
12
|
+
const RUBRIC_EVALUATOR_PROMPT = 'Rubric Evaluator';
|
|
8
13
|
/**
|
|
9
14
|
* LLM Judge Oracle.
|
|
10
15
|
*
|
|
11
16
|
* Uses an LLM to evaluate output quality based on custom criteria.
|
|
12
17
|
* Provides semantic evaluation beyond deterministic checks.
|
|
13
18
|
*
|
|
19
|
+
* Criteria come from `expectedOutput.judgeValidationCriteria`, or else from `config.criteria`. Each is
|
|
20
|
+
* a string or `{ "criterion": "...", "weight": 2 }`, as for {@link DecisionJudgeOracle}. The weight
|
|
21
|
+
* is the leaf weight. A criterion the model does not answer stays unanswered. Malformed criteria fail
|
|
22
|
+
* the oracle without a call.
|
|
23
|
+
*
|
|
14
24
|
* Configuration:
|
|
15
25
|
* - criteria: Array of validation criteria (required)
|
|
16
|
-
* - model: Model
|
|
26
|
+
* - model: Model name or API name. When set, that model is required. Otherwise the Rubric Evaluator prompt selects one.
|
|
17
27
|
* - temperature: Temperature for LLM (default: 0.1 for consistency)
|
|
18
28
|
* - promptTemplate: Custom prompt template (optional, uses default if not provided)
|
|
19
29
|
* - strictMode: Require all criteria to pass (default: false, uses weighted scoring)
|
|
30
|
+
* - timeoutMS: How long to wait for each judge model call, in milliseconds (default: 120000, two
|
|
31
|
+
* minutes). A call that runs over fails the oracle.
|
|
20
32
|
*
|
|
21
33
|
* @example
|
|
22
34
|
* ```typescript
|
|
@@ -37,42 +49,28 @@ import { AIEngine } from '@memberjunction/aiengine';
|
|
|
37
49
|
* });
|
|
38
50
|
* ```
|
|
39
51
|
*/
|
|
52
|
+
function answersFromModel(raw, criteria) {
|
|
53
|
+
const parsed = typeof raw === 'string' ? JSON.parse(raw) : raw;
|
|
54
|
+
const decisions = parsed?.decisions ?? [];
|
|
55
|
+
const scores = parsed?.criteriaScores ?? [];
|
|
56
|
+
const answers = [];
|
|
57
|
+
criteria.forEach((text, index) => {
|
|
58
|
+
const decision = decisions.find((item) => item.key === `c${index}` || item.criterion === text);
|
|
59
|
+
const scored = scores.find((item) => item.criterion === text);
|
|
60
|
+
if (!decision && !scored)
|
|
61
|
+
return;
|
|
62
|
+
const met = decision?.level === 'Met' || decision?.met === true || (typeof scored?.score === 'number' && scored.score >= 1);
|
|
63
|
+
answers.push({ index, met, rationale: decision?.rationale ?? scored?.explanation });
|
|
64
|
+
});
|
|
65
|
+
return answers;
|
|
66
|
+
}
|
|
67
|
+
/** Input, expected output, and actual output, inside the template's one untrusted fence. */
|
|
68
|
+
function judgeSubject(trace) {
|
|
69
|
+
return ['Input:', trace.Input ?? '', '', 'Expected:', trace.Expected ?? '', '', 'Actual:', trace.Actual ?? ''].join('\n');
|
|
70
|
+
}
|
|
40
71
|
export class LLMJudgeOracle {
|
|
41
72
|
constructor() {
|
|
42
73
|
this.type = 'llm-judge';
|
|
43
|
-
/**
|
|
44
|
-
* Default prompt template for LLM judge.
|
|
45
|
-
* @private
|
|
46
|
-
*/
|
|
47
|
-
this.defaultPromptTemplate = `You are an expert AI evaluator. Your task is to judge whether an AI agent's output meets the specified validation criteria.
|
|
48
|
-
|
|
49
|
-
**Input:**
|
|
50
|
-
{{input}}
|
|
51
|
-
|
|
52
|
-
**Expected Output Requirements:**
|
|
53
|
-
{{expected}}
|
|
54
|
-
|
|
55
|
-
**Actual Output:**
|
|
56
|
-
{{actual}}
|
|
57
|
-
|
|
58
|
-
**Validation Criteria:**
|
|
59
|
-
{{criteria}}
|
|
60
|
-
|
|
61
|
-
**Instructions:**
|
|
62
|
-
For each criterion, evaluate whether the actual output satisfies it. Provide:
|
|
63
|
-
1. A score from 0.0 to 1.0 for each criterion
|
|
64
|
-
2. A brief explanation for each score
|
|
65
|
-
3. An overall assessment
|
|
66
|
-
|
|
67
|
-
Respond in JSON format:
|
|
68
|
-
{
|
|
69
|
-
"criteriaScores": [
|
|
70
|
-
{ "criterion": "...", "score": 0.0-1.0, "explanation": "..." }
|
|
71
|
-
],
|
|
72
|
-
"overallScore": 0.0-1.0,
|
|
73
|
-
"overallAssessment": "...",
|
|
74
|
-
"passed": true/false
|
|
75
|
-
}`;
|
|
76
74
|
}
|
|
77
75
|
/**
|
|
78
76
|
* Evaluate output using LLM judge.
|
|
@@ -83,132 +81,65 @@ Respond in JSON format:
|
|
|
83
81
|
*/
|
|
84
82
|
async evaluate(input, config) {
|
|
85
83
|
try {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const criteria = input.expectedOutput?.judgeValidationCriteria ||
|
|
90
|
-
config.criteria;
|
|
91
|
-
if (!criteria || criteria.length === 0) {
|
|
92
|
-
return {
|
|
93
|
-
oracleType: this.type,
|
|
94
|
-
passed: false,
|
|
95
|
-
score: 0,
|
|
96
|
-
message: 'No validation criteria provided'
|
|
97
|
-
};
|
|
84
|
+
const criteria = ReadJudgeCriteria(input, config);
|
|
85
|
+
if (!criteria.Success) {
|
|
86
|
+
return this.failed(criteria.ErrorMessage);
|
|
98
87
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
88
|
+
const timeout = ReadJudgeTimeoutMS(config);
|
|
89
|
+
if (!timeout.Success) {
|
|
90
|
+
return this.failed(timeout.ErrorMessage);
|
|
91
|
+
}
|
|
92
|
+
const trace = BuildJudgeTrace(input);
|
|
93
|
+
const leaves = criteria.Value.map(item => ({ text: item.Criterion, weight: item.Weight }));
|
|
94
|
+
const texts = leaves.map(leaf => leaf.text);
|
|
95
|
+
const strict = config.strictMode === true;
|
|
96
|
+
const passThreshold = typeof config.passThreshold === 'number' ? config.passThreshold : 0.7;
|
|
97
|
+
const version = InlineVersion(leaves, strict, passThreshold);
|
|
98
|
+
const rendered = RenderRubricEvaluatorPrompt(version, { text: judgeSubject(trace) }, 'SinglePass');
|
|
99
|
+
await AIEngine.Instance.Config(false, input.contextUser);
|
|
100
|
+
const prompt = AIEngine.Instance.Prompts.find(item => item.Name === RUBRIC_EVALUATOR_PROMPT);
|
|
101
|
+
if (!prompt) {
|
|
102
|
+
return this.failed('The Rubric Evaluator prompt is not configured.');
|
|
108
103
|
}
|
|
109
|
-
// Prepare data for prompt template
|
|
110
|
-
const inputDefinition = input.test.InputDefinition ?
|
|
111
|
-
(typeof input.test.InputDefinition === 'string' ?
|
|
112
|
-
JSON.parse(input.test.InputDefinition) :
|
|
113
|
-
input.test.InputDefinition) :
|
|
114
|
-
{};
|
|
115
|
-
const promptData = {
|
|
116
|
-
input: JSON.stringify(inputDefinition, null, 2),
|
|
117
|
-
expected: JSON.stringify(input.expectedOutput, null, 2),
|
|
118
|
-
actual: JSON.stringify(input.actualOutput, null, 2),
|
|
119
|
-
criteria: criteria.map((c, i) => `${i + 1}. ${c}`).join('\n')
|
|
120
|
-
};
|
|
121
|
-
// Execute LLM judgment
|
|
122
104
|
const promptParams = new AIPromptParams();
|
|
123
|
-
promptParams.prompt =
|
|
124
|
-
promptParams.
|
|
105
|
+
promptParams.prompt = prompt;
|
|
106
|
+
promptParams.systemPromptOverride = rendered;
|
|
107
|
+
// The Rubric Evaluator record stores TemplateText and may have no TemplateID. A user
|
|
108
|
+
// message still reaches the model in that case; an override alone would not.
|
|
109
|
+
promptParams.templateMessageRole = 'none';
|
|
110
|
+
promptParams.conversationMessages = [{ role: 'user', content: rendered }];
|
|
111
|
+
promptParams.data = { criteria: texts, input: trace.Input, expected: trace.Expected, actual: trace.Actual, model: config.model };
|
|
125
112
|
promptParams.contextUser = input.contextUser;
|
|
113
|
+
promptParams.timeoutMS = timeout.Value;
|
|
114
|
+
const requestedModel = typeof config.model === 'string' ? config.model.trim() : '';
|
|
115
|
+
if (requestedModel) {
|
|
116
|
+
const model = AIEngine.Instance.Models.find(item => item.Name === requestedModel || item.APIName === requestedModel);
|
|
117
|
+
if (!model) {
|
|
118
|
+
return this.failed(`Judge model "${requestedModel}" was not found.`);
|
|
119
|
+
}
|
|
120
|
+
promptParams.override = { modelId: model.ID };
|
|
121
|
+
}
|
|
126
122
|
const runner = new AIPromptRunner();
|
|
127
123
|
const result = await runner.ExecutePrompt(promptParams);
|
|
128
124
|
if (!result.success) {
|
|
129
|
-
return {
|
|
130
|
-
oracleType: this.type,
|
|
131
|
-
passed: false,
|
|
132
|
-
score: 0,
|
|
133
|
-
message: `LLM judgment failed: ${result.errorMessage}`
|
|
134
|
-
};
|
|
125
|
+
return this.failed(`LLM judgment failed: ${result.errorMessage}`);
|
|
135
126
|
}
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return
|
|
144
|
-
oracleType: this.type,
|
|
145
|
-
passed,
|
|
146
|
-
score: judgment.overallScore,
|
|
147
|
-
message: judgment.overallAssessment,
|
|
148
|
-
details: {
|
|
149
|
-
criteriaScores: judgment.criteriaScores,
|
|
150
|
-
llmModel: config.model || 'default',
|
|
151
|
-
llmCost: result.cost
|
|
152
|
-
}
|
|
153
|
-
};
|
|
127
|
+
const answers = answersFromModel(result.result, texts);
|
|
128
|
+
const scored = ScoreInline(leaves, answers, { strict, passThreshold });
|
|
129
|
+
const evidence = [];
|
|
130
|
+
for (const answer of answers)
|
|
131
|
+
evidence[answer.index] = answer.rationale;
|
|
132
|
+
const report = InlineOracleResult(texts, scored, evidence);
|
|
133
|
+
report.details = { ...report.details, llmModel: config.model || 'default', llmCost: result.cost };
|
|
134
|
+
return report;
|
|
154
135
|
}
|
|
155
136
|
catch (error) {
|
|
156
|
-
return {
|
|
157
|
-
oracleType: this.type,
|
|
158
|
-
passed: false,
|
|
159
|
-
score: 0,
|
|
160
|
-
message: `LLM judge error: ${error.message}`
|
|
161
|
-
};
|
|
137
|
+
return this.failed(`LLM judge error: ${error.message}`);
|
|
162
138
|
}
|
|
163
139
|
}
|
|
164
|
-
/**
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
*/
|
|
168
|
-
buildPrompt(input, criteria, customTemplate) {
|
|
169
|
-
const template = customTemplate || this.defaultPromptTemplate;
|
|
170
|
-
// Format input data
|
|
171
|
-
const inputStr = JSON.stringify(input.test.InputDefinition, null, 2);
|
|
172
|
-
const expectedStr = JSON.stringify(input.expectedOutput, null, 2);
|
|
173
|
-
const actualStr = JSON.stringify(input.actualOutput, null, 2);
|
|
174
|
-
const criteriaStr = criteria.map((c, i) => `${i + 1}. ${c}`).join('\n');
|
|
175
|
-
// Replace placeholders. Function replacements throughout: these are test
|
|
176
|
-
// inputs, expected values and actual outputs, all of which routinely
|
|
177
|
-
// contain `$` — and a string replacement would expand `$&`/`` $` ``/`$'`,
|
|
178
|
-
// silently feeding the judge a prompt that differs from the data under
|
|
179
|
-
// test. See issue #3171.
|
|
180
|
-
return template
|
|
181
|
-
.replace('{{input}}', () => inputStr)
|
|
182
|
-
.replace('{{expected}}', () => expectedStr)
|
|
183
|
-
.replace('{{actual}}', () => actualStr)
|
|
184
|
-
.replace('{{criteria}}', () => criteriaStr);
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Parse LLM judgment response.
|
|
188
|
-
* @private
|
|
189
|
-
*/
|
|
190
|
-
parseJudgment(response) {
|
|
191
|
-
try {
|
|
192
|
-
// Try to extract JSON from response
|
|
193
|
-
const jsonMatch = response.match(/\{[\s\S]*\}/);
|
|
194
|
-
if (!jsonMatch) {
|
|
195
|
-
throw new Error('No JSON found in LLM response');
|
|
196
|
-
}
|
|
197
|
-
const parsed = JSON.parse(jsonMatch[0]);
|
|
198
|
-
return {
|
|
199
|
-
criteriaScores: parsed.criteriaScores || [],
|
|
200
|
-
overallScore: parsed.overallScore || 0,
|
|
201
|
-
overallAssessment: parsed.overallAssessment || 'No assessment provided'
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
catch (error) {
|
|
205
|
-
// Fallback to simple parsing
|
|
206
|
-
return {
|
|
207
|
-
criteriaScores: [],
|
|
208
|
-
overallScore: 0,
|
|
209
|
-
overallAssessment: `Failed to parse LLM response: ${response.substring(0, 200)}`
|
|
210
|
-
};
|
|
211
|
-
}
|
|
140
|
+
/** A failed result with this message and a score of 0. */
|
|
141
|
+
failed(message) {
|
|
142
|
+
return { oracleType: this.type, passed: false, score: 0, message };
|
|
212
143
|
}
|
|
213
144
|
}
|
|
214
145
|
//# sourceMappingURL=LLMJudgeOracle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LLMJudgeOracle.js","sourceRoot":"","sources":["../../src/oracles/LLMJudgeOracle.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"LLMJudgeOracle.js","sourceRoot":"","sources":["../../src/oracles/LLMJudgeOracle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACvF,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEjF,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAEtE,sGAAsG;AACtG,MAAM,uBAAuB,GAAG,kBAAkB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,SAAS,gBAAgB,CAAC,GAAY,EAAE,QAAkB;IACtD,MAAM,MAAM,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAiM,CAAC;IAC7P,MAAM,SAAS,GAAG,MAAM,EAAE,SAAS,IAAI,EAAE,CAAC;IAC1C,MAAM,MAAM,GAAG,MAAM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