@retrivora-ai/rag-engine 1.8.1 → 1.8.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 (80) hide show
  1. package/dist/{ILLMProvider-BfRgI1Xh.d.mts → ILLMProvider-BOJFz3Na.d.mts} +47 -1
  2. package/dist/{ILLMProvider-BfRgI1Xh.d.ts → ILLMProvider-BOJFz3Na.d.ts} +47 -1
  3. package/dist/handlers/index.d.mts +2 -2
  4. package/dist/handlers/index.d.ts +2 -2
  5. package/dist/handlers/index.js +509 -162
  6. package/dist/handlers/index.mjs +5849 -15
  7. package/dist/{index-1Z4GuYBi.d.ts → index-BwpcaziY.d.ts} +4 -2
  8. package/dist/{index-BV0z5mb6.d.mts → index-D3V9Et2M.d.mts} +4 -2
  9. package/dist/index.d.mts +30 -16
  10. package/dist/index.d.ts +30 -16
  11. package/dist/index.js +1999 -1210
  12. package/dist/index.mjs +2041 -1205
  13. package/dist/server.d.mts +21 -25
  14. package/dist/server.d.ts +21 -25
  15. package/dist/server.js +536 -163
  16. package/dist/server.mjs +5923 -67
  17. package/package.json +9 -7
  18. package/src/app/api/upload/route.ts +4 -0
  19. package/src/app/constants.tsx +2 -2
  20. package/src/app/globals.css +35 -11
  21. package/src/app/page.tsx +12 -321
  22. package/src/components/AmbientBackground.tsx +29 -0
  23. package/src/components/ArchitectureCard.tsx +17 -0
  24. package/src/components/ArchitectureCardsSection.tsx +15 -0
  25. package/src/components/ChatWidget.tsx +0 -1
  26. package/src/components/ChatWindow.tsx +32 -0
  27. package/src/components/CodeViewer.tsx +51 -0
  28. package/src/components/ConfigProvider.tsx +1 -0
  29. package/src/components/DocViewer.tsx +37 -0
  30. package/src/components/DocumentUpload.tsx +44 -1
  31. package/src/components/Documentation.tsx +58 -0
  32. package/src/components/DynamicChart.tsx +27 -2
  33. package/src/components/Hero.tsx +59 -0
  34. package/src/components/HourglassLoader.tsx +87 -0
  35. package/src/components/Lifecycle.tsx +37 -0
  36. package/src/components/MarkdownComponents.tsx +143 -0
  37. package/src/components/MessageBubble.tsx +91 -1012
  38. package/src/components/Navbar.tsx +55 -0
  39. package/src/components/ObservabilityPanel.tsx +374 -0
  40. package/src/components/ProductCard.tsx +3 -1
  41. package/src/components/UIDispatcher.tsx +341 -0
  42. package/src/components/VisualizationRenderer.tsx +48 -26
  43. package/src/config/ConfigBuilder.ts +38 -1
  44. package/src/core/LangChainAgent.ts +1 -4
  45. package/src/core/Pipeline.ts +209 -86
  46. package/src/core/QueryProcessor.ts +65 -0
  47. package/src/handlers/index.ts +72 -12
  48. package/src/hooks/useRagChat.ts +19 -9
  49. package/src/index.ts +9 -1
  50. package/src/providers/vectordb/MultiTablePostgresProvider.ts +150 -64
  51. package/src/rag/Reranker.ts +99 -6
  52. package/src/types/chat.ts +2 -0
  53. package/src/types/index.ts +52 -0
  54. package/src/types/props.ts +9 -1
  55. package/src/utils/ProductExtractor.ts +347 -0
  56. package/src/utils/UITransformer.ts +4 -53
  57. package/src/utils/synonyms.ts +78 -0
  58. package/dist/ChromaDBProvider-MIDOR4FW.mjs +0 -8
  59. package/dist/MilvusProvider-U7SKC27V.mjs +0 -8
  60. package/dist/MongoDBProvider-YNKC7EJ6.mjs +0 -8
  61. package/dist/MultiTablePostgresProvider-YY7LPNJK.mjs +0 -8
  62. package/dist/PineconeProvider-QZNRKTN2.mjs +0 -8
  63. package/dist/QdrantProvider-RLJTNGPY.mjs +0 -8
  64. package/dist/RedisProvider-SR65SCKV.mjs +0 -8
  65. package/dist/SimpleGraphProvider-SLOXO4M7.mjs +0 -62
  66. package/dist/UniversalVectorProvider-IN67OS56.mjs +0 -9
  67. package/dist/WeaviateProvider-5FWDFITI.mjs +0 -8
  68. package/dist/chunk-5AJ4XHLW.mjs +0 -201
  69. package/dist/chunk-5YGUXK7Z.mjs +0 -80
  70. package/dist/chunk-BFYLQYQU.mjs +0 -3985
  71. package/dist/chunk-CFVEZTBJ.mjs +0 -102
  72. package/dist/chunk-IMP6FUCY.mjs +0 -30
  73. package/dist/chunk-LR3VMDVK.mjs +0 -157
  74. package/dist/chunk-M6JSPGAR.mjs +0 -117
  75. package/dist/chunk-PSFPZXHX.mjs +0 -245
  76. package/dist/chunk-R3RGUMHE.mjs +0 -218
  77. package/dist/chunk-U55XRW3U.mjs +0 -96
  78. package/dist/chunk-VUQJVIJT.mjs +0 -148
  79. package/dist/chunk-X4TOT24V.mjs +0 -89
  80. package/dist/chunk-YLTMFW4M.mjs +0 -49
package/dist/server.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { l as VectorDBConfig, L as LLMConfig, e as EmbeddingConfig, j as RagConfig, I as ILLMProvider, g as IngestDocument, C as ChatMessage, d as ChatResponse, n as RetrievalResult, k as UpsertDocument, V as VectorMatch, G as GraphDBConfig, o as GraphNode, p as Edge, q as GraphSearchResult, m as VectorDBProvider, h as LLMProvider, f as EmbeddingProvider, i as RAGConfig, U as UIConfig, c as ChatOptions, E as EmbedOptions } from './ILLMProvider-BfRgI1Xh.mjs';
1
+ import { n as VectorDBConfig, L as LLMConfig, e as EmbeddingConfig, k as RagConfig, I as ILLMProvider, g as IngestDocument, C as ChatMessage, d as ChatResponse, p as RetrievalResult, m as UpsertDocument, V as VectorMatch, G as GraphDBConfig, q as GraphNode, r as Edge, s as GraphSearchResult, o as VectorDBProvider, h as LLMProvider, f as EmbeddingProvider, j as RAGConfig, U as UIConfig, c as ChatOptions, E as EmbedOptions } from './ILLMProvider-BOJFz3Na.mjs';
2
2
  export { C as Chunk, a as ChunkOptions, D as DocumentChunker } from './DocumentChunker-Dh9TvmGG.mjs';
3
- import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-BV0z5mb6.mjs';
4
- export { C as ConfigValidator, V as ValidationError, b as VectorPlugin, c as createChatHandler, d as createHealthHandler, e as createIngestHandler, f as createStreamHandler, g as createUploadHandler, s as sseErrorFrame, h as sseFrame, i as sseMetaFrame, j as sseTextFrame } from './index-BV0z5mb6.mjs';
3
+ import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-D3V9Et2M.mjs';
4
+ export { C as ConfigValidator, V as ValidationError, b as VectorPlugin, c as createChatHandler, d as createHealthHandler, e as createIngestHandler, f as createStreamHandler, g as createUploadHandler, s as sseErrorFrame, h as sseFrame, i as sseMetaFrame, j as sseTextFrame } from './index-D3V9Et2M.mjs';
5
5
  import 'next/server';
6
6
 
7
7
  /**
@@ -105,6 +105,7 @@ declare class ProviderHealthCheck {
105
105
  * - Error recovery for transient failures
106
106
  * - Multi-tenancy support via namespacing
107
107
  * - LRU-bounded embedding cache (max 500 entries, prevents memory leaks)
108
+ * - Full observability tracing (latency, tokens, hallucination scoring)
108
109
  */
109
110
  declare class Pipeline {
110
111
  private config;
@@ -129,33 +130,26 @@ declare class Pipeline {
129
130
  initialize(): Promise<void>;
130
131
  /**
131
132
  * Ingest documents with automatic chunking, embedding, and batch upsert.
132
- * Handles retries for transient failures.
133
133
  */
134
134
  ingest(documents: IngestDocument[], namespace?: string): Promise<Array<{
135
135
  docId: string | number;
136
136
  chunksIngested: number;
137
137
  }>>;
138
- /**
139
- * Step 1: Chunk the document content.
140
- */
138
+ /** Step 1: Chunk the document content. */
141
139
  private prepareChunks;
142
140
  /**
143
141
  * Step 2: Generate embeddings for chunks with retry logic.
144
142
  * Uses batchEmbed when available for efficiency; falls back to sequential embedding.
145
143
  */
146
144
  private processEmbeddings;
147
- /**
148
- * Step 3: Upsert chunks to vector database with retry logic.
149
- */
145
+ /** Step 3: Upsert chunks to vector database with retry logic. */
150
146
  private processUpserts;
151
- /**
152
- * Step 4: Optional graph-based entity extraction and ingestion.
153
- */
147
+ /** Step 4: Optional graph-based entity extraction and ingestion. */
154
148
  private processGraphIngestion;
155
149
  ask(question: string, history?: ChatMessage[], namespace?: string): Promise<ChatResponse>;
156
150
  /**
157
151
  * High-performance streaming RAG flow.
158
- * Yields text chunks first, then the retrieval metadata at the end.
152
+ * Yields text chunks first, then the retrieval metadata + observability trace at the end.
159
153
  */
160
154
  askStream(question: string, history?: ChatMessage[], namespace?: string): AsyncIterable<string | ChatResponse>;
161
155
  /**
@@ -168,13 +162,9 @@ declare class Pipeline {
168
162
  topK?: number;
169
163
  filter?: Record<string, unknown>;
170
164
  }): Promise<RetrievalResult>;
171
- /**
172
- * Rewrite the user query for better retrieval performance.
173
- */
165
+ /** Rewrite the user query for better retrieval performance. */
174
166
  private rewriteQuery;
175
- /**
176
- * Generate 3-5 short, relevant questions based on the vector database content.
177
- */
167
+ /** Generate 3-5 short, relevant questions based on the vector database content. */
178
168
  getSuggestions(query: string, namespace?: string): Promise<string[]>;
179
169
  }
180
170
 
@@ -363,6 +353,7 @@ declare class ConfigBuilder {
363
353
  private _embedding?;
364
354
  private _ui?;
365
355
  private _rag?;
356
+ private _graphDb?;
366
357
  /**
367
358
  * Set the project/application ID for namespacing
368
359
  */
@@ -379,6 +370,10 @@ declare class ConfigBuilder {
379
370
  * Configure the embedding provider
380
371
  */
381
372
  embedding(provider: EmbeddingProvider | 'auto', model?: string, apiKey?: string, options?: Record<string, unknown>): this;
373
+ /**
374
+ * Configure the graph database provider
375
+ */
376
+ graphDb(provider: string | 'auto', options?: Record<string, unknown>): this;
382
377
  /**
383
378
  * Set RAG-specific pipeline parameters
384
379
  */
@@ -400,6 +395,7 @@ declare class ConfigBuilder {
400
395
  private _autoDetectVectorDb;
401
396
  private _autoDetectLLM;
402
397
  private _autoDetectEmbedding;
398
+ private _autoDetectGraphDb;
403
399
  }
404
400
  /**
405
401
  * Preset configurations for common provider combinations
@@ -664,17 +660,17 @@ declare class MultiTablePostgresProvider extends BaseVectorProvider {
664
660
  private readonly connectionString;
665
661
  private tables;
666
662
  private searchFields;
663
+ private readonly uploadTable;
667
664
  constructor(config: VectorDBConfig);
668
665
  initialize(): Promise<void>;
669
666
  /**
670
- * Upsert is not supported for MultiTablePostgresProvider as it's designed for
671
- * searching across pre-existing tables with varying schemas.
667
+ * Upsert a document by dynamically provisioning a table and columns.
672
668
  */
673
- upsert(_doc: UpsertDocument, _namespace?: string): Promise<void>;
669
+ upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
674
670
  /**
675
- * Batch upsert is not supported for MultiTablePostgresProvider.
671
+ * Batch upsert documents by dynamically provisioning tables and columns based on CSV headers.
676
672
  */
677
- batchUpsert(_docs: UpsertDocument[], _namespace?: string): Promise<void>;
673
+ batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
678
674
  /**
679
675
  * Query all configured tables and merge results, sorted by cosine similarity score.
680
676
  */
package/dist/server.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { l as VectorDBConfig, L as LLMConfig, e as EmbeddingConfig, j as RagConfig, I as ILLMProvider, g as IngestDocument, C as ChatMessage, d as ChatResponse, n as RetrievalResult, k as UpsertDocument, V as VectorMatch, G as GraphDBConfig, o as GraphNode, p as Edge, q as GraphSearchResult, m as VectorDBProvider, h as LLMProvider, f as EmbeddingProvider, i as RAGConfig, U as UIConfig, c as ChatOptions, E as EmbedOptions } from './ILLMProvider-BfRgI1Xh.js';
1
+ import { n as VectorDBConfig, L as LLMConfig, e as EmbeddingConfig, k as RagConfig, I as ILLMProvider, g as IngestDocument, C as ChatMessage, d as ChatResponse, p as RetrievalResult, m as UpsertDocument, V as VectorMatch, G as GraphDBConfig, q as GraphNode, r as Edge, s as GraphSearchResult, o as VectorDBProvider, h as LLMProvider, f as EmbeddingProvider, j as RAGConfig, U as UIConfig, c as ChatOptions, E as EmbedOptions } from './ILLMProvider-BOJFz3Na.js';
2
2
  export { C as Chunk, a as ChunkOptions, D as DocumentChunker } from './DocumentChunker-Dh9TvmGG.js';
3
- import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-1Z4GuYBi.js';
4
- export { C as ConfigValidator, V as ValidationError, b as VectorPlugin, c as createChatHandler, d as createHealthHandler, e as createIngestHandler, f as createStreamHandler, g as createUploadHandler, s as sseErrorFrame, h as sseFrame, i as sseMetaFrame, j as sseTextFrame } from './index-1Z4GuYBi.js';
3
+ import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-BwpcaziY.js';
4
+ export { C as ConfigValidator, V as ValidationError, b as VectorPlugin, c as createChatHandler, d as createHealthHandler, e as createIngestHandler, f as createStreamHandler, g as createUploadHandler, s as sseErrorFrame, h as sseFrame, i as sseMetaFrame, j as sseTextFrame } from './index-BwpcaziY.js';
5
5
  import 'next/server';
6
6
 
7
7
  /**
@@ -105,6 +105,7 @@ declare class ProviderHealthCheck {
105
105
  * - Error recovery for transient failures
106
106
  * - Multi-tenancy support via namespacing
107
107
  * - LRU-bounded embedding cache (max 500 entries, prevents memory leaks)
108
+ * - Full observability tracing (latency, tokens, hallucination scoring)
108
109
  */
109
110
  declare class Pipeline {
110
111
  private config;
@@ -129,33 +130,26 @@ declare class Pipeline {
129
130
  initialize(): Promise<void>;
130
131
  /**
131
132
  * Ingest documents with automatic chunking, embedding, and batch upsert.
132
- * Handles retries for transient failures.
133
133
  */
134
134
  ingest(documents: IngestDocument[], namespace?: string): Promise<Array<{
135
135
  docId: string | number;
136
136
  chunksIngested: number;
137
137
  }>>;
138
- /**
139
- * Step 1: Chunk the document content.
140
- */
138
+ /** Step 1: Chunk the document content. */
141
139
  private prepareChunks;
142
140
  /**
143
141
  * Step 2: Generate embeddings for chunks with retry logic.
144
142
  * Uses batchEmbed when available for efficiency; falls back to sequential embedding.
145
143
  */
146
144
  private processEmbeddings;
147
- /**
148
- * Step 3: Upsert chunks to vector database with retry logic.
149
- */
145
+ /** Step 3: Upsert chunks to vector database with retry logic. */
150
146
  private processUpserts;
151
- /**
152
- * Step 4: Optional graph-based entity extraction and ingestion.
153
- */
147
+ /** Step 4: Optional graph-based entity extraction and ingestion. */
154
148
  private processGraphIngestion;
155
149
  ask(question: string, history?: ChatMessage[], namespace?: string): Promise<ChatResponse>;
156
150
  /**
157
151
  * High-performance streaming RAG flow.
158
- * Yields text chunks first, then the retrieval metadata at the end.
152
+ * Yields text chunks first, then the retrieval metadata + observability trace at the end.
159
153
  */
160
154
  askStream(question: string, history?: ChatMessage[], namespace?: string): AsyncIterable<string | ChatResponse>;
161
155
  /**
@@ -168,13 +162,9 @@ declare class Pipeline {
168
162
  topK?: number;
169
163
  filter?: Record<string, unknown>;
170
164
  }): Promise<RetrievalResult>;
171
- /**
172
- * Rewrite the user query for better retrieval performance.
173
- */
165
+ /** Rewrite the user query for better retrieval performance. */
174
166
  private rewriteQuery;
175
- /**
176
- * Generate 3-5 short, relevant questions based on the vector database content.
177
- */
167
+ /** Generate 3-5 short, relevant questions based on the vector database content. */
178
168
  getSuggestions(query: string, namespace?: string): Promise<string[]>;
179
169
  }
180
170
 
@@ -363,6 +353,7 @@ declare class ConfigBuilder {
363
353
  private _embedding?;
364
354
  private _ui?;
365
355
  private _rag?;
356
+ private _graphDb?;
366
357
  /**
367
358
  * Set the project/application ID for namespacing
368
359
  */
@@ -379,6 +370,10 @@ declare class ConfigBuilder {
379
370
  * Configure the embedding provider
380
371
  */
381
372
  embedding(provider: EmbeddingProvider | 'auto', model?: string, apiKey?: string, options?: Record<string, unknown>): this;
373
+ /**
374
+ * Configure the graph database provider
375
+ */
376
+ graphDb(provider: string | 'auto', options?: Record<string, unknown>): this;
382
377
  /**
383
378
  * Set RAG-specific pipeline parameters
384
379
  */
@@ -400,6 +395,7 @@ declare class ConfigBuilder {
400
395
  private _autoDetectVectorDb;
401
396
  private _autoDetectLLM;
402
397
  private _autoDetectEmbedding;
398
+ private _autoDetectGraphDb;
403
399
  }
404
400
  /**
405
401
  * Preset configurations for common provider combinations
@@ -664,17 +660,17 @@ declare class MultiTablePostgresProvider extends BaseVectorProvider {
664
660
  private readonly connectionString;
665
661
  private tables;
666
662
  private searchFields;
663
+ private readonly uploadTable;
667
664
  constructor(config: VectorDBConfig);
668
665
  initialize(): Promise<void>;
669
666
  /**
670
- * Upsert is not supported for MultiTablePostgresProvider as it's designed for
671
- * searching across pre-existing tables with varying schemas.
667
+ * Upsert a document by dynamically provisioning a table and columns.
672
668
  */
673
- upsert(_doc: UpsertDocument, _namespace?: string): Promise<void>;
669
+ upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
674
670
  /**
675
- * Batch upsert is not supported for MultiTablePostgresProvider.
671
+ * Batch upsert documents by dynamically provisioning tables and columns based on CSV headers.
676
672
  */
677
- batchUpsert(_docs: UpsertDocument[], _namespace?: string): Promise<void>;
673
+ batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
678
674
  /**
679
675
  * Query all configured tables and merge results, sorted by cosine similarity score.
680
676
  */