@memberjunction/record-set-processor 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/dist/RecordProcessExecutor.d.ts +4 -0
- package/dist/RecordProcessExecutor.d.ts.map +1 -1
- package/dist/RecordProcessExecutor.js +17 -42
- package/dist/RecordProcessExecutor.js.map +1 -1
- package/dist/feature-pipeline-drivers/BaseFeaturePipelineDriver.d.ts +92 -0
- package/dist/feature-pipeline-drivers/BaseFeaturePipelineDriver.d.ts.map +1 -0
- package/dist/feature-pipeline-drivers/BaseFeaturePipelineDriver.js +26 -0
- package/dist/feature-pipeline-drivers/BaseFeaturePipelineDriver.js.map +1 -0
- package/dist/feature-pipeline-drivers/DecisionFeaturePipelineDriver.d.ts +79 -0
- package/dist/feature-pipeline-drivers/DecisionFeaturePipelineDriver.d.ts.map +1 -0
- package/dist/feature-pipeline-drivers/DecisionFeaturePipelineDriver.js +257 -0
- package/dist/feature-pipeline-drivers/DecisionFeaturePipelineDriver.js.map +1 -0
- package/dist/feature-pipeline-drivers/LLMFeaturePipelineDriver.d.ts +23 -0
- package/dist/feature-pipeline-drivers/LLMFeaturePipelineDriver.d.ts.map +1 -0
- package/dist/feature-pipeline-drivers/LLMFeaturePipelineDriver.js +85 -0
- package/dist/feature-pipeline-drivers/LLMFeaturePipelineDriver.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/processors/ActionRecordProcessor.d.ts +6 -0
- package/dist/processors/ActionRecordProcessor.d.ts.map +1 -1
- package/dist/processors/ActionRecordProcessor.js +15 -3
- package/dist/processors/ActionRecordProcessor.js.map +1 -1
- package/dist/processors/AgentRecordProcessor.d.ts +2 -0
- package/dist/processors/AgentRecordProcessor.d.ts.map +1 -1
- package/dist/processors/AgentRecordProcessor.js +5 -1
- package/dist/processors/AgentRecordProcessor.js.map +1 -1
- package/dist/processors/FeaturePipelineEscalation.d.ts +155 -0
- package/dist/processors/FeaturePipelineEscalation.d.ts.map +1 -0
- package/dist/processors/FeaturePipelineEscalation.js +208 -0
- package/dist/processors/FeaturePipelineEscalation.js.map +1 -0
- package/dist/processors/InferProcessor.d.ts +210 -5
- package/dist/processors/InferProcessor.d.ts.map +1 -1
- package/dist/processors/InferProcessor.js +608 -96
- package/dist/processors/InferProcessor.js.map +1 -1
- package/dist/processors/WriteBackProcessor.d.ts +2 -0
- package/dist/processors/WriteBackProcessor.d.ts.map +1 -1
- package/dist/processors/WriteBackProcessor.js +10 -4
- package/dist/processors/WriteBackProcessor.js.map +1 -1
- package/dist/watermark/WatermarkService.d.ts +4 -0
- package/dist/watermark/WatermarkService.d.ts.map +1 -1
- package/dist/watermark/WatermarkService.js +6 -2
- package/dist/watermark/WatermarkService.js.map +1 -1
- package/dist/writeBack.d.ts +11 -1
- package/dist/writeBack.d.ts.map +1 -1
- package/dist/writeBack.js +5 -1
- package/dist/writeBack.js.map +1 -1
- package/package.json +17 -16
|
@@ -42,6 +42,8 @@ export declare class RecordProcessExecutor {
|
|
|
42
42
|
/** Runs an already-loaded Record Process. */
|
|
43
43
|
Run(rp: MJRecordProcessEntity, options: RunRecordProcessOptions): Promise<ProcessRunResult>;
|
|
44
44
|
/** Builds the record-set source from a single-record override, a runtime scope override, or the process's stored Scope. */
|
|
45
|
+
BuildSource(rp: MJRecordProcessEntity, provider: IMetadataProvider, singleRecordID?: string, scope?: RecordProcessScopeOverride): IRecordSetSource;
|
|
46
|
+
/** @deprecated Use {@link BuildSource}. */
|
|
45
47
|
buildSource(rp: MJRecordProcessEntity, provider: IMetadataProvider, singleRecordID?: string, scope?: RecordProcessScopeOverride): IRecordSetSource;
|
|
46
48
|
/** Resolves a runtime scope override (UI invocation: selection / view / list / filter) to a source. */
|
|
47
49
|
private buildSourceFromScope;
|
|
@@ -52,6 +54,8 @@ export declare class RecordProcessExecutor {
|
|
|
52
54
|
* dry-run the inner work runs but the mapping only previews (nothing is saved), so EVERY work type's
|
|
53
55
|
* dry-run is side-effect-free, not just FieldRules.
|
|
54
56
|
*/
|
|
57
|
+
BuildProcessor(rp: MJRecordProcessEntity, dryRun?: boolean, provider?: IMetadataProvider): IRecordProcessor;
|
|
58
|
+
/** @deprecated Use {@link BuildProcessor}. */
|
|
55
59
|
buildProcessor(rp: MJRecordProcessEntity, dryRun?: boolean, provider?: IMetadataProvider): IRecordProcessor;
|
|
56
60
|
/**
|
|
57
61
|
* Resolves a processor for a work type the built-in switch doesn't handle by consulting the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordProcessExecutor.d.ts","sourceRoot":"","sources":["../src/RecordProcessExecutor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAA+B,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhG,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAGH,gBAAgB,EAChB,gBAAgB,EAEhB,gBAAgB,EAChB,YAAY,EAGZ,gBAAgB,EAEnB,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAUhF,8CAA8C;AAC9C,MAAM,WAAW,uBAAuB;IACpC,uBAAuB;IACvB,WAAW,EAAE,QAAQ,CAAC;IACtB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,mDAAmD;IACnD,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,mGAAmG;IACnG,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,KAAK,CAAC,EAAE,0BAA0B,CAAC;IACnC;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,sGAAsG;IACtG,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,uFAAuF;IACvF,SAAS,CAAC,EAAE,IA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AAE,EAAE,qBAAqB,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,iBAAiB,GAAG,gBAAgB;IAIlH;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;CAkB9B"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @module @memberjunction/record-set-processor
|
|
6
6
|
*/
|
|
7
7
|
import { LogError, Metadata, RunView } from '@memberjunction/core';
|
|
8
|
-
import {
|
|
8
|
+
import { EscapeSQLString, SafeJSONParse } from '@memberjunction/global';
|
|
9
9
|
import { ArraySource, FilterSource, ListSource, RecordProcessorRegistry, ViewSource, } from '@memberjunction/record-set-processor-base';
|
|
10
10
|
import { RecordSetProcessor } from './RecordSetProcessor.js';
|
|
11
11
|
import { ActionRecordProcessor } from './processors/ActionRecordProcessor.js';
|
|
@@ -13,7 +13,6 @@ import { AgentRecordProcessor } from './processors/AgentRecordProcessor.js';
|
|
|
13
13
|
import { InferProcessor } from './processors/InferProcessor.js';
|
|
14
14
|
import { FieldRulesProcessor } from './processors/FieldRulesProcessor.js';
|
|
15
15
|
import { WriteBackProcessor } from './processors/WriteBackProcessor.js';
|
|
16
|
-
import { validateSpec, validateMaterializationTargets } from '@memberjunction/feature-pipelines';
|
|
17
16
|
/** Builds and runs a RecordSetProcessor pass from a Record Process definition. */
|
|
18
17
|
export class RecordProcessExecutor {
|
|
19
18
|
/** Loads the Record Process by ID and runs it. */
|
|
@@ -48,8 +47,8 @@ export class RecordProcessExecutor {
|
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
return RecordSetProcessor.Instance.Process({
|
|
51
|
-
source: this.
|
|
52
|
-
processor: this.
|
|
50
|
+
source: this.BuildSource(rp, provider, options.singleRecordID, options.scope),
|
|
51
|
+
processor: this.BuildProcessor(rp, options.dryRun, provider),
|
|
53
52
|
contextUser: options.contextUser,
|
|
54
53
|
provider,
|
|
55
54
|
dryRun: options.dryRun,
|
|
@@ -67,7 +66,7 @@ export class RecordProcessExecutor {
|
|
|
67
66
|
});
|
|
68
67
|
}
|
|
69
68
|
/** Builds the record-set source from a single-record override, a runtime scope override, or the process's stored Scope. */
|
|
70
|
-
|
|
69
|
+
BuildSource(rp, provider, singleRecordID, scope) {
|
|
71
70
|
if (singleRecordID) {
|
|
72
71
|
return new ArraySource([{ EntityID: rp.EntityID, RecordID: singleRecordID }], rp.EntityID, 'SingleRecord');
|
|
73
72
|
}
|
|
@@ -98,6 +97,10 @@ export class RecordProcessExecutor {
|
|
|
98
97
|
throw new Error(`Record Process '${rp.Name}': unsupported ScopeType '${rp.ScopeType}'`);
|
|
99
98
|
}
|
|
100
99
|
}
|
|
100
|
+
/** @deprecated Use {@link BuildSource}. */
|
|
101
|
+
buildSource(rp, provider, singleRecordID, scope) {
|
|
102
|
+
return this.BuildSource(rp, provider, singleRecordID, scope);
|
|
103
|
+
}
|
|
101
104
|
/** Resolves a runtime scope override (UI invocation: selection / view / list / filter) to a source. */
|
|
102
105
|
buildSourceFromScope(rp, provider, scope) {
|
|
103
106
|
switch (scope.Kind) {
|
|
@@ -123,7 +126,7 @@ export class RecordProcessExecutor {
|
|
|
123
126
|
* dry-run the inner work runs but the mapping only previews (nothing is saved), so EVERY work type's
|
|
124
127
|
* dry-run is side-effect-free, not just FieldRules.
|
|
125
128
|
*/
|
|
126
|
-
|
|
129
|
+
BuildProcessor(rp, dryRun, provider) {
|
|
127
130
|
if (rp.WorkType === 'FieldRules') {
|
|
128
131
|
const ruleSet = rp.Configuration ? SafeJSONParse(rp.Configuration) : undefined;
|
|
129
132
|
if (!ruleSet || !Array.isArray(ruleSet.Rules)) {
|
|
@@ -148,42 +151,10 @@ export class RecordProcessExecutor {
|
|
|
148
151
|
base = new AgentRecordProcessor(rp.AgentID, inputMapping);
|
|
149
152
|
}
|
|
150
153
|
else if (rp.WorkType === 'Infer') {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
try {
|
|
156
|
-
spec = JSON.parse(rp.Configuration);
|
|
157
|
-
}
|
|
158
|
-
catch (e) {
|
|
159
|
-
throw new Error(`Record Process '${rp.Name}': Configuration is invalid JSON: ${e instanceof Error ? e.message : String(e)}`);
|
|
160
|
-
}
|
|
161
|
-
const issues = validateSpec(spec);
|
|
162
|
-
const errors = issues.filter((i) => i.Severity === 'error');
|
|
163
|
-
if (errors.length > 0) {
|
|
164
|
-
throw new Error(`Record Process '${rp.Name}': invalid DataFeatureSpec in Configuration: ${errors.map((err) => err.Message).join('; ')}`);
|
|
165
|
-
}
|
|
166
|
-
const targetProvider = provider ?? Metadata.Provider;
|
|
167
|
-
if (targetProvider && rp.EntityID) {
|
|
168
|
-
const materializationIssues = validateMaterializationTargets(spec, targetProvider, rp.EntityID);
|
|
169
|
-
const matErrors = materializationIssues.filter((i) => i.Severity === 'error');
|
|
170
|
-
if (matErrors.length > 0) {
|
|
171
|
-
throw new Error(`Record Process '${rp.Name}': invalid materialization targets: ${matErrors.map((err) => `${err.Field ? `[${err.Field}] ` : ''}${err.Message} Fix: ${err.FixRecommendation}`).join('; ')}`);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
if (spec?.ProcessorExtensionKey) {
|
|
176
|
-
const custom = MJGlobal.Instance.ClassFactory.CreateInstance(InferProcessor, spec.ProcessorExtensionKey, rp.PromptID, inputMapping, spec);
|
|
177
|
-
if (custom && custom.constructor !== InferProcessor) {
|
|
178
|
-
base = custom;
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
throw new Error(`Record Process '${rp.Name}': ProcessorExtensionKey '${spec.ProcessorExtensionKey}' not found in ClassFactory`);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
base = new InferProcessor(rp.PromptID, inputMapping, spec);
|
|
186
|
-
}
|
|
154
|
+
// Shared with a Decision pipeline's escalation target, which is built the same way
|
|
155
|
+
const infer = InferProcessor.FromRecordProcess(rp, provider);
|
|
156
|
+
spec = infer.Spec;
|
|
157
|
+
base = infer;
|
|
187
158
|
}
|
|
188
159
|
else {
|
|
189
160
|
// Not a built-in work type — consult the pluggable registry. This is the open seam that
|
|
@@ -221,6 +192,10 @@ export class RecordProcessExecutor {
|
|
|
221
192
|
}
|
|
222
193
|
return base;
|
|
223
194
|
}
|
|
195
|
+
/** @deprecated Use {@link BuildProcessor}. */
|
|
196
|
+
buildProcessor(rp, dryRun, provider) {
|
|
197
|
+
return this.BuildProcessor(rp, dryRun, provider);
|
|
198
|
+
}
|
|
224
199
|
/**
|
|
225
200
|
* Resolves a processor for a work type the built-in switch doesn't handle by consulting the
|
|
226
201
|
* {@link RecordProcessorRegistry}. External packages register a factory keyed by their work-type
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordProcessExecutor.js","sourceRoot":"","sources":["../src/RecordProcessExecutor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAqB,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAY,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"RecordProcessExecutor.js","sourceRoot":"","sources":["../src/RecordProcessExecutor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAqB,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAY,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,aAAa,EAAqB,MAAM,wBAAwB,CAAC;AAE3F,OAAO,EACH,WAAW,EACX,YAAY,EAGZ,UAAU,EAIV,uBAAuB,EAEvB,UAAU,GACb,MAAM,2CAA2C,CAAC;AAGnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO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EAAE,EAAE,CAAC,QAAQ;YACrB,aAAa,EAAE,EAAE,CAAC,aAAa;YAC/B,YAAY,EAAE,EAAE,CAAC,YAAY;YAC7B,aAAa,EAAE,EAAE,CAAC,aAAa;YAC/B,QAAQ,EAAE,EAAE,CAAC,QAAQ;YACrB,eAAe,EAAE,EAAE,CAAC,EAAE;YACtB,iBAAiB,EAAE,EAAE,CAAC,IAAI;YAC1B,MAAM,EAAE,MAAM;YACd,aAAa,EAAE,EAAE;SACpB,CAAC;QACF,MAAM,QAAQ,GAAG,uBAAuB,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACnE,IAAI,CAAC,QAAQ,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,mBAAmB,EAAE,CAAC,IAAI,4BAA4B,EAAE,CAAC,QAAQ,GAAG,CAAC,CAAC;QAC1F,CAAC;QACD,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The Feature Pipeline driver seam. A driver is the one step of a Feature Pipeline
|
|
3
|
+
* that varies by pipeline type: turning one record's context into its output values. Everything
|
|
4
|
+
* else (context building, cache keys and batching, watermarks, constraint validation, history and
|
|
5
|
+
* write-back) stays in `InferProcessor`, which resolves the driver from `MJ: Feature Pipeline Types`
|
|
6
|
+
* by `DataFeatureSpec.PipelineType` and calls {@link BaseFeaturePipelineDriver.ComputeOutputs}.
|
|
7
|
+
*
|
|
8
|
+
* @module @memberjunction/record-set-processor
|
|
9
|
+
*/
|
|
10
|
+
import type { AIPromptParams, AIPromptRunResult, MJAIPromptEntityExtended } from '@memberjunction/ai-core-plus';
|
|
11
|
+
import type { RecordProcessorContext, RecordRef } from '@memberjunction/record-set-processor-base';
|
|
12
|
+
import { type DataFeatureSpec, type FeaturePipelineDriverCapabilities, type FeaturePipelineFieldValueLookup } from '@memberjunction/feature-pipelines';
|
|
13
|
+
/**
|
|
14
|
+
* How a driver calls back into `InferProcessor`'s overridable steps, so that a processor extension
|
|
15
|
+
* registered under `DataFeatureSpec.ProcessorExtensionKey` keeps working whichever driver runs.
|
|
16
|
+
* `InferProcessor` builds this from closures over its own protected hooks.
|
|
17
|
+
*
|
|
18
|
+
* **The contract for drivers.** Every driver must call `BeforeBuildContext` and then `BuildPromptData`
|
|
19
|
+
* once per record, before computing anything, so that an extension's context shaping applies to
|
|
20
|
+
* every pipeline type. `BeforePromptExecute` and `AfterPromptExecute` are LLM-shaped: they take the
|
|
21
|
+
* chat prompt's `AIPromptParams` and `AIPromptRunResult`. A driver that runs an `AIPromptRunner`
|
|
22
|
+
* chat prompt must call both. A driver that doesn't (a Decision model, for example) doesn't call
|
|
23
|
+
* them. An extension that overrides `beforePromptExecute` or `afterPromptExecute` therefore stops
|
|
24
|
+
* firing once its pipeline switches to such a type, and should move that logic into
|
|
25
|
+
* `buildPromptData` or into the driver.
|
|
26
|
+
*/
|
|
27
|
+
export interface FeaturePipelineComputeHooks {
|
|
28
|
+
/** Builds the data object passed to the prompt (`InferProcessor.buildPromptData`). */
|
|
29
|
+
BuildPromptData: (record: RecordRef, ctx: RecordProcessorContext) => Promise<Record<string, unknown>>;
|
|
30
|
+
/** Called before the prompt's context is built (`InferProcessor.beforeBuildContext`). */
|
|
31
|
+
BeforeBuildContext: (record: RecordRef, ctx: RecordProcessorContext) => Promise<void>;
|
|
32
|
+
/** Called immediately before the prompt runs (`InferProcessor.beforePromptExecute`). */
|
|
33
|
+
BeforePromptExecute: (params: AIPromptParams, record: RecordRef, ctx: RecordProcessorContext) => Promise<void>;
|
|
34
|
+
/** Called after the prompt succeeds; returns the raw result (`InferProcessor.afterPromptExecute`). */
|
|
35
|
+
AfterPromptExecute: (result: AIPromptRunResult<unknown>, record: RecordRef, ctx: RecordProcessorContext) => Promise<unknown>;
|
|
36
|
+
}
|
|
37
|
+
/** Everything a driver needs to compute one record's outputs. */
|
|
38
|
+
export interface FeaturePipelineComputeRequest {
|
|
39
|
+
/** The record being processed. */
|
|
40
|
+
Record: RecordRef;
|
|
41
|
+
/** The run's processor context. */
|
|
42
|
+
Context: RecordProcessorContext;
|
|
43
|
+
/** The pipeline's resolved prompt. */
|
|
44
|
+
Prompt: MJAIPromptEntityExtended;
|
|
45
|
+
/** The pipeline's spec, when it has one. */
|
|
46
|
+
Spec?: DataFeatureSpec;
|
|
47
|
+
/** Callbacks into the processor's overridable steps. */
|
|
48
|
+
Hooks: FeaturePipelineComputeHooks;
|
|
49
|
+
/** Optional field values lookup scoped to the pipeline's entity. */
|
|
50
|
+
FieldValues?: FeaturePipelineFieldValueLookup;
|
|
51
|
+
}
|
|
52
|
+
/** A driver computed the record's outputs. */
|
|
53
|
+
export interface FeaturePipelineComputeSuccess {
|
|
54
|
+
Success: true;
|
|
55
|
+
/** The outputs as the model returned them, before constraint validation. */
|
|
56
|
+
RawResult: unknown;
|
|
57
|
+
/** The `MJ: AI Prompt Runs` row that produced them, when there is one. */
|
|
58
|
+
AIPromptRunID?: string;
|
|
59
|
+
/** Each output's confidence, keyed by output name, for drivers that produce one. */
|
|
60
|
+
Confidence?: Record<string, number>;
|
|
61
|
+
}
|
|
62
|
+
/** A driver could not compute the record's outputs. */
|
|
63
|
+
export interface FeaturePipelineComputeFailure {
|
|
64
|
+
Success: false;
|
|
65
|
+
/** Why the computation failed. */
|
|
66
|
+
ErrorMessage: string;
|
|
67
|
+
/** The `MJ: AI Prompt Runs` row of the failed run, when there is one. */
|
|
68
|
+
AIPromptRunID?: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The outcome of {@link BaseFeaturePipelineDriver.ComputeOutputs}. Narrow it with
|
|
72
|
+
* `'ErrorMessage' in result`: this package is not compiled strictly, so `Success` alone does not narrow.
|
|
73
|
+
*/
|
|
74
|
+
export type FeaturePipelineComputeResult = FeaturePipelineComputeSuccess | FeaturePipelineComputeFailure;
|
|
75
|
+
/**
|
|
76
|
+
* Base class for a Feature Pipeline type's driver. Subclasses register with
|
|
77
|
+
* `@RegisterClass(BaseFeaturePipelineDriver, '<DriverClass>')`, where `<DriverClass>` is the value in
|
|
78
|
+
* the type's `MJ: Feature Pipeline Types.DriverClass` column.
|
|
79
|
+
*/
|
|
80
|
+
export declare abstract class BaseFeaturePipelineDriver {
|
|
81
|
+
/** What this driver can produce. */
|
|
82
|
+
abstract get Capabilities(): FeaturePipelineDriverCapabilities;
|
|
83
|
+
/**
|
|
84
|
+
* Checks each output's constraint type, target mode, and rules against {@link Capabilities}.
|
|
85
|
+
* An output with no constraint is not checked for its constraint type unless the type requires constraints.
|
|
86
|
+
* @returns One message per output or rule this driver cannot satisfy; empty when it can produce them all.
|
|
87
|
+
*/
|
|
88
|
+
ValidateOutputs(spec: DataFeatureSpec, fieldValues?: FeaturePipelineFieldValueLookup): string[];
|
|
89
|
+
/** Computes one record's output values. */
|
|
90
|
+
abstract ComputeOutputs(request: FeaturePipelineComputeRequest): Promise<FeaturePipelineComputeResult>;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=BaseFeaturePipelineDriver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseFeaturePipelineDriver.d.ts","sourceRoot":"","sources":["../../src/feature-pipeline-drivers/BaseFeaturePipelineDriver.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAChH,OAAO,KAAK,EAAE,sBAAsB,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AACnG,OAAO,EAGH,KAAK,eAAe,EACpB,KAAK,iCAAiC,EACtC,KAAK,+BAA+B,EACvC,MAAM,mCAAmC,CAAC;AAE3C;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,2BAA2B;IACxC,sFAAsF;IACtF,eAAe,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,sBAAsB,KAAK,OAAO,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,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,MAAM,4BAA4B,GAAG,6BAA6B,GAAG,6BAA6B,CAAC;AAEzG;;;;GAIG;AACH,8BAAsB,yBAAyB;IAC3C,oCAAoC;IACpC,aAAoB,YAAY,IAAI,iCAAiC,CAAC;IAEtE;;;;OAIG;IACI,eAAe,CAAC,IAAI,EAAE,eAAe,EAAE,WAAW,CAAC,EAAE,+BAA+B,GAAG,MAAM,EAAE;IAItG,2CAA2C;aAC3B,cAAc,CAAC,OAAO,EAAE,6BAA6B,GAAG,OAAO,CAAC,4BAA4B,CAAC;CAChH"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The Feature Pipeline driver seam. A driver is the one step of a Feature Pipeline
|
|
3
|
+
* that varies by pipeline type: turning one record's context into its output values. Everything
|
|
4
|
+
* else (context building, cache keys and batching, watermarks, constraint validation, history and
|
|
5
|
+
* write-back) stays in `InferProcessor`, which resolves the driver from `MJ: Feature Pipeline Types`
|
|
6
|
+
* by `DataFeatureSpec.PipelineType` and calls {@link BaseFeaturePipelineDriver.ComputeOutputs}.
|
|
7
|
+
*
|
|
8
|
+
* @module @memberjunction/record-set-processor
|
|
9
|
+
*/
|
|
10
|
+
import { ValidateOutputsAgainstCapabilities, } from '@memberjunction/feature-pipelines';
|
|
11
|
+
/**
|
|
12
|
+
* Base class for a Feature Pipeline type's driver. Subclasses register with
|
|
13
|
+
* `@RegisterClass(BaseFeaturePipelineDriver, '<DriverClass>')`, where `<DriverClass>` is the value in
|
|
14
|
+
* the type's `MJ: Feature Pipeline Types.DriverClass` column.
|
|
15
|
+
*/
|
|
16
|
+
export class BaseFeaturePipelineDriver {
|
|
17
|
+
/**
|
|
18
|
+
* Checks each output's constraint type, target mode, and rules against {@link Capabilities}.
|
|
19
|
+
* An output with no constraint is not checked for its constraint type unless the type requires constraints.
|
|
20
|
+
* @returns One message per output or rule this driver cannot satisfy; empty when it can produce them all.
|
|
21
|
+
*/
|
|
22
|
+
ValidateOutputs(spec, fieldValues) {
|
|
23
|
+
return ValidateOutputsAgainstCapabilities(spec, this.Capabilities, fieldValues);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=BaseFeaturePipelineDriver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseFeaturePipelineDriver.js","sourceRoot":"","sources":["../../src/feature-pipeline-drivers/BaseFeaturePipelineDriver.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EACH,kCAAkC,GAKrC,MAAM,mCAAmC,CAAC;AAqE3C;;;;GAIG;AACH,MAAM,OAAgB,yBAAyB;IAI3C;;;;OAIG;IACI,eAAe,CAAC,IAAqB,EAAE,WAA6C;QACvF,OAAO,kCAAkC,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;IACpF,CAAC;CAIJ"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The `Decision` Feature Pipeline type's driver: runs the pipeline's prompt
|
|
3
|
+
* on a typed decision model for each record, answering Likelihood, Choice, and Score questions
|
|
4
|
+
* together in a single call via `AIDecisionRunner`.
|
|
5
|
+
*
|
|
6
|
+
* Produces calibrated per-output confidence scores for field targets, without model reasoning.
|
|
7
|
+
*
|
|
8
|
+
* Prompt-execution hooks (beforePromptExecute / afterPromptExecute) are LLM-specific and are not
|
|
9
|
+
* called for Decision pipelines.
|
|
10
|
+
*
|
|
11
|
+
* NOTE ON CONFIDENCE & CACHING:
|
|
12
|
+
* Direct computations by this driver produce per-output confidence scores returned in
|
|
13
|
+
* {@link FeaturePipelineComputeSuccess.Confidence} and persisted to `MJ: Feature Values` history.
|
|
14
|
+
* However, cache hits served from `MJ: Feature Value Cache` carry no confidence because the cache
|
|
15
|
+
* table schema stores only input key hashes, prompt version hashes, and serialized output JSON;
|
|
16
|
+
* it has no confidence column. Consumers should note that cached evaluations do not retain confidence.
|
|
17
|
+
*
|
|
18
|
+
* @module @memberjunction/record-set-processor
|
|
19
|
+
*/
|
|
20
|
+
import { AIDecisionRunner } from '@memberjunction/ai-prompts';
|
|
21
|
+
import { type DecisionQuestion, type DecisionAnswer } from '@memberjunction/ai';
|
|
22
|
+
import type { MJAIPromptEntityExtended } from '@memberjunction/ai-core-plus';
|
|
23
|
+
import { type DataFeatureOutput, type FeaturePipelineDriverCapabilities } from '@memberjunction/feature-pipelines';
|
|
24
|
+
import { BaseFeaturePipelineDriver, type FeaturePipelineComputeRequest, type FeaturePipelineComputeResult } from './BaseFeaturePipelineDriver.js';
|
|
25
|
+
/**
|
|
26
|
+
* Runs the pipeline's prompt on a typed decision model for each record, mapping outputs to
|
|
27
|
+
* Likelihood, Choice, or Score questions and extracting calibrated confidence scores.
|
|
28
|
+
*/
|
|
29
|
+
export declare class DecisionFeaturePipelineDriver extends BaseFeaturePipelineDriver {
|
|
30
|
+
/** Supported constraint types (boolean, enum, numeric) and field targets; produces confidence, no reasoning. */
|
|
31
|
+
get Capabilities(): FeaturePipelineDriverCapabilities;
|
|
32
|
+
/**
|
|
33
|
+
* Executes the Decision pipeline for a single record:
|
|
34
|
+
* 1. Validates that the prompt runs on Decision models ({@link IsDecisionPrompt}).
|
|
35
|
+
* 2. Renders the record state via `BeforeBuildContext` and `BuildPromptData`, canonicalizing it.
|
|
36
|
+
* 3. Checks estimated state tokens against the strictest `Decision.MaxStateTokens` limit of the models the prompt may run on (fails if exceeded, never truncates).
|
|
37
|
+
* 4. Builds typed decision questions (Likelihood, Choice, Score) from the spec's outputs.
|
|
38
|
+
* 5. Executes the decision via `AIDecisionRunner.ExecuteDecision`.
|
|
39
|
+
* 6. Maps answers back to output values (applying boolean constraint threshold and score rubric rescaling) and confidences.
|
|
40
|
+
*/
|
|
41
|
+
ComputeOutputs(request: FeaturePipelineComputeRequest): Promise<FeaturePipelineComputeResult>;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the prompt is meant for Decision models: its model type is Decision or, when it has none (so
|
|
44
|
+
* `AIDecisionRunner` applies its own Decision floor), a Decision model is bound to it. Model types are
|
|
45
|
+
* compared by ID. The prompt's name plays no part, so a prompt whose type is LLM is refused here, before
|
|
46
|
+
* the record's state is rendered, whatever it is called.
|
|
47
|
+
*/
|
|
48
|
+
protected IsDecisionPrompt(prompt: MJAIPromptEntityExtended): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The strictest `Decision.MaxStateTokens` among the models the prompt may run on, or undefined when none
|
|
51
|
+
* declares one. The runner picks the model per call, by credentials and failover, so the state is
|
|
52
|
+
* checked against every model it may pick rather than against whichever binding is read first. Those
|
|
53
|
+
* models are the Decision models bound to the prompt or, when none is bound, every active Decision model.
|
|
54
|
+
*/
|
|
55
|
+
protected ResolveMaxStateTokens(prompt: MJAIPromptEntityExtended): number | undefined;
|
|
56
|
+
/** The ID of the model type `AIDecisionRunner` requires, matched by name as the runner matches it. */
|
|
57
|
+
private decisionModelTypeID;
|
|
58
|
+
/** The active Decision models bound to the prompt through its active or preview `MJ: AI Prompt Models` rows. */
|
|
59
|
+
private boundDecisionModels;
|
|
60
|
+
/** The models the prompt may run on: its bound Decision models, or every active Decision model when none is bound. */
|
|
61
|
+
private eligibleDecisionModels;
|
|
62
|
+
/** Whether the model is active and of the given model type. */
|
|
63
|
+
private isActiveOfType;
|
|
64
|
+
/** Factory method to create an AIDecisionRunner instance (extension point for unit testing). */
|
|
65
|
+
protected CreateDecisionRunner(): AIDecisionRunner;
|
|
66
|
+
/** Builds decision questions (Likelihood, Choice, Score) from the spec outputs. */
|
|
67
|
+
protected BuildQuestions(request: FeaturePipelineComputeRequest): Record<string, DecisionQuestion>;
|
|
68
|
+
/**
|
|
69
|
+
* The value lists of the record's entity, for a request the processor sent without its lookup (a driver
|
|
70
|
+
* called on its own). Reads the run's provider, and the global one only when the run has none.
|
|
71
|
+
*/
|
|
72
|
+
private recordEntityFieldValues;
|
|
73
|
+
/** Maps the decision model's answers back to structured output values and per-output confidences. */
|
|
74
|
+
protected MapAnswers(outputs: DataFeatureOutput[], answers: Record<string, DecisionAnswer>): {
|
|
75
|
+
rawResult: Record<string, unknown>;
|
|
76
|
+
confidence: Record<string, number>;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=DecisionFeaturePipelineDriver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DecisionFeaturePipelineDriver.d.ts","sourceRoot":"","sources":["../../src/feature-pipeline-drivers/DecisionFeaturePipelineDriver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EACH,gBAAgB,EAEnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACH,KAAK,gBAAgB,EAIrB,KAAK,cAAc,EACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAA2B,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACtG,OAAO,EAIH,KAAK,iBAAiB,EACtB,KAAK,iCAAiC,EAEzC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACH,yBAAyB,EACzB,KAAK,6BAA6B,EAClC,KAAK,4BAA4B,EACpC,MAAM,6BAA6B,CAAC;AAMrC;;;GAGG;AACH,qBACa,6BAA8B,SAAQ,yBAAyB;IACxE,gHAAgH;IAChH,IAAW,YAAY,IAAI,iCAAiC,CAE3D;IAED;;;;;;;;OAQG;IACU,cAAc,CAAC,OAAO,EAAE,6BAA6B,GAAG,OAAO,CAAC,4BAA4B,CAAC;IAyD1G;;;;;OAKG;IACH,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO;IAWrE;;;;;OAKG;IACH,SAAS,CAAC,qBAAqB,CAAC,MAAM,EAAE,wBAAwB,GAAG,MAAM,GAAG,SAAS;IAOrF,sGAAsG;IACtG,OAAO,CAAC,mBAAmB;IAK3B,gHAAgH;IAChH,OAAO,CAAC,mBAAmB;I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