@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,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Expands a labelled corpus × a matrix of cells into `MJ: Tests` records for the
|
|
3
|
+
* `Decision Eval` test type, plus the suite that runs them. Pure: the generator rig
|
|
4
|
+
* (`integration-test-suite/rigs/generate-decision-eval-suite.ts`) reads the files and writes the
|
|
5
|
+
* output.
|
|
6
|
+
*
|
|
7
|
+
* One record per (point, cell), named `<point id> [<cell label>]` so the scorecard can group runs
|
|
8
|
+
* by cell, with a stable ID derived from that pair so regenerating updates records rather than
|
|
9
|
+
* orphaning them. The scheme is the Prompt Eval generator's.
|
|
10
|
+
*
|
|
11
|
+
* @module @memberjunction/testing-engine
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
import type { LabelledDecisionPoint } from './corpus.js';
|
|
15
|
+
import { type DecisionCorpusPoint, type DecisionEvalConfig } from './types.js';
|
|
16
|
+
/** The test type's name, as the metadata record declares it. */
|
|
17
|
+
export declare const DECISION_EVAL_TEST_TYPE_NAME = "Decision Eval";
|
|
18
|
+
/** The suite name when neither the matrix nor the command line gives one. */
|
|
19
|
+
export declare const DEFAULT_DECISION_EVAL_SUITE_NAME = "Decision Eval \u2014 Conversation Routing";
|
|
20
|
+
/** Repeats per record when neither the matrix nor the command line gives a count. */
|
|
21
|
+
export declare const DEFAULT_DECISION_EVAL_REPS = 5;
|
|
22
|
+
/** A cell's label: it becomes the bracketed part of every record's name, so it holds no brackets. */
|
|
23
|
+
export declare const DecisionEvalCellLabelSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
24
|
+
/** One matrix cell: the conditions every point is observed under. */
|
|
25
|
+
export declare const DecisionEvalMatrixCellSchema: z.ZodObject<{
|
|
26
|
+
/** Names the cell. It becomes the bracketed part of every record's name. */
|
|
27
|
+
label: z.ZodEffects<z.ZodString, string, string>;
|
|
28
|
+
stateLayout: z.ZodEnum<["production", "structured"]>;
|
|
29
|
+
promptName: z.ZodOptional<z.ZodString>;
|
|
30
|
+
modelId: z.ZodOptional<z.ZodString>;
|
|
31
|
+
vendorId: z.ZodOptional<z.ZodString>;
|
|
32
|
+
failover: z.ZodOptional<z.ZodBoolean>;
|
|
33
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
seed: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
/** USD per million input tokens, for the cost estimate only. */
|
|
36
|
+
inputPricePer1M: z.ZodOptional<z.ZodNumber>;
|
|
37
|
+
/** USD per million output tokens, for the cost estimate only. */
|
|
38
|
+
outputPricePer1M: z.ZodOptional<z.ZodNumber>;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
label: string;
|
|
41
|
+
stateLayout: "production" | "structured";
|
|
42
|
+
promptName?: string | undefined;
|
|
43
|
+
modelId?: string | undefined;
|
|
44
|
+
vendorId?: string | undefined;
|
|
45
|
+
failover?: boolean | undefined;
|
|
46
|
+
temperature?: number | undefined;
|
|
47
|
+
seed?: number | undefined;
|
|
48
|
+
inputPricePer1M?: number | undefined;
|
|
49
|
+
outputPricePer1M?: number | undefined;
|
|
50
|
+
}, {
|
|
51
|
+
label: string;
|
|
52
|
+
stateLayout: "production" | "structured";
|
|
53
|
+
promptName?: string | undefined;
|
|
54
|
+
modelId?: string | undefined;
|
|
55
|
+
vendorId?: string | undefined;
|
|
56
|
+
failover?: boolean | undefined;
|
|
57
|
+
temperature?: number | undefined;
|
|
58
|
+
seed?: number | undefined;
|
|
59
|
+
inputPricePer1M?: number | undefined;
|
|
60
|
+
outputPricePer1M?: number | undefined;
|
|
61
|
+
}>;
|
|
62
|
+
/** One matrix cell. */
|
|
63
|
+
export type DecisionEvalMatrixCell = z.infer<typeof DecisionEvalMatrixCellSchema>;
|
|
64
|
+
/** A matrix file. Keys it doesn't know, such as `_comment`, are ignored. */
|
|
65
|
+
export declare const DecisionEvalMatrixSchema: z.ZodObject<{
|
|
66
|
+
suiteName: z.ZodOptional<z.ZodString>;
|
|
67
|
+
reps: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
cells: z.ZodArray<z.ZodObject<{
|
|
69
|
+
/** Names the cell. It becomes the bracketed part of every record's name. */
|
|
70
|
+
label: z.ZodEffects<z.ZodString, string, string>;
|
|
71
|
+
stateLayout: z.ZodEnum<["production", "structured"]>;
|
|
72
|
+
promptName: z.ZodOptional<z.ZodString>;
|
|
73
|
+
modelId: z.ZodOptional<z.ZodString>;
|
|
74
|
+
vendorId: z.ZodOptional<z.ZodString>;
|
|
75
|
+
failover: z.ZodOptional<z.ZodBoolean>;
|
|
76
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
77
|
+
seed: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
/** USD per million input tokens, for the cost estimate only. */
|
|
79
|
+
inputPricePer1M: z.ZodOptional<z.ZodNumber>;
|
|
80
|
+
/** USD per million output tokens, for the cost estimate only. */
|
|
81
|
+
outputPricePer1M: z.ZodOptional<z.ZodNumber>;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
label: string;
|
|
84
|
+
stateLayout: "production" | "structured";
|
|
85
|
+
promptName?: string | undefined;
|
|
86
|
+
modelId?: string | undefined;
|
|
87
|
+
vendorId?: string | undefined;
|
|
88
|
+
failover?: boolean | undefined;
|
|
89
|
+
temperature?: number | undefined;
|
|
90
|
+
seed?: number | undefined;
|
|
91
|
+
inputPricePer1M?: number | undefined;
|
|
92
|
+
outputPricePer1M?: number | undefined;
|
|
93
|
+
}, {
|
|
94
|
+
label: string;
|
|
95
|
+
stateLayout: "production" | "structured";
|
|
96
|
+
promptName?: string | undefined;
|
|
97
|
+
modelId?: string | undefined;
|
|
98
|
+
vendorId?: string | undefined;
|
|
99
|
+
failover?: boolean | undefined;
|
|
100
|
+
temperature?: number | undefined;
|
|
101
|
+
seed?: number | undefined;
|
|
102
|
+
inputPricePer1M?: number | undefined;
|
|
103
|
+
outputPricePer1M?: number | undefined;
|
|
104
|
+
}>, "many">;
|
|
105
|
+
}, "strip", z.ZodTypeAny, {
|
|
106
|
+
cells: {
|
|
107
|
+
label: string;
|
|
108
|
+
stateLayout: "production" | "structured";
|
|
109
|
+
promptName?: string | undefined;
|
|
110
|
+
modelId?: string | undefined;
|
|
111
|
+
vendorId?: string | undefined;
|
|
112
|
+
failover?: boolean | undefined;
|
|
113
|
+
temperature?: number | undefined;
|
|
114
|
+
seed?: number | undefined;
|
|
115
|
+
inputPricePer1M?: number | undefined;
|
|
116
|
+
outputPricePer1M?: number | undefined;
|
|
117
|
+
}[];
|
|
118
|
+
suiteName?: string | undefined;
|
|
119
|
+
reps?: number | undefined;
|
|
120
|
+
}, {
|
|
121
|
+
cells: {
|
|
122
|
+
label: string;
|
|
123
|
+
stateLayout: "production" | "structured";
|
|
124
|
+
promptName?: string | undefined;
|
|
125
|
+
modelId?: string | undefined;
|
|
126
|
+
vendorId?: string | undefined;
|
|
127
|
+
failover?: boolean | undefined;
|
|
128
|
+
temperature?: number | undefined;
|
|
129
|
+
seed?: number | undefined;
|
|
130
|
+
inputPricePer1M?: number | undefined;
|
|
131
|
+
outputPricePer1M?: number | undefined;
|
|
132
|
+
}[];
|
|
133
|
+
suiteName?: string | undefined;
|
|
134
|
+
reps?: number | undefined;
|
|
135
|
+
}>;
|
|
136
|
+
/** A matrix file. */
|
|
137
|
+
export type DecisionEvalMatrix = z.infer<typeof DecisionEvalMatrixSchema>;
|
|
138
|
+
/** An mj-sync record: its fields and its primary key. */
|
|
139
|
+
export interface SyncRecord {
|
|
140
|
+
fields: Record<string, unknown>;
|
|
141
|
+
primaryKey: {
|
|
142
|
+
ID: string;
|
|
143
|
+
};
|
|
144
|
+
relatedEntities?: Record<string, SyncRecord[]>;
|
|
145
|
+
}
|
|
146
|
+
/** The run's estimated size and cost. */
|
|
147
|
+
export interface DecisionEvalRunEstimate {
|
|
148
|
+
PromptTokens: number;
|
|
149
|
+
CompletionTokens: number;
|
|
150
|
+
/** USD, or null when no cell carries prices. */
|
|
151
|
+
USD: number | null;
|
|
152
|
+
PerCell: Array<{
|
|
153
|
+
Label: string;
|
|
154
|
+
USD: number | null;
|
|
155
|
+
}>;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Parses and validates a matrix file. Throws naming the problem, and names a repeated cell label.
|
|
159
|
+
*
|
|
160
|
+
* @param text The file's text.
|
|
161
|
+
* @param source The file's name, for messages.
|
|
162
|
+
*/
|
|
163
|
+
export declare function ParseDecisionEvalMatrix(text: string, source: string): DecisionEvalMatrix;
|
|
164
|
+
/**
|
|
165
|
+
* Parses and validates a matrix file against a decision's matrix schema. Throws naming the
|
|
166
|
+
* problem, and names a repeated cell label. Shared by the routing and discovery matrices.
|
|
167
|
+
*
|
|
168
|
+
* @param text The file's text.
|
|
169
|
+
* @param source The file's name, for messages.
|
|
170
|
+
* @param schema The decision's matrix schema.
|
|
171
|
+
*/
|
|
172
|
+
export declare function ParseEvalMatrixFile<TMatrix extends {
|
|
173
|
+
cells: ReadonlyArray<{
|
|
174
|
+
label: string;
|
|
175
|
+
}>;
|
|
176
|
+
}>(text: string, source: string, schema: {
|
|
177
|
+
safeParse(value: unknown): {
|
|
178
|
+
success: true;
|
|
179
|
+
data: TMatrix;
|
|
180
|
+
} | {
|
|
181
|
+
success: false;
|
|
182
|
+
error: z.ZodError;
|
|
183
|
+
};
|
|
184
|
+
}): TMatrix;
|
|
185
|
+
/**
|
|
186
|
+
* A stable UUID for a pair of strings: FNV-1a over `a::b`, spread across a v4-shaped UUID. The same
|
|
187
|
+
* scheme as the Prompt Eval generator's, so regenerating updates the same records.
|
|
188
|
+
*
|
|
189
|
+
* @param a The first part, such as a point ID.
|
|
190
|
+
* @param b The second part, such as a cell label.
|
|
191
|
+
*/
|
|
192
|
+
export declare function StableEvalId(a: string, b: string): string;
|
|
193
|
+
/**
|
|
194
|
+
* A record's name: `<point id> [<cell label>]`. The scorecard splits it back apart.
|
|
195
|
+
*
|
|
196
|
+
* @param pointId The point.
|
|
197
|
+
* @param cellLabel The cell.
|
|
198
|
+
*/
|
|
199
|
+
export declare function DecisionEvalTestName(pointId: string, cellLabel: string): string;
|
|
200
|
+
/**
|
|
201
|
+
* A cell's test `Configuration`. The `decision-label-match` oracle scores the `continues`
|
|
202
|
+
* Likelihood against the label at 0.5.
|
|
203
|
+
*
|
|
204
|
+
* @param cell The cell.
|
|
205
|
+
*/
|
|
206
|
+
export declare function BuildDecisionEvalConfiguration(cell: DecisionEvalMatrixCell): DecisionEvalConfig;
|
|
207
|
+
/**
|
|
208
|
+
* One `MJ: Tests` record: the point as its input, its label as the expected outcome, the cell as
|
|
209
|
+
* its configuration, and `RepeatCount` repeats. The description carries IDs only, never text.
|
|
210
|
+
*
|
|
211
|
+
* @param testCase The labelled point.
|
|
212
|
+
* @param cell The cell.
|
|
213
|
+
* @param reps Repeats per record.
|
|
214
|
+
* @param labelSource Where the label came from.
|
|
215
|
+
*/
|
|
216
|
+
export declare function BuildDecisionEvalTestRecord(testCase: LabelledDecisionPoint, cell: DecisionEvalMatrixCell, reps: number, labelSource: string): SyncRecord;
|
|
217
|
+
/**
|
|
218
|
+
* The suite record, with a membership row per test in order.
|
|
219
|
+
*
|
|
220
|
+
* @param suiteName The suite's name.
|
|
221
|
+
* @param testNames The tests' names, in run order.
|
|
222
|
+
* @param description The suite's description.
|
|
223
|
+
*/
|
|
224
|
+
export declare function BuildDecisionEvalSuiteRecord(suiteName: string, testNames: readonly string[], description: string): SyncRecord;
|
|
225
|
+
/**
|
|
226
|
+
* Estimates the run's tokens and cost. Each call's prompt is the state and questions the builders
|
|
227
|
+
* produce for the point (with the point's own agent names, since no engine is loaded offline) at
|
|
228
|
+
* four characters a token, plus a fixed allowance for the prompt around them. A floor, not a
|
|
229
|
+
* ceiling.
|
|
230
|
+
*
|
|
231
|
+
* @param cases The labelled points.
|
|
232
|
+
* @param cells The matrix cells.
|
|
233
|
+
* @param reps Repeats per record.
|
|
234
|
+
*/
|
|
235
|
+
export declare function EstimateDecisionEvalRun(cases: readonly LabelledDecisionPoint[], cells: readonly DecisionEvalMatrixCell[], reps: number): DecisionEvalRunEstimate;
|
|
236
|
+
/**
|
|
237
|
+
* Whether a point has something to decide, judged offline with the point's own agents and the
|
|
238
|
+
* conversation manager assumed present. False when the previous agent never answered in the
|
|
239
|
+
* history: production makes no call then, and the driver records the run as `Skipped`.
|
|
240
|
+
*
|
|
241
|
+
* @param point The corpus point.
|
|
242
|
+
*/
|
|
243
|
+
export declare function IsDecidableOffline(point: DecisionCorpusPoint): boolean;
|
|
244
|
+
//# sourceMappingURL=suite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suite.d.ts","sourceRoot":"","sources":["../../src/decision-eval/suite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEtD,OAAO,EAAiD,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE3H,gEAAgE;AAChE,eAAO,MAAM,4BAA4B,kBAAkB,CAAC;AAE5D,6EAA6E;AAC7E,eAAO,MAAM,gCAAgC,8CAAyC,CAAC;AAEvF,qFAAqF;AACrF,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAiB5C,qGAAqG;AACrG,eAAO,MAAM,2BAA2B,2CAAqF,CAAC;AAE9H,qEAAqE;AACrE,eAAO,MAAM,4BAA4B;IACrC,4EAA4E;;;;;;;;;IAS5E,gEAAgE;;IAEhE,iEAAiE;;;;;;;;;;;;;;;;;;;;;;;;EAEnE,CAAC;AAEH,uBAAuB;AACvB,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAElF,4EAA4E;AAC5E,eAAO,MAAM,wBAAwB;;;;QAnBjC,4EAA4E;;;;;;;;;QAS5E,gEAAgE;;QAEhE,iEAAiE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYnE,CAAC;AAEH,qBAAqB;AACrB,MAAM,MAAM,kB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ED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE/E;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,sBAAsB,GAAG,kBAAkB,CAgB/F;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CACvC,QAAQ,EAAE,qBAAqB,EAC/B,IAAI,EAAE,sBAAsB,EAC5B,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GACpB,UAAU,CAiBZ;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,UAAU,CAW7H;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACnC,KAAK,EAAE,SAAS,qBAAqB,EAAE,EACvC,KAAK,EAAE,SAAS,sBAAsB,EAAE,EACxC,IAAI,EAAE,MAAM,GACb,uBAAuB,CAmBzB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAEtE"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Expands a labelled corpus × a matrix of cells into `MJ: Tests` records for the
|
|
3
|
+
* `Decision Eval` test type, plus the suite that runs them. Pure: the generator rig
|
|
4
|
+
* (`integration-test-suite/rigs/generate-decision-eval-suite.ts`) reads the files and writes the
|
|
5
|
+
* output.
|
|
6
|
+
*
|
|
7
|
+
* One record per (point, cell), named `<point id> [<cell label>]` so the scorecard can group runs
|
|
8
|
+
* by cell, with a stable ID derived from that pair so regenerating updates records rather than
|
|
9
|
+
* orphaning them. The scheme is the Prompt Eval generator's.
|
|
10
|
+
*
|
|
11
|
+
* @module @memberjunction/testing-engine
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
import { BuildRoutingQuestions, BuildRoutingState, BuildRoutingStateStructured, CanAskRoutingDecision } from '@memberjunction/ai-core-plus';
|
|
15
|
+
import { MapPointToRoutingInput } from './point-mapping.js';
|
|
16
|
+
import { DECISION_EVAL_STATE_LAYOUTS, DescribeZodError } from './types.js';
|
|
17
|
+
/** The test type's name, as the metadata record declares it. */
|
|
18
|
+
export const DECISION_EVAL_TEST_TYPE_NAME = 'Decision Eval';
|
|
19
|
+
/** The suite name when neither the matrix nor the command line gives one. */
|
|
20
|
+
export const DEFAULT_DECISION_EVAL_SUITE_NAME = 'Decision Eval — Conversation Routing';
|
|
21
|
+
/** Repeats per record when neither the matrix nor the command line gives a count. */
|
|
22
|
+
export const DEFAULT_DECISION_EVAL_REPS = 5;
|
|
23
|
+
/** A decision reply is a short JSON object. Reasoning models bill thinking as output, so this reads low. */
|
|
24
|
+
const ASSUMED_COMPLETION_TOKENS = 120;
|
|
25
|
+
/** What the decision prompt adds around the state and questions. A guess until measured. */
|
|
26
|
+
const ASSUMED_PROMPT_OVERHEAD_TOKENS = 600;
|
|
27
|
+
/**
|
|
28
|
+
* The agents the generator resolves against, with no engine loaded: the point's own names, and a
|
|
29
|
+
* stand-in conversation manager (the driver uses the engine's Sage).
|
|
30
|
+
*/
|
|
31
|
+
const OFFLINE_CATALOG = {
|
|
32
|
+
FindAgent: () => undefined,
|
|
33
|
+
ConversationManager: { ID: '00000000-0000-4000-8000-000000000000', Name: 'Sage', Description: null }
|
|
34
|
+
};
|
|
35
|
+
/** A cell's label: it becomes the bracketed part of every record's name, so it holds no brackets. */
|
|
36
|
+
export const DecisionEvalCellLabelSchema = z.string().min(1).refine(label => !/[[\]]/.test(label), 'must not contain [ or ]');
|
|
37
|
+
/** One matrix cell: the conditions every point is observed under. */
|
|
38
|
+
export const DecisionEvalMatrixCellSchema = z.object({
|
|
39
|
+
/** Names the cell. It becomes the bracketed part of every record's name. */
|
|
40
|
+
label: DecisionEvalCellLabelSchema,
|
|
41
|
+
stateLayout: z.enum(DECISION_EVAL_STATE_LAYOUTS),
|
|
42
|
+
promptName: z.string().min(1).optional(),
|
|
43
|
+
modelId: z.string().uuid().optional(),
|
|
44
|
+
vendorId: z.string().uuid().optional(),
|
|
45
|
+
failover: z.boolean().optional(),
|
|
46
|
+
temperature: z.number().optional(),
|
|
47
|
+
seed: z.number().int().optional(),
|
|
48
|
+
/** USD per million input tokens, for the cost estimate only. */
|
|
49
|
+
inputPricePer1M: z.number().nonnegative().optional(),
|
|
50
|
+
/** USD per million output tokens, for the cost estimate only. */
|
|
51
|
+
outputPricePer1M: z.number().nonnegative().optional()
|
|
52
|
+
});
|
|
53
|
+
/** A matrix file. Keys it doesn't know, such as `_comment`, are ignored. */
|
|
54
|
+
export const DecisionEvalMatrixSchema = z.object({
|
|
55
|
+
suiteName: z.string().min(1).optional(),
|
|
56
|
+
reps: z.number().int().positive().optional(),
|
|
57
|
+
cells: z.array(DecisionEvalMatrixCellSchema).min(1)
|
|
58
|
+
});
|
|
59
|
+
/**
|
|
60
|
+
* Parses and validates a matrix file. Throws naming the problem, and names a repeated cell label.
|
|
61
|
+
*
|
|
62
|
+
* @param text The file's text.
|
|
63
|
+
* @param source The file's name, for messages.
|
|
64
|
+
*/
|
|
65
|
+
export function ParseDecisionEvalMatrix(text, source) {
|
|
66
|
+
return ParseEvalMatrixFile(text, source, DecisionEvalMatrixSchema);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Parses and validates a matrix file against a decision's matrix schema. Throws naming the
|
|
70
|
+
* problem, and names a repeated cell label. Shared by the routing and discovery matrices.
|
|
71
|
+
*
|
|
72
|
+
* @param text The file's text.
|
|
73
|
+
* @param source The file's name, for messages.
|
|
74
|
+
* @param schema The decision's matrix schema.
|
|
75
|
+
*/
|
|
76
|
+
export function ParseEvalMatrixFile(text, source, schema) {
|
|
77
|
+
let json;
|
|
78
|
+
try {
|
|
79
|
+
json = JSON.parse(text);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
throw new Error(`${source}: not valid JSON (${error instanceof Error ? error.message : String(error)})`);
|
|
83
|
+
}
|
|
84
|
+
const result = schema.safeParse(json);
|
|
85
|
+
if (!result.success) {
|
|
86
|
+
throw new Error(`${source}: ${DescribeZodError(result.error)}`);
|
|
87
|
+
}
|
|
88
|
+
const seen = new Set();
|
|
89
|
+
for (const cell of result.data.cells) {
|
|
90
|
+
if (seen.has(cell.label)) {
|
|
91
|
+
throw new Error(`${source}: cell label '${cell.label}' appears twice`);
|
|
92
|
+
}
|
|
93
|
+
seen.add(cell.label);
|
|
94
|
+
}
|
|
95
|
+
return result.data;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* A stable UUID for a pair of strings: FNV-1a over `a::b`, spread across a v4-shaped UUID. The same
|
|
99
|
+
* scheme as the Prompt Eval generator's, so regenerating updates the same records.
|
|
100
|
+
*
|
|
101
|
+
* @param a The first part, such as a point ID.
|
|
102
|
+
* @param b The second part, such as a cell label.
|
|
103
|
+
*/
|
|
104
|
+
export function StableEvalId(a, b) {
|
|
105
|
+
let hash = 0x811c9dc5;
|
|
106
|
+
for (const char of `${a}::${b}`) {
|
|
107
|
+
hash = Math.imul(hash ^ char.charCodeAt(0), 0x01000193) >>> 0;
|
|
108
|
+
}
|
|
109
|
+
const hex = hash.toString(16).padStart(8, '0');
|
|
110
|
+
const tail = Array.from({ length: 3 }, (_, i) => (Math.imul(hash + i + 1, 0x01000193) >>> 0).toString(16).padStart(8, '0')).join('');
|
|
111
|
+
return `${hex}-${tail.slice(0, 4)}-4${tail.slice(4, 7)}-a${tail.slice(7, 10)}-${tail.slice(10, 22)}`.toUpperCase();
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* A record's name: `<point id> [<cell label>]`. The scorecard splits it back apart.
|
|
115
|
+
*
|
|
116
|
+
* @param pointId The point.
|
|
117
|
+
* @param cellLabel The cell.
|
|
118
|
+
*/
|
|
119
|
+
export function DecisionEvalTestName(pointId, cellLabel) {
|
|
120
|
+
return `${pointId} [${cellLabel}]`;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* A cell's test `Configuration`. The `decision-label-match` oracle scores the `continues`
|
|
124
|
+
* Likelihood against the label at 0.5.
|
|
125
|
+
*
|
|
126
|
+
* @param cell The cell.
|
|
127
|
+
*/
|
|
128
|
+
export function BuildDecisionEvalConfiguration(cell) {
|
|
129
|
+
return {
|
|
130
|
+
decision: 'conversation-routing',
|
|
131
|
+
stateLayout: cell.stateLayout,
|
|
132
|
+
promptName: cell.promptName,
|
|
133
|
+
modelId: cell.modelId,
|
|
134
|
+
vendorId: cell.vendorId,
|
|
135
|
+
failover: cell.failover,
|
|
136
|
+
temperature: cell.temperature,
|
|
137
|
+
seed: cell.seed,
|
|
138
|
+
oracles: [{
|
|
139
|
+
type: 'decision-label-match',
|
|
140
|
+
weight: 1,
|
|
141
|
+
config: { question: 'continues', positiveLabel: 'continue', threshold: 0.5 }
|
|
142
|
+
}]
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* One `MJ: Tests` record: the point as its input, its label as the expected outcome, the cell as
|
|
147
|
+
* its configuration, and `RepeatCount` repeats. The description carries IDs only, never text.
|
|
148
|
+
*
|
|
149
|
+
* @param testCase The labelled point.
|
|
150
|
+
* @param cell The cell.
|
|
151
|
+
* @param reps Repeats per record.
|
|
152
|
+
* @param labelSource Where the label came from.
|
|
153
|
+
*/
|
|
154
|
+
export function BuildDecisionEvalTestRecord(testCase, cell, reps, labelSource) {
|
|
155
|
+
const name = DecisionEvalTestName(testCase.Point.id, cell.label);
|
|
156
|
+
return {
|
|
157
|
+
fields: {
|
|
158
|
+
TypeID: `@lookup:MJ: Test Types.Name=${DECISION_EVAL_TEST_TYPE_NAME}`,
|
|
159
|
+
Name: name,
|
|
160
|
+
Description: `Conversation-routing decision point ${testCase.Point.id} under cell '${cell.label}'. `
|
|
161
|
+
+ 'Generated by generate-decision-eval-suite.ts; do not hand-edit.',
|
|
162
|
+
// JSON columns: mj-sync serializes the objects, so they are not pre-stringified.
|
|
163
|
+
InputDefinition: { point: testCase.Point },
|
|
164
|
+
ExpectedOutcomes: { label: testCase.Label, labelSource },
|
|
165
|
+
Configuration: BuildDecisionEvalConfiguration(cell),
|
|
166
|
+
RepeatCount: reps,
|
|
167
|
+
Status: 'Active'
|
|
168
|
+
},
|
|
169
|
+
primaryKey: { ID: StableEvalId(testCase.Point.id, cell.label) }
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* The suite record, with a membership row per test in order.
|
|
174
|
+
*
|
|
175
|
+
* @param suiteName The suite's name.
|
|
176
|
+
* @param testNames The tests' names, in run order.
|
|
177
|
+
* @param description The suite's description.
|
|
178
|
+
*/
|
|
179
|
+
export function BuildDecisionEvalSuiteRecord(suiteName, testNames, description) {
|
|
180
|
+
return {
|
|
181
|
+
fields: { Name: suiteName, Description: description, Status: 'Active' },
|
|
182
|
+
primaryKey: { ID: StableEvalId(suiteName, 'suite') },
|
|
183
|
+
relatedEntities: {
|
|
184
|
+
'MJ: Test Suite Tests': testNames.map((name, i) => ({
|
|
185
|
+
fields: { SuiteID: '@parent:ID', TestID: `@lookup:MJ: Tests.Name=${name}`, Sequence: i + 1, Status: 'Active' },
|
|
186
|
+
primaryKey: { ID: StableEvalId(name, 'membership') }
|
|
187
|
+
}))
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Estimates the run's tokens and cost. Each call's prompt is the state and questions the builders
|
|
193
|
+
* produce for the point (with the point's own agent names, since no engine is loaded offline) at
|
|
194
|
+
* four characters a token, plus a fixed allowance for the prompt around them. A floor, not a
|
|
195
|
+
* ceiling.
|
|
196
|
+
*
|
|
197
|
+
* @param cases The labelled points.
|
|
198
|
+
* @param cells The matrix cells.
|
|
199
|
+
* @param reps Repeats per record.
|
|
200
|
+
*/
|
|
201
|
+
export function EstimateDecisionEvalRun(cases, cells, reps) {
|
|
202
|
+
const perCell = cells.map(cell => {
|
|
203
|
+
const promptTokens = cases.reduce((sum, c) => sum + estimatePromptTokens(c, cell), 0) * reps;
|
|
204
|
+
const completionTokens = cases.length * ASSUMED_COMPLETION_TOKENS * reps;
|
|
205
|
+
const priced = cell.inputPricePer1M !== undefined && cell.outputPricePer1M !== undefined;
|
|
206
|
+
return {
|
|
207
|
+
Label: cell.label,
|
|
208
|
+
PromptTokens: promptTokens,
|
|
209
|
+
CompletionTokens: completionTokens,
|
|
210
|
+
USD: priced ? (promptTokens * (cell.inputPricePer1M ?? 0) + completionTokens * (cell.outputPricePer1M ?? 0)) / 1e6 : null
|
|
211
|
+
};
|
|
212
|
+
});
|
|
213
|
+
const priced = perCell.filter((c) => c.USD !== null);
|
|
214
|
+
return {
|
|
215
|
+
PromptTokens: perCell.reduce((sum, c) => sum + c.PromptTokens, 0),
|
|
216
|
+
CompletionTokens: perCell.reduce((sum, c) => sum + c.CompletionTokens, 0),
|
|
217
|
+
USD: priced.length === 0 ? null : priced.reduce((sum, c) => sum + c.USD, 0),
|
|
218
|
+
PerCell: perCell.map(c => ({ Label: c.Label, USD: c.USD }))
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Whether a point has something to decide, judged offline with the point's own agents and the
|
|
223
|
+
* conversation manager assumed present. False when the previous agent never answered in the
|
|
224
|
+
* history: production makes no call then, and the driver records the run as `Skipped`.
|
|
225
|
+
*
|
|
226
|
+
* @param point The corpus point.
|
|
227
|
+
*/
|
|
228
|
+
export function IsDecidableOffline(point) {
|
|
229
|
+
return CanAskRoutingDecision(MapPointToRoutingInput(point, OFFLINE_CATALOG));
|
|
230
|
+
}
|
|
231
|
+
/** One call's prompt tokens for a point under a cell, estimated offline. */
|
|
232
|
+
function estimatePromptTokens(testCase, cell) {
|
|
233
|
+
const input = MapPointToRoutingInput(testCase.Point, OFFLINE_CATALOG);
|
|
234
|
+
const state = cell.stateLayout === 'structured' ? JSON.stringify(BuildRoutingStateStructured(input), null, 1) : BuildRoutingState(input);
|
|
235
|
+
const questions = JSON.stringify(BuildRoutingQuestions(input));
|
|
236
|
+
return Math.ceil((state.length + questions.length) / 4) + ASSUMED_PROMPT_OVERHEAD_TOKENS;
|
|
237
|
+
}
|
|
238
|
+
//# sourceMappingURL=suite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suite.js","sourceRoot":"","sources":["../../src/decision-eval/suite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE5I,OAAO,EAAE,sBAAsB,EAAiC,MAAM,iBAAiB,CAAC;AACxF,OAAO,EAAE,2BAA2B,EAAE,gBAAgB,EAAqD,MAAM,SAAS,CAAC;AAE3H,gEAAgE;AAChE,MAAM,CAAC,MAAM,4BAA4B,GAAG,eAAe,CAAC;AAE5D,6EAA6E;AAC7E,MAAM,CAAC,MAAM,gCAAgC,GAAG,sCAAsC,CAAC;AAEvF,qFAAqF;AACrF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAE5C,4GAA4G;AAC5G,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAEtC,4FAA4F;AAC5F,MAAM,8BAA8B,GAAG,GAAG,CAAC;AAE3C;;;GAGG;AACH,MAAM,eAAe,GAA6B;IAC9C,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS;IAC1B,mBAAmB,EAAE,EAAE,EAAE,EAAE,sCAAsC,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE;CACvG,CAAC;AAEF,qGAAqG;AACrG,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,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