@retrivora-ai/rag-engine 1.0.4 → 1.0.6
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/{RagConfig-DRJO4hGU.d.mts → RagConfig-BjC6zSTV.d.mts} +62 -1
- package/dist/{RagConfig-DRJO4hGU.d.ts → RagConfig-BjC6zSTV.d.ts} +62 -1
- package/dist/{chunk-6MLZHQZT.mjs → chunk-ZCDJSGUW.mjs} +237 -104
- package/dist/handlers/index.d.mts +2 -2
- package/dist/handlers/index.d.ts +2 -2
- package/dist/handlers/index.js +239 -106
- package/dist/handlers/index.mjs +11 -3
- package/dist/index-C3bLmWcR.d.ts +206 -0
- package/dist/index-CU_fQq__.d.mts +206 -0
- package/dist/index.d.mts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.js +103 -89
- package/dist/index.mjs +91 -95
- package/dist/server.d.mts +45 -97
- package/dist/server.d.ts +45 -97
- package/dist/server.js +319 -221
- package/dist/server.mjs +78 -167
- package/package.json +12 -10
- package/src/components/ChatWindow.tsx +2 -2
- package/src/components/ConfigProvider.tsx +2 -2
- package/src/components/MessageBubble.tsx +2 -2
- package/src/components/SourceCard.tsx +1 -1
- package/src/components/ThemeToggle.tsx +1 -1
- package/src/config/ConfigBuilder.ts +86 -211
- package/src/config/RagConfig.ts +4 -0
- package/src/config/uiConstants.ts +23 -0
- package/src/core/ConfigResolver.ts +57 -29
- package/src/core/LangChainAgent.ts +73 -40
- package/src/core/Pipeline.ts +64 -8
- package/src/core/ProviderRegistry.ts +2 -2
- package/src/core/QueryProcessor.ts +45 -12
- package/src/handlers/index.ts +138 -49
- package/src/hooks/useRagChat.ts +71 -32
- package/src/server.ts +12 -2
- package/dist/DocumentChunker-C-sCZPhi.d.mts +0 -102
- package/dist/DocumentChunker-C-sCZPhi.d.ts +0 -102
- package/dist/index-B2mutkgp.d.ts +0 -116
- package/dist/index-Bjy0es5a.d.mts +0 -116
package/dist/server.d.mts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
export { b as
|
|
5
|
-
import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-Bjy0es5a.mjs';
|
|
6
|
-
export { C as ConfigValidator, V as ValidationError, c as createChatHandler, b as createHealthHandler, d as createIngestHandler, e as createUploadHandler } from './index-Bjy0es5a.mjs';
|
|
1
|
+
import { i as VectorDBConfig, L as LLMConfig, c as EmbeddingConfig, g as RagConfig, e as IngestDocument, C as ChatMessage, b as ChatResponse, k as RetrievalResult, h as UpsertDocument, V as VectorMatch, G as GraphDBConfig, l as GraphNode, m as Edge, n as GraphSearchResult, I as ILLMProvider, j as VectorDBProvider, f as LLMProvider, d as EmbeddingProvider, R as RAGConfig, U as UIConfig, a as ChatOptions, E as EmbedOptions } from './RagConfig-BjC6zSTV.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-CU_fQq__.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-CU_fQq__.mjs';
|
|
7
5
|
import 'next/server';
|
|
8
6
|
|
|
9
7
|
/**
|
|
@@ -97,55 +95,6 @@ declare class ProviderHealthCheck {
|
|
|
97
95
|
}>;
|
|
98
96
|
}
|
|
99
97
|
|
|
100
|
-
/**
|
|
101
|
-
* VectorPlugin — main orchestrator class.
|
|
102
|
-
* This is the primary interface for host applications.
|
|
103
|
-
*
|
|
104
|
-
* Features:
|
|
105
|
-
* - Configuration resolution from host + environment
|
|
106
|
-
* - Configuration validation with detailed error messages
|
|
107
|
-
* - Provider health checks before initialization
|
|
108
|
-
* - Multi-provider support (Vector DBs & LLMs)
|
|
109
|
-
* - Per-tenant data isolation via namespacing
|
|
110
|
-
*/
|
|
111
|
-
declare class VectorPlugin {
|
|
112
|
-
private config;
|
|
113
|
-
private pipeline;
|
|
114
|
-
private validationPromise;
|
|
115
|
-
constructor(hostConfig?: Partial<RagConfig>);
|
|
116
|
-
/**
|
|
117
|
-
* Get the current resolved configuration.
|
|
118
|
-
*/
|
|
119
|
-
getConfig(): RagConfig;
|
|
120
|
-
/**
|
|
121
|
-
* Perform pre-flight health checks on all configured providers.
|
|
122
|
-
* Useful to verify connectivity before running operations.
|
|
123
|
-
*
|
|
124
|
-
* @returns Health status for vector DB, LLM, and embedding providers
|
|
125
|
-
*/
|
|
126
|
-
checkHealth(): Promise<{
|
|
127
|
-
vectorDb: HealthCheckResult;
|
|
128
|
-
llm: HealthCheckResult;
|
|
129
|
-
embedding?: HealthCheckResult;
|
|
130
|
-
allHealthy: boolean;
|
|
131
|
-
}>;
|
|
132
|
-
/**
|
|
133
|
-
* Run a chat query.
|
|
134
|
-
*/
|
|
135
|
-
chat(message: string, history?: ChatMessage[], namespace?: string): Promise<ChatResponse>;
|
|
136
|
-
/**
|
|
137
|
-
* Run a streaming chat query.
|
|
138
|
-
*/
|
|
139
|
-
chatStream(message: string, history?: ChatMessage[], namespace?: string): AsyncGenerator<string | ChatResponse, void, any>;
|
|
140
|
-
/**
|
|
141
|
-
* Ingest documents into the vector database.
|
|
142
|
-
*/
|
|
143
|
-
ingest(documents: IngestDocument[], namespace?: string): Promise<Array<{
|
|
144
|
-
docId: string | number;
|
|
145
|
-
chunksIngested: number;
|
|
146
|
-
}>>;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
98
|
/**
|
|
150
99
|
* Pipeline — orchestrates the RAG flow: Embed → Search → Augment → Generate.
|
|
151
100
|
*
|
|
@@ -155,6 +104,7 @@ declare class VectorPlugin {
|
|
|
155
104
|
* - Smart embedding strategy (integrated / separate / external)
|
|
156
105
|
* - Error recovery for transient failures
|
|
157
106
|
* - Multi-tenancy support via namespacing
|
|
107
|
+
* - LRU-bounded embedding cache (max 500 entries, prevents memory leaks)
|
|
158
108
|
*/
|
|
159
109
|
declare class Pipeline {
|
|
160
110
|
private config;
|
|
@@ -167,6 +117,7 @@ declare class Pipeline {
|
|
|
167
117
|
private entityExtractor?;
|
|
168
118
|
private reranker;
|
|
169
119
|
private agent?;
|
|
120
|
+
/** LRU-bounded cache: avoids re-embedding identical queries within the same process. */
|
|
170
121
|
private embeddingCache;
|
|
171
122
|
private initialised;
|
|
172
123
|
constructor(config: RagConfig);
|
|
@@ -185,6 +136,7 @@ declare class Pipeline {
|
|
|
185
136
|
private prepareChunks;
|
|
186
137
|
/**
|
|
187
138
|
* Step 2: Generate embeddings for chunks with retry logic.
|
|
139
|
+
* Uses batchEmbed when available for efficiency; falls back to sequential embedding.
|
|
188
140
|
*/
|
|
189
141
|
private processEmbeddings;
|
|
190
142
|
/**
|
|
@@ -203,6 +155,7 @@ declare class Pipeline {
|
|
|
203
155
|
askStream(question: string, history?: ChatMessage[], namespace?: string): AsyncIterable<string | ChatResponse>;
|
|
204
156
|
/**
|
|
205
157
|
* Universal retrieval method combining all enabled providers.
|
|
158
|
+
* Uses an LRU-bounded embedding cache to avoid re-embedding the same query.
|
|
206
159
|
*/
|
|
207
160
|
retrieve(query: string, options: {
|
|
208
161
|
namespace?: string;
|
|
@@ -218,10 +171,20 @@ declare class Pipeline {
|
|
|
218
171
|
/**
|
|
219
172
|
* ConfigResolver — validates and normalizes host configuration.
|
|
220
173
|
* It merges host-provided config with environment defaults.
|
|
174
|
+
*
|
|
175
|
+
* The `getRagConfig()` result is memoized at module level so that
|
|
176
|
+
* environment variables are only parsed once per process, avoiding
|
|
177
|
+
* repeated work in serverless cold starts and per-request handler calls.
|
|
178
|
+
*/
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Reset the cached env config. Useful in tests where environment variables
|
|
182
|
+
* change between test cases.
|
|
221
183
|
*/
|
|
184
|
+
declare function resetConfigCache(): void;
|
|
222
185
|
declare class ConfigResolver {
|
|
223
186
|
/**
|
|
224
|
-
* Resolves the final configuration by merging host-provided config with defaults.
|
|
187
|
+
* Resolves the final configuration by merging host-provided config with environment defaults.
|
|
225
188
|
* @param hostConfig - Partial configuration passed from the host application.
|
|
226
189
|
*/
|
|
227
190
|
static resolve(hostConfig?: Partial<RagConfig>): RagConfig;
|
|
@@ -374,7 +337,7 @@ declare function getRagConfig(env?: Record<string, string | undefined>): RagConf
|
|
|
374
337
|
* - Fluent API for easy configuration
|
|
375
338
|
* - Type-safe provider selection
|
|
376
339
|
* - Automatic environment variable resolution
|
|
377
|
-
* - Built-in validation
|
|
340
|
+
* - Built-in validation at build() time
|
|
378
341
|
* - Support for presets
|
|
379
342
|
*
|
|
380
343
|
* @example
|
|
@@ -389,7 +352,12 @@ declare function getRagConfig(env?: Record<string, string | undefined>): RagConf
|
|
|
389
352
|
*/
|
|
390
353
|
|
|
391
354
|
declare class ConfigBuilder {
|
|
392
|
-
private
|
|
355
|
+
private _projectId?;
|
|
356
|
+
private _vectorDb?;
|
|
357
|
+
private _llm?;
|
|
358
|
+
private _embedding?;
|
|
359
|
+
private _ui?;
|
|
360
|
+
private _rag?;
|
|
393
361
|
/**
|
|
394
362
|
* Set the project/application ID for namespacing
|
|
395
363
|
*/
|
|
@@ -407,88 +375,68 @@ declare class ConfigBuilder {
|
|
|
407
375
|
*/
|
|
408
376
|
embedding(provider: EmbeddingProvider | 'auto', model?: string, apiKey?: string, options?: Record<string, unknown>): this;
|
|
409
377
|
/**
|
|
410
|
-
* Set RAG-specific parameters
|
|
378
|
+
* Set RAG-specific pipeline parameters
|
|
411
379
|
*/
|
|
412
|
-
rag(options:
|
|
413
|
-
chunkSize?: number;
|
|
414
|
-
chunkOverlap?: number;
|
|
415
|
-
topK?: number;
|
|
416
|
-
}): this;
|
|
380
|
+
rag(options: RAGConfig): this;
|
|
417
381
|
/**
|
|
418
|
-
* Set UI
|
|
382
|
+
* Set UI branding and appearance options.
|
|
383
|
+
* Accepts the full UIConfig interface.
|
|
419
384
|
*/
|
|
420
|
-
ui(options:
|
|
421
|
-
branding?: string;
|
|
422
|
-
primaryColor?: string;
|
|
423
|
-
darkMode?: boolean;
|
|
424
|
-
}): this;
|
|
385
|
+
ui(options: UIConfig): this;
|
|
425
386
|
/**
|
|
426
|
-
* Build and return the
|
|
387
|
+
* Build and return the final RagConfig.
|
|
388
|
+
* Throws if required fields (projectId, vectorDb, llm, embedding) are not set.
|
|
427
389
|
*/
|
|
428
390
|
build(): RagConfig;
|
|
429
391
|
/**
|
|
430
392
|
* Build and return as JSON for serialization
|
|
431
393
|
*/
|
|
432
394
|
toJSON(): string;
|
|
433
|
-
private
|
|
434
|
-
private
|
|
435
|
-
private
|
|
395
|
+
private _autoDetectVectorDb;
|
|
396
|
+
private _autoDetectLLM;
|
|
397
|
+
private _autoDetectEmbedding;
|
|
436
398
|
}
|
|
437
399
|
/**
|
|
438
400
|
* Preset configurations for common provider combinations
|
|
439
401
|
*/
|
|
440
402
|
declare const PRESETS: {
|
|
441
|
-
/**
|
|
442
|
-
* OpenAI + Pinecone: Production-ready cloud setup
|
|
443
|
-
*/
|
|
403
|
+
/** OpenAI + Pinecone: Production-ready cloud setup */
|
|
444
404
|
readonly 'openai-pinecone': {
|
|
445
405
|
readonly vectorDb: "pinecone";
|
|
446
406
|
readonly llm: "openai";
|
|
447
407
|
readonly embedding: "openai";
|
|
448
408
|
};
|
|
449
|
-
/**
|
|
450
|
-
* Claude + Qdrant: Open-source vector DB + proprietary LLM
|
|
451
|
-
*/
|
|
409
|
+
/** Claude + Qdrant: Open-source vector DB + proprietary LLM */
|
|
452
410
|
readonly 'claude-qdrant': {
|
|
453
411
|
readonly vectorDb: "qdrant";
|
|
454
412
|
readonly llm: "anthropic";
|
|
455
413
|
readonly embedding: "openai";
|
|
456
414
|
};
|
|
457
|
-
/**
|
|
458
|
-
* Local development: Ollama + local Qdrant
|
|
459
|
-
*/
|
|
415
|
+
/** Local development: Ollama + local Qdrant */
|
|
460
416
|
readonly 'local-dev': {
|
|
461
417
|
readonly vectorDb: "qdrant";
|
|
462
418
|
readonly llm: "ollama";
|
|
463
419
|
readonly embedding: "ollama";
|
|
464
420
|
};
|
|
465
|
-
/**
|
|
466
|
-
* Fully open-source: Ollama LLM + Qdrant vector DB + Ollama embeddings
|
|
467
|
-
*/
|
|
421
|
+
/** Fully open-source: Ollama LLM + Qdrant + Ollama embeddings */
|
|
468
422
|
readonly 'fully-open-source': {
|
|
469
423
|
readonly vectorDb: "qdrant";
|
|
470
424
|
readonly llm: "ollama";
|
|
471
425
|
readonly embedding: "ollama";
|
|
472
426
|
};
|
|
473
|
-
/**
|
|
474
|
-
* PostgreSQL stack: pgvector + OpenAI
|
|
475
|
-
*/
|
|
427
|
+
/** PostgreSQL stack: pgvector + OpenAI */
|
|
476
428
|
readonly 'postgres-openai': {
|
|
477
429
|
readonly vectorDb: "postgresql";
|
|
478
430
|
readonly llm: "openai";
|
|
479
431
|
readonly embedding: "openai";
|
|
480
432
|
};
|
|
481
|
-
/**
|
|
482
|
-
* Enterprise MongoDB: MongoDB Atlas with OpenAI
|
|
483
|
-
*/
|
|
433
|
+
/** Enterprise MongoDB: MongoDB Atlas with OpenAI */
|
|
484
434
|
readonly 'mongodb-openai': {
|
|
485
435
|
readonly vectorDb: "mongodb";
|
|
486
436
|
readonly llm: "openai";
|
|
487
437
|
readonly embedding: "openai";
|
|
488
438
|
};
|
|
489
|
-
/**
|
|
490
|
-
* Redis stack for caching + search
|
|
491
|
-
*/
|
|
439
|
+
/** Redis stack for caching + search */
|
|
492
440
|
readonly 'redis-openai': {
|
|
493
441
|
readonly vectorDb: "redis";
|
|
494
442
|
readonly llm: "openai";
|
|
@@ -497,7 +445,7 @@ declare const PRESETS: {
|
|
|
497
445
|
};
|
|
498
446
|
type PresetName = keyof typeof PRESETS;
|
|
499
447
|
/**
|
|
500
|
-
* Helper to create
|
|
448
|
+
* Helper to create a ConfigBuilder pre-seeded with a named preset.
|
|
501
449
|
*/
|
|
502
450
|
declare function createFromPreset(presetName: PresetName): ConfigBuilder;
|
|
503
451
|
|
|
@@ -996,4 +944,4 @@ declare class UniversalLLMAdapter implements ILLMProvider {
|
|
|
996
944
|
ping(): Promise<boolean>;
|
|
997
945
|
}
|
|
998
946
|
|
|
999
|
-
export { AnthropicProvider, BaseVectorProvider, type BatchOptions, BatchProcessor, type BatchResult, ChatMessage, ChatOptions, ChatResponse, ChromaDBProvider, ConfigBuilder, ConfigResolver, DocumentParser, EmbedOptions, EmbeddingConfig, EmbeddingProvider, EmbeddingStrategy, EmbeddingStrategyResolver, HealthCheckResult, ILLMProvider, IProviderHealthChecker, IProviderValidator, IngestDocument, LLMConfig, LLMFactory, LLMProvider, LLM_PROFILES, MilvusProvider, MongoDBProvider, MultiTablePostgresProvider, OllamaProvider, OpenAIProvider, PRESETS, PineconeProvider, Pipeline, PostgreSQLProvider, ProviderHealthCheck, ProviderRegistry, QdrantProvider, RagConfig, RedisProvider, UniversalLLMAdapter, UniversalVectorProvider, UpsertDocument, VECTOR_PROFILES, VectorDBConfig, VectorDBProvider, VectorMatch,
|
|
947
|
+
export { AnthropicProvider, BaseVectorProvider, type BatchOptions, BatchProcessor, type BatchResult, ChatMessage, ChatOptions, ChatResponse, ChromaDBProvider, ConfigBuilder, ConfigResolver, DocumentParser, EmbedOptions, EmbeddingConfig, EmbeddingProvider, EmbeddingStrategy, EmbeddingStrategyResolver, HealthCheckResult, ILLMProvider, IProviderHealthChecker, IProviderValidator, IngestDocument, LLMConfig, LLMFactory, LLMProvider, LLM_PROFILES, MilvusProvider, MongoDBProvider, MultiTablePostgresProvider, OllamaProvider, OpenAIProvider, PRESETS, PineconeProvider, Pipeline, PostgreSQLProvider, ProviderHealthCheck, ProviderRegistry, QdrantProvider, RAGConfig, RagConfig, RedisProvider, UIConfig, UniversalLLMAdapter, UniversalVectorProvider, UpsertDocument, VECTOR_PROFILES, VectorDBConfig, VectorDBProvider, VectorMatch, WeaviateProvider, createFromPreset, getRagConfig, resetConfigCache };
|
package/dist/server.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
export { b as
|
|
5
|
-
import { H as HealthCheckResult, I as IProviderValidator, a as IProviderHealthChecker } from './index-B2mutkgp.js';
|
|
6
|
-
export { C as ConfigValidator, V as ValidationError, c as createChatHandler, b as createHealthHandler, d as createIngestHandler, e as createUploadHandler } from './index-B2mutkgp.js';
|
|
1
|
+
import { i as VectorDBConfig, L as LLMConfig, c as EmbeddingConfig, g as RagConfig, e as IngestDocument, C as ChatMessage, b as ChatResponse, k as RetrievalResult, h as UpsertDocument, V as VectorMatch, G as GraphDBConfig, l as GraphNode, m as Edge, n as GraphSearchResult, I as ILLMProvider, j as VectorDBProvider, f as LLMProvider, d as EmbeddingProvider, R as RAGConfig, U as UIConfig, a as ChatOptions, E as EmbedOptions } from './RagConfig-BjC6zSTV.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-C3bLmWcR.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-C3bLmWcR.js';
|
|
7
5
|
import 'next/server';
|
|
8
6
|
|
|
9
7
|
/**
|
|
@@ -97,55 +95,6 @@ declare class ProviderHealthCheck {
|
|
|
97
95
|
}>;
|
|
98
96
|
}
|
|
99
97
|
|
|
100
|
-
/**
|
|
101
|
-
* VectorPlugin — main orchestrator class.
|
|
102
|
-
* This is the primary interface for host applications.
|
|
103
|
-
*
|
|
104
|
-
* Features:
|
|
105
|
-
* - Configuration resolution from host + environment
|
|
106
|
-
* - Configuration validation with detailed error messages
|
|
107
|
-
* - Provider health checks before initialization
|
|
108
|
-
* - Multi-provider support (Vector DBs & LLMs)
|
|
109
|
-
* - Per-tenant data isolation via namespacing
|
|
110
|
-
*/
|
|
111
|
-
declare class VectorPlugin {
|
|
112
|
-
private config;
|
|
113
|
-
private pipeline;
|
|
114
|
-
private validationPromise;
|
|
115
|
-
constructor(hostConfig?: Partial<RagConfig>);
|
|
116
|
-
/**
|
|
117
|
-
* Get the current resolved configuration.
|
|
118
|
-
*/
|
|
119
|
-
getConfig(): RagConfig;
|
|
120
|
-
/**
|
|
121
|
-
* Perform pre-flight health checks on all configured providers.
|
|
122
|
-
* Useful to verify connectivity before running operations.
|
|
123
|
-
*
|
|
124
|
-
* @returns Health status for vector DB, LLM, and embedding providers
|
|
125
|
-
*/
|
|
126
|
-
checkHealth(): Promise<{
|
|
127
|
-
vectorDb: HealthCheckResult;
|
|
128
|
-
llm: HealthCheckResult;
|
|
129
|
-
embedding?: HealthCheckResult;
|
|
130
|
-
allHealthy: boolean;
|
|
131
|
-
}>;
|
|
132
|
-
/**
|
|
133
|
-
* Run a chat query.
|
|
134
|
-
*/
|
|
135
|
-
chat(message: string, history?: ChatMessage[], namespace?: string): Promise<ChatResponse>;
|
|
136
|
-
/**
|
|
137
|
-
* Run a streaming chat query.
|
|
138
|
-
*/
|
|
139
|
-
chatStream(message: string, history?: ChatMessage[], namespace?: string): AsyncGenerator<string | ChatResponse, void, any>;
|
|
140
|
-
/**
|
|
141
|
-
* Ingest documents into the vector database.
|
|
142
|
-
*/
|
|
143
|
-
ingest(documents: IngestDocument[], namespace?: string): Promise<Array<{
|
|
144
|
-
docId: string | number;
|
|
145
|
-
chunksIngested: number;
|
|
146
|
-
}>>;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
98
|
/**
|
|
150
99
|
* Pipeline — orchestrates the RAG flow: Embed → Search → Augment → Generate.
|
|
151
100
|
*
|
|
@@ -155,6 +104,7 @@ declare class VectorPlugin {
|
|
|
155
104
|
* - Smart embedding strategy (integrated / separate / external)
|
|
156
105
|
* - Error recovery for transient failures
|
|
157
106
|
* - Multi-tenancy support via namespacing
|
|
107
|
+
* - LRU-bounded embedding cache (max 500 entries, prevents memory leaks)
|
|
158
108
|
*/
|
|
159
109
|
declare class Pipeline {
|
|
160
110
|
private config;
|
|
@@ -167,6 +117,7 @@ declare class Pipeline {
|
|
|
167
117
|
private entityExtractor?;
|
|
168
118
|
private reranker;
|
|
169
119
|
private agent?;
|
|
120
|
+
/** LRU-bounded cache: avoids re-embedding identical queries within the same process. */
|
|
170
121
|
private embeddingCache;
|
|
171
122
|
private initialised;
|
|
172
123
|
constructor(config: RagConfig);
|
|
@@ -185,6 +136,7 @@ declare class Pipeline {
|
|
|
185
136
|
private prepareChunks;
|
|
186
137
|
/**
|
|
187
138
|
* Step 2: Generate embeddings for chunks with retry logic.
|
|
139
|
+
* Uses batchEmbed when available for efficiency; falls back to sequential embedding.
|
|
188
140
|
*/
|
|
189
141
|
private processEmbeddings;
|
|
190
142
|
/**
|
|
@@ -203,6 +155,7 @@ declare class Pipeline {
|
|
|
203
155
|
askStream(question: string, history?: ChatMessage[], namespace?: string): AsyncIterable<string | ChatResponse>;
|
|
204
156
|
/**
|
|
205
157
|
* Universal retrieval method combining all enabled providers.
|
|
158
|
+
* Uses an LRU-bounded embedding cache to avoid re-embedding the same query.
|
|
206
159
|
*/
|
|
207
160
|
retrieve(query: string, options: {
|
|
208
161
|
namespace?: string;
|
|
@@ -218,10 +171,20 @@ declare class Pipeline {
|
|
|
218
171
|
/**
|
|
219
172
|
* ConfigResolver — validates and normalizes host configuration.
|
|
220
173
|
* It merges host-provided config with environment defaults.
|
|
174
|
+
*
|
|
175
|
+
* The `getRagConfig()` result is memoized at module level so that
|
|
176
|
+
* environment variables are only parsed once per process, avoiding
|
|
177
|
+
* repeated work in serverless cold starts and per-request handler calls.
|
|
178
|
+
*/
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Reset the cached env config. Useful in tests where environment variables
|
|
182
|
+
* change between test cases.
|
|
221
183
|
*/
|
|
184
|
+
declare function resetConfigCache(): void;
|
|
222
185
|
declare class ConfigResolver {
|
|
223
186
|
/**
|
|
224
|
-
* Resolves the final configuration by merging host-provided config with defaults.
|
|
187
|
+
* Resolves the final configuration by merging host-provided config with environment defaults.
|
|
225
188
|
* @param hostConfig - Partial configuration passed from the host application.
|
|
226
189
|
*/
|
|
227
190
|
static resolve(hostConfig?: Partial<RagConfig>): RagConfig;
|
|
@@ -374,7 +337,7 @@ declare function getRagConfig(env?: Record<string, string | undefined>): RagConf
|
|
|
374
337
|
* - Fluent API for easy configuration
|
|
375
338
|
* - Type-safe provider selection
|
|
376
339
|
* - Automatic environment variable resolution
|
|
377
|
-
* - Built-in validation
|
|
340
|
+
* - Built-in validation at build() time
|
|
378
341
|
* - Support for presets
|
|
379
342
|
*
|
|
380
343
|
* @example
|
|
@@ -389,7 +352,12 @@ declare function getRagConfig(env?: Record<string, string | undefined>): RagConf
|
|
|
389
352
|
*/
|
|
390
353
|
|
|
391
354
|
declare class ConfigBuilder {
|
|
392
|
-
private
|
|
355
|
+
private _projectId?;
|
|
356
|
+
private _vectorDb?;
|
|
357
|
+
private _llm?;
|
|
358
|
+
private _embedding?;
|
|
359
|
+
private _ui?;
|
|
360
|
+
private _rag?;
|
|
393
361
|
/**
|
|
394
362
|
* Set the project/application ID for namespacing
|
|
395
363
|
*/
|
|
@@ -407,88 +375,68 @@ declare class ConfigBuilder {
|
|
|
407
375
|
*/
|
|
408
376
|
embedding(provider: EmbeddingProvider | 'auto', model?: string, apiKey?: string, options?: Record<string, unknown>): this;
|
|
409
377
|
/**
|
|
410
|
-
* Set RAG-specific parameters
|
|
378
|
+
* Set RAG-specific pipeline parameters
|
|
411
379
|
*/
|
|
412
|
-
rag(options:
|
|
413
|
-
chunkSize?: number;
|
|
414
|
-
chunkOverlap?: number;
|
|
415
|
-
topK?: number;
|
|
416
|
-
}): this;
|
|
380
|
+
rag(options: RAGConfig): this;
|
|
417
381
|
/**
|
|
418
|
-
* Set UI
|
|
382
|
+
* Set UI branding and appearance options.
|
|
383
|
+
* Accepts the full UIConfig interface.
|
|
419
384
|
*/
|
|
420
|
-
ui(options:
|
|
421
|
-
branding?: string;
|
|
422
|
-
primaryColor?: string;
|
|
423
|
-
darkMode?: boolean;
|
|
424
|
-
}): this;
|
|
385
|
+
ui(options: UIConfig): this;
|
|
425
386
|
/**
|
|
426
|
-
* Build and return the
|
|
387
|
+
* Build and return the final RagConfig.
|
|
388
|
+
* Throws if required fields (projectId, vectorDb, llm, embedding) are not set.
|
|
427
389
|
*/
|
|
428
390
|
build(): RagConfig;
|
|
429
391
|
/**
|
|
430
392
|
* Build and return as JSON for serialization
|
|
431
393
|
*/
|
|
432
394
|
toJSON(): string;
|
|
433
|
-
private
|
|
434
|
-
private
|
|
435
|
-
private
|
|
395
|
+
private _autoDetectVectorDb;
|
|
396
|
+
private _autoDetectLLM;
|
|
397
|
+
private _autoDetectEmbedding;
|
|
436
398
|
}
|
|
437
399
|
/**
|
|
438
400
|
* Preset configurations for common provider combinations
|
|
439
401
|
*/
|
|
440
402
|
declare const PRESETS: {
|
|
441
|
-
/**
|
|
442
|
-
* OpenAI + Pinecone: Production-ready cloud setup
|
|
443
|
-
*/
|
|
403
|
+
/** OpenAI + Pinecone: Production-ready cloud setup */
|
|
444
404
|
readonly 'openai-pinecone': {
|
|
445
405
|
readonly vectorDb: "pinecone";
|
|
446
406
|
readonly llm: "openai";
|
|
447
407
|
readonly embedding: "openai";
|
|
448
408
|
};
|
|
449
|
-
/**
|
|
450
|
-
* Claude + Qdrant: Open-source vector DB + proprietary LLM
|
|
451
|
-
*/
|
|
409
|
+
/** Claude + Qdrant: Open-source vector DB + proprietary LLM */
|
|
452
410
|
readonly 'claude-qdrant': {
|
|
453
411
|
readonly vectorDb: "qdrant";
|
|
454
412
|
readonly llm: "anthropic";
|
|
455
413
|
readonly embedding: "openai";
|
|
456
414
|
};
|
|
457
|
-
/**
|
|
458
|
-
* Local development: Ollama + local Qdrant
|
|
459
|
-
*/
|
|
415
|
+
/** Local development: Ollama + local Qdrant */
|
|
460
416
|
readonly 'local-dev': {
|
|
461
417
|
readonly vectorDb: "qdrant";
|
|
462
418
|
readonly llm: "ollama";
|
|
463
419
|
readonly embedding: "ollama";
|
|
464
420
|
};
|
|
465
|
-
/**
|
|
466
|
-
* Fully open-source: Ollama LLM + Qdrant vector DB + Ollama embeddings
|
|
467
|
-
*/
|
|
421
|
+
/** Fully open-source: Ollama LLM + Qdrant + Ollama embeddings */
|
|
468
422
|
readonly 'fully-open-source': {
|
|
469
423
|
readonly vectorDb: "qdrant";
|
|
470
424
|
readonly llm: "ollama";
|
|
471
425
|
readonly embedding: "ollama";
|
|
472
426
|
};
|
|
473
|
-
/**
|
|
474
|
-
* PostgreSQL stack: pgvector + OpenAI
|
|
475
|
-
*/
|
|
427
|
+
/** PostgreSQL stack: pgvector + OpenAI */
|
|
476
428
|
readonly 'postgres-openai': {
|
|
477
429
|
readonly vectorDb: "postgresql";
|
|
478
430
|
readonly llm: "openai";
|
|
479
431
|
readonly embedding: "openai";
|
|
480
432
|
};
|
|
481
|
-
/**
|
|
482
|
-
* Enterprise MongoDB: MongoDB Atlas with OpenAI
|
|
483
|
-
*/
|
|
433
|
+
/** Enterprise MongoDB: MongoDB Atlas with OpenAI */
|
|
484
434
|
readonly 'mongodb-openai': {
|
|
485
435
|
readonly vectorDb: "mongodb";
|
|
486
436
|
readonly llm: "openai";
|
|
487
437
|
readonly embedding: "openai";
|
|
488
438
|
};
|
|
489
|
-
/**
|
|
490
|
-
* Redis stack for caching + search
|
|
491
|
-
*/
|
|
439
|
+
/** Redis stack for caching + search */
|
|
492
440
|
readonly 'redis-openai': {
|
|
493
441
|
readonly vectorDb: "redis";
|
|
494
442
|
readonly llm: "openai";
|
|
@@ -497,7 +445,7 @@ declare const PRESETS: {
|
|
|
497
445
|
};
|
|
498
446
|
type PresetName = keyof typeof PRESETS;
|
|
499
447
|
/**
|
|
500
|
-
* Helper to create
|
|
448
|
+
* Helper to create a ConfigBuilder pre-seeded with a named preset.
|
|
501
449
|
*/
|
|
502
450
|
declare function createFromPreset(presetName: PresetName): ConfigBuilder;
|
|
503
451
|
|
|
@@ -996,4 +944,4 @@ declare class UniversalLLMAdapter implements ILLMProvider {
|
|
|
996
944
|
ping(): Promise<boolean>;
|
|
997
945
|
}
|
|
998
946
|
|
|
999
|
-
export { AnthropicProvider, BaseVectorProvider, type BatchOptions, BatchProcessor, type BatchResult, ChatMessage, ChatOptions, ChatResponse, ChromaDBProvider, ConfigBuilder, ConfigResolver, DocumentParser, EmbedOptions, EmbeddingConfig, EmbeddingProvider, EmbeddingStrategy, EmbeddingStrategyResolver, HealthCheckResult, ILLMProvider, IProviderHealthChecker, IProviderValidator, IngestDocument, LLMConfig, LLMFactory, LLMProvider, LLM_PROFILES, MilvusProvider, MongoDBProvider, MultiTablePostgresProvider, OllamaProvider, OpenAIProvider, PRESETS, PineconeProvider, Pipeline, PostgreSQLProvider, ProviderHealthCheck, ProviderRegistry, QdrantProvider, RagConfig, RedisProvider, UniversalLLMAdapter, UniversalVectorProvider, UpsertDocument, VECTOR_PROFILES, VectorDBConfig, VectorDBProvider, VectorMatch,
|
|
947
|
+
export { AnthropicProvider, BaseVectorProvider, type BatchOptions, BatchProcessor, type BatchResult, ChatMessage, ChatOptions, ChatResponse, ChromaDBProvider, ConfigBuilder, ConfigResolver, DocumentParser, EmbedOptions, EmbeddingConfig, EmbeddingProvider, EmbeddingStrategy, EmbeddingStrategyResolver, HealthCheckResult, ILLMProvider, IProviderHealthChecker, IProviderValidator, IngestDocument, LLMConfig, LLMFactory, LLMProvider, LLM_PROFILES, MilvusProvider, MongoDBProvider, MultiTablePostgresProvider, OllamaProvider, OpenAIProvider, PRESETS, PineconeProvider, Pipeline, PostgreSQLProvider, ProviderHealthCheck, ProviderRegistry, QdrantProvider, RAGConfig, RagConfig, RedisProvider, UIConfig, UniversalLLMAdapter, UniversalVectorProvider, UpsertDocument, VECTOR_PROFILES, VectorDBConfig, VectorDBProvider, VectorMatch, WeaviateProvider, createFromPreset, getRagConfig, resetConfigCache };
|