@retrivora-ai/rag-engine 1.2.1 → 1.2.3

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 (50) hide show
  1. package/dist/DocumentChunker-BXOUMKoP.d.ts +93 -0
  2. package/dist/DocumentChunker-D1dg5iCi.d.mts +93 -0
  3. package/dist/{chunk-GCPPRD2G.mjs → chunk-WGPNEAK3.mjs} +37 -3
  4. package/dist/handlers/index.d.mts +2 -2
  5. package/dist/handlers/index.d.ts +2 -2
  6. package/dist/handlers/index.js +37 -3
  7. package/dist/handlers/index.mjs +1 -1
  8. package/dist/{index-DbtE8wLM.d.ts → index-B67KQ9NN.d.ts} +1 -1
  9. package/dist/{RagConfig-BOLOz0_O.d.mts → index-Cti1u0y1.d.mts} +86 -94
  10. package/dist/{RagConfig-BOLOz0_O.d.ts → index-Cti1u0y1.d.ts} +86 -94
  11. package/dist/{index-64BDupW3.d.mts → index-kUXnRvuI.d.mts} +1 -1
  12. package/dist/index.d.mts +52 -78
  13. package/dist/index.d.ts +52 -78
  14. package/dist/index.js +313 -124
  15. package/dist/index.mjs +293 -97
  16. package/dist/server.d.mts +5 -4
  17. package/dist/server.d.ts +5 -4
  18. package/dist/server.js +37 -3
  19. package/dist/server.mjs +1 -1
  20. package/package.json +2 -1
  21. package/src/components/ChatWidget.tsx +1 -8
  22. package/src/components/ChatWindow.tsx +120 -29
  23. package/src/components/ConfigProvider.tsx +7 -33
  24. package/src/components/DocumentUpload.tsx +1 -8
  25. package/src/components/DynamicChart.tsx +113 -0
  26. package/src/components/MessageBubble.tsx +51 -13
  27. package/src/components/ProductCard.tsx +1 -7
  28. package/src/components/ProductCarousel.tsx +1 -7
  29. package/src/components/SourceCard.tsx +1 -6
  30. package/src/config/RagConfig.ts +2 -0
  31. package/src/config/uiConstants.ts +23 -0
  32. package/src/core/LangChainAgent.ts +20 -2
  33. package/src/core/Pipeline.ts +19 -1
  34. package/src/core/VectorPlugin.ts +1 -1
  35. package/src/handlers/index.ts +1 -1
  36. package/src/hooks/useRagChat.ts +1 -45
  37. package/src/hooks/useStoredMessages.ts +1 -1
  38. package/src/index.ts +20 -5
  39. package/src/llm/ILLMProvider.ts +1 -13
  40. package/src/llm/providers/AnthropicProvider.ts +2 -1
  41. package/src/llm/providers/GeminiProvider.ts +2 -1
  42. package/src/llm/providers/OllamaProvider.ts +2 -1
  43. package/src/llm/providers/OpenAIProvider.ts +2 -1
  44. package/src/llm/providers/UniversalLLMAdapter.ts +2 -1
  45. package/src/server.ts +2 -2
  46. package/src/types/chat.ts +53 -0
  47. package/src/types/index.ts +3 -0
  48. package/src/types/props.ts +79 -0
  49. package/dist/DocumentChunker-Dh9TvmGG.d.mts +0 -45
  50. package/dist/DocumentChunker-Dh9TvmGG.d.ts +0 -45
@@ -1,62 +1,12 @@
1
- interface VectorMatch {
2
- id: string | number;
3
- score: number;
4
- content: string;
5
- metadata?: Record<string, unknown>;
6
- }
7
- interface UpsertDocument {
8
- id: string | number;
9
- vector: number[];
1
+ type MessageRole = 'user' | 'assistant' | 'system';
2
+ interface ChatMessage {
3
+ role: MessageRole;
10
4
  content: string;
11
- metadata?: Record<string, unknown>;
12
5
  }
13
- interface IngestDocument {
14
- docId: string | number;
15
- content: string;
16
- metadata?: Record<string, unknown>;
17
- }
18
- interface ChatResponse {
19
- reply: string;
20
- sources: VectorMatch[];
21
- graphData?: GraphSearchResult;
22
- }
23
- interface GraphNode {
6
+ interface RagMessage extends ChatMessage {
24
7
  id: string;
25
- label: string;
26
- properties?: Record<string, unknown>;
27
- }
28
- interface Edge {
29
- source: string;
30
- target: string;
31
- type: string;
32
- properties?: Record<string, unknown>;
33
- }
34
- interface GraphSearchResult {
35
- nodes: GraphNode[];
36
- edges: Edge[];
37
- }
38
- interface RetrievalResult {
39
- sources: VectorMatch[];
40
- graphData?: GraphSearchResult;
41
- }
42
- interface Product {
43
- id: string | number;
44
- name: string;
45
- brand?: string;
46
- price?: string | number;
47
- image?: string;
48
- link?: string;
49
- description?: string;
50
- }
51
-
52
- /**
53
- * Generic LLM Provider interface.
54
- * Covers both chat completion and embedding generation so a single
55
- * provider can handle both responsibilities when appropriate.
56
- */
57
- interface ChatMessage {
58
- role: 'user' | 'assistant' | 'system';
59
- content: string;
8
+ sources?: VectorMatch[];
9
+ createdAt: string;
60
10
  }
61
11
  interface ChatOptions {
62
12
  /** Override max tokens for this specific call */
@@ -66,44 +16,33 @@ interface ChatOptions {
66
16
  /** Stop sequences */
67
17
  stop?: string[];
68
18
  }
69
- interface EmbedOptions {
70
- /** Override model for this specific embed call */
71
- model?: string;
72
- /** Specify the task type for models that require prefixes (e.g. nomic-embed-text) */
73
- taskType?: 'query' | 'document';
19
+ interface UseRagChatOptions {
20
+ /** Override the chat API endpoint (default: /api/chat) */
21
+ apiUrl?: string;
22
+ /** Override project namespace */
23
+ namespace?: string;
24
+ /** Persist chat history to localStorage (default: true) */
25
+ persist?: boolean;
26
+ /** Called after each successful assistant reply */
27
+ onReply?: (message: RagMessage) => void;
28
+ /** Called on error */
29
+ onError?: (error: string) => void;
74
30
  }
75
- interface ILLMProvider {
76
- /**
77
- * Send a chat completion request.
78
- * @param messages the full conversation history
79
- * @param context – retrieved RAG context to inject
80
- * @param options – optional per-call overrides
81
- * @returns – the assistant's reply text
82
- */
83
- chat(messages: ChatMessage[], context: string, options?: ChatOptions): Promise<string>;
84
- /**
85
- * Send a streaming chat completion request.
86
- * @returns an async iterable of text chunks
87
- */
88
- chatStream?(messages: ChatMessage[], context: string, options?: ChatOptions): AsyncIterable<string>;
89
- /**
90
- * Generate an embedding vector for the given text.
91
- * @param text – text to embed
92
- * @param options – optional overrides
93
- * @returns – float array (the embedding)
94
- */
95
- embed(text: string, options?: EmbedOptions): Promise<number[]>;
96
- /**
97
- * Generate embedding vectors for multiple texts in a single batch.
98
- * @param texts – array of texts to embed
99
- * @param options – optional overrides
100
- * @returns – array of float arrays
101
- */
102
- batchEmbed(texts: string[], options?: EmbedOptions): Promise<number[][]>;
103
- /**
104
- * Check if the provider endpoint is reachable.
105
- */
106
- ping(): Promise<boolean>;
31
+ interface UseRagChatReturn {
32
+ /** All messages in the current conversation */
33
+ messages: RagMessage[];
34
+ /** Whether a response is in flight */
35
+ isLoading: boolean;
36
+ /** Current error message, or null */
37
+ error: string | null;
38
+ /** Send a user message */
39
+ send: (text: string) => Promise<void>;
40
+ /** Clear the conversation (and localStorage if persist=true) */
41
+ clear: () => void;
42
+ /** Retry the last failed send */
43
+ retry: () => Promise<void>;
44
+ /** Programmatically set the conversation (e.g. to restore from a DB) */
45
+ setMessages: React.Dispatch<React.SetStateAction<RagMessage[]>>;
107
46
  }
108
47
 
109
48
  /**
@@ -233,6 +172,8 @@ interface UIConfig {
233
172
  allowUpload?: boolean;
234
173
  /** Whether to allow manual resizing of the chat window. Defaults to true. */
235
174
  allowResize?: boolean;
175
+ /** Whether to enable voice search input. Defaults to true. */
176
+ enableVoiceInput?: boolean;
236
177
  }
237
178
  interface RAGConfig {
238
179
  /** Number of top-K chunks retrieved per query */
@@ -280,4 +221,55 @@ interface RagConfig {
280
221
  graphDb?: GraphDBConfig;
281
222
  }
282
223
 
283
- export type { ChatMessage as C, EmbedOptions as E, GraphDBConfig as G, ILLMProvider as I, LLMConfig as L, Product as P, RAGConfig as R, UIConfig as U, VectorMatch as V, ChatOptions as a, ChatResponse as b, EmbeddingConfig as c, EmbeddingProvider as d, IngestDocument as e, LLMProvider as f, RagConfig as g, UpsertDocument as h, VectorDBConfig as i, VectorDBProvider as j, RetrievalResult as k, GraphNode as l, Edge as m, GraphSearchResult as n };
224
+ interface VectorMatch {
225
+ id: string | number;
226
+ score: number;
227
+ content: string;
228
+ metadata?: Record<string, unknown>;
229
+ }
230
+ interface UpsertDocument {
231
+ id: string | number;
232
+ vector: number[];
233
+ content: string;
234
+ metadata?: Record<string, unknown>;
235
+ }
236
+ interface IngestDocument {
237
+ docId: string | number;
238
+ content: string;
239
+ metadata?: Record<string, unknown>;
240
+ }
241
+ interface ChatResponse {
242
+ reply: string;
243
+ sources: VectorMatch[];
244
+ graphData?: GraphSearchResult;
245
+ }
246
+ interface GraphNode {
247
+ id: string;
248
+ label: string;
249
+ properties?: Record<string, unknown>;
250
+ }
251
+ interface Edge {
252
+ source: string;
253
+ target: string;
254
+ type: string;
255
+ properties?: Record<string, unknown>;
256
+ }
257
+ interface GraphSearchResult {
258
+ nodes: GraphNode[];
259
+ edges: Edge[];
260
+ }
261
+ interface RetrievalResult {
262
+ sources: VectorMatch[];
263
+ graphData?: GraphSearchResult;
264
+ }
265
+ interface Product {
266
+ id: string | number;
267
+ name: string;
268
+ brand?: string;
269
+ price?: string | number;
270
+ image?: string;
271
+ link?: string;
272
+ description?: string;
273
+ }
274
+
275
+ export type { ChatMessage as C, EmbeddingConfig as E, GraphDBConfig as G, IngestDocument as I, LLMConfig as L, Product as P, RagMessage as R, UIConfig as U, VectorMatch as V, UseRagChatOptions as a, UseRagChatReturn as b, ChatOptions as c, ChatResponse as d, EmbeddingProvider as e, LLMProvider as f, RAGConfig as g, RagConfig as h, UpsertDocument as i, VectorDBConfig as j, VectorDBProvider as k, RetrievalResult as l, GraphNode as m, Edge as n, GraphSearchResult as o };
@@ -1,4 +1,4 @@
1
- import { g as RagConfig, C as ChatMessage, b as ChatResponse, e as IngestDocument } from './RagConfig-BOLOz0_O.mjs';
1
+ import { h as RagConfig, C as ChatMessage, d as ChatResponse, I as IngestDocument } from './index-Cti1u0y1.mjs';
2
2
  import { NextRequest, NextResponse } from 'next/server';
3
3
 
4
4
  interface ValidationError {
package/dist/index.d.mts CHANGED
@@ -1,27 +1,19 @@
1
- import React$1, { ReactNode } from 'react';
2
- import { P as Product, C as ChatMessage, V as VectorMatch, U as UIConfig } from './RagConfig-BOLOz0_O.mjs';
3
- export { a as ChatOptions, b as ChatResponse, E as EmbedOptions, c as EmbeddingConfig, d as EmbeddingProvider, I as ILLMProvider, e as IngestDocument, L as LLMConfig, f as LLMProvider, R as RAGConfig, g as RagConfig, h as UpsertDocument, i as VectorDBConfig, j as VectorDBProvider } from './RagConfig-BOLOz0_O.mjs';
4
- export { C as Chunk, a as ChunkOptions } from './DocumentChunker-Dh9TvmGG.mjs';
5
-
6
- interface ChatWidgetProps {
7
- /** Position of the floating button. Defaults to bottom-right. */
8
- position?: 'bottom-right' | 'bottom-left';
9
- /** Called when the user clicks 'Add to Cart' on a product */
10
- onAddToCart?: (product: Product) => void;
11
- }
12
- declare function ChatWidget({ position, onAddToCart }: ChatWidgetProps): React$1.JSX.Element | null;
1
+ import React, { CSSProperties, MouseEvent, ReactNode } from 'react';
2
+ import { P as Product, U as UIConfig, R as RagMessage, V as VectorMatch, a as UseRagChatOptions, b as UseRagChatReturn } from './index-Cti1u0y1.mjs';
3
+ export { C as ChatMessage, c as ChatOptions, d as ChatResponse, E as EmbeddingConfig, e as EmbeddingProvider, I as IngestDocument, L as LLMConfig, f as LLMProvider, g as RAGConfig, h as RagConfig, i as UpsertDocument, j as VectorDBConfig, k as VectorDBProvider } from './index-Cti1u0y1.mjs';
4
+ export { C as Chunk, a as ChunkOptions, E as EmbedOptions, I as ILLMProvider } from './DocumentChunker-D1dg5iCi.mjs';
13
5
 
14
6
  interface ChatWindowProps {
15
7
  /** Additional className for the wrapper div */
16
8
  className?: string;
17
9
  /** Inline styles for the wrapper div */
18
- style?: React$1.CSSProperties;
10
+ style?: CSSProperties;
19
11
  /** Called when the close button is clicked (for widget mode) */
20
12
  onClose?: () => void;
21
13
  /** Whether to show a close (X) button in the header */
22
14
  showClose?: boolean;
23
15
  /** Called when the user starts dragging the resize handle */
24
- onResizeStart?: (e: React$1.MouseEvent) => void;
16
+ onResizeStart?: (e: MouseEvent) => void;
25
17
  /** Called when the user clicks the reset size button */
26
18
  onResetResize?: () => void;
27
19
  /** Whether the window has been resized from its default */
@@ -33,8 +25,30 @@ interface ChatWindowProps {
33
25
  /** Called when the user clicks 'Add to Cart' on a product */
34
26
  onAddToCart?: (product: Product) => void;
35
27
  }
36
- declare function ChatWindow({ className, style, onClose, showClose, onResizeStart, onResetResize, isResized, onMaximize, isMaximized, onAddToCart }: ChatWindowProps): React$1.JSX.Element;
37
-
28
+ interface ChatWidgetProps {
29
+ /** Position of the floating button. Defaults to bottom-right. */
30
+ position?: 'bottom-right' | 'bottom-left';
31
+ /** Called when the user clicks 'Add to Cart' on a product */
32
+ onAddToCart?: (product: Product) => void;
33
+ }
34
+ interface MessageBubbleProps {
35
+ message: RagMessage;
36
+ sources?: VectorMatch[];
37
+ isStreaming?: boolean;
38
+ primaryColor: string;
39
+ accentColor: string;
40
+ onAddToCart?: (product: Product) => void;
41
+ }
42
+ interface ProductCardProps {
43
+ product: Product;
44
+ primaryColor?: string;
45
+ onAddToCart?: (product: Product) => void;
46
+ }
47
+ interface ProductCarouselProps {
48
+ products: Product[];
49
+ primaryColor?: string;
50
+ onAddToCart?: (product: Product) => void;
51
+ }
38
52
  interface DocumentUploadProps {
39
53
  /** Optional namespace for the upload */
40
54
  namespace?: string;
@@ -43,82 +57,42 @@ interface DocumentUploadProps {
43
57
  /** Additional className */
44
58
  className?: string;
45
59
  }
46
- declare function DocumentUpload({ namespace, onUploadComplete, className }: DocumentUploadProps): React$1.JSX.Element;
47
-
48
- interface MessageBubbleProps {
49
- message: ChatMessage;
50
- sources?: VectorMatch[];
51
- isStreaming?: boolean;
52
- primaryColor?: string;
53
- accentColor?: string;
54
- onAddToCart?: (product: Product) => void;
55
- }
56
- declare function MessageBubble({ message, sources, isStreaming, primaryColor, accentColor, onAddToCart, }: MessageBubbleProps): React$1.JSX.Element;
57
-
58
60
  interface SourceCardProps {
59
61
  source: VectorMatch;
60
62
  index: number;
61
63
  }
62
- declare function SourceCard({ source, index }: SourceCardProps): React$1.JSX.Element;
63
-
64
- /**
65
- * ConfigProvider — React Context that makes RagConfig (UI subset) available
66
- * to all child components without prop drilling.
67
- *
68
- * Only the UI-safe portions of RagConfig are exposed to the client.
69
- */
70
-
71
64
  interface ClientConfig {
72
65
  projectId: string;
73
66
  ui: Required<UIConfig>;
74
67
  }
75
- declare function ConfigProvider({ config, children, }: {
68
+ interface ConfigProviderProps {
76
69
  config?: {
77
70
  projectId?: string;
78
71
  ui?: Partial<UIConfig>;
79
72
  };
80
73
  children: ReactNode;
81
- }): React$1.JSX.Element;
74
+ }
75
+
76
+ declare function ChatWidget({ position, onAddToCart }: ChatWidgetProps): React.JSX.Element | null;
77
+
78
+ declare function ChatWindow({ className, style, onClose, showClose, onResizeStart, onResetResize, isResized, onMaximize, isMaximized, onAddToCart }: ChatWindowProps): React.JSX.Element;
79
+
80
+ declare function DocumentUpload({ namespace, onUploadComplete, className }: DocumentUploadProps): React.JSX.Element;
81
+
82
+ declare function MessageBubble({ message, sources, isStreaming, primaryColor, accentColor, onAddToCart, }: MessageBubbleProps): React.JSX.Element;
83
+
84
+ declare function SourceCard({ source, index }: SourceCardProps): React.JSX.Element;
85
+
86
+ /**
87
+ * ConfigProvider — React Context that makes RagConfig (UI subset) available
88
+ * to all child components without prop drilling.
89
+ *
90
+ * Only the UI-safe portions of RagConfig are exposed to the client.
91
+ */
92
+
93
+ declare function ConfigProvider({ config, children, }: ConfigProviderProps): React.JSX.Element;
82
94
  declare function useConfig(): ClientConfig;
83
95
 
84
- type MessageRole = 'user' | 'assistant';
85
- interface RagMessage {
86
- id: string;
87
- role: MessageRole;
88
- content: string;
89
- /** Retrieved source chunks (assistant messages only) */
90
- sources?: VectorMatch[];
91
- /** ISO timestamp */
92
- createdAt: string;
93
- }
94
- interface UseRagChatOptions {
95
- /** Override the chat API endpoint (default: /api/chat) */
96
- apiUrl?: string;
97
- /** Override project namespace */
98
- namespace?: string;
99
- /** Persist chat history to localStorage (default: true) */
100
- persist?: boolean;
101
- /** Called after each successful assistant reply */
102
- onReply?: (message: RagMessage) => void;
103
- /** Called on error */
104
- onError?: (error: string) => void;
105
- }
106
- interface UseRagChatReturn {
107
- /** All messages in the current conversation */
108
- messages: RagMessage[];
109
- /** Whether a response is in flight */
110
- isLoading: boolean;
111
- /** Current error message, or null */
112
- error: string | null;
113
- /** Send a user message */
114
- send: (text: string) => Promise<void>;
115
- /** Clear the conversation (and localStorage if persist=true) */
116
- clear: () => void;
117
- /** Retry the last failed send */
118
- retry: () => Promise<void>;
119
- /** Programmatically set the conversation (e.g. to restore from a DB) */
120
- setMessages: React.Dispatch<React.SetStateAction<RagMessage[]>>;
121
- }
122
96
  declare function useRagChat(projectId: string, options?: UseRagChatOptions): UseRagChatReturn;
123
97
 
124
- export { ChatMessage, ChatWidget, ChatWindow, type ClientConfig, ConfigProvider, DocumentUpload, MessageBubble, type RagMessage, SourceCard, UIConfig, type UseRagChatOptions, type UseRagChatReturn, VectorMatch, useConfig, useRagChat };
98
+ export { ChatWidget, type ChatWidgetProps, ChatWindow, type ChatWindowProps, type ClientConfig, ConfigProvider, DocumentUpload, type DocumentUploadProps, MessageBubble, type MessageBubbleProps, type ProductCardProps, type ProductCarouselProps, RagMessage, SourceCard, type SourceCardProps, UIConfig, UseRagChatOptions, UseRagChatReturn, VectorMatch, useConfig, useRagChat };
package/dist/index.d.ts CHANGED
@@ -1,27 +1,19 @@
1
- import React$1, { ReactNode } from 'react';
2
- import { P as Product, C as ChatMessage, V as VectorMatch, U as UIConfig } from './RagConfig-BOLOz0_O.js';
3
- export { a as ChatOptions, b as ChatResponse, E as EmbedOptions, c as EmbeddingConfig, d as EmbeddingProvider, I as ILLMProvider, e as IngestDocument, L as LLMConfig, f as LLMProvider, R as RAGConfig, g as RagConfig, h as UpsertDocument, i as VectorDBConfig, j as VectorDBProvider } from './RagConfig-BOLOz0_O.js';
4
- export { C as Chunk, a as ChunkOptions } from './DocumentChunker-Dh9TvmGG.js';
5
-
6
- interface ChatWidgetProps {
7
- /** Position of the floating button. Defaults to bottom-right. */
8
- position?: 'bottom-right' | 'bottom-left';
9
- /** Called when the user clicks 'Add to Cart' on a product */
10
- onAddToCart?: (product: Product) => void;
11
- }
12
- declare function ChatWidget({ position, onAddToCart }: ChatWidgetProps): React$1.JSX.Element | null;
1
+ import React, { CSSProperties, MouseEvent, ReactNode } from 'react';
2
+ import { P as Product, U as UIConfig, R as RagMessage, V as VectorMatch, a as UseRagChatOptions, b as UseRagChatReturn } from './index-Cti1u0y1.js';
3
+ export { C as ChatMessage, c as ChatOptions, d as ChatResponse, E as EmbeddingConfig, e as EmbeddingProvider, I as IngestDocument, L as LLMConfig, f as LLMProvider, g as RAGConfig, h as RagConfig, i as UpsertDocument, j as VectorDBConfig, k as VectorDBProvider } from './index-Cti1u0y1.js';
4
+ export { C as Chunk, a as ChunkOptions, E as EmbedOptions, I as ILLMProvider } from './DocumentChunker-BXOUMKoP.js';
13
5
 
14
6
  interface ChatWindowProps {
15
7
  /** Additional className for the wrapper div */
16
8
  className?: string;
17
9
  /** Inline styles for the wrapper div */
18
- style?: React$1.CSSProperties;
10
+ style?: CSSProperties;
19
11
  /** Called when the close button is clicked (for widget mode) */
20
12
  onClose?: () => void;
21
13
  /** Whether to show a close (X) button in the header */
22
14
  showClose?: boolean;
23
15
  /** Called when the user starts dragging the resize handle */
24
- onResizeStart?: (e: React$1.MouseEvent) => void;
16
+ onResizeStart?: (e: MouseEvent) => void;
25
17
  /** Called when the user clicks the reset size button */
26
18
  onResetResize?: () => void;
27
19
  /** Whether the window has been resized from its default */
@@ -33,8 +25,30 @@ interface ChatWindowProps {
33
25
  /** Called when the user clicks 'Add to Cart' on a product */
34
26
  onAddToCart?: (product: Product) => void;
35
27
  }
36
- declare function ChatWindow({ className, style, onClose, showClose, onResizeStart, onResetResize, isResized, onMaximize, isMaximized, onAddToCart }: ChatWindowProps): React$1.JSX.Element;
37
-
28
+ interface ChatWidgetProps {
29
+ /** Position of the floating button. Defaults to bottom-right. */
30
+ position?: 'bottom-right' | 'bottom-left';
31
+ /** Called when the user clicks 'Add to Cart' on a product */
32
+ onAddToCart?: (product: Product) => void;
33
+ }
34
+ interface MessageBubbleProps {
35
+ message: RagMessage;
36
+ sources?: VectorMatch[];
37
+ isStreaming?: boolean;
38
+ primaryColor: string;
39
+ accentColor: string;
40
+ onAddToCart?: (product: Product) => void;
41
+ }
42
+ interface ProductCardProps {
43
+ product: Product;
44
+ primaryColor?: string;
45
+ onAddToCart?: (product: Product) => void;
46
+ }
47
+ interface ProductCarouselProps {
48
+ products: Product[];
49
+ primaryColor?: string;
50
+ onAddToCart?: (product: Product) => void;
51
+ }
38
52
  interface DocumentUploadProps {
39
53
  /** Optional namespace for the upload */
40
54
  namespace?: string;
@@ -43,82 +57,42 @@ interface DocumentUploadProps {
43
57
  /** Additional className */
44
58
  className?: string;
45
59
  }
46
- declare function DocumentUpload({ namespace, onUploadComplete, className }: DocumentUploadProps): React$1.JSX.Element;
47
-
48
- interface MessageBubbleProps {
49
- message: ChatMessage;
50
- sources?: VectorMatch[];
51
- isStreaming?: boolean;
52
- primaryColor?: string;
53
- accentColor?: string;
54
- onAddToCart?: (product: Product) => void;
55
- }
56
- declare function MessageBubble({ message, sources, isStreaming, primaryColor, accentColor, onAddToCart, }: MessageBubbleProps): React$1.JSX.Element;
57
-
58
60
  interface SourceCardProps {
59
61
  source: VectorMatch;
60
62
  index: number;
61
63
  }
62
- declare function SourceCard({ source, index }: SourceCardProps): React$1.JSX.Element;
63
-
64
- /**
65
- * ConfigProvider — React Context that makes RagConfig (UI subset) available
66
- * to all child components without prop drilling.
67
- *
68
- * Only the UI-safe portions of RagConfig are exposed to the client.
69
- */
70
-
71
64
  interface ClientConfig {
72
65
  projectId: string;
73
66
  ui: Required<UIConfig>;
74
67
  }
75
- declare function ConfigProvider({ config, children, }: {
68
+ interface ConfigProviderProps {
76
69
  config?: {
77
70
  projectId?: string;
78
71
  ui?: Partial<UIConfig>;
79
72
  };
80
73
  children: ReactNode;
81
- }): React$1.JSX.Element;
74
+ }
75
+
76
+ declare function ChatWidget({ position, onAddToCart }: ChatWidgetProps): React.JSX.Element | null;
77
+
78
+ declare function ChatWindow({ className, style, onClose, showClose, onResizeStart, onResetResize, isResized, onMaximize, isMaximized, onAddToCart }: ChatWindowProps): React.JSX.Element;
79
+
80
+ declare function DocumentUpload({ namespace, onUploadComplete, className }: DocumentUploadProps): React.JSX.Element;
81
+
82
+ declare function MessageBubble({ message, sources, isStreaming, primaryColor, accentColor, onAddToCart, }: MessageBubbleProps): React.JSX.Element;
83
+
84
+ declare function SourceCard({ source, index }: SourceCardProps): React.JSX.Element;
85
+
86
+ /**
87
+ * ConfigProvider — React Context that makes RagConfig (UI subset) available
88
+ * to all child components without prop drilling.
89
+ *
90
+ * Only the UI-safe portions of RagConfig are exposed to the client.
91
+ */
92
+
93
+ declare function ConfigProvider({ config, children, }: ConfigProviderProps): React.JSX.Element;
82
94
  declare function useConfig(): ClientConfig;
83
95
 
84
- type MessageRole = 'user' | 'assistant';
85
- interface RagMessage {
86
- id: string;
87
- role: MessageRole;
88
- content: string;
89
- /** Retrieved source chunks (assistant messages only) */
90
- sources?: VectorMatch[];
91
- /** ISO timestamp */
92
- createdAt: string;
93
- }
94
- interface UseRagChatOptions {
95
- /** Override the chat API endpoint (default: /api/chat) */
96
- apiUrl?: string;
97
- /** Override project namespace */
98
- namespace?: string;
99
- /** Persist chat history to localStorage (default: true) */
100
- persist?: boolean;
101
- /** Called after each successful assistant reply */
102
- onReply?: (message: RagMessage) => void;
103
- /** Called on error */
104
- onError?: (error: string) => void;
105
- }
106
- interface UseRagChatReturn {
107
- /** All messages in the current conversation */
108
- messages: RagMessage[];
109
- /** Whether a response is in flight */
110
- isLoading: boolean;
111
- /** Current error message, or null */
112
- error: string | null;
113
- /** Send a user message */
114
- send: (text: string) => Promise<void>;
115
- /** Clear the conversation (and localStorage if persist=true) */
116
- clear: () => void;
117
- /** Retry the last failed send */
118
- retry: () => Promise<void>;
119
- /** Programmatically set the conversation (e.g. to restore from a DB) */
120
- setMessages: React.Dispatch<React.SetStateAction<RagMessage[]>>;
121
- }
122
96
  declare function useRagChat(projectId: string, options?: UseRagChatOptions): UseRagChatReturn;
123
97
 
124
- export { ChatMessage, ChatWidget, ChatWindow, type ClientConfig, ConfigProvider, DocumentUpload, MessageBubble, type RagMessage, SourceCard, UIConfig, type UseRagChatOptions, type UseRagChatReturn, VectorMatch, useConfig, useRagChat };
98
+ export { ChatWidget, type ChatWidgetProps, ChatWindow, type ChatWindowProps, type ClientConfig, ConfigProvider, DocumentUpload, type DocumentUploadProps, MessageBubble, type MessageBubbleProps, type ProductCardProps, type ProductCarouselProps, RagMessage, SourceCard, type SourceCardProps, UIConfig, UseRagChatOptions, UseRagChatReturn, VectorMatch, useConfig, useRagChat };