@memberjunction/ai-prompts 2.77.0 → 2.79.0
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 +70 -1
- package/dist/AIPromptRunner.d.ts +3 -1
- package/dist/AIPromptRunner.d.ts.map +1 -1
- package/dist/AIPromptRunner.js +276 -37
- package/dist/AIPromptRunner.js.map +1 -1
- package/dist/ExecutionPlanner.d.ts +1 -0
- package/dist/ExecutionPlanner.d.ts.map +1 -1
- package/dist/ExecutionPlanner.js +43 -0
- package/dist/ExecutionPlanner.js.map +1 -1
- package/dist/ParallelExecution.d.ts +3 -0
- package/dist/ParallelExecution.d.ts.map +1 -1
- package/dist/ParallelExecutionCoordinator.d.ts.map +1 -1
- package/dist/ParallelExecutionCoordinator.js +12 -4
- package/dist/ParallelExecutionCoordinator.js.map +1 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -2847,4 +2847,73 @@ WHERE ID = @PromptID;
|
|
|
2847
2847
|
5. **Use configuration parameters** for environment-specific settings beyond just model selection
|
|
2848
2848
|
6. **Assign models explicitly to configurations** to ensure clear separation between environments
|
|
2849
2849
|
|
|
2850
|
-
For more details on API key management, see the [AI Core API Keys documentation](../Core/README.md#api-key-management).
|
|
2850
|
+
For more details on API key management, see the [AI Core API Keys documentation](../Core/README.md#api-key-management).
|
|
2851
|
+
|
|
2852
|
+
## Model Selection Tracking (v2.78+)
|
|
2853
|
+
|
|
2854
|
+
The AIPromptRunner now provides comprehensive tracking of model selection decisions through the `modelSelectionInfo` property in `AIPromptRunResult`. This feature helps developers understand:
|
|
2855
|
+
|
|
2856
|
+
- Which models were considered during selection
|
|
2857
|
+
- Why specific models were or weren't available
|
|
2858
|
+
- Which configuration influenced the selection
|
|
2859
|
+
- What selection strategy was used
|
|
2860
|
+
|
|
2861
|
+
### Enhanced Model Selection Information
|
|
2862
|
+
|
|
2863
|
+
```typescript
|
|
2864
|
+
const result = await promptRunner.ExecutePrompt(params);
|
|
2865
|
+
|
|
2866
|
+
if (result.modelSelectionInfo) {
|
|
2867
|
+
// Access the configuration that was used
|
|
2868
|
+
const config = result.modelSelectionInfo.aiConfiguration;
|
|
2869
|
+
console.log(`Configuration: ${config?.Name || 'Default'}`);
|
|
2870
|
+
|
|
2871
|
+
// See all models that were considered
|
|
2872
|
+
for (const candidate of result.modelSelectionInfo.modelsConsidered) {
|
|
2873
|
+
console.log(`Model: ${candidate.model.Name}`);
|
|
2874
|
+
console.log(` Vendor: ${candidate.vendor?.Name || 'default'}`);
|
|
2875
|
+
console.log(` Priority: ${candidate.priority}`);
|
|
2876
|
+
console.log(` Available: ${candidate.available}`);
|
|
2877
|
+
if (!candidate.available) {
|
|
2878
|
+
console.log(` Reason: ${candidate.unavailableReason}`);
|
|
2879
|
+
}
|
|
2880
|
+
}
|
|
2881
|
+
|
|
2882
|
+
// Understand the final selection
|
|
2883
|
+
console.log(`Selected: ${result.modelSelectionInfo.modelSelected.Name}`);
|
|
2884
|
+
console.log(`Vendor: ${result.modelSelectionInfo.vendorSelected?.Name}`);
|
|
2885
|
+
console.log(`Reason: ${result.modelSelectionInfo.selectionReason}`);
|
|
2886
|
+
console.log(`Strategy: ${result.modelSelectionInfo.selectionStrategy}`);
|
|
2887
|
+
}
|
|
2888
|
+
```
|
|
2889
|
+
|
|
2890
|
+
### Database Storage
|
|
2891
|
+
|
|
2892
|
+
Model selection information is stored in the `AIPromptRun.ModelSelection` field as JSON, containing:
|
|
2893
|
+
- Model and vendor IDs (not full entities)
|
|
2894
|
+
- Configuration ID and name
|
|
2895
|
+
- Array of considered models with their availability status
|
|
2896
|
+
- Selection reason and strategy
|
|
2897
|
+
|
|
2898
|
+
Additional fields track:
|
|
2899
|
+
- `SelectionStrategy`: The strategy used ('Default', 'Specific', 'ByPower')
|
|
2900
|
+
- `ModelPowerRank`: Power rank of the selected model
|
|
2901
|
+
- `Status`: Execution status ('Pending', 'Running', 'Completed', 'Failed', 'Cancelled')
|
|
2902
|
+
- `Cancelled`: Boolean flag for cancellation
|
|
2903
|
+
- `CancellationReason`: Why execution was cancelled
|
|
2904
|
+
- `ErrorDetails`: Detailed error information for failures
|
|
2905
|
+
|
|
2906
|
+
### Benefits
|
|
2907
|
+
|
|
2908
|
+
- **Debugging**: Understand why a specific model was selected
|
|
2909
|
+
- **Monitoring**: Track which models are being used across prompts
|
|
2910
|
+
- **Optimization**: Identify models that are frequently unavailable
|
|
2911
|
+
- **Compliance**: Audit model selection for regulatory requirements
|
|
2912
|
+
|
|
2913
|
+
## Version History
|
|
2914
|
+
|
|
2915
|
+
- **2.78.0** - Added model selection tracking with full entity objects in results
|
|
2916
|
+
- **2.77.0** - Enhanced status tracking and cancellation support
|
|
2917
|
+
- **2.76.0** - Added intelligent failover system
|
|
2918
|
+
- **2.75.0** - Introduced dynamic template composition
|
|
2919
|
+
- **2.50.0** - Initial release with core prompt execution
|
package/dist/AIPromptRunner.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ export declare class AIPromptRunner {
|
|
|
45
45
|
model?: AIModelEntityExtended;
|
|
46
46
|
severity?: 'warning' | 'error' | 'critical';
|
|
47
47
|
}): void;
|
|
48
|
+
private isInferenceProvider;
|
|
48
49
|
ExecutePrompt<T = unknown>(params: AIPromptParams): Promise<AIPromptRunResult<T>>;
|
|
49
50
|
private executeSinglePrompt;
|
|
50
51
|
private executePromptInParallel;
|
|
@@ -53,10 +54,11 @@ export declare class AIPromptRunner {
|
|
|
53
54
|
private renderPromptWithChildTemplates;
|
|
54
55
|
private selectModel;
|
|
55
56
|
private buildModelVendorCandidates;
|
|
57
|
+
private selectModelWithAPIKeyTracked;
|
|
56
58
|
private selectModelWithAPIKey;
|
|
57
59
|
private createPromptRun;
|
|
58
60
|
private renderPromptTemplate;
|
|
59
|
-
protected executeModelWithFailover(model: AIModelEntityExtended, renderedPrompt: string, prompt: AIPromptEntity, params: AIPromptParams, vendorId: string | null, conversationMessages?: ChatMessage[], templateMessageRole?: TemplateMessageRole, cancellationToken?: AbortSignal, allCandidates?: ModelVendorCandidate[], promptRun?: AIPromptRunEntity): Promise<ChatResult>;
|
|
61
|
+
protected executeModelWithFailover(model: AIModelEntityExtended, renderedPrompt: string, prompt: AIPromptEntity, params: AIPromptParams, vendorId: string | null, conversationMessages?: ChatMessage[], templateMessageRole?: TemplateMessageRole, cancellationToken?: AbortSignal, allCandidates?: ModelVendorCandidate[], promptRun?: AIPromptRunEntity, vendorDriverClass?: string, vendorApiName?: string): Promise<ChatResult>;
|
|
60
62
|
protected buildFailoverCandidates(prompt: AIPromptEntity): Promise<ModelVendorCandidate[]>;
|
|
61
63
|
protected createCandidatesFromModels(models: AIModelEntityExtended[]): ModelVendorCandidate[];
|
|
62
64
|
protected updatePromptRunWithFailoverSuccess(promptRun: AIPromptRunEntity, failoverAttempts: FailoverAttempt[], currentModel: AIModelEntityExtended, currentVendorId: string | null): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AIPromptRunner.d.ts","sourceRoot":"","sources":["../src/AIPromptRunner.ts"],"names":[],"mappings":";AAAA,OAAO,EAAuB,UAAU,EAAmB,WAAW,EAA8B,MAAM,oBAAoB,CAAC;AAC/H,OAAO,EAAqB,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGpF,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"AIPromptRunner.d.ts","sourceRoot":"","sources":["../src/AIPromptRunner.ts"],"names":[],"mappings":";AAAA,OAAO,EAAuB,UAAU,EAAmB,WAAW,EAA8B,MAAM,oBAAoB,CAAC;AAC/H,OAAO,EAAqB,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGpF,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,iBAAiB,EAAmF,MAAM,+BAA+B,CAAC;AAQ1L,OAAO,EACH,mBAAmB,EAEnB,cAAc,EACjB,MAAM,8BAA8B,CAAC;AAkEtC,UAAU,oBAAoB;IAC5B,KAAK,EAAE,q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