@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.
- package/dist/DocumentChunker-BXOUMKoP.d.ts +93 -0
- package/dist/DocumentChunker-D1dg5iCi.d.mts +93 -0
- package/dist/{chunk-GCPPRD2G.mjs → chunk-WGPNEAK3.mjs} +37 -3
- package/dist/handlers/index.d.mts +2 -2
- package/dist/handlers/index.d.ts +2 -2
- package/dist/handlers/index.js +37 -3
- package/dist/handlers/index.mjs +1 -1
- package/dist/{index-DbtE8wLM.d.ts → index-B67KQ9NN.d.ts} +1 -1
- package/dist/{RagConfig-BOLOz0_O.d.mts → index-Cti1u0y1.d.mts} +86 -94
- package/dist/{RagConfig-BOLOz0_O.d.ts → index-Cti1u0y1.d.ts} +86 -94
- package/dist/{index-64BDupW3.d.mts → index-kUXnRvuI.d.mts} +1 -1
- package/dist/index.d.mts +52 -78
- package/dist/index.d.ts +52 -78
- package/dist/index.js +313 -124
- package/dist/index.mjs +293 -97
- package/dist/server.d.mts +5 -4
- package/dist/server.d.ts +5 -4
- package/dist/server.js +37 -3
- package/dist/server.mjs +1 -1
- package/package.json +2 -1
- package/src/components/ChatWidget.tsx +1 -8
- package/src/components/ChatWindow.tsx +120 -29
- package/src/components/ConfigProvider.tsx +7 -33
- package/src/components/DocumentUpload.tsx +1 -8
- package/src/components/DynamicChart.tsx +113 -0
- package/src/components/MessageBubble.tsx +51 -13
- package/src/components/ProductCard.tsx +1 -7
- package/src/components/ProductCarousel.tsx +1 -7
- package/src/components/SourceCard.tsx +1 -6
- package/src/config/RagConfig.ts +2 -0
- package/src/config/uiConstants.ts +23 -0
- package/src/core/LangChainAgent.ts +20 -2
- package/src/core/Pipeline.ts +19 -1
- package/src/core/VectorPlugin.ts +1 -1
- package/src/handlers/index.ts +1 -1
- package/src/hooks/useRagChat.ts +1 -45
- package/src/hooks/useStoredMessages.ts +1 -1
- package/src/index.ts +20 -5
- package/src/llm/ILLMProvider.ts +1 -13
- package/src/llm/providers/AnthropicProvider.ts +2 -1
- package/src/llm/providers/GeminiProvider.ts +2 -1
- package/src/llm/providers/OllamaProvider.ts +2 -1
- package/src/llm/providers/OpenAIProvider.ts +2 -1
- package/src/llm/providers/UniversalLLMAdapter.ts +2 -1
- package/src/server.ts +2 -2
- package/src/types/chat.ts +53 -0
- package/src/types/index.ts +3 -0
- package/src/types/props.ts +79 -0
- package/dist/DocumentChunker-Dh9TvmGG.d.mts +0 -45
- package/dist/DocumentChunker-Dh9TvmGG.d.ts +0 -45
|
@@ -1,62 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
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
|
-
|
|
26
|
-
|
|
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
|
|
70
|
-
/** Override
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
|
|
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
|
|
76
|
-
/**
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
|
2
|
-
import { P as Product,
|
|
3
|
-
export {
|
|
4
|
-
export { C as Chunk, a as ChunkOptions } from './DocumentChunker-
|
|
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?:
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
68
|
+
interface ConfigProviderProps {
|
|
76
69
|
config?: {
|
|
77
70
|
projectId?: string;
|
|
78
71
|
ui?: Partial<UIConfig>;
|
|
79
72
|
};
|
|
80
73
|
children: ReactNode;
|
|
81
|
-
}
|
|
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 {
|
|
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
|
|
2
|
-
import { P as Product,
|
|
3
|
-
export {
|
|
4
|
-
export { C as Chunk, a as ChunkOptions } from './DocumentChunker-
|
|
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?:
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
68
|
+
interface ConfigProviderProps {
|
|
76
69
|
config?: {
|
|
77
70
|
projectId?: string;
|
|
78
71
|
ui?: Partial<UIConfig>;
|
|
79
72
|
};
|
|
80
73
|
children: ReactNode;
|
|
81
|
-
}
|
|
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 {
|
|
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 };
|