@retrivora-ai/rag-engine 1.2.0 → 1.2.2

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 (49) hide show
  1. package/dist/DocumentChunker-BXOUMKoP.d.ts +93 -0
  2. package/dist/DocumentChunker-D1dg5iCi.d.mts +93 -0
  3. package/dist/{chunk-OCDCJUNE.mjs → chunk-GCPPRD2G.mjs} +70 -1
  4. package/dist/handlers/index.d.mts +2 -2
  5. package/dist/handlers/index.d.ts +2 -2
  6. package/dist/handlers/index.js +70 -0
  7. package/dist/handlers/index.mjs +3 -1
  8. package/dist/{index-CYgr00ot.d.ts → index-B67KQ9NN.d.ts} +14 -2
  9. package/dist/{RagConfig-FyMB_UG6.d.mts → index-Cti1u0y1.d.mts} +87 -86
  10. package/dist/{RagConfig-FyMB_UG6.d.ts → index-Cti1u0y1.d.ts} +87 -86
  11. package/dist/{index-D-lfcqlL.d.mts → index-kUXnRvuI.d.mts} +14 -2
  12. package/dist/index.d.mts +53 -89
  13. package/dist/index.d.ts +53 -89
  14. package/dist/index.js +139 -27
  15. package/dist/index.mjs +143 -27
  16. package/dist/server.d.mts +9 -4
  17. package/dist/server.d.ts +9 -4
  18. package/dist/server.js +51 -0
  19. package/dist/server.mjs +1 -1
  20. package/package.json +1 -1
  21. package/src/app/api/suggestions/route.ts +4 -0
  22. package/src/components/ChatWidget.tsx +1 -7
  23. package/src/components/ChatWindow.tsx +180 -25
  24. package/src/components/ConfigProvider.tsx +7 -33
  25. package/src/components/DocumentUpload.tsx +1 -8
  26. package/src/components/MessageBubble.tsx +1 -12
  27. package/src/components/ProductCard.tsx +1 -15
  28. package/src/components/ProductCarousel.tsx +2 -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/Pipeline.ts +57 -1
  33. package/src/core/VectorPlugin.ts +8 -1
  34. package/src/handlers/index.ts +31 -1
  35. package/src/hooks/useRagChat.ts +1 -45
  36. package/src/hooks/useStoredMessages.ts +1 -1
  37. package/src/index.ts +20 -5
  38. package/src/llm/ILLMProvider.ts +1 -13
  39. package/src/llm/providers/AnthropicProvider.ts +2 -1
  40. package/src/llm/providers/GeminiProvider.ts +2 -1
  41. package/src/llm/providers/OllamaProvider.ts +2 -1
  42. package/src/llm/providers/OpenAIProvider.ts +2 -1
  43. package/src/llm/providers/UniversalLLMAdapter.ts +2 -1
  44. package/src/server.ts +2 -2
  45. package/src/types/chat.ts +53 -0
  46. package/src/types/index.ts +17 -0
  47. package/src/types/props.ts +79 -0
  48. package/dist/DocumentChunker-Dh9TvmGG.d.mts +0 -45
  49. package/dist/DocumentChunker-Dh9TvmGG.d.ts +0 -45
@@ -1,12 +1,13 @@
1
- /**
2
- * Generic LLM Provider interface.
3
- * Covers both chat completion and embedding generation so a single
4
- * provider can handle both responsibilities when appropriate.
5
- */
1
+ type MessageRole = 'user' | 'assistant' | 'system';
6
2
  interface ChatMessage {
7
- role: 'user' | 'assistant' | 'system';
3
+ role: MessageRole;
8
4
  content: string;
9
5
  }
6
+ interface RagMessage extends ChatMessage {
7
+ id: string;
8
+ sources?: VectorMatch[];
9
+ createdAt: string;
10
+ }
10
11
  interface ChatOptions {
11
12
  /** Override max tokens for this specific call */
12
13
  maxTokens?: number;
@@ -15,86 +16,33 @@ interface ChatOptions {
15
16
  /** Stop sequences */
16
17
  stop?: string[];
17
18
  }
18
- interface EmbedOptions {
19
- /** Override model for this specific embed call */
20
- model?: string;
21
- /** Specify the task type for models that require prefixes (e.g. nomic-embed-text) */
22
- taskType?: 'query' | 'document';
23
- }
24
- interface ILLMProvider {
25
- /**
26
- * Send a chat completion request.
27
- * @param messages the full conversation history
28
- * @param context – retrieved RAG context to inject
29
- * @param options – optional per-call overrides
30
- * @returns – the assistant's reply text
31
- */
32
- chat(messages: ChatMessage[], context: string, options?: ChatOptions): Promise<string>;
33
- /**
34
- * Send a streaming chat completion request.
35
- * @returns – an async iterable of text chunks
36
- */
37
- chatStream?(messages: ChatMessage[], context: string, options?: ChatOptions): AsyncIterable<string>;
38
- /**
39
- * Generate an embedding vector for the given text.
40
- * @param text – text to embed
41
- * @param options – optional overrides
42
- * @returns – float array (the embedding)
43
- */
44
- embed(text: string, options?: EmbedOptions): Promise<number[]>;
45
- /**
46
- * Generate embedding vectors for multiple texts in a single batch.
47
- * @param texts – array of texts to embed
48
- * @param options – optional overrides
49
- * @returns – array of float arrays
50
- */
51
- batchEmbed(texts: string[], options?: EmbedOptions): Promise<number[][]>;
52
- /**
53
- * Check if the provider endpoint is reachable.
54
- */
55
- ping(): Promise<boolean>;
56
- }
57
-
58
- interface VectorMatch {
59
- id: string | number;
60
- score: number;
61
- content: string;
62
- metadata?: Record<string, unknown>;
63
- }
64
- interface UpsertDocument {
65
- id: string | number;
66
- vector: number[];
67
- content: string;
68
- metadata?: Record<string, unknown>;
69
- }
70
- interface IngestDocument {
71
- docId: string | number;
72
- content: string;
73
- metadata?: Record<string, unknown>;
74
- }
75
- interface ChatResponse {
76
- reply: string;
77
- sources: VectorMatch[];
78
- graphData?: GraphSearchResult;
79
- }
80
- interface GraphNode {
81
- id: string;
82
- label: string;
83
- properties?: Record<string, unknown>;
84
- }
85
- interface Edge {
86
- source: string;
87
- target: string;
88
- type: string;
89
- properties?: Record<string, unknown>;
90
- }
91
- interface GraphSearchResult {
92
- nodes: GraphNode[];
93
- edges: Edge[];
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;
94
30
  }
95
- interface RetrievalResult {
96
- sources: VectorMatch[];
97
- graphData?: GraphSearchResult;
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[]>>;
98
46
  }
99
47
 
100
48
  /**
@@ -224,6 +172,8 @@ interface UIConfig {
224
172
  allowUpload?: boolean;
225
173
  /** Whether to allow manual resizing of the chat window. Defaults to true. */
226
174
  allowResize?: boolean;
175
+ /** Whether to enable voice search input. Defaults to true. */
176
+ enableVoiceInput?: boolean;
227
177
  }
228
178
  interface RAGConfig {
229
179
  /** Number of top-K chunks retrieved per query */
@@ -271,4 +221,55 @@ interface RagConfig {
271
221
  graphDb?: GraphDBConfig;
272
222
  }
273
223
 
274
- export type { ChatMessage as C, EmbedOptions as E, GraphDBConfig as G, ILLMProvider as I, LLMConfig as L, 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-FyMB_UG6.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 {
@@ -112,6 +112,10 @@ declare class VectorPlugin {
112
112
  docId: string | number;
113
113
  chunksIngested: number;
114
114
  }>>;
115
+ /**
116
+ * Get auto-suggestions based on a query prefix.
117
+ */
118
+ getSuggestions(query: string, namespace?: string): Promise<string[]>;
115
119
  }
116
120
 
117
121
  /**
@@ -202,5 +206,13 @@ declare function createUploadHandler(configOrPlugin?: Partial<RagConfig> | Vecto
202
206
  chunksIngested: number;
203
207
  }[];
204
208
  }>>;
209
+ /**
210
+ * createSuggestionsHandler — factory for the auto-suggestions endpoint.
211
+ */
212
+ declare function createSuggestionsHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin): (req: NextRequest) => Promise<NextResponse<{
213
+ error: string;
214
+ }> | NextResponse<{
215
+ suggestions: string[];
216
+ }>>;
205
217
 
206
- export { ConfigValidator as C, type HealthCheckResult as H, type IProviderValidator as I, type ValidationError as V, type IProviderHealthChecker as a, VectorPlugin as b, createChatHandler as c, createHealthHandler as d, createIngestHandler as e, createStreamHandler as f, createUploadHandler as g, sseFrame as h, sseMetaFrame as i, sseTextFrame as j, sseErrorFrame as s };
218
+ export { ConfigValidator as C, type HealthCheckResult as H, type IProviderValidator as I, type ValidationError as V, type IProviderHealthChecker as a, VectorPlugin as b, createChatHandler as c, createHealthHandler as d, createIngestHandler as e, createStreamHandler as f, createUploadHandler as g, sseFrame as h, sseMetaFrame as i, sseTextFrame as j, createSuggestionsHandler as k, sseErrorFrame as s };
package/dist/index.d.mts CHANGED
@@ -1,27 +1,19 @@
1
- import React$1, { ReactNode } from 'react';
2
- import { C as ChatMessage, V as VectorMatch, U as UIConfig } from './RagConfig-FyMB_UG6.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-FyMB_UG6.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: any) => 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 */
@@ -31,10 +23,32 @@ interface ChatWindowProps {
31
23
  /** Whether the window is currently maximized */
32
24
  isMaximized?: boolean;
33
25
  /** Called when the user clicks 'Add to Cart' on a product */
34
- onAddToCart?: (product: any) => void;
26
+ onAddToCart?: (product: Product) => void;
27
+ }
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;
35
51
  }
36
- declare function ChatWindow({ className, style, onClose, showClose, onResizeStart, onResetResize, isResized, onMaximize, isMaximized, onAddToCart }: ChatWindowProps): React$1.JSX.Element;
37
-
38
52
  interface DocumentUploadProps {
39
53
  /** Optional namespace for the upload */
40
54
  namespace?: string;
@@ -43,92 +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 Product {
49
- id: string | number;
50
- name: string;
51
- brand?: string;
52
- price?: string | number;
53
- image?: string;
54
- link?: string;
55
- description?: string;
56
- }
57
-
58
- interface MessageBubbleProps {
59
- message: ChatMessage;
60
- sources?: VectorMatch[];
61
- isStreaming?: boolean;
62
- primaryColor?: string;
63
- accentColor?: string;
64
- onAddToCart?: (product: Product) => void;
65
- }
66
- declare function MessageBubble({ message, sources, isStreaming, primaryColor, accentColor, onAddToCart, }: MessageBubbleProps): React$1.JSX.Element;
67
-
68
60
  interface SourceCardProps {
69
61
  source: VectorMatch;
70
62
  index: number;
71
63
  }
72
- declare function SourceCard({ source, index }: SourceCardProps): React$1.JSX.Element;
73
-
74
- /**
75
- * ConfigProvider — React Context that makes RagConfig (UI subset) available
76
- * to all child components without prop drilling.
77
- *
78
- * Only the UI-safe portions of RagConfig are exposed to the client.
79
- */
80
-
81
64
  interface ClientConfig {
82
65
  projectId: string;
83
66
  ui: Required<UIConfig>;
84
67
  }
85
- declare function ConfigProvider({ config, children, }: {
68
+ interface ConfigProviderProps {
86
69
  config?: {
87
70
  projectId?: string;
88
71
  ui?: Partial<UIConfig>;
89
72
  };
90
73
  children: ReactNode;
91
- }): 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;
92
94
  declare function useConfig(): ClientConfig;
93
95
 
94
- type MessageRole = 'user' | 'assistant';
95
- interface RagMessage {
96
- id: string;
97
- role: MessageRole;
98
- content: string;
99
- /** Retrieved source chunks (assistant messages only) */
100
- sources?: VectorMatch[];
101
- /** ISO timestamp */
102
- createdAt: string;
103
- }
104
- interface UseRagChatOptions {
105
- /** Override the chat API endpoint (default: /api/chat) */
106
- apiUrl?: string;
107
- /** Override project namespace */
108
- namespace?: string;
109
- /** Persist chat history to localStorage (default: true) */
110
- persist?: boolean;
111
- /** Called after each successful assistant reply */
112
- onReply?: (message: RagMessage) => void;
113
- /** Called on error */
114
- onError?: (error: string) => void;
115
- }
116
- interface UseRagChatReturn {
117
- /** All messages in the current conversation */
118
- messages: RagMessage[];
119
- /** Whether a response is in flight */
120
- isLoading: boolean;
121
- /** Current error message, or null */
122
- error: string | null;
123
- /** Send a user message */
124
- send: (text: string) => Promise<void>;
125
- /** Clear the conversation (and localStorage if persist=true) */
126
- clear: () => void;
127
- /** Retry the last failed send */
128
- retry: () => Promise<void>;
129
- /** Programmatically set the conversation (e.g. to restore from a DB) */
130
- setMessages: React.Dispatch<React.SetStateAction<RagMessage[]>>;
131
- }
132
96
  declare function useRagChat(projectId: string, options?: UseRagChatOptions): UseRagChatReturn;
133
97
 
134
- 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 { C as ChatMessage, V as VectorMatch, U as UIConfig } from './RagConfig-FyMB_UG6.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-FyMB_UG6.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: any) => 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 */
@@ -31,10 +23,32 @@ interface ChatWindowProps {
31
23
  /** Whether the window is currently maximized */
32
24
  isMaximized?: boolean;
33
25
  /** Called when the user clicks 'Add to Cart' on a product */
34
- onAddToCart?: (product: any) => void;
26
+ onAddToCart?: (product: Product) => void;
27
+ }
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;
35
51
  }
36
- declare function ChatWindow({ className, style, onClose, showClose, onResizeStart, onResetResize, isResized, onMaximize, isMaximized, onAddToCart }: ChatWindowProps): React$1.JSX.Element;
37
-
38
52
  interface DocumentUploadProps {
39
53
  /** Optional namespace for the upload */
40
54
  namespace?: string;
@@ -43,92 +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 Product {
49
- id: string | number;
50
- name: string;
51
- brand?: string;
52
- price?: string | number;
53
- image?: string;
54
- link?: string;
55
- description?: string;
56
- }
57
-
58
- interface MessageBubbleProps {
59
- message: ChatMessage;
60
- sources?: VectorMatch[];
61
- isStreaming?: boolean;
62
- primaryColor?: string;
63
- accentColor?: string;
64
- onAddToCart?: (product: Product) => void;
65
- }
66
- declare function MessageBubble({ message, sources, isStreaming, primaryColor, accentColor, onAddToCart, }: MessageBubbleProps): React$1.JSX.Element;
67
-
68
60
  interface SourceCardProps {
69
61
  source: VectorMatch;
70
62
  index: number;
71
63
  }
72
- declare function SourceCard({ source, index }: SourceCardProps): React$1.JSX.Element;
73
-
74
- /**
75
- * ConfigProvider — React Context that makes RagConfig (UI subset) available
76
- * to all child components without prop drilling.
77
- *
78
- * Only the UI-safe portions of RagConfig are exposed to the client.
79
- */
80
-
81
64
  interface ClientConfig {
82
65
  projectId: string;
83
66
  ui: Required<UIConfig>;
84
67
  }
85
- declare function ConfigProvider({ config, children, }: {
68
+ interface ConfigProviderProps {
86
69
  config?: {
87
70
  projectId?: string;
88
71
  ui?: Partial<UIConfig>;
89
72
  };
90
73
  children: ReactNode;
91
- }): 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;
92
94
  declare function useConfig(): ClientConfig;
93
95
 
94
- type MessageRole = 'user' | 'assistant';
95
- interface RagMessage {
96
- id: string;
97
- role: MessageRole;
98
- content: string;
99
- /** Retrieved source chunks (assistant messages only) */
100
- sources?: VectorMatch[];
101
- /** ISO timestamp */
102
- createdAt: string;
103
- }
104
- interface UseRagChatOptions {
105
- /** Override the chat API endpoint (default: /api/chat) */
106
- apiUrl?: string;
107
- /** Override project namespace */
108
- namespace?: string;
109
- /** Persist chat history to localStorage (default: true) */
110
- persist?: boolean;
111
- /** Called after each successful assistant reply */
112
- onReply?: (message: RagMessage) => void;
113
- /** Called on error */
114
- onError?: (error: string) => void;
115
- }
116
- interface UseRagChatReturn {
117
- /** All messages in the current conversation */
118
- messages: RagMessage[];
119
- /** Whether a response is in flight */
120
- isLoading: boolean;
121
- /** Current error message, or null */
122
- error: string | null;
123
- /** Send a user message */
124
- send: (text: string) => Promise<void>;
125
- /** Clear the conversation (and localStorage if persist=true) */
126
- clear: () => void;
127
- /** Retry the last failed send */
128
- retry: () => Promise<void>;
129
- /** Programmatically set the conversation (e.g. to restore from a DB) */
130
- setMessages: React.Dispatch<React.SetStateAction<RagMessage[]>>;
131
- }
132
96
  declare function useRagChat(projectId: string, options?: UseRagChatOptions): UseRagChatReturn;
133
97
 
134
- 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 };