@retrivora-ai/rag-engine 2.0.2 → 2.0.4

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/FREE_TIER_ARCHITECTURE.md +232 -0
  2. package/README.md +9 -0
  3. package/dist/{ILLMProvider-DMxLyTdq.d.mts → ILLMProvider-0rRBYbVW.d.mts} +133 -1
  4. package/dist/{ILLMProvider-DMxLyTdq.d.ts → ILLMProvider-0rRBYbVW.d.ts} +133 -1
  5. package/dist/handlers/index.d.mts +2 -2
  6. package/dist/handlers/index.d.ts +2 -2
  7. package/dist/handlers/index.js +681 -17
  8. package/dist/handlers/index.mjs +681 -17
  9. package/dist/index-B1wGUlSL.d.mts +532 -0
  10. package/dist/{index-tzwc7UhY.d.ts → index-BIHHp_f6.d.ts} +1 -1
  11. package/dist/{index-DHsFLJXQ.d.mts → index-BvODr57d.d.mts} +1 -1
  12. package/dist/index-DcklhThn.d.ts +532 -0
  13. package/dist/index.css +51 -3
  14. package/dist/index.d.mts +6 -105
  15. package/dist/index.d.ts +6 -105
  16. package/dist/index.js +1918 -8
  17. package/dist/index.mjs +1913 -8
  18. package/dist/server.d.mts +51 -7
  19. package/dist/server.d.ts +51 -7
  20. package/dist/server.js +723 -17
  21. package/dist/server.mjs +706 -17
  22. package/package.json +9 -7
  23. package/src/app/page.tsx +54 -18
  24. package/src/components/ChatWindow.tsx +2 -2
  25. package/src/components/DocumentUpload.tsx +5 -4
  26. package/src/components/MessageBubble.tsx +2 -4
  27. package/src/core/DatabaseStorage.ts +5 -1
  28. package/src/core/LicenseVerifier.ts +1 -1
  29. package/src/core/Pipeline.ts +23 -5
  30. package/src/handlers/index.ts +48 -1
  31. package/src/index.ts +22 -4
  32. package/src/rendering/IntentClassifier.ts +167 -0
  33. package/src/rendering/RendererRegistry.ts +164 -0
  34. package/src/rendering/RuleEngine.ts +67 -0
  35. package/src/rendering/VisualizationDecisionEngine.ts +164 -0
  36. package/src/rendering/__tests__/VisualizationDecisionEngine.test.ts +237 -0
  37. package/src/rendering/index.ts +12 -0
  38. package/src/rendering/rules/Rule1SpecificInfoRule.ts +28 -0
  39. package/src/rendering/rules/Rule2ComparisonRule.ts +24 -0
  40. package/src/rendering/rules/Rule3ProductDiscoveryRule.ts +28 -0
  41. package/src/rendering/rules/Rule4AnalyticalRule.ts +38 -0
  42. package/src/rendering/rules/Rule5MixedResponseRule.ts +29 -0
  43. package/src/rendering/rules/Rule6SmallResultSetRule.ts +24 -0
  44. package/src/rendering/rules/Rule7LargeTableRule.ts +35 -0
  45. package/src/rendering/types.ts +96 -0
  46. package/src/server.ts +3 -2
  47. package/src/types/index.ts +48 -0
  48. package/src/utils/DocumentParser.ts +64 -28
  49. package/src/utils/UITransformer.ts +15 -4
  50. package/dist/index-CfkqZd2Y.d.ts +0 -197
  51. package/dist/index-xygonxpW.d.mts +0 -197
package/dist/index.d.mts CHANGED
@@ -1,108 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { CSSProperties, MouseEvent, ReactNode } from 'react';
3
- import { P as Product, U as UIConfig, R as RagMessage, V as VectorMatch, O as ObservabilityTrace, a as UseRagChatOptions, b as UseRagChatReturn } from './ILLMProvider-DMxLyTdq.mjs';
4
- export { C as ChatMessage, c as ChatOptions, d as ChatResponse, E as EmbedOptions, e as EmbeddingConfig, f as EmbeddingProvider, I as ILLMProvider, g as IngestDocument, L as LLMConfig, h as LLMProvider, i as LatencyBreakdown, j as RAGConfig, k as RagConfig, l as RetrievalConfig, m as RetrievedChunk, T as TokenUsage, n as UniversalRagConfig, o as UpsertDocument, p as VectorDBConfig, q as VectorDBProvider, W as WorkflowConfig } from './ILLMProvider-DMxLyTdq.mjs';
5
- export { A as AuthenticationException, C as Chunk, a as ChunkOptions, b as ConfigurationException, E as EmbeddingFailedException, P as ProviderNotFoundException, R as RateLimitException, c as RetrievalException, d as Retrivora, e as RetrivoraError, f as RetrivoraErrorCode } from './index-xygonxpW.mjs';
6
-
7
- type ChatViewportSize = 'compact' | 'medium' | 'large';
8
- interface ChatWindowProps {
9
- /** Additional className for the wrapper div */
10
- className?: string;
11
- /** Inline styles for the wrapper div */
12
- style?: CSSProperties;
13
- /** Called when the close button is clicked (for widget mode) */
14
- onClose?: () => void;
15
- /** Whether to show a close (X) button in the header */
16
- showClose?: boolean;
17
- /** Called when the user starts dragging the resize handle */
18
- onResizeStart?: (e: MouseEvent) => void;
19
- /** Called when the user clicks the reset size button */
20
- onResetResize?: () => void;
21
- /** Whether the window has been resized from its default */
22
- isResized?: boolean;
23
- /** Called when the user clicks the maximize/minimize button */
24
- onMaximize?: () => void;
25
- /** Whether the window is currently maximized */
26
- isMaximized?: boolean;
27
- /** Called when the user clicks 'Add to Cart' on a product */
28
- onAddToCart?: (product: Product) => void;
29
- /** Optional custom API URL to send chat messages to */
30
- apiUrl?: string;
31
- /**
32
- * Base URL for Retrivora SDK history/feedback/sessions endpoints.
33
- * Defaults to '/api/retrivora'. Set this to match your catch-all route location.
34
- */
35
- retrivoraApiBase?: string;
36
- /** Optional custom headers to send with the chat request */
37
- headers?: Record<string, string>;
38
- }
39
- interface ChatWidgetProps {
40
- /** Position of the floating button. Defaults to bottom-right. */
41
- position?: 'bottom-right' | 'bottom-left';
42
- /** Called when the user clicks 'Add to Cart' on a product */
43
- onAddToCart?: (product: Product) => void;
44
- /** Optional custom API URL to send chat messages to */
45
- apiUrl?: string;
46
- /**
47
- * Base URL for Retrivora SDK history/feedback/sessions endpoints.
48
- * Defaults to '/api/retrivora'.
49
- */
50
- retrivoraApiBase?: string;
51
- /** Optional custom headers to send with the chat request */
52
- headers?: Record<string, string>;
53
- }
54
- interface MessageBubbleProps {
55
- message: RagMessage;
56
- sources?: VectorMatch[];
57
- isStreaming?: boolean;
58
- primaryColor: string;
59
- accentColor: string;
60
- onAddToCart?: (product: Product) => void;
61
- viewportSize?: ChatViewportSize;
62
- /** Called when the user clicks thumbs up or thumbs down on an assistant message */
63
- onFeedback?: (messageId: string, rating: 'thumbs_up' | 'thumbs_down') => void;
64
- }
65
- interface ProductCardProps {
66
- product: Product;
67
- primaryColor?: string;
68
- onAddToCart?: (product: Product) => void;
69
- }
70
- interface ProductCarouselProps {
71
- products: Product[];
72
- primaryColor?: string;
73
- onAddToCart?: (product: Product) => void;
74
- }
75
- interface DocumentUploadProps {
76
- /** Optional namespace for the upload */
77
- namespace?: string;
78
- /** Callback when upload completes */
79
- onUploadComplete?: (results: unknown) => void;
80
- /** Additional className */
81
- className?: string;
82
- }
83
- interface SourceCardProps {
84
- source: VectorMatch;
85
- index: number;
86
- }
87
- interface ClientConfig {
88
- projectId: string;
89
- ui: Required<UIConfig>;
90
- embedding?: {
91
- model?: string;
92
- dimensions?: number;
93
- };
94
- }
95
- interface ConfigProviderProps {
96
- config?: {
97
- projectId?: string;
98
- ui?: Partial<UIConfig>;
99
- embedding?: {
100
- model?: string;
101
- dimensions?: number;
102
- };
103
- };
104
- children: ReactNode;
105
- }
2
+ import { C as ChatWidgetProps, a as ChatWindowProps, D as DocumentUploadProps, M as MessageBubbleProps, S as SourceCardProps, b as ConfigProviderProps, c as ClientConfig, P as ProductCardProps, d as ProductCarouselProps } from './index-B1wGUlSL.mjs';
3
+ export { A as AuthenticationException, e as ChartType, f as Chunk, g as ChunkOptions, h as ConfigurationException, i as DecisionContext, E as EmbeddingFailedException, I as IRenderRule, j as IRendererStrategy, k as IntentCategory, l as IntentClassifier, m as ProviderNotFoundException, R as RateLimitException, n as RenderDecision, o as RenderType, p as RendererRegistry, q as RetrievalException, r as Retrivora, s as RetrivoraError, t as RetrivoraErrorCode, u as RuleEngine, V as VisualizationDecisionEngine, v as decideVisualization } from './index-B1wGUlSL.mjs';
4
+ import { O as ObservabilityTrace, U as UseRagChatOptions, a as UseRagChatReturn } from './ILLMProvider-0rRBYbVW.mjs';
5
+ export { C as ChatMessage, b as ChatOptions, c as ChatResponse, E as EmbedOptions, d as EmbeddingConfig, e as EmbeddingProvider, I as ILLMProvider, f as IngestDocument, L as LLMConfig, g as LLMProvider, h as LatencyBreakdown, R as RAGConfig, i as RagConfig, j as RagMessage, k as RetrievalConfig, l as RetrievedChunk, T as TokenUsage, m as UIConfig, n as UniversalRagConfig, o as UpsertDocument, V as VectorDBConfig, p as VectorDBProvider, q as VectorMatch, W as WorkflowConfig } from './ILLMProvider-0rRBYbVW.mjs';
6
+ import 'react';
106
7
 
107
8
  declare function ChatWidget({ position, onAddToCart, apiUrl, retrivoraApiBase, headers }: ChatWidgetProps): react_jsx_runtime.JSX.Element | null;
108
9
 
@@ -147,4 +48,4 @@ declare function useRagChat(projectId: string, options?: UseRagChatOptions): Use
147
48
  */
148
49
  declare function addSynonyms(customSynonyms: Record<string, string[]>): void;
149
50
 
150
- export { ChatWidget, type ChatWidgetProps, ChatWindow, type ChatWindowProps, type ClientConfig, CodeViewer, ConfigProvider, DocumentUpload, type DocumentUploadProps, MessageBubble, type MessageBubbleProps, ObservabilityPanel, ObservabilityTrace, ProductCard, type ProductCardProps, ProductCarousel, type ProductCarouselProps, RagMessage, SourceCard, type SourceCardProps, UIConfig, UseRagChatOptions, UseRagChatReturn, VectorMatch, addSynonyms, useConfig, useRagChat };
51
+ export { ChatWidget, ChatWidgetProps, ChatWindow, ChatWindowProps, ClientConfig, CodeViewer, ConfigProvider, DocumentUpload, DocumentUploadProps, MessageBubble, MessageBubbleProps, ObservabilityPanel, ObservabilityTrace, ProductCard, ProductCardProps, ProductCarousel, ProductCarouselProps, SourceCard, SourceCardProps, UseRagChatOptions, UseRagChatReturn, addSynonyms, useConfig, useRagChat };
package/dist/index.d.ts CHANGED
@@ -1,108 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { CSSProperties, MouseEvent, ReactNode } from 'react';
3
- import { P as Product, U as UIConfig, R as RagMessage, V as VectorMatch, O as ObservabilityTrace, a as UseRagChatOptions, b as UseRagChatReturn } from './ILLMProvider-DMxLyTdq.js';
4
- export { C as ChatMessage, c as ChatOptions, d as ChatResponse, E as EmbedOptions, e as EmbeddingConfig, f as EmbeddingProvider, I as ILLMProvider, g as IngestDocument, L as LLMConfig, h as LLMProvider, i as LatencyBreakdown, j as RAGConfig, k as RagConfig, l as RetrievalConfig, m as RetrievedChunk, T as TokenUsage, n as UniversalRagConfig, o as UpsertDocument, p as VectorDBConfig, q as VectorDBProvider, W as WorkflowConfig } from './ILLMProvider-DMxLyTdq.js';
5
- export { A as AuthenticationException, C as Chunk, a as ChunkOptions, b as ConfigurationException, E as EmbeddingFailedException, P as ProviderNotFoundException, R as RateLimitException, c as RetrievalException, d as Retrivora, e as RetrivoraError, f as RetrivoraErrorCode } from './index-CfkqZd2Y.js';
6
-
7
- type ChatViewportSize = 'compact' | 'medium' | 'large';
8
- interface ChatWindowProps {
9
- /** Additional className for the wrapper div */
10
- className?: string;
11
- /** Inline styles for the wrapper div */
12
- style?: CSSProperties;
13
- /** Called when the close button is clicked (for widget mode) */
14
- onClose?: () => void;
15
- /** Whether to show a close (X) button in the header */
16
- showClose?: boolean;
17
- /** Called when the user starts dragging the resize handle */
18
- onResizeStart?: (e: MouseEvent) => void;
19
- /** Called when the user clicks the reset size button */
20
- onResetResize?: () => void;
21
- /** Whether the window has been resized from its default */
22
- isResized?: boolean;
23
- /** Called when the user clicks the maximize/minimize button */
24
- onMaximize?: () => void;
25
- /** Whether the window is currently maximized */
26
- isMaximized?: boolean;
27
- /** Called when the user clicks 'Add to Cart' on a product */
28
- onAddToCart?: (product: Product) => void;
29
- /** Optional custom API URL to send chat messages to */
30
- apiUrl?: string;
31
- /**
32
- * Base URL for Retrivora SDK history/feedback/sessions endpoints.
33
- * Defaults to '/api/retrivora'. Set this to match your catch-all route location.
34
- */
35
- retrivoraApiBase?: string;
36
- /** Optional custom headers to send with the chat request */
37
- headers?: Record<string, string>;
38
- }
39
- interface ChatWidgetProps {
40
- /** Position of the floating button. Defaults to bottom-right. */
41
- position?: 'bottom-right' | 'bottom-left';
42
- /** Called when the user clicks 'Add to Cart' on a product */
43
- onAddToCart?: (product: Product) => void;
44
- /** Optional custom API URL to send chat messages to */
45
- apiUrl?: string;
46
- /**
47
- * Base URL for Retrivora SDK history/feedback/sessions endpoints.
48
- * Defaults to '/api/retrivora'.
49
- */
50
- retrivoraApiBase?: string;
51
- /** Optional custom headers to send with the chat request */
52
- headers?: Record<string, string>;
53
- }
54
- interface MessageBubbleProps {
55
- message: RagMessage;
56
- sources?: VectorMatch[];
57
- isStreaming?: boolean;
58
- primaryColor: string;
59
- accentColor: string;
60
- onAddToCart?: (product: Product) => void;
61
- viewportSize?: ChatViewportSize;
62
- /** Called when the user clicks thumbs up or thumbs down on an assistant message */
63
- onFeedback?: (messageId: string, rating: 'thumbs_up' | 'thumbs_down') => void;
64
- }
65
- interface ProductCardProps {
66
- product: Product;
67
- primaryColor?: string;
68
- onAddToCart?: (product: Product) => void;
69
- }
70
- interface ProductCarouselProps {
71
- products: Product[];
72
- primaryColor?: string;
73
- onAddToCart?: (product: Product) => void;
74
- }
75
- interface DocumentUploadProps {
76
- /** Optional namespace for the upload */
77
- namespace?: string;
78
- /** Callback when upload completes */
79
- onUploadComplete?: (results: unknown) => void;
80
- /** Additional className */
81
- className?: string;
82
- }
83
- interface SourceCardProps {
84
- source: VectorMatch;
85
- index: number;
86
- }
87
- interface ClientConfig {
88
- projectId: string;
89
- ui: Required<UIConfig>;
90
- embedding?: {
91
- model?: string;
92
- dimensions?: number;
93
- };
94
- }
95
- interface ConfigProviderProps {
96
- config?: {
97
- projectId?: string;
98
- ui?: Partial<UIConfig>;
99
- embedding?: {
100
- model?: string;
101
- dimensions?: number;
102
- };
103
- };
104
- children: ReactNode;
105
- }
2
+ import { C as ChatWidgetProps, a as ChatWindowProps, D as DocumentUploadProps, M as MessageBubbleProps, S as SourceCardProps, b as ConfigProviderProps, c as ClientConfig, P as ProductCardProps, d as ProductCarouselProps } from './index-DcklhThn.js';
3
+ export { A as AuthenticationException, e as ChartType, f as Chunk, g as ChunkOptions, h as ConfigurationException, i as DecisionContext, E as EmbeddingFailedException, I as IRenderRule, j as IRendererStrategy, k as IntentCategory, l as IntentClassifier, m as ProviderNotFoundException, R as RateLimitException, n as RenderDecision, o as RenderType, p as RendererRegistry, q as RetrievalException, r as Retrivora, s as RetrivoraError, t as RetrivoraErrorCode, u as RuleEngine, V as VisualizationDecisionEngine, v as decideVisualization } from './index-DcklhThn.js';
4
+ import { O as ObservabilityTrace, U as UseRagChatOptions, a as UseRagChatReturn } from './ILLMProvider-0rRBYbVW.js';
5
+ export { C as ChatMessage, b as ChatOptions, c as ChatResponse, E as EmbedOptions, d as EmbeddingConfig, e as EmbeddingProvider, I as ILLMProvider, f as IngestDocument, L as LLMConfig, g as LLMProvider, h as LatencyBreakdown, R as RAGConfig, i as RagConfig, j as RagMessage, k as RetrievalConfig, l as RetrievedChunk, T as TokenUsage, m as UIConfig, n as UniversalRagConfig, o as UpsertDocument, V as VectorDBConfig, p as VectorDBProvider, q as VectorMatch, W as WorkflowConfig } from './ILLMProvider-0rRBYbVW.js';
6
+ import 'react';
106
7
 
107
8
  declare function ChatWidget({ position, onAddToCart, apiUrl, retrivoraApiBase, headers }: ChatWidgetProps): react_jsx_runtime.JSX.Element | null;
108
9
 
@@ -147,4 +48,4 @@ declare function useRagChat(projectId: string, options?: UseRagChatOptions): Use
147
48
  */
148
49
  declare function addSynonyms(customSynonyms: Record<string, string[]>): void;
149
50
 
150
- export { ChatWidget, type ChatWidgetProps, ChatWindow, type ChatWindowProps, type ClientConfig, CodeViewer, ConfigProvider, DocumentUpload, type DocumentUploadProps, MessageBubble, type MessageBubbleProps, ObservabilityPanel, ObservabilityTrace, ProductCard, type ProductCardProps, ProductCarousel, type ProductCarouselProps, RagMessage, SourceCard, type SourceCardProps, UIConfig, UseRagChatOptions, UseRagChatReturn, VectorMatch, addSynonyms, useConfig, useRagChat };
51
+ export { ChatWidget, ChatWidgetProps, ChatWindow, ChatWindowProps, ClientConfig, CodeViewer, ConfigProvider, DocumentUpload, DocumentUploadProps, MessageBubble, MessageBubbleProps, ObservabilityPanel, ObservabilityTrace, ProductCard, ProductCardProps, ProductCarousel, ProductCarouselProps, SourceCard, SourceCardProps, UseRagChatOptions, UseRagChatReturn, addSynonyms, useConfig, useRagChat };