@retrivora-ai/rag-engine 1.2.1 → 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 (43) hide show
  1. package/dist/DocumentChunker-BXOUMKoP.d.ts +93 -0
  2. package/dist/DocumentChunker-D1dg5iCi.d.mts +93 -0
  3. package/dist/handlers/index.d.mts +2 -2
  4. package/dist/handlers/index.d.ts +2 -2
  5. package/dist/{index-DbtE8wLM.d.ts → index-B67KQ9NN.d.ts} +1 -1
  6. package/dist/{RagConfig-BOLOz0_O.d.mts → index-Cti1u0y1.d.mts} +86 -94
  7. package/dist/{RagConfig-BOLOz0_O.d.ts → index-Cti1u0y1.d.ts} +86 -94
  8. package/dist/{index-64BDupW3.d.mts → index-kUXnRvuI.d.mts} +1 -1
  9. package/dist/index.d.mts +52 -78
  10. package/dist/index.d.ts +52 -78
  11. package/dist/index.js +93 -27
  12. package/dist/index.mjs +97 -27
  13. package/dist/server.d.mts +5 -4
  14. package/dist/server.d.ts +5 -4
  15. package/package.json +1 -1
  16. package/src/components/ChatWidget.tsx +1 -8
  17. package/src/components/ChatWindow.tsx +119 -29
  18. package/src/components/ConfigProvider.tsx +7 -33
  19. package/src/components/DocumentUpload.tsx +1 -8
  20. package/src/components/MessageBubble.tsx +1 -12
  21. package/src/components/ProductCard.tsx +1 -7
  22. package/src/components/ProductCarousel.tsx +1 -7
  23. package/src/components/SourceCard.tsx +1 -6
  24. package/src/config/RagConfig.ts +2 -0
  25. package/src/config/uiConstants.ts +23 -0
  26. package/src/core/Pipeline.ts +2 -1
  27. package/src/core/VectorPlugin.ts +1 -1
  28. package/src/handlers/index.ts +1 -1
  29. package/src/hooks/useRagChat.ts +1 -45
  30. package/src/hooks/useStoredMessages.ts +1 -1
  31. package/src/index.ts +20 -5
  32. package/src/llm/ILLMProvider.ts +1 -13
  33. package/src/llm/providers/AnthropicProvider.ts +2 -1
  34. package/src/llm/providers/GeminiProvider.ts +2 -1
  35. package/src/llm/providers/OllamaProvider.ts +2 -1
  36. package/src/llm/providers/OpenAIProvider.ts +2 -1
  37. package/src/llm/providers/UniversalLLMAdapter.ts +2 -1
  38. package/src/server.ts +2 -2
  39. package/src/types/chat.ts +53 -0
  40. package/src/types/index.ts +3 -0
  41. package/src/types/props.ts +79 -0
  42. package/dist/DocumentChunker-Dh9TvmGG.d.mts +0 -45
  43. package/dist/DocumentChunker-Dh9TvmGG.d.ts +0 -45
@@ -0,0 +1,93 @@
1
+ import { C as ChatMessage, c as ChatOptions } from './index-Cti1u0y1.js';
2
+
3
+ /**
4
+ * Generic LLM Provider interface.
5
+ * Covers both chat completion and embedding generation so a single
6
+ * provider can handle both responsibilities when appropriate.
7
+ */
8
+
9
+ interface EmbedOptions {
10
+ /** Override model for this specific embed call */
11
+ model?: string;
12
+ /** Specify the task type for models that require prefixes (e.g. nomic-embed-text) */
13
+ taskType?: 'query' | 'document';
14
+ }
15
+ interface ILLMProvider {
16
+ /**
17
+ * Send a chat completion request.
18
+ * @param messages – the full conversation history
19
+ * @param context – retrieved RAG context to inject
20
+ * @param options – optional per-call overrides
21
+ * @returns – the assistant's reply text
22
+ */
23
+ chat(messages: ChatMessage[], context: string, options?: ChatOptions): Promise<string>;
24
+ /**
25
+ * Send a streaming chat completion request.
26
+ * @returns – an async iterable of text chunks
27
+ */
28
+ chatStream?(messages: ChatMessage[], context: string, options?: ChatOptions): AsyncIterable<string>;
29
+ /**
30
+ * Generate an embedding vector for the given text.
31
+ * @param text – text to embed
32
+ * @param options – optional overrides
33
+ * @returns – float array (the embedding)
34
+ */
35
+ embed(text: string, options?: EmbedOptions): Promise<number[]>;
36
+ /**
37
+ * Generate embedding vectors for multiple texts in a single batch.
38
+ * @param texts – array of texts to embed
39
+ * @param options – optional overrides
40
+ * @returns – array of float arrays
41
+ */
42
+ batchEmbed(texts: string[], options?: EmbedOptions): Promise<number[][]>;
43
+ /**
44
+ * Check if the provider endpoint is reachable.
45
+ */
46
+ ping(): Promise<boolean>;
47
+ }
48
+
49
+ /**
50
+ * DocumentChunker — splits long text into overlapping chunks
51
+ * suitable for vector embedding and retrieval.
52
+ *
53
+ * Strategy: sentence-aware sliding window
54
+ * 1. Split on sentence boundaries
55
+ * 2. Accumulate sentences into chunks up to `chunkSize` characters
56
+ * 3. Carry over `chunkOverlap` characters from the previous chunk
57
+ */
58
+ interface Chunk {
59
+ id: string;
60
+ content: string;
61
+ metadata?: Record<string, unknown>;
62
+ }
63
+ interface ChunkOptions {
64
+ /** Target chunk size in characters (default 1000) */
65
+ chunkSize?: number;
66
+ /** Overlap between consecutive chunks in characters (default 200) */
67
+ chunkOverlap?: number;
68
+ /** Source document identifier used as ID prefix */
69
+ docId?: string | number;
70
+ /** Extra metadata to attach to every chunk */
71
+ metadata?: Record<string, unknown>;
72
+ /** Characters used to split text, in order of priority */
73
+ separators?: string[];
74
+ }
75
+ declare class DocumentChunker {
76
+ private readonly chunkSize;
77
+ private readonly chunkOverlap;
78
+ private readonly separators;
79
+ constructor(chunkSize?: number, chunkOverlap?: number, separators?: string[]);
80
+ /**
81
+ * Split a single text string into overlapping chunks using a recursive strategy.
82
+ * Preserves structural boundaries (Markdown headers) where possible.
83
+ */
84
+ chunk(text: string, options?: ChunkOptions): Chunk[];
85
+ private recursiveSplit;
86
+ chunkMany(documents: Array<{
87
+ content: string;
88
+ docId?: string | number;
89
+ metadata?: Record<string, unknown>;
90
+ }>): Chunk[];
91
+ }
92
+
93
+ export { type Chunk as C, DocumentChunker as D, type EmbedOptions as E, type ILLMProvider as I, type ChunkOptions as a };
@@ -0,0 +1,93 @@
1
+ import { C as ChatMessage, c as ChatOptions } from './index-Cti1u0y1.mjs';
2
+
3
+ /**
4
+ * Generic LLM Provider interface.
5
+ * Covers both chat completion and embedding generation so a single
6
+ * provider can handle both responsibilities when appropriate.
7
+ */
8
+
9
+ interface EmbedOptions {
10
+ /** Override model for this specific embed call */
11
+ model?: string;
12
+ /** Specify the task type for models that require prefixes (e.g. nomic-embed-text) */
13
+ taskType?: 'query' | 'document';
14
+ }
15
+ interface ILLMProvider {
16
+ /**
17
+ * Send a chat completion request.
18
+ * @param messages – the full conversation history
19
+ * @param context – retrieved RAG context to inject
20
+ * @param options – optional per-call overrides
21
+ * @returns – the assistant's reply text
22
+ */
23
+ chat(messages: ChatMessage[], context: string, options?: ChatOptions): Promise<string>;
24
+ /**
25
+ * Send a streaming chat completion request.
26
+ * @returns – an async iterable of text chunks
27
+ */
28
+ chatStream?(messages: ChatMessage[], context: string, options?: ChatOptions): AsyncIterable<string>;
29
+ /**
30
+ * Generate an embedding vector for the given text.
31
+ * @param text – text to embed
32
+ * @param options – optional overrides
33
+ * @returns – float array (the embedding)
34
+ */
35
+ embed(text: string, options?: EmbedOptions): Promise<number[]>;
36
+ /**
37
+ * Generate embedding vectors for multiple texts in a single batch.
38
+ * @param texts – array of texts to embed
39
+ * @param options – optional overrides
40
+ * @returns – array of float arrays
41
+ */
42
+ batchEmbed(texts: string[], options?: EmbedOptions): Promise<number[][]>;
43
+ /**
44
+ * Check if the provider endpoint is reachable.
45
+ */
46
+ ping(): Promise<boolean>;
47
+ }
48
+
49
+ /**
50
+ * DocumentChunker — splits long text into overlapping chunks
51
+ * suitable for vector embedding and retrieval.
52
+ *
53
+ * Strategy: sentence-aware sliding window
54
+ * 1. Split on sentence boundaries
55
+ * 2. Accumulate sentences into chunks up to `chunkSize` characters
56
+ * 3. Carry over `chunkOverlap` characters from the previous chunk
57
+ */
58
+ interface Chunk {
59
+ id: string;
60
+ content: string;
61
+ metadata?: Record<string, unknown>;
62
+ }
63
+ interface ChunkOptions {
64
+ /** Target chunk size in characters (default 1000) */
65
+ chunkSize?: number;
66
+ /** Overlap between consecutive chunks in characters (default 200) */
67
+ chunkOverlap?: number;
68
+ /** Source document identifier used as ID prefix */
69
+ docId?: string | number;
70
+ /** Extra metadata to attach to every chunk */
71
+ metadata?: Record<string, unknown>;
72
+ /** Characters used to split text, in order of priority */
73
+ separators?: string[];
74
+ }
75
+ declare class DocumentChunker {
76
+ private readonly chunkSize;
77
+ private readonly chunkOverlap;
78
+ private readonly separators;
79
+ constructor(chunkSize?: number, chunkOverlap?: number, separators?: string[]);
80
+ /**
81
+ * Split a single text string into overlapping chunks using a recursive strategy.
82
+ * Preserves structural boundaries (Markdown headers) where possible.
83
+ */
84
+ chunk(text: string, options?: ChunkOptions): Chunk[];
85
+ private recursiveSplit;
86
+ chunkMany(documents: Array<{
87
+ content: string;
88
+ docId?: string | number;
89
+ metadata?: Record<string, unknown>;
90
+ }>): Chunk[];
91
+ }
92
+
93
+ export { type Chunk as C, DocumentChunker as D, type EmbedOptions as E, type ILLMProvider as I, type ChunkOptions as a };
@@ -1,3 +1,3 @@
1
- import '../RagConfig-BOLOz0_O.mjs';
2
- export { c as createChatHandler, d as createHealthHandler, e as createIngestHandler, f as createStreamHandler, k as createSuggestionsHandler, g as createUploadHandler, s as sseErrorFrame, h as sseFrame, i as sseMetaFrame, j as sseTextFrame } from '../index-64BDupW3.mjs';
1
+ import '../index-Cti1u0y1.mjs';
2
+ export { c as createChatHandler, d as createHealthHandler, e as createIngestHandler, f as createStreamHandler, k as createSuggestionsHandler, g as createUploadHandler, s as sseErrorFrame, h as sseFrame, i as sseMetaFrame, j as sseTextFrame } from '../index-kUXnRvuI.mjs';
3
3
  import 'next/server';
@@ -1,3 +1,3 @@
1
- import '../RagConfig-BOLOz0_O.js';
2
- export { c as createChatHandler, d as createHealthHandler, e as createIngestHandler, f as createStreamHandler, k as createSuggestionsHandler, g as createUploadHandler, s as sseErrorFrame, h as sseFrame, i as sseMetaFrame, j as sseTextFrame } from '../index-DbtE8wLM.js';
1
+ import '../index-Cti1u0y1.js';
2
+ export { c as createChatHandler, d as createHealthHandler, e as createIngestHandler, f as createStreamHandler, k as createSuggestionsHandler, g as createUploadHandler, s as sseErrorFrame, h as sseFrame, i as sseMetaFrame, j as sseTextFrame } from '../index-B67KQ9NN.js';
3
3
  import 'next/server';
@@ -1,4 +1,4 @@
1
- import { g as RagConfig, C as ChatMessage, b as ChatResponse, e as IngestDocument } from './RagConfig-BOLOz0_O.js';
1
+ import { h as RagConfig, C as ChatMessage, d as ChatResponse, I as IngestDocument } from './index-Cti1u0y1.js';
2
2
  import { NextRequest, NextResponse } from 'next/server';
3
3
 
4
4
  interface ValidationError {
@@ -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,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 {