@retrivora-ai/rag-engine 1.8.0 → 1.8.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.
- package/dist/DocumentChunker-Dh9TvmGG.d.mts +45 -0
- package/dist/DocumentChunker-Dh9TvmGG.d.ts +45 -0
- package/dist/{index-DPsQodME.d.mts → ILLMProvider-BOJFz3Na.d.mts} +104 -1
- package/dist/{index-DPsQodME.d.ts → ILLMProvider-BOJFz3Na.d.ts} +104 -1
- package/dist/MultiTablePostgresProvider-ZLGSKTJR.mjs +8 -0
- package/dist/chunk-ICKRMZQK.mjs +76 -0
- package/dist/{chunk-PV3MFHWU.mjs → chunk-LZVVLSDN.mjs} +977 -516
- package/dist/chunk-OZFBG4BA.mjs +291 -0
- package/dist/handlers/index.d.mts +2 -2
- package/dist/handlers/index.d.ts +2 -2
- package/dist/handlers/index.js +1269 -656
- package/dist/handlers/index.mjs +4 -1
- package/dist/{index-Bb2yEopi.d.mts → index-BwpcaziY.d.ts} +10 -2
- package/dist/{index-CkbTzj9J.d.ts → index-D3V9Et2M.d.mts} +10 -2
- package/dist/index.d.mts +24 -4
- package/dist/index.d.ts +24 -4
- package/dist/index.js +1354 -826
- package/dist/index.mjs +1284 -795
- package/dist/server.d.mts +47 -27
- package/dist/server.d.ts +47 -27
- package/dist/server.js +1417 -829
- package/dist/server.mjs +164 -176
- package/package.json +6 -2
- package/src/app/api/upload/route.ts +4 -0
- package/src/app/constants.tsx +2 -2
- package/src/app/page.tsx +12 -322
- package/src/components/AmbientBackground.tsx +29 -0
- package/src/components/ArchitectureCard.tsx +17 -0
- package/src/components/ArchitectureCardsSection.tsx +15 -0
- package/src/components/ChatWindow.tsx +32 -0
- package/src/components/CodeViewer.tsx +51 -0
- package/src/components/ConfigProvider.tsx +1 -0
- package/src/components/DocViewer.tsx +37 -0
- package/src/components/DocumentUpload.tsx +44 -1
- package/src/components/Documentation.tsx +58 -0
- package/src/components/DynamicChart.tsx +27 -2
- package/src/components/Hero.tsx +59 -0
- package/src/components/HourglassLoader.tsx +87 -0
- package/src/components/Lifecycle.tsx +37 -0
- package/src/components/MarkdownComponents.tsx +140 -0
- package/src/components/MessageBubble.tsx +124 -904
- package/src/components/Navbar.tsx +55 -0
- package/src/components/ObservabilityPanel.tsx +374 -0
- package/src/components/ProductCard.tsx +5 -3
- package/src/components/UIDispatcher.tsx +344 -0
- package/src/components/VisualizationRenderer.tsx +372 -250
- package/src/config/RagConfig.ts +5 -0
- package/src/config/serverConfig.ts +3 -1
- package/src/core/Pipeline.ts +240 -271
- package/src/core/ProviderRegistry.ts +2 -2
- package/src/core/VectorPlugin.ts +9 -0
- package/src/handlers/index.ts +91 -15
- package/src/hooks/useRagChat.ts +21 -11
- package/src/index.ts +9 -1
- package/src/llm/LLMFactory.ts +54 -2
- package/src/llm/providers/AnthropicProvider.ts +12 -8
- package/src/llm/providers/GeminiProvider.ts +188 -143
- package/src/llm/providers/OllamaProvider.ts +7 -3
- package/src/llm/providers/OpenAIProvider.ts +12 -8
- package/src/providers/vectordb/MultiTablePostgresProvider.ts +150 -64
- package/src/types/chat.ts +8 -0
- package/src/types/index.ts +132 -0
- package/src/types/props.ts +9 -1
- package/src/utils/ProductExtractor.ts +347 -0
- package/src/utils/SchemaMapper.ts +129 -0
- package/src/utils/UITransformer.ts +470 -209
- package/src/utils/synonyms.ts +78 -0
- package/dist/DocumentChunker-C1GEEosY.d.ts +0 -93
- package/dist/DocumentChunker-CFEiRopR.d.mts +0 -93
- package/dist/PostgreSQLProvider-BMOETDZA.mjs +0 -8
- package/dist/chunk-FLOSGE6A.mjs +0 -202
package/dist/server.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
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-Bb2yEopi.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
|
+
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-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';
|
|
6
5
|
import 'next/server';
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -106,6 +105,7 @@ declare class ProviderHealthCheck {
|
|
|
106
105
|
* - Error recovery for transient failures
|
|
107
106
|
* - Multi-tenancy support via namespacing
|
|
108
107
|
* - LRU-bounded embedding cache (max 500 entries, prevents memory leaks)
|
|
108
|
+
* - Full observability tracing (latency, tokens, hallucination scoring)
|
|
109
109
|
*/
|
|
110
110
|
declare class Pipeline {
|
|
111
111
|
private config;
|
|
@@ -122,54 +122,49 @@ declare class Pipeline {
|
|
|
122
122
|
private embeddingCache;
|
|
123
123
|
private initialised;
|
|
124
124
|
constructor(config: RagConfig);
|
|
125
|
+
/**
|
|
126
|
+
* Expose the underlying LLM provider (set after initialize()).
|
|
127
|
+
* Used by the stream handler to pass to UITransformer.analyzeAndDecide().
|
|
128
|
+
*/
|
|
129
|
+
getLLMProvider(): ILLMProvider | undefined;
|
|
125
130
|
initialize(): Promise<void>;
|
|
126
131
|
/**
|
|
127
132
|
* Ingest documents with automatic chunking, embedding, and batch upsert.
|
|
128
|
-
* Handles retries for transient failures.
|
|
129
133
|
*/
|
|
130
134
|
ingest(documents: IngestDocument[], namespace?: string): Promise<Array<{
|
|
131
135
|
docId: string | number;
|
|
132
136
|
chunksIngested: number;
|
|
133
137
|
}>>;
|
|
134
|
-
/**
|
|
135
|
-
* Step 1: Chunk the document content.
|
|
136
|
-
*/
|
|
138
|
+
/** Step 1: Chunk the document content. */
|
|
137
139
|
private prepareChunks;
|
|
138
140
|
/**
|
|
139
141
|
* Step 2: Generate embeddings for chunks with retry logic.
|
|
140
142
|
* Uses batchEmbed when available for efficiency; falls back to sequential embedding.
|
|
141
143
|
*/
|
|
142
144
|
private processEmbeddings;
|
|
143
|
-
/**
|
|
144
|
-
* Step 3: Upsert chunks to vector database with retry logic.
|
|
145
|
-
*/
|
|
145
|
+
/** Step 3: Upsert chunks to vector database with retry logic. */
|
|
146
146
|
private processUpserts;
|
|
147
|
-
/**
|
|
148
|
-
* Step 4: Optional graph-based entity extraction and ingestion.
|
|
149
|
-
*/
|
|
147
|
+
/** Step 4: Optional graph-based entity extraction and ingestion. */
|
|
150
148
|
private processGraphIngestion;
|
|
151
149
|
ask(question: string, history?: ChatMessage[], namespace?: string): Promise<ChatResponse>;
|
|
152
150
|
/**
|
|
153
151
|
* High-performance streaming RAG flow.
|
|
154
|
-
* 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.
|
|
155
153
|
*/
|
|
156
154
|
askStream(question: string, history?: ChatMessage[], namespace?: string): AsyncIterable<string | ChatResponse>;
|
|
157
155
|
/**
|
|
158
156
|
* Universal retrieval method combining all enabled providers.
|
|
159
157
|
* Uses an LRU-bounded embedding cache to avoid re-embedding the same query.
|
|
160
158
|
*/
|
|
159
|
+
private generateUiTransformation;
|
|
161
160
|
retrieve(query: string, options: {
|
|
162
161
|
namespace?: string;
|
|
163
162
|
topK?: number;
|
|
164
163
|
filter?: Record<string, unknown>;
|
|
165
164
|
}): Promise<RetrievalResult>;
|
|
166
|
-
/**
|
|
167
|
-
* Rewrite the user query for better retrieval performance.
|
|
168
|
-
*/
|
|
165
|
+
/** Rewrite the user query for better retrieval performance. */
|
|
169
166
|
private rewriteQuery;
|
|
170
|
-
/**
|
|
171
|
-
* Generate 3-5 short, relevant questions based on the vector database content.
|
|
172
|
-
*/
|
|
167
|
+
/** Generate 3-5 short, relevant questions based on the vector database content. */
|
|
173
168
|
getSuggestions(query: string, namespace?: string): Promise<string[]>;
|
|
174
169
|
}
|
|
175
170
|
|
|
@@ -659,17 +654,17 @@ declare class MultiTablePostgresProvider extends BaseVectorProvider {
|
|
|
659
654
|
private readonly connectionString;
|
|
660
655
|
private tables;
|
|
661
656
|
private searchFields;
|
|
657
|
+
private readonly uploadTable;
|
|
662
658
|
constructor(config: VectorDBConfig);
|
|
663
659
|
initialize(): Promise<void>;
|
|
664
660
|
/**
|
|
665
|
-
* Upsert
|
|
666
|
-
* searching across pre-existing tables with varying schemas.
|
|
661
|
+
* Upsert a document by dynamically provisioning a table and columns.
|
|
667
662
|
*/
|
|
668
|
-
upsert(
|
|
663
|
+
upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
|
|
669
664
|
/**
|
|
670
|
-
* Batch upsert
|
|
665
|
+
* Batch upsert documents by dynamically provisioning tables and columns based on CSV headers.
|
|
671
666
|
*/
|
|
672
|
-
batchUpsert(
|
|
667
|
+
batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
|
|
673
668
|
/**
|
|
674
669
|
* Query all configured tables and merge results, sorted by cosine similarity score.
|
|
675
670
|
*/
|
|
@@ -871,6 +866,31 @@ declare class UniversalVectorProvider extends BaseVectorProvider {
|
|
|
871
866
|
* LLMFactory — instantiates the correct ILLMProvider based on llmConfig.provider.
|
|
872
867
|
*/
|
|
873
868
|
declare class LLMFactory {
|
|
869
|
+
/**
|
|
870
|
+
* Register a custom LLM provider factory at runtime.
|
|
871
|
+
*
|
|
872
|
+
* Use this to add support for any LLM backend (Azure OpenAI, Cohere, Mistral,
|
|
873
|
+
* Bedrock, etc.) without modifying this library's source code.
|
|
874
|
+
*
|
|
875
|
+
* @example
|
|
876
|
+
* // In your Next.js app initialization:
|
|
877
|
+
* import { LLMFactory } from '@retrivora-ai/rag-engine/server';
|
|
878
|
+
* import { MyCustomProvider } from './providers/MyCustomProvider';
|
|
879
|
+
*
|
|
880
|
+
* LLMFactory.register('my-provider', (config) => new MyCustomProvider(config));
|
|
881
|
+
*
|
|
882
|
+
* // Then set in your .env.local:
|
|
883
|
+
* // LLM_PROVIDER=my-provider
|
|
884
|
+
*/
|
|
885
|
+
static register(name: string, factory: (config: LLMConfig) => ILLMProvider): void;
|
|
886
|
+
/**
|
|
887
|
+
* Unregister a previously registered custom provider.
|
|
888
|
+
*/
|
|
889
|
+
static unregister(name: string): void;
|
|
890
|
+
/**
|
|
891
|
+
* List all registered provider names (built-in + custom).
|
|
892
|
+
*/
|
|
893
|
+
static listProviders(): string[];
|
|
874
894
|
static create(llmConfig: LLMConfig, embeddingConfig?: EmbeddingConfig): ILLMProvider;
|
|
875
895
|
static getValidator(provider: LLMProvider): IProviderValidator | null;
|
|
876
896
|
static getHealthChecker(provider: LLMProvider): IProviderHealthChecker | null;
|
package/dist/server.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
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-CkbTzj9J.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
|
+
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-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';
|
|
6
5
|
import 'next/server';
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -106,6 +105,7 @@ declare class ProviderHealthCheck {
|
|
|
106
105
|
* - Error recovery for transient failures
|
|
107
106
|
* - Multi-tenancy support via namespacing
|
|
108
107
|
* - LRU-bounded embedding cache (max 500 entries, prevents memory leaks)
|
|
108
|
+
* - Full observability tracing (latency, tokens, hallucination scoring)
|
|
109
109
|
*/
|
|
110
110
|
declare class Pipeline {
|
|
111
111
|
private config;
|
|
@@ -122,54 +122,49 @@ declare class Pipeline {
|
|
|
122
122
|
private embeddingCache;
|
|
123
123
|
private initialised;
|
|
124
124
|
constructor(config: RagConfig);
|
|
125
|
+
/**
|
|
126
|
+
* Expose the underlying LLM provider (set after initialize()).
|
|
127
|
+
* Used by the stream handler to pass to UITransformer.analyzeAndDecide().
|
|
128
|
+
*/
|
|
129
|
+
getLLMProvider(): ILLMProvider | undefined;
|
|
125
130
|
initialize(): Promise<void>;
|
|
126
131
|
/**
|
|
127
132
|
* Ingest documents with automatic chunking, embedding, and batch upsert.
|
|
128
|
-
* Handles retries for transient failures.
|
|
129
133
|
*/
|
|
130
134
|
ingest(documents: IngestDocument[], namespace?: string): Promise<Array<{
|
|
131
135
|
docId: string | number;
|
|
132
136
|
chunksIngested: number;
|
|
133
137
|
}>>;
|
|
134
|
-
/**
|
|
135
|
-
* Step 1: Chunk the document content.
|
|
136
|
-
*/
|
|
138
|
+
/** Step 1: Chunk the document content. */
|
|
137
139
|
private prepareChunks;
|
|
138
140
|
/**
|
|
139
141
|
* Step 2: Generate embeddings for chunks with retry logic.
|
|
140
142
|
* Uses batchEmbed when available for efficiency; falls back to sequential embedding.
|
|
141
143
|
*/
|
|
142
144
|
private processEmbeddings;
|
|
143
|
-
/**
|
|
144
|
-
* Step 3: Upsert chunks to vector database with retry logic.
|
|
145
|
-
*/
|
|
145
|
+
/** Step 3: Upsert chunks to vector database with retry logic. */
|
|
146
146
|
private processUpserts;
|
|
147
|
-
/**
|
|
148
|
-
* Step 4: Optional graph-based entity extraction and ingestion.
|
|
149
|
-
*/
|
|
147
|
+
/** Step 4: Optional graph-based entity extraction and ingestion. */
|
|
150
148
|
private processGraphIngestion;
|
|
151
149
|
ask(question: string, history?: ChatMessage[], namespace?: string): Promise<ChatResponse>;
|
|
152
150
|
/**
|
|
153
151
|
* High-performance streaming RAG flow.
|
|
154
|
-
* 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.
|
|
155
153
|
*/
|
|
156
154
|
askStream(question: string, history?: ChatMessage[], namespace?: string): AsyncIterable<string | ChatResponse>;
|
|
157
155
|
/**
|
|
158
156
|
* Universal retrieval method combining all enabled providers.
|
|
159
157
|
* Uses an LRU-bounded embedding cache to avoid re-embedding the same query.
|
|
160
158
|
*/
|
|
159
|
+
private generateUiTransformation;
|
|
161
160
|
retrieve(query: string, options: {
|
|
162
161
|
namespace?: string;
|
|
163
162
|
topK?: number;
|
|
164
163
|
filter?: Record<string, unknown>;
|
|
165
164
|
}): Promise<RetrievalResult>;
|
|
166
|
-
/**
|
|
167
|
-
* Rewrite the user query for better retrieval performance.
|
|
168
|
-
*/
|
|
165
|
+
/** Rewrite the user query for better retrieval performance. */
|
|
169
166
|
private rewriteQuery;
|
|
170
|
-
/**
|
|
171
|
-
* Generate 3-5 short, relevant questions based on the vector database content.
|
|
172
|
-
*/
|
|
167
|
+
/** Generate 3-5 short, relevant questions based on the vector database content. */
|
|
173
168
|
getSuggestions(query: string, namespace?: string): Promise<string[]>;
|
|
174
169
|
}
|
|
175
170
|
|
|
@@ -659,17 +654,17 @@ declare class MultiTablePostgresProvider extends BaseVectorProvider {
|
|
|
659
654
|
private readonly connectionString;
|
|
660
655
|
private tables;
|
|
661
656
|
private searchFields;
|
|
657
|
+
private readonly uploadTable;
|
|
662
658
|
constructor(config: VectorDBConfig);
|
|
663
659
|
initialize(): Promise<void>;
|
|
664
660
|
/**
|
|
665
|
-
* Upsert
|
|
666
|
-
* searching across pre-existing tables with varying schemas.
|
|
661
|
+
* Upsert a document by dynamically provisioning a table and columns.
|
|
667
662
|
*/
|
|
668
|
-
upsert(
|
|
663
|
+
upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
|
|
669
664
|
/**
|
|
670
|
-
* Batch upsert
|
|
665
|
+
* Batch upsert documents by dynamically provisioning tables and columns based on CSV headers.
|
|
671
666
|
*/
|
|
672
|
-
batchUpsert(
|
|
667
|
+
batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
|
|
673
668
|
/**
|
|
674
669
|
* Query all configured tables and merge results, sorted by cosine similarity score.
|
|
675
670
|
*/
|
|
@@ -871,6 +866,31 @@ declare class UniversalVectorProvider extends BaseVectorProvider {
|
|
|
871
866
|
* LLMFactory — instantiates the correct ILLMProvider based on llmConfig.provider.
|
|
872
867
|
*/
|
|
873
868
|
declare class LLMFactory {
|
|
869
|
+
/**
|
|
870
|
+
* Register a custom LLM provider factory at runtime.
|
|
871
|
+
*
|
|
872
|
+
* Use this to add support for any LLM backend (Azure OpenAI, Cohere, Mistral,
|
|
873
|
+
* Bedrock, etc.) without modifying this library's source code.
|
|
874
|
+
*
|
|
875
|
+
* @example
|
|
876
|
+
* // In your Next.js app initialization:
|
|
877
|
+
* import { LLMFactory } from '@retrivora-ai/rag-engine/server';
|
|
878
|
+
* import { MyCustomProvider } from './providers/MyCustomProvider';
|
|
879
|
+
*
|
|
880
|
+
* LLMFactory.register('my-provider', (config) => new MyCustomProvider(config));
|
|
881
|
+
*
|
|
882
|
+
* // Then set in your .env.local:
|
|
883
|
+
* // LLM_PROVIDER=my-provider
|
|
884
|
+
*/
|
|
885
|
+
static register(name: string, factory: (config: LLMConfig) => ILLMProvider): void;
|
|
886
|
+
/**
|
|
887
|
+
* Unregister a previously registered custom provider.
|
|
888
|
+
*/
|
|
889
|
+
static unregister(name: string): void;
|
|
890
|
+
/**
|
|
891
|
+
* List all registered provider names (built-in + custom).
|
|
892
|
+
*/
|
|
893
|
+
static listProviders(): string[];
|
|
874
894
|
static create(llmConfig: LLMConfig, embeddingConfig?: EmbeddingConfig): ILLMProvider;
|
|
875
895
|
static getValidator(provider: LLMProvider): IProviderValidator | null;
|
|
876
896
|
static getHealthChecker(provider: LLMProvider): IProviderHealthChecker | null;
|