ai-pipeline-orchestrator 0.1.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/CONTRIBUTING.md +77 -0
  3. package/LICENSE +21 -0
  4. package/README.md +466 -0
  5. package/dist/context/index.cjs +75 -0
  6. package/dist/context/index.cjs.map +1 -0
  7. package/dist/context/index.d.cts +38 -0
  8. package/dist/context/index.d.ts +38 -0
  9. package/dist/context/index.mjs +48 -0
  10. package/dist/context/index.mjs.map +1 -0
  11. package/dist/core/index.cjs +203 -0
  12. package/dist/core/index.cjs.map +1 -0
  13. package/dist/core/index.d.cts +36 -0
  14. package/dist/core/index.d.ts +36 -0
  15. package/dist/core/index.mjs +175 -0
  16. package/dist/core/index.mjs.map +1 -0
  17. package/dist/handlers/index.cjs +564 -0
  18. package/dist/handlers/index.cjs.map +1 -0
  19. package/dist/handlers/index.d.cts +105 -0
  20. package/dist/handlers/index.d.ts +105 -0
  21. package/dist/handlers/index.mjs +522 -0
  22. package/dist/handlers/index.mjs.map +1 -0
  23. package/dist/index.cjs +971 -0
  24. package/dist/index.cjs.map +1 -0
  25. package/dist/index.d.cts +8 -0
  26. package/dist/index.d.ts +8 -0
  27. package/dist/index.mjs +920 -0
  28. package/dist/index.mjs.map +1 -0
  29. package/dist/intent/index.cjs +265 -0
  30. package/dist/intent/index.cjs.map +1 -0
  31. package/dist/intent/index.d.cts +26 -0
  32. package/dist/intent/index.d.ts +26 -0
  33. package/dist/intent/index.mjs +226 -0
  34. package/dist/intent/index.mjs.map +1 -0
  35. package/dist/llm-classifier-Cq-QHJc4.d.ts +59 -0
  36. package/dist/llm-classifier-pOp7OO-V.d.cts +59 -0
  37. package/dist/providers/index.cjs +64 -0
  38. package/dist/providers/index.cjs.map +1 -0
  39. package/dist/providers/index.d.cts +13 -0
  40. package/dist/providers/index.d.ts +13 -0
  41. package/dist/providers/index.mjs +29 -0
  42. package/dist/providers/index.mjs.map +1 -0
  43. package/dist/types-DGSj206n.d.cts +42 -0
  44. package/dist/types-DGSj206n.d.ts +42 -0
  45. package/dist/utils/index.cjs +74 -0
  46. package/dist/utils/index.cjs.map +1 -0
  47. package/dist/utils/index.d.cts +10 -0
  48. package/dist/utils/index.d.ts +10 -0
  49. package/dist/utils/index.mjs +46 -0
  50. package/dist/utils/index.mjs.map +1 -0
  51. package/package.json +147 -0
@@ -0,0 +1,105 @@
1
+ import { a as OrchestrationHandler, O as OrchestrationContext } from '../types-DGSj206n.cjs';
2
+ import { I as IntentClassifier, L as LLMIntentClassifier } from '../llm-classifier-pOp7OO-V.cjs';
3
+ import { Logger } from '../utils/index.cjs';
4
+ import { ContextOptimizer } from '../context/index.cjs';
5
+ import { ProviderConfig } from '../providers/index.cjs';
6
+
7
+ interface IntentHandlerConfig {
8
+ classifier: IntentClassifier;
9
+ llmFallback?: {
10
+ enabled: boolean;
11
+ classifier: LLMIntentClassifier;
12
+ confidenceThreshold?: number;
13
+ };
14
+ contextKey?: string;
15
+ onFallback?: (data: {
16
+ message: string;
17
+ keywordIntent: string;
18
+ keywordConfidence: number;
19
+ llmIntent: string;
20
+ llmConfidence: number;
21
+ matchedKeywords?: string[];
22
+ }) => void | Promise<void>;
23
+ logger?: Logger;
24
+ }
25
+ /**
26
+ * Creates intent detection handler with hybrid classification.
27
+ * Uses keyword matching first, falls back to LLM if confidence is low and LLM is enabled.
28
+ *
29
+ * Keyword matching algorithm:
30
+ * - Scoring: Each keyword match adds points equal to the keyword's word count.
31
+ * - Single-word keywords (e.g., "hello") score 1 point
32
+ * - Multi-word keywords (e.g., "help me") score 2 points
33
+ *
34
+ * - Selection: The category with the highest score wins. Confidence is calculated as the margin between the best and second-best scores, normalized to 0-1.
35
+ *
36
+ * Note: This is a simple heuristic. For production use, consider the LLM fallback option in createIntentHandler when confidence is low.
37
+ */
38
+ declare function createIntentHandler(config: IntentHandlerConfig): OrchestrationHandler;
39
+
40
+ interface ContextHandlerConfig {
41
+ optimizer: ContextOptimizer;
42
+ getTopics?: (context: OrchestrationContext) => string[];
43
+ isFirstMessage?: (context: OrchestrationContext) => boolean;
44
+ outputKey?: string;
45
+ logger?: Logger;
46
+ }
47
+ /**
48
+ * Creates context building handler for dynamic prompt generation.
49
+ */
50
+ declare function createContextHandler(config: ContextHandlerConfig): OrchestrationHandler;
51
+
52
+ interface RateLimiter {
53
+ check(identifier: string): Promise<{
54
+ allowed: boolean;
55
+ retryAfter?: number;
56
+ }>;
57
+ }
58
+ interface RateLimitHandlerConfig {
59
+ limiter: RateLimiter;
60
+ identifierKey?: string;
61
+ getIdentifier?: (context: OrchestrationContext) => string;
62
+ outputKey?: string;
63
+ logger?: Logger;
64
+ }
65
+ /**
66
+ * Creates rate limiting handler to prevent abuse.
67
+ */
68
+ declare function createRateLimitHandler(config: RateLimitHandlerConfig): OrchestrationHandler;
69
+
70
+ interface ModerationRule {
71
+ pattern: RegExp;
72
+ reason: string;
73
+ }
74
+ interface ModerationConfig {
75
+ spamPatterns?: string[];
76
+ profanityWords?: string[];
77
+ customRules?: ModerationRule[];
78
+ outputKey?: string;
79
+ logger?: Logger;
80
+ }
81
+ /**
82
+ * Creates content moderation handler for spam and profanity filtering.
83
+ */
84
+ declare function createModerationHandler(config?: ModerationConfig): OrchestrationHandler;
85
+
86
+ interface AIHandlerConfig extends ProviderConfig {
87
+ maxTokens?: number;
88
+ temperature?: number;
89
+ getSystemPrompt?: (context: OrchestrationContext) => string;
90
+ outputKey?: string;
91
+ logger?: Logger;
92
+ }
93
+ interface StreamingAIHandlerConfig extends AIHandlerConfig {
94
+ onChunk: (chunk: string) => void | Promise<void>;
95
+ }
96
+ /**
97
+ * Creates AI generation handler.
98
+ */
99
+ declare function createAIHandler(config: AIHandlerConfig): OrchestrationHandler;
100
+ /**
101
+ * Creates streaming AI generation handler.
102
+ */
103
+ declare function createStreamingAIHandler(config: StreamingAIHandlerConfig): OrchestrationHandler;
104
+
105
+ export { type AIHandlerConfig, type ContextHandlerConfig, type IntentHandlerConfig, type ModerationConfig, type ModerationRule, type RateLimitHandlerConfig, type RateLimiter, type StreamingAIHandlerConfig, createAIHandler, createContextHandler, createIntentHandler, createModerationHandler, createRateLimitHandler, createStreamingAIHandler };
@@ -0,0 +1,105 @@
1
+ import { a as OrchestrationHandler, O as OrchestrationContext } from '../types-DGSj206n.js';
2
+ import { I as IntentClassifier, L as LLMIntentClassifier } from '../llm-classifier-Cq-QHJc4.js';
3
+ import { Logger } from '../utils/index.js';
4
+ import { ContextOptimizer } from '../context/index.js';
5
+ import { ProviderConfig } from '../providers/index.js';
6
+
7
+ interface IntentHandlerConfig {
8
+ classifier: IntentClassifier;
9
+ llmFallback?: {
10
+ enabled: boolean;
11
+ classifier: LLMIntentClassifier;
12
+ confidenceThreshold?: number;
13
+ };
14
+ contextKey?: string;
15
+ onFallback?: (data: {
16
+ message: string;
17
+ keywordIntent: string;
18
+ keywordConfidence: number;
19
+ llmIntent: string;
20
+ llmConfidence: number;
21
+ matchedKeywords?: string[];
22
+ }) => void | Promise<void>;
23
+ logger?: Logger;
24
+ }
25
+ /**
26
+ * Creates intent detection handler with hybrid classification.
27
+ * Uses keyword matching first, falls back to LLM if confidence is low and LLM is enabled.
28
+ *
29
+ * Keyword matching algorithm:
30
+ * - Scoring: Each keyword match adds points equal to the keyword's word count.
31
+ * - Single-word keywords (e.g., "hello") score 1 point
32
+ * - Multi-word keywords (e.g., "help me") score 2 points
33
+ *
34
+ * - Selection: The category with the highest score wins. Confidence is calculated as the margin between the best and second-best scores, normalized to 0-1.
35
+ *
36
+ * Note: This is a simple heuristic. For production use, consider the LLM fallback option in createIntentHandler when confidence is low.
37
+ */
38
+ declare function createIntentHandler(config: IntentHandlerConfig): OrchestrationHandler;
39
+
40
+ interface ContextHandlerConfig {
41
+ optimizer: ContextOptimizer;
42
+ getTopics?: (context: OrchestrationContext) => string[];
43
+ isFirstMessage?: (context: OrchestrationContext) => boolean;
44
+ outputKey?: string;
45
+ logger?: Logger;
46
+ }
47
+ /**
48
+ * Creates context building handler for dynamic prompt generation.
49
+ */
50
+ declare function createContextHandler(config: ContextHandlerConfig): OrchestrationHandler;
51
+
52
+ interface RateLimiter {
53
+ check(identifier: string): Promise<{
54
+ allowed: boolean;
55
+ retryAfter?: number;
56
+ }>;
57
+ }
58
+ interface RateLimitHandlerConfig {
59
+ limiter: RateLimiter;
60
+ identifierKey?: string;
61
+ getIdentifier?: (context: OrchestrationContext) => string;
62
+ outputKey?: string;
63
+ logger?: Logger;
64
+ }
65
+ /**
66
+ * Creates rate limiting handler to prevent abuse.
67
+ */
68
+ declare function createRateLimitHandler(config: RateLimitHandlerConfig): OrchestrationHandler;
69
+
70
+ interface ModerationRule {
71
+ pattern: RegExp;
72
+ reason: string;
73
+ }
74
+ interface ModerationConfig {
75
+ spamPatterns?: string[];
76
+ profanityWords?: string[];
77
+ customRules?: ModerationRule[];
78
+ outputKey?: string;
79
+ logger?: Logger;
80
+ }
81
+ /**
82
+ * Creates content moderation handler for spam and profanity filtering.
83
+ */
84
+ declare function createModerationHandler(config?: ModerationConfig): OrchestrationHandler;
85
+
86
+ interface AIHandlerConfig extends ProviderConfig {
87
+ maxTokens?: number;
88
+ temperature?: number;
89
+ getSystemPrompt?: (context: OrchestrationContext) => string;
90
+ outputKey?: string;
91
+ logger?: Logger;
92
+ }
93
+ interface StreamingAIHandlerConfig extends AIHandlerConfig {
94
+ onChunk: (chunk: string) => void | Promise<void>;
95
+ }
96
+ /**
97
+ * Creates AI generation handler.
98
+ */
99
+ declare function createAIHandler(config: AIHandlerConfig): OrchestrationHandler;
100
+ /**
101
+ * Creates streaming AI generation handler.
102
+ */
103
+ declare function createStreamingAIHandler(config: StreamingAIHandlerConfig): OrchestrationHandler;
104
+
105
+ export { type AIHandlerConfig, type ContextHandlerConfig, type IntentHandlerConfig, type ModerationConfig, type ModerationRule, type RateLimitHandlerConfig, type RateLimiter, type StreamingAIHandlerConfig, createAIHandler, createContextHandler, createIntentHandler, createModerationHandler, createRateLimitHandler, createStreamingAIHandler };