@memberjunction/testing-engine 6.2.0-edge.1 → 6.2.0-edge.3
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 +47 -4
- package/dist/drivers/AgentEvalDriver.d.ts.map +1 -1
- package/dist/drivers/AgentEvalDriver.js +180 -24
- 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 -10
- package/dist/drivers/PromptEvalDriver.js.map +1 -1
- package/dist/drivers/RubricCalibrationTestDriver.d.ts +40 -0
- package/dist/drivers/RubricCalibrationTestDriver.d.ts.map +1 -0
- package/dist/drivers/RubricCalibrationTestDriver.js +194 -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/control-tool-map.d.ts +23 -0
- package/dist/drivers/control-tool-map.d.ts.map +1 -0
- package/dist/drivers/control-tool-map.js +31 -0
- package/dist/drivers/control-tool-map.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 +14 -4
- package/dist/engine/TestEngine.js.map +1 -1
- package/dist/eval/decision.d.ts +2 -0
- package/dist/eval/decision.d.ts.map +1 -1
- package/dist/eval/decision.js +20 -0
- package/dist/eval/decision.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/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 +85 -155
- package/dist/oracles/LLMJudgeOracle.js.map +1 -1
- package/dist/oracles/RubricOracle.d.ts +53 -0
- package/dist/oracles/RubricOracle.d.ts.map +1 -0
- package/dist/oracles/RubricOracle.js +78 -0
- package/dist/oracles/RubricOracle.js.map +1 -0
- package/dist/oracles/TraceValidatorOracle.js +1 -1
- package/dist/oracles/TraceValidatorOracle.js.map +1 -1
- 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 +76 -0
- package/dist/oracles/rubric-resolution.d.ts.map +1 -0
- package/dist/oracles/rubric-resolution.js +138 -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/result-formatter.d.ts +5 -0
- package/dist/utils/result-formatter.d.ts.map +1 -1
- package/dist/utils/result-formatter.js +8 -2
- package/dist/utils/result-formatter.js.map +1 -1
- package/package.json +12 -10
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import '@memberjunction/ai-agents';
|
|
2
|
+
import { ProviderRubricEngine } from '@memberjunction/rubrics';
|
|
3
|
+
/**
|
|
4
|
+
* Judges a test run with a rubric. The subject is the test run and the context
|
|
5
|
+
* is the test. A host can inject the engine; otherwise the call uses the input provider.
|
|
6
|
+
* The oracle config's `evaluator` is an evaluator selection (IRubricEvaluatorSelection);
|
|
7
|
+
* LLM SinglePass when it is absent.
|
|
8
|
+
*/
|
|
9
|
+
export class RubricOracle {
|
|
10
|
+
constructor(engine) {
|
|
11
|
+
this.engine = engine;
|
|
12
|
+
this.type = 'rubric';
|
|
13
|
+
}
|
|
14
|
+
async evaluate(input, config) {
|
|
15
|
+
const settings = config;
|
|
16
|
+
const provider = input.provider;
|
|
17
|
+
const engine = this.engine ?? (provider ? ProviderRubricEngine(provider, input.contextUser) : undefined);
|
|
18
|
+
if (!engine) {
|
|
19
|
+
return { oracleType: this.type, passed: false, score: 0, message: 'No rubric engine is configured.' };
|
|
20
|
+
}
|
|
21
|
+
if (!input.testRunId) {
|
|
22
|
+
return { oracleType: this.type, passed: false, score: 0, message: 'subject not found or not readable' };
|
|
23
|
+
}
|
|
24
|
+
const result = await engine.EvaluateRecord({
|
|
25
|
+
rubricId: settings.rubricId,
|
|
26
|
+
versionId: settings.rubricVersionId,
|
|
27
|
+
subjectEntityName: 'MJ: Test Runs',
|
|
28
|
+
subjectRecordId: input.testRunId,
|
|
29
|
+
contextEntityName: 'MJ: Tests',
|
|
30
|
+
contextRecordId: input.test?.ID,
|
|
31
|
+
passThreshold: settings.passThreshold ?? null,
|
|
32
|
+
evaluatorConfig: settings.evaluator,
|
|
33
|
+
content: RubricOracleContent(input),
|
|
34
|
+
});
|
|
35
|
+
const passed = result.outcome === 'Passed' || result.outcome === 'Scored';
|
|
36
|
+
const label = settings.versionLabel ?? settings.rubricVersionId ?? 'published';
|
|
37
|
+
const shown = result.displayScore ?? result.score ?? 0;
|
|
38
|
+
return {
|
|
39
|
+
oracleType: this.type,
|
|
40
|
+
passed,
|
|
41
|
+
score: result.score ?? 0,
|
|
42
|
+
message: `${settings.rubricId ?? 'rubric'} v${label}: ${result.outcome} (${shown})`,
|
|
43
|
+
details: {
|
|
44
|
+
RubricEvaluationID: result.evaluationId,
|
|
45
|
+
RubricVersionLabel: label,
|
|
46
|
+
Outcome: result.outcome,
|
|
47
|
+
Criteria: result.criteria.map(item => ({
|
|
48
|
+
Key: item.key,
|
|
49
|
+
Name: item.key,
|
|
50
|
+
NormalizedScore: item.normalizedScore,
|
|
51
|
+
Rationale: item.rationale,
|
|
52
|
+
})),
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/** The output the driver already has. The test-run row is not saved until later. */
|
|
58
|
+
export function RubricOracleContent(input) {
|
|
59
|
+
let text = typeof input.actualOutput === 'string' ? input.actualOutput : undefined;
|
|
60
|
+
if (!text && input.actualOutput && typeof input.actualOutput === 'object') {
|
|
61
|
+
const obj = input.actualOutput;
|
|
62
|
+
if (typeof obj.message === 'string')
|
|
63
|
+
text = obj.message;
|
|
64
|
+
else if (typeof obj.response === 'string')
|
|
65
|
+
text = obj.response;
|
|
66
|
+
else if (typeof obj.text === 'string')
|
|
67
|
+
text = obj.text;
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
text,
|
|
71
|
+
data: {
|
|
72
|
+
input: input.test?.InputDefinition,
|
|
73
|
+
expectedOutput: input.expectedOutput,
|
|
74
|
+
actualOutput: input.actualOutput,
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=RubricOracle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RubricOracle.js","sourceRoot":"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I,CAAC,IAAI,IAAI,KAAK,CAAC,YAAY,IAAI,OAAO,KAAK,CAAC,YAAY,KAAK,QAAQ,EAAE,CAAC;QACxE,MAAM,GAAG,GAAG,KAAK,CAAC,YAAuC,CAAC;QAC1D,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ;YAAE,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC;aACnD,IAAI,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ;YAAE,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC;aAC1D,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ;YAAE,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IAC3D,CAAC;IACD,OAAO;QACH,IAAI;QACJ,IAAI,EAAE;YACF,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,eAAe;YAClC,cAAc,EAAE,KAAK,CAAC,cAAc;YACpC,YAAY,EAAE,KAAK,CAAC,YAAY;SACnC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -67,7 +67,7 @@ export class TraceValidatorOracle {
|
|
|
67
67
|
const stepsResult = await rv.RunView({
|
|
68
68
|
EntityName: 'MJ: AI Agent Run Steps',
|
|
69
69
|
ExtraFilter: `AgentRunID='${agentRun.ID}'`,
|
|
70
|
-
OrderBy: '
|
|
70
|
+
OrderBy: 'StepNumber ASC',
|
|
71
71
|
ResultType: 'entity_object'
|
|
72
72
|
}, input.contextUser);
|
|
73
73
|
if (!stepsResult.Success) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TraceValidatorOracle.js","sourceRoot":"","sources":["../../src/oracles/TraceValidatorOracle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAK/C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,oBAAoB;IAAjC;QACa,SAAI,GAAG,iBAAiB,CAAC;IAwItC,CAAC;IAtIG;;;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C;IACL,CAAC;CACJ"}
|
package/dist/oracles/index.d.ts
CHANGED
|
@@ -6,7 +6,12 @@ export * from './SchemaValidatorOracle.js';
|
|
|
6
6
|
export * from './TraceValidatorOracle.js';
|
|
7
7
|
export * from './TraceSubAgentValidatorOracle.js';
|
|
8
8
|
export * from './AgentDecisionOracle.js';
|
|
9
|
+
export * from './DecisionLabelMatchOracle.js';
|
|
10
|
+
export * from './DiscoveryLabelMatchOracle.js';
|
|
9
11
|
export * from './LLMJudgeOracle.js';
|
|
12
|
+
export * from './DecisionJudgeOracle.js';
|
|
10
13
|
export * from './ExactMatchOracle.js';
|
|
11
14
|
export * from './SQLValidatorOracle.js';
|
|
15
|
+
export * from './RubricOracle.js';
|
|
16
|
+
export * from './rubric-resolution.js';
|
|
12
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/oracles/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/oracles/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC"}
|
package/dist/oracles/index.js
CHANGED
|
@@ -6,7 +6,12 @@ export * from './SchemaValidatorOracle.js';
|
|
|
6
6
|
export * from './TraceValidatorOracle.js';
|
|
7
7
|
export * from './TraceSubAgentValidatorOracle.js';
|
|
8
8
|
export * from './AgentDecisionOracle.js';
|
|
9
|
+
export * from './DecisionLabelMatchOracle.js';
|
|
10
|
+
export * from './DiscoveryLabelMatchOracle.js';
|
|
9
11
|
export * from './LLMJudgeOracle.js';
|
|
12
|
+
export * from './DecisionJudgeOracle.js';
|
|
10
13
|
export * from './ExactMatchOracle.js';
|
|
11
14
|
export * from './SQLValidatorOracle.js';
|
|
15
|
+
export * from './RubricOracle.js';
|
|
16
|
+
export * from './rubric-resolution.js';
|
|
12
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/oracles/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/oracles/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type RubricScoreResult, type RubricVersionSnapshot } from '@memberjunction/rubrics-base';
|
|
2
|
+
import type { OracleResult } from '../types.js';
|
|
3
|
+
/** One binary leaf. Weight defaults to 1. A weight of 0 is kept and does not enter the weighted mean. */
|
|
4
|
+
export type InlineCriterion = {
|
|
5
|
+
text: string;
|
|
6
|
+
weight?: number;
|
|
7
|
+
};
|
|
8
|
+
/** A binary inline rubric. Met = 1 and Not met = 0. There is no version row. */
|
|
9
|
+
export declare function InlineVersion(criteria: Array<string | InlineCriterion>, strict: boolean, passThreshold: number): RubricVersionSnapshot;
|
|
10
|
+
export declare function ScoreInline(criteria: Array<string | InlineCriterion>, answers: {
|
|
11
|
+
index: number;
|
|
12
|
+
met: boolean;
|
|
13
|
+
rationale?: string;
|
|
14
|
+
}[], options: {
|
|
15
|
+
strict?: boolean;
|
|
16
|
+
passThreshold?: number;
|
|
17
|
+
}): RubricScoreResult;
|
|
18
|
+
/** Computer Use verdicts, reported in the same inline details shape. Not stored as a RubricEvaluation. */
|
|
19
|
+
export declare function InlineOracleFromVerdicts(verdicts: {
|
|
20
|
+
criterion: string;
|
|
21
|
+
met: boolean;
|
|
22
|
+
evidence?: string;
|
|
23
|
+
}[], passThreshold?: number): OracleResult;
|
|
24
|
+
export declare function InlineOracleResult(criteria: string[], scored: RubricScoreResult, evidence?: (string | undefined)[]): OracleResult;
|
|
25
|
+
//# sourceMappingURL=inline-rubric.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline-rubric.d.ts","sourceRoot":"","sources":["../../src/oracles/inline-rubric.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,iBAAiB,EAAE,KAAK,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACjH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,yGAAyG;AACzG,MAAM,MAAM,eAAe,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAMhE,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,GAAG,eAAe,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,GAAG,qBAAqB,CAmCtI;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,GAAG,eAAe,CAAC,EAAE,OAAO,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,EAAE,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,iBAAiB,CAU/M;AAED,0GAA0G;AAC1G,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,EAAE,aAAa,SAAM,GAAG,YAAY,CAO9I;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,iBAAiB,EAAE,QAAQ,GAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAO,GAAG,YAAY,CAmBrI"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { RubricScoring } from '@memberjunction/rubrics-base';
|
|
2
|
+
function inlineLeaves(criteria) {
|
|
3
|
+
return criteria.map(item => typeof item === 'string' ? { text: item, weight: 1 } : { text: item.text, weight: item.weight ?? 1 });
|
|
4
|
+
}
|
|
5
|
+
/** A binary inline rubric. Met = 1 and Not met = 0. There is no version row. */
|
|
6
|
+
export function InlineVersion(criteria, strict, passThreshold) {
|
|
7
|
+
const leaves = inlineLeaves(criteria);
|
|
8
|
+
return {
|
|
9
|
+
id: 'inline',
|
|
10
|
+
rubricId: 'inline',
|
|
11
|
+
notApplicablePolicy: 'NotAllowed',
|
|
12
|
+
minimumCompleteness: 1,
|
|
13
|
+
passThreshold,
|
|
14
|
+
scoreDisplayMin: 0,
|
|
15
|
+
scoreDisplayMax: 1,
|
|
16
|
+
nodes: leaves.map((leaf, index) => ({
|
|
17
|
+
id: `c${index}`,
|
|
18
|
+
key: `c${index}`,
|
|
19
|
+
name: leaf.text,
|
|
20
|
+
nodeType: 'Criterion',
|
|
21
|
+
scaleId: 'met',
|
|
22
|
+
weight: leaf.weight,
|
|
23
|
+
isAdvisory: false,
|
|
24
|
+
isGate: strict,
|
|
25
|
+
gateMinimumScore: strict ? 1 : null,
|
|
26
|
+
evidenceRequired: false,
|
|
27
|
+
rationaleRequired: false,
|
|
28
|
+
sequence: index,
|
|
29
|
+
})),
|
|
30
|
+
scales: [{
|
|
31
|
+
id: 'met',
|
|
32
|
+
scaleType: 'Levels',
|
|
33
|
+
higherIsBetter: true,
|
|
34
|
+
levels: [
|
|
35
|
+
{ id: 'not-met', label: 'Not met', value: 0, normalizedValue: 0, sequence: 0 },
|
|
36
|
+
{ id: 'met', label: 'Met', value: 1, normalizedValue: 1, sequence: 1 },
|
|
37
|
+
],
|
|
38
|
+
}],
|
|
39
|
+
bands: [],
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function ScoreInline(criteria, answers, options) {
|
|
43
|
+
const version = InlineVersion(criteria, options.strict === true, options.passThreshold ?? 0.7);
|
|
44
|
+
return RubricScoring.Compute({
|
|
45
|
+
version,
|
|
46
|
+
answers: answers.map(answer => ({
|
|
47
|
+
criterionId: `c${answer.index}`,
|
|
48
|
+
scaleLevelId: answer.met ? 'met' : 'not-met',
|
|
49
|
+
rationale: answer.rationale,
|
|
50
|
+
})),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/** Computer Use verdicts, reported in the same inline details shape. Not stored as a RubricEvaluation. */
|
|
54
|
+
export function InlineOracleFromVerdicts(verdicts, passThreshold = 0.7) {
|
|
55
|
+
const scored = ScoreInline(verdicts.map(verdict => verdict.criterion), verdicts.map((verdict, index) => ({
|
|
56
|
+
index,
|
|
57
|
+
met: verdict.met,
|
|
58
|
+
rationale: verdict.evidence,
|
|
59
|
+
})), { passThreshold });
|
|
60
|
+
return InlineOracleResult(verdicts.map(verdict => verdict.criterion), scored, verdicts.map(verdict => verdict.evidence));
|
|
61
|
+
}
|
|
62
|
+
export function InlineOracleResult(criteria, scored, evidence = []) {
|
|
63
|
+
const passed = scored.outcome === 'Passed';
|
|
64
|
+
return {
|
|
65
|
+
oracleType: 'llm-judge',
|
|
66
|
+
passed,
|
|
67
|
+
score: scored.normalizedScore ?? 0,
|
|
68
|
+
message: `inline: ${scored.outcome} (${scored.normalizedScore ?? 0})`,
|
|
69
|
+
details: {
|
|
70
|
+
inline: true,
|
|
71
|
+
Outcome: scored.outcome,
|
|
72
|
+
Criteria: scored.nodes.map((node, index) => ({
|
|
73
|
+
Key: node.key,
|
|
74
|
+
Name: criteria[index] ?? node.key,
|
|
75
|
+
NormalizedScore: node.normalizedScore,
|
|
76
|
+
GateFailed: node.gateFailed,
|
|
77
|
+
Rationale: evidence[index],
|
|
78
|
+
})),
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=inline-rubric.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline-rubric.js","sourceRoot":"","sources":["../../src/oracles/inline-rubric.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAsD,MAAM,8BAA8B,CAAC;AAMjH,SAAS,YAAY,CAAC,QAAyC;IAC3D,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EA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AAC,SAAS,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC7H,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,QAAkB,EAAE,MAAyB,EAAE,WAAmC,EAAE;IACnH,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,KAAK,QAAQ,CAAC;IAC3C,OAAO;QACH,UAAU,EAAE,WAAW;QACvB,MAAM;QACN,KAAK,EAAE,MAAM,CAAC,eAAe,IAAI,CAAC;QAClC,OAAO,EAAE,WAAW,MAAM,CAAC,OAAO,KAAK,MAAM,CAAC,eAAe,IAAI,CAAC,GAAG;QACrE,OAAO,EAAE;YACL,MAAM,EAAE,IAAI;YACZ,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;gBACzC,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,GAAG;gBACjC,eAAe,EAAE,IAAI,CAAC,eAAe;gBACrC,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC;aAC7B,CAAC,CAAC;SACN;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The trace and criteria the judge oracles evaluate
|
|
3
|
+
* @module @memberjunction/testing-engine
|
|
4
|
+
*
|
|
5
|
+
* `LLMJudgeOracle` and `DecisionJudgeOracle` judge the same trace against the same criteria, so a
|
|
6
|
+
* test can run both side by side. Both read them, and their model-call timeout, through these
|
|
7
|
+
* helpers, so both accept, and reject, exactly the same criteria and settings.
|
|
8
|
+
*/
|
|
9
|
+
import { OracleInput, OracleConfig } from '../types.js';
|
|
10
|
+
/**
|
|
11
|
+
* The trace a judge evaluates, as pretty-printed JSON. Each part is `JSON.stringify`'s output, so it
|
|
12
|
+
* is `undefined` when the value it renders is `undefined`.
|
|
13
|
+
*/
|
|
14
|
+
export interface JudgeTrace {
|
|
15
|
+
/** The test's input definition, parsed first when it is stored as a JSON string; `{}` when it has none. */
|
|
16
|
+
Input: string | undefined;
|
|
17
|
+
/** The test's expected output. */
|
|
18
|
+
Expected: string | undefined;
|
|
19
|
+
/** The output the test produced. */
|
|
20
|
+
Actual: string | undefined;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* One criterion a judge scores against. A test states it as a string, or as
|
|
24
|
+
* `{ "criterion": "...", "weight": 2 }`.
|
|
25
|
+
*/
|
|
26
|
+
export interface JudgeCriterion {
|
|
27
|
+
/** What the output must satisfy, as the test states it. */
|
|
28
|
+
Criterion: string;
|
|
29
|
+
/** The criterion's weight in a weighted score: a finite number of 0 or more, 1 when the test sets none. */
|
|
30
|
+
Weight: number;
|
|
31
|
+
}
|
|
32
|
+
/** A value read from the test or the oracle config, or the reason it cannot be used. */
|
|
33
|
+
export type JudgeReadResult<T> = {
|
|
34
|
+
Success: true;
|
|
35
|
+
Value: T;
|
|
36
|
+
} | {
|
|
37
|
+
Success: false;
|
|
38
|
+
ErrorMessage: string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* How long a judge waits for each model call when the oracle config sets no `timeoutMS`: two minutes.
|
|
42
|
+
* A judge call is one prompt over one test's trace, so this is generous; it is there so a hung call
|
|
43
|
+
* fails the oracle instead of hanging the test run.
|
|
44
|
+
*/
|
|
45
|
+
export declare const DEFAULT_JUDGE_TIMEOUT_MS = 120000;
|
|
46
|
+
/**
|
|
47
|
+
* Builds the trace a judge evaluates from the oracle input.
|
|
48
|
+
*
|
|
49
|
+
* @param input - The oracle input
|
|
50
|
+
* @returns The input definition, the expected output and the actual output, as JSON
|
|
51
|
+
* @throws SyntaxError when the test's input definition is a string that is not valid JSON
|
|
52
|
+
*/
|
|
53
|
+
export declare function BuildJudgeTrace(input: OracleInput): JudgeTrace;
|
|
54
|
+
/**
|
|
55
|
+
* Reads the criteria a judge scores against: the expected output's `judgeValidationCriteria` when it
|
|
56
|
+
* is set, otherwise the oracle config's `criteria`. Each entry is a non-empty string (weight 1), or
|
|
57
|
+
* an object with a non-empty `criterion` and an optional `weight` that is a finite number of 0 or more.
|
|
58
|
+
* At least one criterion must weigh more than 0.
|
|
59
|
+
*
|
|
60
|
+
* @param input - The oracle input
|
|
61
|
+
* @param config - The oracle config
|
|
62
|
+
* @returns The criteria, in the order the test lists them, or the reason they cannot be read: there
|
|
63
|
+
* are none, the value is not an array, an entry is malformed, or every weight is 0
|
|
64
|
+
*/
|
|
65
|
+
export declare function ReadJudgeCriteria(input: OracleInput, config: OracleConfig): JudgeReadResult<JudgeCriterion[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Reads how long a judge waits for each model call from the oracle config's `timeoutMS`. The runner
|
|
68
|
+
* applies it to each model call as `AIPromptParams.timeoutMS`, so a failover to another model gets a
|
|
69
|
+
* fresh budget, and a call that runs over fails.
|
|
70
|
+
*
|
|
71
|
+
* @param config - The oracle config
|
|
72
|
+
* @returns The timeout in milliseconds, {@link DEFAULT_JUDGE_TIMEOUT_MS} when the config sets none, or
|
|
73
|
+
* the reason the config's value is not a positive, finite number
|
|
74
|
+
*/
|
|
75
|
+
export declare function ReadJudgeTimeoutMS(config: OracleConfig): JudgeReadResult<number>;
|
|
76
|
+
//# sourceMappingURL=judge-trace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"judge-trace.d.ts","sourceRoot":"","sources":["../../src/oracles/judge-trace.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,UAAU;IACvB,2GAA2G;IAC3G,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,kCAAkC;IAClC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,oCAAoC;IACpC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC3B,2DAA2D;IAC3D,SAAS,EAAE,MAAM,CAAC;IAClB,2GAA2G;IAC3G,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,wFAAwF;AACxF,MAAM,MAAM,eAAe,CAAC,CAAC,IACvB;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAC3B;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,SAAU,CAAC;AAEhD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,CAM9D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,GAAG,eAAe,CAAC,cAAc,EAAE,CAAC,CAS7G;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,CAAC,MAAM,CAAC,CAOhF"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The trace and criteria the judge oracles evaluate
|
|
3
|
+
* @module @memberjunction/testing-engine
|
|
4
|
+
*
|
|
5
|
+
* `LLMJudgeOracle` and `DecisionJudgeOracle` judge the same trace against the same criteria, so a
|
|
6
|
+
* test can run both side by side. Both read them, and their model-call timeout, through these
|
|
7
|
+
* helpers, so both accept, and reject, exactly the same criteria and settings.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* How long a judge waits for each model call when the oracle config sets no `timeoutMS`: two minutes.
|
|
11
|
+
* A judge call is one prompt over one test's trace, so this is generous; it is there so a hung call
|
|
12
|
+
* fails the oracle instead of hanging the test run.
|
|
13
|
+
*/
|
|
14
|
+
export const DEFAULT_JUDGE_TIMEOUT_MS = 120_000;
|
|
15
|
+
/**
|
|
16
|
+
* Builds the trace a judge evaluates from the oracle input.
|
|
17
|
+
*
|
|
18
|
+
* @param input - The oracle input
|
|
19
|
+
* @returns The input definition, the expected output and the actual output, as JSON
|
|
20
|
+
* @throws SyntaxError when the test's input definition is a string that is not valid JSON
|
|
21
|
+
*/
|
|
22
|
+
export function BuildJudgeTrace(input) {
|
|
23
|
+
return {
|
|
24
|
+
Input: JSON.stringify(readInputDefinition(input), null, 2),
|
|
25
|
+
Expected: JSON.stringify(input.expectedOutput, null, 2),
|
|
26
|
+
Actual: JSON.stringify(input.actualOutput, null, 2),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Reads the criteria a judge scores against: the expected output's `judgeValidationCriteria` when it
|
|
31
|
+
* is set, otherwise the oracle config's `criteria`. Each entry is a non-empty string (weight 1), or
|
|
32
|
+
* an object with a non-empty `criterion` and an optional `weight` that is a finite number of 0 or more.
|
|
33
|
+
* At least one criterion must weigh more than 0.
|
|
34
|
+
*
|
|
35
|
+
* @param input - The oracle input
|
|
36
|
+
* @param config - The oracle config
|
|
37
|
+
* @returns The criteria, in the order the test lists them, or the reason they cannot be read: there
|
|
38
|
+
* are none, the value is not an array, an entry is malformed, or every weight is 0
|
|
39
|
+
*/
|
|
40
|
+
export function ReadJudgeCriteria(input, config) {
|
|
41
|
+
const raw = readExpectedCriteria(input.expectedOutput) || config.criteria;
|
|
42
|
+
if (!raw || (Array.isArray(raw) && raw.length === 0)) {
|
|
43
|
+
return { Success: false, ErrorMessage: 'No validation criteria provided' };
|
|
44
|
+
}
|
|
45
|
+
if (!Array.isArray(raw)) {
|
|
46
|
+
return { Success: false, ErrorMessage: `Validation criteria must be an array of criteria, not a ${typeof raw}` };
|
|
47
|
+
}
|
|
48
|
+
return readCriteriaEntries(raw);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Reads how long a judge waits for each model call from the oracle config's `timeoutMS`. The runner
|
|
52
|
+
* applies it to each model call as `AIPromptParams.timeoutMS`, so a failover to another model gets a
|
|
53
|
+
* fresh budget, and a call that runs over fails.
|
|
54
|
+
*
|
|
55
|
+
* @param config - The oracle config
|
|
56
|
+
* @returns The timeout in milliseconds, {@link DEFAULT_JUDGE_TIMEOUT_MS} when the config sets none, or
|
|
57
|
+
* the reason the config's value is not a positive, finite number
|
|
58
|
+
*/
|
|
59
|
+
export function ReadJudgeTimeoutMS(config) {
|
|
60
|
+
const timeoutMS = config.timeoutMS ?? DEFAULT_JUDGE_TIMEOUT_MS;
|
|
61
|
+
if (typeof timeoutMS !== 'number' || !Number.isFinite(timeoutMS) || timeoutMS <= 0) {
|
|
62
|
+
const shown = typeof timeoutMS === 'number' ? String(timeoutMS) : JSON.stringify(timeoutMS);
|
|
63
|
+
return { Success: false, ErrorMessage: `timeoutMS must be a positive number of milliseconds, not ${shown}` };
|
|
64
|
+
}
|
|
65
|
+
return { Success: true, Value: timeoutMS };
|
|
66
|
+
}
|
|
67
|
+
/** The test's input definition, parsed when it is a JSON string, or `{}` when it has none. */
|
|
68
|
+
function readInputDefinition(input) {
|
|
69
|
+
const definition = input.test.InputDefinition;
|
|
70
|
+
if (!definition) {
|
|
71
|
+
return {};
|
|
72
|
+
}
|
|
73
|
+
return typeof definition === 'string' ? JSON.parse(definition) : definition;
|
|
74
|
+
}
|
|
75
|
+
/** The expected output's `judgeValidationCriteria`, when the expected output is an object. */
|
|
76
|
+
function readExpectedCriteria(expectedOutput) {
|
|
77
|
+
if (typeof expectedOutput !== 'object' || expectedOutput === null || !('judgeValidationCriteria' in expectedOutput)) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
return expectedOutput.judgeValidationCriteria;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Every entry as a criterion, or the reason they cannot be read: the first malformed entry, or every
|
|
84
|
+
* weight being 0, which leaves a weighted score with nothing to weigh.
|
|
85
|
+
*/
|
|
86
|
+
function readCriteriaEntries(entries) {
|
|
87
|
+
const criteria = [];
|
|
88
|
+
for (const [index, entry] of entries.entries()) {
|
|
89
|
+
const criterion = readCriterion(entry);
|
|
90
|
+
if (!criterion) {
|
|
91
|
+
return {
|
|
92
|
+
Success: false,
|
|
93
|
+
ErrorMessage: `Criterion ${index + 1} must be a non-empty string, or an object with a non-empty "criterion" ` +
|
|
94
|
+
'and an optional "weight" that is a number of 0 or more',
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
criteria.push(criterion);
|
|
98
|
+
}
|
|
99
|
+
if (criteria.every(c => c.Weight === 0)) {
|
|
100
|
+
return {
|
|
101
|
+
Success: false,
|
|
102
|
+
ErrorMessage: 'Every criterion has weight 0, so none counts toward the score: give at least one a weight above 0',
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
return { Success: true, Value: criteria };
|
|
106
|
+
}
|
|
107
|
+
/** One criterion: a string (weight 1), or `{ criterion, weight? }`. Undefined when it is neither. */
|
|
108
|
+
function readCriterion(entry) {
|
|
109
|
+
if (typeof entry === 'string') {
|
|
110
|
+
return entry.trim() ? { Criterion: entry, Weight: 1 } : undefined;
|
|
111
|
+
}
|
|
112
|
+
if (typeof entry !== 'object' || entry === null || !('criterion' in entry)) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
const text = entry.criterion;
|
|
116
|
+
const weight = 'weight' in entry && entry.weight != null ? entry.weight : 1;
|
|
117
|
+
if (typeof text !== 'string' || !text.trim()) {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
if (typeof weight !== 'number' || !Number.isFinite(weight) || weight < 0) {
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
return { Criterion: text, Weight: weight };
|
|
124
|
+
}
|
|
125
|
+
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Q,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QAC3C,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QACvE,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** The reusable binary scale. Created once and shared by every promoted draft. */
|
|
2
|
+
export declare const BINARY_SCALE_NAME = "Binary (Met / Not met)";
|
|
3
|
+
export interface PromotedCriterion {
|
|
4
|
+
key: string;
|
|
5
|
+
name: string;
|
|
6
|
+
weight: number;
|
|
7
|
+
isGate: boolean;
|
|
8
|
+
gateMinimumScore: number | null;
|
|
9
|
+
sequence: number;
|
|
10
|
+
}
|
|
11
|
+
/** A draft rubric that copies the inline judge. The version stays Draft. */
|
|
12
|
+
export interface PromotedRubric {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
passThreshold: number;
|
|
16
|
+
notApplicablePolicy: 'NotAllowed';
|
|
17
|
+
scoreDisplayMin: 0;
|
|
18
|
+
scoreDisplayMax: 1;
|
|
19
|
+
status: 'Draft';
|
|
20
|
+
criteria: PromotedCriterion[];
|
|
21
|
+
}
|
|
22
|
+
export type PromoteCriteriaPlan = {
|
|
23
|
+
ok: true;
|
|
24
|
+
rubric: PromotedRubric;
|
|
25
|
+
} | {
|
|
26
|
+
ok: false;
|
|
27
|
+
message: string;
|
|
28
|
+
};
|
|
29
|
+
export interface PromoteCriteriaStore {
|
|
30
|
+
saveRubric(input: {
|
|
31
|
+
name: string;
|
|
32
|
+
description: string;
|
|
33
|
+
}): Promise<string>;
|
|
34
|
+
ensureBinaryScale(): Promise<string>;
|
|
35
|
+
saveDraftVersion(input: PromotedRubric & {
|
|
36
|
+
rubricId: string;
|
|
37
|
+
scaleId: string;
|
|
38
|
+
}): Promise<string>;
|
|
39
|
+
setTestRubric(testId: string, rubricId: string): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Plans a Draft rubric from a test's inline criteria. Does not publish and does not replace a rubric
|
|
43
|
+
* the test already has. Weights, the judge threshold, and strict mode are copied onto the leaves.
|
|
44
|
+
*/
|
|
45
|
+
export declare function BuildPromotedRubric(input: {
|
|
46
|
+
testName: string;
|
|
47
|
+
testId: string;
|
|
48
|
+
existingRubricId?: string | null;
|
|
49
|
+
expectedOutcomes: unknown;
|
|
50
|
+
configuration: unknown;
|
|
51
|
+
}): PromoteCriteriaPlan;
|
|
52
|
+
/** Writes the draft and points the test at it. The version status is Draft. */
|
|
53
|
+
export declare function PromoteInlineCriteria(testId: string, rubric: PromotedRubric, store: PromoteCriteriaStore): Promise<{
|
|
54
|
+
rubricId: string;
|
|
55
|
+
versionId: string;
|
|
56
|
+
}>;
|
|
57
|
+
//# sourceMappingURL=promote-criteria.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promote-criteria.d.ts","sourceRoot":"","sources":["../../src/oracles/promote-criteria.ts"],"names":[],"mappings":"AAKA,kFAAkF;AAClF,eAAO,MAAM,iBAAiB,2BAA2B,CAAC;AAE1D,MAAM,WAAW,iBAAiB;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAA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