@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
package/README.md
CHANGED
|
@@ -106,10 +106,13 @@ graph LR
|
|
|
106
106
|
| Oracle | Description |
|
|
107
107
|
|--------|-------------|
|
|
108
108
|
| `ExactMatchOracle` | Compares output against an expected string |
|
|
109
|
-
| `LLMJudgeOracle` |
|
|
109
|
+
| `LLMJudgeOracle` | Scores the test's inline criteria with RubricScoring, through the same metadata prompts as the LLM rubric evaluator: the criteria render through *Rubric Criterion*, the judge named in `judgePrompt` (default *Rubric Evaluator - Default Judge*) fills *Rubric Evaluator*'s slot, and the input, expected and actual outputs travel as one delimited subject message. `model` pins the model and `timeoutMS` bounds the call. It does not read MJ: Test Rubrics |
|
|
110
110
|
| `SchemaValidatorOracle` | Validates output against a JSON schema |
|
|
111
111
|
| `SQLValidatorOracle` | Validates output by running SQL queries |
|
|
112
112
|
| `TraceValidatorOracle` | Validates execution trace/steps of an agent run |
|
|
113
|
+
| `RubricOracle` | Judges the test run with a rubric. The subject is the test run and the context is the test |
|
|
114
|
+
|
|
115
|
+
A test run picks one rubric. The first source that names one wins: the run override, the `rubric` oracle's own config, `Test.RubricID`, `TestSuite.RubricID` walking up `ParentID`, then the agent's default Evaluation rubric. The published version is pinned when the suite run starts, so a publish during the run does not split the suite. An explicitly named version is used as given. When a rubric is resolved and the test did not configure a `rubric` oracle, the driver adds one. A test that already has an `llm-judge` oracle keeps that list, and the agent's Evaluation rubric is not added. The added rubric oracle always gates status. It contributes to the score when `scoringWeights` is absent or already names `rubric`.
|
|
113
116
|
|
|
114
117
|
### Variable Resolution
|
|
115
118
|
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Reads a Decision Eval corpus: `corpus.jsonl` (one decision point per line) and
|
|
3
|
+
* `labels.jsonl` (one label per line, several sources per point).
|
|
4
|
+
*
|
|
5
|
+
* Every line is validated against its schema, and a line that doesn't match fails the whole read
|
|
6
|
+
* with its file and line number. A point that silently drops out of a corpus looks exactly like a
|
|
7
|
+
* point the model got right, so nothing here skips a bad line.
|
|
8
|
+
*
|
|
9
|
+
* The functions take the files' text, not paths, so they are pure: the suite generator reads the
|
|
10
|
+
* files.
|
|
11
|
+
*
|
|
12
|
+
* @module @memberjunction/testing-engine
|
|
13
|
+
*/
|
|
14
|
+
import type { z } from 'zod';
|
|
15
|
+
import { type DecisionCorpusLabel, type DecisionCorpusPoint, type DecisionEvalLabel } from './types.js';
|
|
16
|
+
/** A corpus or label file that does not match its schema, with where. */
|
|
17
|
+
export declare class DecisionCorpusError extends Error {
|
|
18
|
+
readonly File: string;
|
|
19
|
+
readonly Line: number;
|
|
20
|
+
readonly Detail: string;
|
|
21
|
+
/**
|
|
22
|
+
* @param File The file's name, as the message shows it.
|
|
23
|
+
* @param Line The 1-based line number, or 0 for a problem with the file as a whole.
|
|
24
|
+
* @param Detail What is wrong.
|
|
25
|
+
*/
|
|
26
|
+
constructor(File: string, Line: number, Detail: string);
|
|
27
|
+
}
|
|
28
|
+
/** A parsed line, with the line it came from. */
|
|
29
|
+
export interface NumberedLine<T> {
|
|
30
|
+
/** The 1-based line number. */
|
|
31
|
+
Line: number;
|
|
32
|
+
/** The parsed value. */
|
|
33
|
+
Value: T;
|
|
34
|
+
}
|
|
35
|
+
/** One labelled point: a corpus point with the label the chosen source gave it. */
|
|
36
|
+
export interface LabelledDecisionPoint {
|
|
37
|
+
/** The point. */
|
|
38
|
+
Point: DecisionCorpusPoint;
|
|
39
|
+
/** Its label from the chosen source. */
|
|
40
|
+
Label: DecisionEvalLabel;
|
|
41
|
+
}
|
|
42
|
+
/** A corpus joined to one label source. */
|
|
43
|
+
export interface JoinedDecisionCorpus {
|
|
44
|
+
/** The points that have a label from the source, in corpus order. */
|
|
45
|
+
Cases: LabelledDecisionPoint[];
|
|
46
|
+
/** IDs of points with no label from the source. */
|
|
47
|
+
UnlabelledPointIds: string[];
|
|
48
|
+
/** How many of the source's labels name a point the corpus doesn't have. */
|
|
49
|
+
OrphanLabelCount: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Parses `corpus.jsonl`. Blank lines are skipped. Throws a {@link DecisionCorpusError} naming the
|
|
53
|
+
* line when a line is not JSON, does not match the point schema, or repeats a point ID.
|
|
54
|
+
*
|
|
55
|
+
* @param text The file's text.
|
|
56
|
+
* @param fileName The file's name, for messages.
|
|
57
|
+
*/
|
|
58
|
+
export declare function ParseDecisionCorpus(text: string, fileName?: string): DecisionCorpusPoint[];
|
|
59
|
+
/**
|
|
60
|
+
* Parses `labels.jsonl`. Blank lines are skipped. Throws a {@link DecisionCorpusError} naming the
|
|
61
|
+
* line when a line is not JSON or does not match the label schema.
|
|
62
|
+
*
|
|
63
|
+
* @param text The file's text.
|
|
64
|
+
* @param fileName The file's name, for messages.
|
|
65
|
+
*/
|
|
66
|
+
export declare function ParseDecisionLabels(text: string, fileName?: string): NumberedLine<DecisionCorpusLabel>[];
|
|
67
|
+
/**
|
|
68
|
+
* Each point's label from one source. The same label given twice is fine; two different labels
|
|
69
|
+
* from the same source for one point throw, naming both lines, because either choice would be a
|
|
70
|
+
* guess.
|
|
71
|
+
*
|
|
72
|
+
* @param labels The parsed label lines.
|
|
73
|
+
* @param source The label source, such as `construction`.
|
|
74
|
+
* @param fileName The label file's name, for messages.
|
|
75
|
+
*/
|
|
76
|
+
export declare function SelectLabelSource(labels: readonly NumberedLine<DecisionCorpusLabel>[], source: string, fileName?: string): Map<string, DecisionEvalLabel>;
|
|
77
|
+
/**
|
|
78
|
+
* Joins the corpus to one label source. Point IDs are compared case-insensitively.
|
|
79
|
+
*
|
|
80
|
+
* @param points The corpus points, in file order.
|
|
81
|
+
* @param labelsById Each point's label from the source ({@link SelectLabelSource}).
|
|
82
|
+
*/
|
|
83
|
+
export declare function JoinDecisionCorpus(points: readonly DecisionCorpusPoint[], labelsById: ReadonlyMap<string, DecisionEvalLabel>): JoinedDecisionCorpus;
|
|
84
|
+
/**
|
|
85
|
+
* Parses each non-blank line as JSON and validates it, keeping line numbers. Throws a
|
|
86
|
+
* {@link DecisionCorpusError} naming the first line that is not JSON or does not match. Shared by
|
|
87
|
+
* the routing and discovery corpus readers.
|
|
88
|
+
*
|
|
89
|
+
* @param text The file's text.
|
|
90
|
+
* @param fileName The file's name, for messages.
|
|
91
|
+
* @param schema Each line's schema.
|
|
92
|
+
*/
|
|
93
|
+
export declare function ParseJsonLines<TSchema extends z.ZodTypeAny>(text: string, fileName: string, schema: TSchema): NumberedLine<z.infer<TSchema>>[];
|
|
94
|
+
//# sourceMappingURL=corpus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"corpus.d.ts","sourceRoot":"","sources":["../../src/decision-eval/corpus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAIH,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACzB,MAAM,SAAS,CAAC;AAEjB,yEAAyE;AACzE,qBAAa,mBAAoB,SAAQ,KAAK;aAMd,IAAI,EAAE,MAAM;aAAkB,IAAI,EAAE,MAAM;aAAkB,MAAM,EAAE,MAAM;IALtG;;;;OAIG;gBACyB,IAAI,EAAE,MAAM,EAAkB,IAAI,EAAE,MAAM,EAAkB,MAAM,EAAE,MAAM;CAIzG;AAED,iDAAiD;AACjD,MAAM,WAAW,YAAY,CAAC,CAAC;IAC3B,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,wBAAwB;IACxB,KAAK,EAAE,CAAC,CAAC;CACZ;AAED,mFAAmF;AACnF,MAAM,WAAW,qBAAqB;IAClC,iBAAiB;IACjB,KAAK,EAAE,mBAAmB,CAAC;IAC3B,wCAAwC;IACxC,KAAK,EAAE,iBAAiB,CAAC;CAC5B;AAED,2CAA2C;AAC3C,MAAM,WAAW,oBAAoB;IACjC,qEAAqE;IACrE,KAAK,EAAE,qBAAqB,EAAE,CAAC;IAC/B,mDAAmD;IACnD,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,4EAA4E;IAC5E,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAuB,GAAG,mBAAmB,EAAE,CAY1G;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAuB,GAAG,YAAY,CAAC,mBAAmB,CAAC,EAAE,CAExH;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC7B,MAAM,EAAE,SAAS,YAAY,CAAC,mBAAmB,CAAC,EAAE,EACpD,MAAM,EAAE,MAAM,EACd,QAAQ,GAAE,MAAuB,GAClC,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAehC;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAC9B,MAAM,EAAE,SAAS,mBAAmB,EAAE,EACtC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,GACnD,oBAAoB,CAgBtB;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,OAAO,SAAS,CAAC,CAAC,UAAU,EACvD,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,GAChB,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAgBlC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Reads a Decision Eval corpus: `corpus.jsonl` (one decision point per line) and
|
|
3
|
+
* `labels.jsonl` (one label per line, several sources per point).
|
|
4
|
+
*
|
|
5
|
+
* Every line is validated against its schema, and a line that doesn't match fails the whole read
|
|
6
|
+
* with its file and line number. A point that silently drops out of a corpus looks exactly like a
|
|
7
|
+
* point the model got right, so nothing here skips a bad line.
|
|
8
|
+
*
|
|
9
|
+
* The functions take the files' text, not paths, so they are pure: the suite generator reads the
|
|
10
|
+
* files.
|
|
11
|
+
*
|
|
12
|
+
* @module @memberjunction/testing-engine
|
|
13
|
+
*/
|
|
14
|
+
import { DecisionCorpusLabelSchema, DecisionCorpusPointSchema, DescribeZodError } from './types.js';
|
|
15
|
+
/** A corpus or label file that does not match its schema, with where. */
|
|
16
|
+
export class DecisionCorpusError extends Error {
|
|
17
|
+
/**
|
|
18
|
+
* @param File The file's name, as the message shows it.
|
|
19
|
+
* @param Line The 1-based line number, or 0 for a problem with the file as a whole.
|
|
20
|
+
* @param Detail What is wrong.
|
|
21
|
+
*/
|
|
22
|
+
constructor(File, Line, Detail) {
|
|
23
|
+
super(Line > 0 ? `${File} line ${Line}: ${Detail}` : `${File}: ${Detail}`);
|
|
24
|
+
this.File = File;
|
|
25
|
+
this.Line = Line;
|
|
26
|
+
this.Detail = Detail;
|
|
27
|
+
this.name = 'DecisionCorpusError';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Parses `corpus.jsonl`. Blank lines are skipped. Throws a {@link DecisionCorpusError} naming the
|
|
32
|
+
* line when a line is not JSON, does not match the point schema, or repeats a point ID.
|
|
33
|
+
*
|
|
34
|
+
* @param text The file's text.
|
|
35
|
+
* @param fileName The file's name, for messages.
|
|
36
|
+
*/
|
|
37
|
+
export function ParseDecisionCorpus(text, fileName = 'corpus.jsonl') {
|
|
38
|
+
const points = ParseJsonLines(text, fileName, DecisionCorpusPointSchema);
|
|
39
|
+
const firstLineById = new Map();
|
|
40
|
+
for (const { Line, Value } of points) {
|
|
41
|
+
const key = Value.id.toUpperCase();
|
|
42
|
+
const first = firstLineById.get(key);
|
|
43
|
+
if (first !== undefined) {
|
|
44
|
+
throw new DecisionCorpusError(fileName, Line, `point ${Value.id} repeats the point on line ${first}`);
|
|
45
|
+
}
|
|
46
|
+
firstLineById.set(key, Line);
|
|
47
|
+
}
|
|
48
|
+
return points.map(p => p.Value);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Parses `labels.jsonl`. Blank lines are skipped. Throws a {@link DecisionCorpusError} naming the
|
|
52
|
+
* line when a line is not JSON or does not match the label schema.
|
|
53
|
+
*
|
|
54
|
+
* @param text The file's text.
|
|
55
|
+
* @param fileName The file's name, for messages.
|
|
56
|
+
*/
|
|
57
|
+
export function ParseDecisionLabels(text, fileName = 'labels.jsonl') {
|
|
58
|
+
return ParseJsonLines(text, fileName, DecisionCorpusLabelSchema);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Each point's label from one source. The same label given twice is fine; two different labels
|
|
62
|
+
* from the same source for one point throw, naming both lines, because either choice would be a
|
|
63
|
+
* guess.
|
|
64
|
+
*
|
|
65
|
+
* @param labels The parsed label lines.
|
|
66
|
+
* @param source The label source, such as `construction`.
|
|
67
|
+
* @param fileName The label file's name, for messages.
|
|
68
|
+
*/
|
|
69
|
+
export function SelectLabelSource(labels, source, fileName = 'labels.jsonl') {
|
|
70
|
+
const chosen = new Map();
|
|
71
|
+
for (const { Line, Value } of labels) {
|
|
72
|
+
if (Value.source !== source) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const key = Value.id.toUpperCase();
|
|
76
|
+
const earlier = chosen.get(key);
|
|
77
|
+
if (earlier && earlier.Value !== Value.label) {
|
|
78
|
+
throw new DecisionCorpusError(fileName, Line, `point ${Value.id} is labelled '${Value.label}' by '${source}', but line ${earlier.Line} labels it '${earlier.Value}'`);
|
|
79
|
+
}
|
|
80
|
+
chosen.set(key, earlier ?? { Line, Value: Value.label });
|
|
81
|
+
}
|
|
82
|
+
return new Map([...chosen].map(([id, numbered]) => [id, numbered.Value]));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Joins the corpus to one label source. Point IDs are compared case-insensitively.
|
|
86
|
+
*
|
|
87
|
+
* @param points The corpus points, in file order.
|
|
88
|
+
* @param labelsById Each point's label from the source ({@link SelectLabelSource}).
|
|
89
|
+
*/
|
|
90
|
+
export function JoinDecisionCorpus(points, labelsById) {
|
|
91
|
+
const cases = [];
|
|
92
|
+
const unlabelled = [];
|
|
93
|
+
const known = new Set();
|
|
94
|
+
for (const point of points) {
|
|
95
|
+
const key = point.id.toUpperCase();
|
|
96
|
+
known.add(key);
|
|
97
|
+
const label = labelsById.get(key);
|
|
98
|
+
if (label) {
|
|
99
|
+
cases.push({ Point: point, Label: label });
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
unlabelled.push(point.id);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const orphans = [...labelsById.keys()].filter(id => !known.has(id)).length;
|
|
106
|
+
return { Cases: cases, UnlabelledPointIds: unlabelled, OrphanLabelCount: orphans };
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Parses each non-blank line as JSON and validates it, keeping line numbers. Throws a
|
|
110
|
+
* {@link DecisionCorpusError} naming the first line that is not JSON or does not match. Shared by
|
|
111
|
+
* the routing and discovery corpus readers.
|
|
112
|
+
*
|
|
113
|
+
* @param text The file's text.
|
|
114
|
+
* @param fileName The file's name, for messages.
|
|
115
|
+
* @param schema Each line's schema.
|
|
116
|
+
*/
|
|
117
|
+
export function ParseJsonLines(text, fileName, schema) {
|
|
118
|
+
const parsed = [];
|
|
119
|
+
const lines = text.split(/\r?\n/);
|
|
120
|
+
lines.forEach((raw, index) => {
|
|
121
|
+
if (raw.trim() === '') {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const line = index + 1;
|
|
125
|
+
const json = parseJson(raw, fileName, line);
|
|
126
|
+
const result = schema.safeParse(json);
|
|
127
|
+
if (!result.success) {
|
|
128
|
+
throw new DecisionCorpusError(fileName, line, DescribeZodError(result.error));
|
|
129
|
+
}
|
|
130
|
+
parsed.push({ Line: line, Value: result.data });
|
|
131
|
+
});
|
|
132
|
+
return parsed;
|
|
133
|
+
}
|
|
134
|
+
/** One line's JSON, or a {@link DecisionCorpusError} naming the line. */
|
|
135
|
+
function parseJson(raw, fileName, line) {
|
|
136
|
+
try {
|
|
137
|
+
return JSON.parse(raw);
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
141
|
+
throw new DecisionCorpusError(fileName, line, `not valid JSON (${reason})`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=corpus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"corpus.js","sourceRoot":"","sources":["../../src/decision-eval/corpus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EACH,yBAAyB,EACzB,yBAAyB,EACzB,gBAAgB,EAInB,MAAM,SAAS,CAAC;AAEjB,yEAAyE;AACzE,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC1C;;;;OAIG;IACH,YAA4B,IAAY,EAAkB,IAAY,EAAkB,MAAc;QAClG,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,SAAS,IAAI,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,MAAM,EAAE,CAAC,CAAC;QADnD,SAAI,GAAJ,IAAI,CAAQ;QAAkB,SAAI,GAAJ,IAAI,CAAQ;QAAkB,WAAM,GAAN,MAAM,CAAQ;QAElG,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACtC,CAAC;CACJ;AA4BD;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY,EAAE,WAAmB,cAAc;IAC/E,MAAM,MAAM,GAAG,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,yBAAyB,CAAC,CAAC;IACzE,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;IAChD,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,KAAK,EAAE,CAAC;QACb,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtE,MAAM,IAAI,mBAAmB,CAAC,QAAQ,EAAE,IAAI,EAAE,mBAAmB,MAAM,GAAG,CAAC,CAAC;IAChF,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The `semantic-search` baseline: what `Find Candidate Agents` would have listed first
|
|
3
|
+
* for a request, which is where Sage's old two-turn discovery started from.
|
|
4
|
+
*
|
|
5
|
+
* The search itself is shared, not copied: the driver runs `DecisionDiscoveryAgentSearch` from
|
|
6
|
+
* `@memberjunction/ai-agents`, the same hybrid search over `MJ: AI Agents` that the action and
|
|
7
|
+
* production's discovery run. What this module adds is the action's reading of the results, which
|
|
8
|
+
* lives inside the action (`@memberjunction/core-actions`, `BaseFindAgentsAction`) and is mirrored
|
|
9
|
+
* here because this package cannot depend on the actions:
|
|
10
|
+
* - a result passes the action's floor when its semantic component reaches the floor, or it has
|
|
11
|
+
* any lexical component;
|
|
12
|
+
* - its reported score is the larger of the two components, else the blended score;
|
|
13
|
+
* - the action keeps the passing results that are agents the user may run and can discover
|
|
14
|
+
* directly, in rank order, and lists them.
|
|
15
|
+
*
|
|
16
|
+
* The constants are the ones Sage's prompt passes the action (`MaxResults = 5`,
|
|
17
|
+
* `MinimumSimilarityScore = 0.5`), which are also the action's defaults.
|
|
18
|
+
*
|
|
19
|
+
* @module @memberjunction/testing-engine
|
|
20
|
+
*/
|
|
21
|
+
import type { EntitySearchResult } from '@memberjunction/core';
|
|
22
|
+
import type { DiscoveryBaselineRecord } from './discovery-types.js';
|
|
23
|
+
/** The similarity floor Sage passes `Find Candidate Agents`, and the action's default. */
|
|
24
|
+
export declare const FIND_CANDIDATE_AGENTS_MIN_SIMILARITY = 0.5;
|
|
25
|
+
/** The result count Sage asks `Find Candidate Agents` for, and the action's default. */
|
|
26
|
+
export declare const FIND_CANDIDATE_AGENTS_MAX_RESULTS = 5;
|
|
27
|
+
/** How many results the action asks the search for: threefold, for its permission filter. */
|
|
28
|
+
export declare const FIND_CANDIDATE_AGENTS_TOP_K: number;
|
|
29
|
+
/** An agent the baseline may list: one the user may run and can discover directly. */
|
|
30
|
+
export interface DiscoveryBaselineAgent {
|
|
31
|
+
ID: string;
|
|
32
|
+
Name: string | null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The score `Find Candidate Agents` reports for a result: the larger of its semantic and lexical
|
|
36
|
+
* components, or its blended score when neither is present or both are zero.
|
|
37
|
+
*
|
|
38
|
+
* @param result A search result.
|
|
39
|
+
*/
|
|
40
|
+
export declare function FindCandidateAgentsScore(result: EntitySearchResult): number;
|
|
41
|
+
/**
|
|
42
|
+
* Whether `Find Candidate Agents` keeps a result: its semantic component reaches the floor, or it
|
|
43
|
+
* has any lexical component. (The blended hybrid score is rank-based, so the action never compares
|
|
44
|
+
* it with the floor.)
|
|
45
|
+
*
|
|
46
|
+
* @param result A search result.
|
|
47
|
+
* @param floor The similarity floor.
|
|
48
|
+
*/
|
|
49
|
+
export declare function PassesFindCandidateAgentsFloor(result: EntitySearchResult, floor?: number): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* What the baseline found for one request: the best-ranked candidate, floor or not, and the
|
|
52
|
+
* best-ranked candidate that passes the floor, which is the first row the action returns. A result
|
|
53
|
+
* that is not a candidate (an agent the user may not run, one that cannot be discovered directly,
|
|
54
|
+
* or the conversation manager) is skipped, through `RankOptionsBySearch`.
|
|
55
|
+
*
|
|
56
|
+
* @param results The search's results, best first.
|
|
57
|
+
* @param candidates The agents the action may list.
|
|
58
|
+
* @param topK How many results the search was asked for.
|
|
59
|
+
* @param floor The similarity floor.
|
|
60
|
+
*/
|
|
61
|
+
export declare function RankSemanticSearchBaseline(results: readonly EntitySearchResult[], candidates: ReadonlyArray<DiscoveryBaselineAgent>, topK?: number, floor?: number): DiscoveryBaselineRecord;
|
|
62
|
+
//# sourceMappingURL=discovery-baseline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery-baseline.d.ts","sourceRoot":"","sources":["../../src/decision-eval/discovery-baseline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG/D,OAAO,KAAK,EAA8B,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE7F,0FAA0F;AAC1F,eAAO,MAAM,oCAAoC,MAAM,CAAC;AAExD,wFAAwF;AACxF,eAAO,MAAM,iCAAiC,IAAI,CAAC;AAEnD,6FAA6F;AAC7F,eAAO,MAAM,2BAA2B,QAAwC,CAAC;AAEjF,sFAAsF;AACtF,MAAM,WAAW,sBAAsB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAE3E;AAED;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,GAAE,MAA6C,GAAG,OAAO,CAGxI;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CACtC,OAAO,EAAE,SAAS,kBAAkB,EAAE,EACtC,UAAU,EAAE,aAAa,CAAC,sBAAsB,CAAC,EACjD,IAAI,GAAE,MAAoC,EAC1C,KAAK,GAAE,MAA6C,GACrD,uBAAuB,CAczB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The `semantic-search` baseline: what `Find Candidate Agents` would have listed first
|
|
3
|
+
* for a request, which is where Sage's old two-turn discovery started from.
|
|
4
|
+
*
|
|
5
|
+
* The search itself is shared, not copied: the driver runs `DecisionDiscoveryAgentSearch` from
|
|
6
|
+
* `@memberjunction/ai-agents`, the same hybrid search over `MJ: AI Agents` that the action and
|
|
7
|
+
* production's discovery run. What this module adds is the action's reading of the results, which
|
|
8
|
+
* lives inside the action (`@memberjunction/core-actions`, `BaseFindAgentsAction`) and is mirrored
|
|
9
|
+
* here because this package cannot depend on the actions:
|
|
10
|
+
* - a result passes the action's floor when its semantic component reaches the floor, or it has
|
|
11
|
+
* any lexical component;
|
|
12
|
+
* - its reported score is the larger of the two components, else the blended score;
|
|
13
|
+
* - the action keeps the passing results that are agents the user may run and can discover
|
|
14
|
+
* directly, in rank order, and lists them.
|
|
15
|
+
*
|
|
16
|
+
* The constants are the ones Sage's prompt passes the action (`MaxResults = 5`,
|
|
17
|
+
* `MinimumSimilarityScore = 0.5`), which are also the action's defaults.
|
|
18
|
+
*
|
|
19
|
+
* @module @memberjunction/testing-engine
|
|
20
|
+
*/
|
|
21
|
+
import { NormalizeUUID } from '@memberjunction/global';
|
|
22
|
+
import { RankOptionsBySearch } from '@memberjunction/ai-agents';
|
|
23
|
+
/** The similarity floor Sage passes `Find Candidate Agents`, and the action's default. */
|
|
24
|
+
export const FIND_CANDIDATE_AGENTS_MIN_SIMILARITY = 0.5;
|
|
25
|
+
/** The result count Sage asks `Find Candidate Agents` for, and the action's default. */
|
|
26
|
+
export const FIND_CANDIDATE_AGENTS_MAX_RESULTS = 5;
|
|
27
|
+
/** How many results the action asks the search for: threefold, for its permission filter. */
|
|
28
|
+
export const FIND_CANDIDATE_AGENTS_TOP_K = FIND_CANDIDATE_AGENTS_MAX_RESULTS * 3;
|
|
29
|
+
/**
|
|
30
|
+
* The score `Find Candidate Agents` reports for a result: the larger of its semantic and lexical
|
|
31
|
+
* components, or its blended score when neither is present or both are zero.
|
|
32
|
+
*
|
|
33
|
+
* @param result A search result.
|
|
34
|
+
*/
|
|
35
|
+
export function FindCandidateAgentsScore(result) {
|
|
36
|
+
return Math.max(result.components?.semantic ?? 0, result.components?.lexical ?? 0) || result.score;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Whether `Find Candidate Agents` keeps a result: its semantic component reaches the floor, or it
|
|
40
|
+
* has any lexical component. (The blended hybrid score is rank-based, so the action never compares
|
|
41
|
+
* it with the floor.)
|
|
42
|
+
*
|
|
43
|
+
* @param result A search result.
|
|
44
|
+
* @param floor The similarity floor.
|
|
45
|
+
*/
|
|
46
|
+
export function PassesFindCandidateAgentsFloor(result, floor = FIND_CANDIDATE_AGENTS_MIN_SIMILARITY) {
|
|
47
|
+
const semantic = result.components?.semantic;
|
|
48
|
+
return (semantic != null && semantic >= floor) || result.components?.lexical != null;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* What the baseline found for one request: the best-ranked candidate, floor or not, and the
|
|
52
|
+
* best-ranked candidate that passes the floor, which is the first row the action returns. A result
|
|
53
|
+
* that is not a candidate (an agent the user may not run, one that cannot be discovered directly,
|
|
54
|
+
* or the conversation manager) is skipped, through `RankOptionsBySearch`.
|
|
55
|
+
*
|
|
56
|
+
* @param results The search's results, best first.
|
|
57
|
+
* @param candidates The agents the action may list.
|
|
58
|
+
* @param topK How many results the search was asked for.
|
|
59
|
+
* @param floor The similarity floor.
|
|
60
|
+
*/
|
|
61
|
+
export function RankSemanticSearchBaseline(results, candidates, topK = FIND_CANDIDATE_AGENTS_TOP_K, floor = FIND_CANDIDATE_AGENTS_MIN_SIMILARITY) {
|
|
62
|
+
const options = candidates.map(c => ({ ID: c.ID, Name: c.Name ?? '', Description: '' }));
|
|
63
|
+
const byName = new Map(candidates.map(c => [NormalizeUUID(c.ID), c.Name]));
|
|
64
|
+
const firstOf = (kept) => {
|
|
65
|
+
const [top] = RankOptionsBySearch(options, kept.map(r => r.recordId), 1);
|
|
66
|
+
return top ? baselineCandidate(results, top.ID, byName.get(NormalizeUUID(top.ID)) ?? null, floor) : null;
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
Floor: floor,
|
|
70
|
+
TopK: topK,
|
|
71
|
+
Results: results.length,
|
|
72
|
+
TopRanked: firstOf(results),
|
|
73
|
+
TopMatch: firstOf(results.filter(r => PassesFindCandidateAgentsFloor(r, floor)))
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/** One candidate's record, from its first result. */
|
|
77
|
+
function baselineCandidate(results, agentId, agentName, floor) {
|
|
78
|
+
const index = results.findIndex(r => NormalizeUUID(r.recordId) === NormalizeUUID(agentId));
|
|
79
|
+
const result = results[index];
|
|
80
|
+
return {
|
|
81
|
+
AgentId: agentId,
|
|
82
|
+
AgentName: agentName,
|
|
83
|
+
Rank: index + 1,
|
|
84
|
+
Score: FindCandidateAgentsScore(result),
|
|
85
|
+
Semantic: result.components?.semantic ?? null,
|
|
86
|
+
Lexical: result.components?.lexical ?? null,
|
|
87
|
+
PassesFloor: PassesFindCandidateAgentsFloor(result, floor)
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=discovery-baseline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery-baseline.js","sourceRoot":"","sources":["../../src/decision-eval/discovery-baseline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAgC,MAAM,2BAA2B,CAAC;AAG9F,0FAA0F;AAC1F,MAAM,CAAC,MAAM,oCAAoC,GAAG,GAAG,CAAC;AAExD,wFAAwF;AACxF,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,CAAC;AAEnD,6FAA6F;AAC7F,MAAM,CAAC,MAAM,2BAA2B,GAAG,iCAAiC,GAAG,CAAC,CAAC;AAQjF;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAA0B;IAC/D,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,IAAI,CAAC,EAAE,MAAM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CAAC,IAAI,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7G,CAAC,CAAC;IACF,OAAO;QACH,KAAK,EAAE,KAAK;QACZ,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,OAAO,CAAC,MAAM;QACvB,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC;QAC3B,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,8BAA8B,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;KACnF,CAAC;AACN,CAAC;AAED,qDAAqD;AACrD,SAAS,iBAAiB,CAAC,OAAsC,EAAE,OAAe,EAAE,SAAwB,EAAE,KAAa;IACvH,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3F,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9B,OAAO;QACH,OAAO,EAAE,OAAO;QAChB,SAAS,EAAE,SAAS;QACpB,IAAI,EAAE,KAAK,GAAG,CAAC;QACf,KAAK,EAAE,wBAAwB,CAAC,MAAM,CAAC;QACvC,QAAQ,EAAE,MAAM,CAAC,UAAU,EAAE,QAAQ,IAAI,IAAI;QAC7C,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,OAAO,IAAI,IAAI;QAC3C,WAAW,EAAE,8BAA8B,CAAC,MAAM,EAAE,KAAK,CAAC;KAC7D,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Reads an agent-discovery corpus: `corpus.jsonl` (one request per line) and
|
|
3
|
+
* `labels.jsonl` (one label per line, several sources per request). It mirrors the routing
|
|
4
|
+
* corpus reader (`corpus.ts`), and shares its line parser: every line is validated, and a bad line
|
|
5
|
+
* fails the whole read with its file and line number, because a request that silently drops out
|
|
6
|
+
* looks exactly like one the model got right.
|
|
7
|
+
*
|
|
8
|
+
* Pure: the functions take the files' text, and the suite generator reads the files.
|
|
9
|
+
*
|
|
10
|
+
* @module @memberjunction/testing-engine
|
|
11
|
+
*/
|
|
12
|
+
import { type NumberedLine } from './corpus.js';
|
|
13
|
+
import { type DiscoveryCorpusLabel, type DiscoveryCorpusRequest, type DiscoveryLabel } from './discovery-types.js';
|
|
14
|
+
/** One labelled request: a corpus request with the label the chosen source gave it. */
|
|
15
|
+
export interface LabelledDiscoveryRequest {
|
|
16
|
+
/** The request. */
|
|
17
|
+
Request: DiscoveryCorpusRequest;
|
|
18
|
+
/** Its label from the chosen source. */
|
|
19
|
+
Label: DiscoveryLabel;
|
|
20
|
+
}
|
|
21
|
+
/** A discovery corpus joined to one label source. */
|
|
22
|
+
export interface JoinedDiscoveryCorpus {
|
|
23
|
+
/** The requests that have a label from the source, in corpus order. */
|
|
24
|
+
Cases: LabelledDiscoveryRequest[];
|
|
25
|
+
/** IDs of requests with no label from the source. */
|
|
26
|
+
UnlabelledRequestIds: string[];
|
|
27
|
+
/** How many of the source's labels name a request the corpus doesn't have. */
|
|
28
|
+
OrphanLabelCount: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Parses a discovery `corpus.jsonl`. Blank lines are skipped. Throws a {@link DecisionCorpusError}
|
|
32
|
+
* naming the line when a line is not JSON, does not match the request schema, or repeats an ID.
|
|
33
|
+
*
|
|
34
|
+
* @param text The file's text.
|
|
35
|
+
* @param fileName The file's name, for messages.
|
|
36
|
+
*/
|
|
37
|
+
export declare function ParseDiscoveryCorpus(text: string, fileName?: string): DiscoveryCorpusRequest[];
|
|
38
|
+
/**
|
|
39
|
+
* Parses a discovery `labels.jsonl`. Blank lines are skipped. Throws a {@link DecisionCorpusError}
|
|
40
|
+
* naming the line when a line is not JSON or does not match the label schema: an `agent` label
|
|
41
|
+
* needs an `agentId`, and a `none` label a `kind`.
|
|
42
|
+
*
|
|
43
|
+
* @param text The file's text.
|
|
44
|
+
* @param fileName The file's name, for messages.
|
|
45
|
+
*/
|
|
46
|
+
export declare function ParseDiscoveryLabels(text: string, fileName?: string): NumberedLine<DiscoveryCorpusLabel>[];
|
|
47
|
+
/**
|
|
48
|
+
* Each request's label from one source. The same label given twice is fine; two different labels
|
|
49
|
+
* from the same source for one request throw, naming both lines.
|
|
50
|
+
*
|
|
51
|
+
* @param labels The parsed label lines.
|
|
52
|
+
* @param source The label source, such as `construction`.
|
|
53
|
+
* @param fileName The label file's name, for messages.
|
|
54
|
+
*/
|
|
55
|
+
export declare function SelectDiscoveryLabelSource(labels: readonly NumberedLine<DiscoveryCorpusLabel>[], source: string, fileName?: string): Map<string, DiscoveryLabel>;
|
|
56
|
+
/**
|
|
57
|
+
* Joins the corpus to one label source. Request IDs are compared case-insensitively.
|
|
58
|
+
*
|
|
59
|
+
* @param requests The corpus requests, in file order.
|
|
60
|
+
* @param labelsById Each request's label from the source ({@link SelectDiscoveryLabelSource}).
|
|
61
|
+
*/
|
|
62
|
+
export declare function JoinDiscoveryCorpus(requests: readonly DiscoveryCorpusRequest[], labelsById: ReadonlyMap<string, DiscoveryLabel>): JoinedDiscoveryCorpus;
|
|
63
|
+
/**
|
|
64
|
+
* A label line without its request ID and source.
|
|
65
|
+
*
|
|
66
|
+
* @param label The label line.
|
|
67
|
+
*/
|
|
68
|
+
export declare function ToDiscoveryLabel(label: DiscoveryCorpusLabel): DiscoveryLabel;
|
|
69
|
+
/**
|
|
70
|
+
* A label as one comparable string: `agent:<AGENT ID>` (upper case) or `none:<kind>`.
|
|
71
|
+
*
|
|
72
|
+
* @param label The label.
|
|
73
|
+
*/
|
|
74
|
+
export declare function DescribeDiscoveryLabel(label: DiscoveryLabel): string;
|
|
75
|
+
//# sourceMappingURL=discovery-corpus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery-corpus.d.ts","sourceRoot":"","sources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G,cAAc,CAE5E;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAEpE"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Reads an agent-discovery corpus: `corpus.jsonl` (one request per line) and
|
|
3
|
+
* `labels.jsonl` (one label per line, several sources per request). It mirrors the routing
|
|
4
|
+
* corpus reader (`corpus.ts`), and shares its line parser: every line is validated, and a bad line
|
|
5
|
+
* fails the whole read with its file and line number, because a request that silently drops out
|
|
6
|
+
* looks exactly like one the model got right.
|
|
7
|
+
*
|
|
8
|
+
* Pure: the functions take the files' text, and the suite generator reads the files.
|
|
9
|
+
*
|
|
10
|
+
* @module @memberjunction/testing-engine
|
|
11
|
+
*/
|
|
12
|
+
import { DecisionCorpusError, ParseJsonLines } from './corpus.js';
|
|
13
|
+
import { DiscoveryCorpusLabelSchema, DiscoveryCorpusRequestSchema } from './discovery-types.js';
|
|
14
|
+
/**
|
|
15
|
+
* Parses a discovery `corpus.jsonl`. Blank lines are skipped. Throws a {@link DecisionCorpusError}
|
|
16
|
+
* naming the line when a line is not JSON, does not match the request schema, or repeats an ID.
|
|
17
|
+
*
|
|
18
|
+
* @param text The file's text.
|
|
19
|
+
* @param fileName The file's name, for messages.
|
|
20
|
+
*/
|
|
21
|
+
export function ParseDiscoveryCorpus(text, fileName = 'corpus.jsonl') {
|
|
22
|
+
const requests = ParseJsonLines(text, fileName, DiscoveryCorpusRequestSchema);
|
|
23
|
+
const firstLineById = new Map();
|
|
24
|
+
for (const { Line, Value } of requests) {
|
|
25
|
+
const key = Value.id.toUpperCase();
|
|
26
|
+
const first = firstLineById.get(key);
|
|
27
|
+
if (first !== undefined) {
|
|
28
|
+
throw new DecisionCorpusError(fileName, Line, `request ${Value.id} repeats the request on line ${first}`);
|
|
29
|
+
}
|
|
30
|
+
firstLineById.set(key, Line);
|
|
31
|
+
}
|
|
32
|
+
return requests.map(r => r.Value);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Parses a discovery `labels.jsonl`. Blank lines are skipped. Throws a {@link DecisionCorpusError}
|
|
36
|
+
* naming the line when a line is not JSON or does not match the label schema: an `agent` label
|
|
37
|
+
* needs an `agentId`, and a `none` label a `kind`.
|
|
38
|
+
*
|
|
39
|
+
* @param text The file's text.
|
|
40
|
+
* @param fileName The file's name, for messages.
|
|
41
|
+
*/
|
|
42
|
+
export function ParseDiscoveryLabels(text, fileName = 'labels.jsonl') {
|
|
43
|
+
return ParseJsonLines(text, fileName, DiscoveryCorpusLabelSchema);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Each request's label from one source. The same label given twice is fine; two different labels
|
|
47
|
+
* from the same source for one request throw, naming both lines.
|
|
48
|
+
*
|
|
49
|
+
* @param labels The parsed label lines.
|
|
50
|
+
* @param source The label source, such as `construction`.
|
|
51
|
+
* @param fileName The label file's name, for messages.
|
|
52
|
+
*/
|
|
53
|
+
export function SelectDiscoveryLabelSource(labels, source, fileName = 'labels.jsonl') {
|
|
54
|
+
const chosen = new Map();
|
|
55
|
+
for (const { Line, Value } of labels) {
|
|
56
|
+
if (Value.source !== source) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const key = Value.id.toUpperCase();
|
|
60
|
+
const label = ToDiscoveryLabel(Value);
|
|
61
|
+
const earlier = chosen.get(key);
|
|
62
|
+
if (earlier && DescribeDiscoveryLabel(earlier.Value) !== DescribeDiscoveryLabel(label)) {
|
|
63
|
+
throw new DecisionCorpusError(fileName, Line, `request ${Value.id} is labelled '${DescribeDiscoveryLabel(label)}' by '${source}', `
|
|
64
|
+
+ `but line ${earlier.Line} labels it '${DescribeDiscoveryLabel(earlier.Value)}'`);
|
|
65
|
+
}
|
|
66
|
+
chosen.set(key, earlier ?? { Line, Value: label });
|
|
67
|
+
}
|
|
68
|
+
return new Map([...chosen].map(([id, numbered]) => [id, numbered.Value]));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Joins the corpus to one label source. Request IDs are compared case-insensitively.
|
|
72
|
+
*
|
|
73
|
+
* @param requests The corpus requests, in file order.
|
|
74
|
+
* @param labelsById Each request's label from the source ({@link SelectDiscoveryLabelSource}).
|
|
75
|
+
*/
|
|
76
|
+
export function JoinDiscoveryCorpus(requests, labelsById) {
|
|
77
|
+
const cases = [];
|
|
78
|
+
const unlabelled = [];
|
|
79
|
+
const known = new Set();
|
|
80
|
+
for (const request of requests) {
|
|
81
|
+
const key = request.id.toUpperCase();
|
|
82
|
+
known.add(key);
|
|
83
|
+
const label = labelsById.get(key);
|
|
84
|
+
if (label) {
|
|
85
|
+
cases.push({ Request: request, Label: label });
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
unlabelled.push(request.id);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const orphans = [...labelsById.keys()].filter(id => !known.has(id)).length;
|
|
92
|
+
return { Cases: cases, UnlabelledRequestIds: unlabelled, OrphanLabelCount: orphans };
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* A label line without its request ID and source.
|
|
96
|
+
*
|
|
97
|
+
* @param label The label line.
|
|
98
|
+
*/
|
|
99
|
+
export function ToDiscoveryLabel(label) {
|
|
100
|
+
return label.label === 'agent' ? { label: 'agent', agentId: label.agentId } : { label: 'none', kind: label.kind };
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* A label as one comparable string: `agent:<AGENT ID>` (upper case) or `none:<kind>`.
|
|
104
|
+
*
|
|
105
|
+
* @param label The label.
|
|
106
|
+
*/
|
|
107
|
+
export function DescribeDiscoveryLabel(label) {
|
|
108
|
+
return label.label === 'agent' ? `agent:${label.agentId.toUpperCase()}` : `none:${label.kind}`;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=discovery-corpus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery-corpus.js","sourceRoot":"","sources":["../../src/decision-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CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Maps a discovery corpus request to the decision's state, the way production builds
|
|
3
|
+
* it, so the eval asks exactly what Sage's discovery asks.
|
|
4
|
+
*
|
|
5
|
+
* Production (`BaseAgent`) reads the run's opening request with `OpeningRequestText`: the text of
|
|
6
|
+
* the last user message when the run starts, trimmed and capped. A corpus request is that one user
|
|
7
|
+
* message, so its state is `OpeningRequestText` over a conversation holding only it.
|
|
8
|
+
*
|
|
9
|
+
* @module @memberjunction/testing-engine
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* The state production's decision discovery sends for a request: `OpeningRequestText` of a
|
|
13
|
+
* conversation whose only message is the request, from the user. Empty when the request is blank.
|
|
14
|
+
*
|
|
15
|
+
* @param request The request, as the user typed it.
|
|
16
|
+
*/
|
|
17
|
+
export declare function DiscoveryDecisionState(request: string): string;
|
|
18
|
+
//# sourceMappingURL=discovery-mapping.d.ts.map
|