@memberjunction/ai 2.50.0 → 2.51.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.
@@ -0,0 +1,62 @@
1
+ import { ChatResult } from './chat.types';
2
+ export type ExecutionStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
3
+ export type CancellationReason = 'user_requested' | 'timeout' | 'error' | 'resource_limit';
4
+ export interface ModelInfo {
5
+ modelId: string;
6
+ modelName: string;
7
+ vendorId?: string;
8
+ vendorName?: string;
9
+ powerRank?: number;
10
+ modelType?: string;
11
+ }
12
+ export interface JudgeMetadata {
13
+ judgePromptId: string;
14
+ judgeExecutionTimeMS: number;
15
+ judgeTokensUsed?: number;
16
+ judgeCancelled?: boolean;
17
+ judgeErrorMessage?: string;
18
+ }
19
+ export interface ValidationAttempt {
20
+ attemptNumber: number;
21
+ success: boolean;
22
+ errorMessage?: string;
23
+ validationErrors?: any[];
24
+ rawOutput: string;
25
+ parsedOutput?: unknown;
26
+ timestamp: Date;
27
+ }
28
+ export interface AIPromptRunResult<T = unknown> {
29
+ success: boolean;
30
+ status?: ExecutionStatus;
31
+ cancelled?: boolean;
32
+ cancellationReason?: CancellationReason;
33
+ rawResult?: string;
34
+ result?: T;
35
+ chatResult: ChatResult;
36
+ errorMessage?: string;
37
+ promptRun?: any;
38
+ executionTimeMS?: number;
39
+ promptTokens?: number;
40
+ completionTokens?: number;
41
+ tokensUsed?: number;
42
+ combinedPromptTokens?: number;
43
+ combinedCompletionTokens?: number;
44
+ combinedTokensUsed?: number;
45
+ cost?: number;
46
+ costCurrency?: string;
47
+ combinedCost?: number;
48
+ validationResult?: any;
49
+ validationAttempts?: ValidationAttempt[];
50
+ additionalResults?: AIPromptRunResult<T>[];
51
+ ranking?: number;
52
+ judgeRationale?: string;
53
+ modelInfo?: ModelInfo;
54
+ judgeMetadata?: JudgeMetadata;
55
+ wasStreamed?: boolean;
56
+ cacheInfo?: {
57
+ cacheHit: boolean;
58
+ cacheKey?: string;
59
+ cacheSource?: string;
60
+ };
61
+ }
62
+ //# sourceMappingURL=prompt.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.types.d.ts","sourceRoot":"","sources":["../../src/generic/prompt.types.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAK1C,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;AAK3F,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,GAAG,SAAS,GAAG,OAAO,GAAG,gBAAgB,CAAC;AAK3F,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAKD,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAKD,MAAM,WAAW,iBAAiB;IAEhC,aAAa,EAAE,MAAM,CAAC;IAEtB,OAAO,EAAE,OAAO,CAAC;IAEjB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,gBAAgB,CAAC,EAAE,GAAG,EAAE,CAAC;IAEzB,SAAS,EAAE,MAAM,CAAC;IAElB,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,SAAS,EAAE,IAAI,CAAC;CACjB;AAKD,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAG,OAAO;IAI5C,OAAO,EAAE,OAAO,CAAC;IAKjB,MAAM,CAAC,EA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types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.types.js","sourceRoot":"","sources":["../../src/generic/prompt.types.ts"],"names":[],"mappings":""}
package/dist/index.d.ts CHANGED
@@ -9,4 +9,5 @@ export * from './generic/embed.types';
9
9
  export * from './generic/baseEmbeddings';
10
10
  export * from './generic/baseAudio';
11
11
  export * from './generic/baseVideo';
12
+ export * from './generic/prompt.types';
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC"}
package/dist/index.js CHANGED
@@ -25,4 +25,5 @@ __exportStar(require("./generic/embed.types"), exports);
25
25
  __exportStar(require("./generic/baseEmbeddings"), exports);
26
26
  __exportStar(require("./generic/baseAudio"), exports);
27
27
  __exportStar(require("./generic/baseVideo"), exports);
28
+ __exportStar(require("./generic/prompt.types"), exports);
28
29
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAmC;AACnC,oDAAkC;AAClC,0DAAwC;AACxC,uDAAqC;AACrC,2DAAyC;AACzC,4DAA0C;AAC1C,6DAA2C;AAC3C,wDAAsC;AACtC,2DAAyC;AACzC,sDAAoC;AACpC,sDAAoC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAmC;AACnC,oDAAkC;AAClC,0DAAwC;AACxC,uDAAqC;AACrC,2DAAyC;AACzC,4DAA0C;AAC1C,6DAA2C;AAC3C,wDAAsC;AACtC,2DAAyC;AACzC,sDAAoC;AACpC,sDAAoC;AACpC,yDAAuC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/ai",
3
- "version": "2.50.0",
3
+ "version": "2.51.0",
4
4
  "description": "MemberJunction: AI Module - LLMs and other AI services wrapped and abstracted for use in MemberJunction",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,7 +15,7 @@
15
15
  "author": "MemberJunction.com",
16
16
  "license": "ISC",
17
17
  "dependencies": {
18
- "@memberjunction/global": "2.50.0",
18
+ "@memberjunction/global": "2.51.0",
19
19
  "dotenv": "^16.4.1",
20
20
  "rxjs": "^7.8.1"
21
21
  },
package/readme.md CHANGED
@@ -6,6 +6,17 @@ The MemberJunction AI Core package provides a comprehensive abstraction layer fo
6
6
 
7
7
  This package serves as the foundation for all AI capabilities in the MemberJunction ecosystem. It defines abstract base classes and interfaces that are implemented by provider-specific packages, enabling seamless integration with various AI services while maintaining a consistent API.
8
8
 
9
+ ### Type Organization Update (2025)
10
+
11
+ As part of a major type reorganization to improve code organization and reduce circular dependencies:
12
+ - **Core Package** now contains:
13
+ - Base AI model abstractions (`BaseModel`, `BaseLLM`, `BaseEmbeddings`, etc.)
14
+ - Core AI result types (`BaseResult`, `ChatResult`, `ModelUsage`, etc.)
15
+ - Common interfaces and types used across all AI packages
16
+ - **Agent-specific types** have moved to `@memberjunction/ai-agents`
17
+ - **Prompt-specific types** remain in `@memberjunction/ai-prompts`
18
+ - **Engine-specific types** (like agent type definitions) are in `@memberjunction/aiengine`
19
+
9
20
  ## Standalone Usage
10
21
 
11
22
  **IMPORTANT**: This package can be used completely independently from the rest of the MemberJunction framework:
@@ -538,11 +549,53 @@ The BaseLLM class uses a template method pattern for handling streaming:
538
549
 
539
550
  This architecture allows for a clean separation between common streaming logic and provider-specific implementations.
540
551
 
552
+ ## Import Examples
553
+
554
+ ```typescript
555
+ // Import base model classes
556
+ import { BaseLLM, BaseEmbeddings, BaseAudioGenerator } from '@memberjunction/ai';
557
+
558
+ // Import result types
559
+ import { ChatResult, ModelUsage, BaseResult } from '@memberjunction/ai';
560
+
561
+ // Import parameter types
562
+ import { ChatParams, ChatMessage, StreamingChatCallbacks } from '@memberjunction/ai';
563
+
564
+ // Import utility classes
565
+ import { AIAPIKeys, GetAIAPIKey } from '@memberjunction/ai';
566
+ ```
567
+
541
568
  ## Dependencies
542
569
 
543
570
  - `@memberjunction/global` - MemberJunction global utilities including class factory
544
571
  - `rxjs` - Reactive extensions for JavaScript
545
572
 
573
+ ## Type Exports
574
+
575
+ The Core package exports fundamental types used throughout the AI ecosystem:
576
+
577
+ ### Base Model Classes
578
+ - `BaseModel` - Foundation class for all AI models
579
+ - `BaseLLM` - Base class for language models
580
+ - `BaseEmbeddings` - Base class for embedding models
581
+ - `BaseAudioGenerator` - Base class for audio models
582
+ - `BaseVideoGenerator` - Base class for video models
583
+ - `BaseDiffusion` - Base class for image generation models
584
+
585
+ ### Core Result Types
586
+ - `BaseResult` - Base result structure for all AI operations
587
+ - `ChatResult` - Result from chat completions
588
+ - `ModelUsage` - Token/resource usage tracking
589
+ - `SummarizeResult` - Text summarization results
590
+ - `ClassifyResult` - Text classification results
591
+ - `EmbeddingResult` - Embedding generation results
592
+
593
+ ### Common Interfaces
594
+ - `ChatMessage` - Message structure for conversations
595
+ - `ChatParams` - Parameters for chat operations
596
+ - `StreamingChatCallbacks` - Callbacks for streaming responses
597
+ - `ParallelChatCompletionsCallbacks` - Callbacks for parallel execution
598
+
546
599
  ## API Reference
547
600
 
548
601
  ### Result Types