@retrivora-ai/rag-engine 0.1.7 → 0.1.9
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/{ChromaDBProvider-QNI7UCX4.mjs → ChromaDBProvider-T7TK3ONZ.mjs} +2 -2
- package/dist/{MilvusProvider-OO6QGZDZ.mjs → MilvusProvider-Y5FV5EAE.mjs} +2 -2
- package/dist/{MongoDBProvider-WWVJG3WT.mjs → MongoDBProvider-QHMGD2LZ.mjs} +2 -2
- package/dist/{PineconeProvider-ZRAFNFEC.mjs → PineconeProvider-A47MRRYJ.mjs} +2 -2
- package/dist/{PostgreSQLProvider-ZNXA67IM.mjs → PostgreSQLProvider-PJ5ER5Z4.mjs} +1 -1
- package/dist/{QdrantProvider-VAED5VA7.mjs → QdrantProvider-OLPJK7CY.mjs} +2 -2
- package/dist/{RagConfig-hBGXJmSx.d.mts → RagConfig-D_rSf8ep.d.mts} +1 -1
- package/dist/{RagConfig-hBGXJmSx.d.ts → RagConfig-D_rSf8ep.d.ts} +1 -1
- package/dist/{RedisProvider-ASONNYBI.mjs → RedisProvider-ANEJ3BHR.mjs} +2 -2
- package/dist/UniversalVectorProvider-QJIV2AJJ.mjs +9 -0
- package/dist/{WeaviateProvider-PSDCUGC7.mjs → WeaviateProvider-WIK2QN23.mjs} +2 -2
- package/dist/{chunk-7YQWGERZ.mjs → chunk-2VR5ZMXV.mjs} +740 -193
- package/dist/{chunk-QEYVWVT5.mjs → chunk-5HXNKSCR.mjs} +1 -1
- package/dist/{chunk-ZM6TYIDH.mjs → chunk-BMHJTWSU.mjs} +4 -2
- package/dist/{chunk-UKDXCXW7.mjs → chunk-EDLTMSNY.mjs} +1 -1
- package/dist/{chunk-I4E63NIC.mjs → chunk-FWCSY2DS.mjs} +14 -1
- package/dist/{chunk-VPNRDXIA.mjs → chunk-HOMXEE3M.mjs} +17 -11
- package/dist/{chunk-V75V7BT2.mjs → chunk-RUKZC3ON.mjs} +3 -3
- package/dist/{chunk-7NXI6ZWX.mjs → chunk-VEJNRS4B.mjs} +9 -6
- package/dist/{chunk-HUGLYKD6.mjs → chunk-VKE5ZW7Y.mjs} +28 -10
- package/dist/chunk-VV2ML6TM.mjs +156 -0
- package/dist/{chunk-CWQQHAF6.mjs → chunk-W2PQR3UK.mjs} +4 -6
- package/dist/handlers/index.d.mts +2 -2
- package/dist/handlers/index.d.ts +2 -2
- package/dist/handlers/index.js +877 -625
- package/dist/handlers/index.mjs +3 -4
- package/dist/index-BJ8CUArE.d.mts +114 -0
- package/dist/index-DtNprGGj.d.ts +114 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +67 -58
- package/dist/index.mjs +74 -47
- package/dist/server.d.mts +601 -17
- package/dist/server.d.ts +601 -17
- package/dist/server.js +1426 -708
- package/dist/server.mjs +429 -18
- package/package.json +11 -2
- package/src/app/constants.tsx +220 -0
- package/src/app/page.tsx +193 -363
- package/src/app/types.ts +30 -0
- package/src/components/ChatWindow.tsx +3 -11
- package/src/config/ConfigBuilder.ts +373 -0
- package/src/config/EmbeddingStrategy.ts +147 -0
- package/src/config/serverConfig.ts +51 -18
- package/src/core/ConfigValidator.ts +67 -50
- package/src/core/Pipeline.ts +28 -26
- package/src/core/PluginManager.ts +277 -0
- package/src/core/ProviderHealthCheck.ts +75 -139
- package/src/core/ProviderRegistry.ts +38 -15
- package/src/providers/vectordb/ChromaDBProvider.ts +37 -12
- package/src/providers/vectordb/MilvusProvider.ts +25 -10
- package/src/providers/vectordb/MultiTablePostgresProvider.ts +164 -0
- package/src/providers/vectordb/PineconeProvider.ts +17 -2
- package/src/providers/vectordb/QdrantProvider.ts +3 -6
- package/src/providers/vectordb/RedisProvider.ts +34 -11
- package/src/providers/vectordb/UniversalVectorProvider.ts +220 -0
- package/src/providers/vectordb/WeaviateProvider.ts +17 -10
- package/src/server.ts +29 -10
- package/dist/LLMFactory-JFOY2V4X.mjs +0 -8
- package/dist/chunk-JI6VD5TJ.mjs +0 -387
- package/dist/index-Bx182KKn.d.ts +0 -64
- package/dist/index-Ck2pt7-8.d.mts +0 -64
- package/src/test-refactor.ts +0 -59
package/dist/server.d.mts
CHANGED
|
@@ -1,11 +1,162 @@
|
|
|
1
|
-
import { a as RagConfig, C as ChatResponse, I as IngestDocument, c as VectorDBConfig, b as UpsertDocument, V as VectorMatch, L as LLMConfig, E as EmbeddingConfig } from './RagConfig-
|
|
2
|
-
export { R as RAGConfig, U as UIConfig } from './RagConfig-
|
|
1
|
+
import { a as RagConfig, C as ChatResponse, I as IngestDocument, c as VectorDBConfig, b as UpsertDocument, V as VectorMatch, L as LLMConfig, E as EmbeddingConfig, d as VectorDBProvider, e as LLMProvider, f as EmbeddingProvider } from './RagConfig-D_rSf8ep.mjs';
|
|
2
|
+
export { R as RAGConfig, U as UIConfig } from './RagConfig-D_rSf8ep.mjs';
|
|
3
3
|
import { C as ChatMessage, I as ILLMProvider, a as ChatOptions, E as EmbedOptions } from './DocumentChunker-BEyzadsv.mjs';
|
|
4
4
|
export { b as Chunk, c as ChunkOptions, D as DocumentChunker } from './DocumentChunker-BEyzadsv.mjs';
|
|
5
|
-
import { H as HealthCheckResult } from './index-
|
|
6
|
-
export { c as createChatHandler, a as createHealthHandler, b as createIngestHandler, d as createUploadHandler } from './index-
|
|
5
|
+
import { H as HealthCheckResult } from './index-BJ8CUArE.mjs';
|
|
6
|
+
export { P as ProviderHealthCheck, c as createChatHandler, a as createHealthHandler, b as createIngestHandler, d as createUploadHandler } from './index-BJ8CUArE.mjs';
|
|
7
7
|
import 'next/server';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* ConfigValidator.ts — Comprehensive configuration validation.
|
|
11
|
+
*
|
|
12
|
+
* Validates RagConfig against provider requirements and best practices.
|
|
13
|
+
* Returns detailed errors for misconfiguration.
|
|
14
|
+
*
|
|
15
|
+
* Key invariant: option keys validated here MUST match the keys each
|
|
16
|
+
* Provider constructor reads. See each provider's constructor for the
|
|
17
|
+
* canonical option names.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
interface ValidationError {
|
|
21
|
+
field: string;
|
|
22
|
+
message: string;
|
|
23
|
+
suggestion?: string;
|
|
24
|
+
severity: 'error' | 'warning';
|
|
25
|
+
}
|
|
26
|
+
declare class ConfigValidator {
|
|
27
|
+
/**
|
|
28
|
+
* Validates the entire RagConfig object.
|
|
29
|
+
* Returns an array of validation errors. Empty array = valid config.
|
|
30
|
+
*/
|
|
31
|
+
static validate(config: RagConfig): ValidationError[];
|
|
32
|
+
private static validateVectorDbConfig;
|
|
33
|
+
/**
|
|
34
|
+
* Pinecone — only needs apiKey (environment was removed in SDK v7+).
|
|
35
|
+
* Options key: { apiKey: string }
|
|
36
|
+
*/
|
|
37
|
+
private static validatePineconeConfig;
|
|
38
|
+
/**
|
|
39
|
+
* PostgreSQL / pgvector — needs a connection string.
|
|
40
|
+
* Options key: { connectionString: string }
|
|
41
|
+
*/
|
|
42
|
+
private static validatePostgresConfig;
|
|
43
|
+
/**
|
|
44
|
+
* MongoDB — needs uri, database, and collection.
|
|
45
|
+
* Options keys: { uri: string, database: string, collection: string }
|
|
46
|
+
*/
|
|
47
|
+
private static validateMongoDBConfig;
|
|
48
|
+
/**
|
|
49
|
+
* Milvus — accepts baseUrl OR uri (preferred) OR host+port.
|
|
50
|
+
* MilvusProvider reads opts.baseUrl ?? opts.uri.
|
|
51
|
+
* Options keys: { baseUrl?: string, uri?: string, host?: string, port?: number }
|
|
52
|
+
*/
|
|
53
|
+
private static validateMilvusConfig;
|
|
54
|
+
/**
|
|
55
|
+
* Qdrant — needs baseUrl (or url alias).
|
|
56
|
+
* Options keys: { baseUrl: string, apiKey?: string }
|
|
57
|
+
*/
|
|
58
|
+
private static validateQdrantConfig;
|
|
59
|
+
/**
|
|
60
|
+
* ChromaDB — accepts baseUrl OR host.
|
|
61
|
+
* ChromaDBProvider reads opts.baseUrl.
|
|
62
|
+
* Options keys: { baseUrl?: string, host?: string, port?: number }
|
|
63
|
+
*/
|
|
64
|
+
private static validateChromaDBConfig;
|
|
65
|
+
/**
|
|
66
|
+
* Redis — accepts baseUrl OR url OR host+port.
|
|
67
|
+
* RedisProvider reads opts.baseUrl.
|
|
68
|
+
* Options keys: { baseUrl?: string, url?: string, host?: string, port?: number, apiKey?: string }
|
|
69
|
+
*/
|
|
70
|
+
private static validateRedisConfig;
|
|
71
|
+
/**
|
|
72
|
+
* Weaviate — accepts baseUrl OR url.
|
|
73
|
+
* WeaviateProvider reads opts.baseUrl.
|
|
74
|
+
* Options keys: { baseUrl?: string, url?: string, apiKey?: string }
|
|
75
|
+
*/
|
|
76
|
+
private static validateWeaviateConfig;
|
|
77
|
+
/**
|
|
78
|
+
* Universal REST / custom REST adapter.
|
|
79
|
+
* Options key: { baseUrl: string }
|
|
80
|
+
*/
|
|
81
|
+
private static validateRestConfig;
|
|
82
|
+
private static validateLLMConfig;
|
|
83
|
+
private static validateEmbeddingConfig;
|
|
84
|
+
private static validateUIConfig;
|
|
85
|
+
private static validateRAGConfig;
|
|
86
|
+
private static isValidCSSColor;
|
|
87
|
+
/**
|
|
88
|
+
* Throws if there are error-level validation issues.
|
|
89
|
+
* Logs warnings to console.
|
|
90
|
+
*/
|
|
91
|
+
static validateAndThrow(config: RagConfig): void;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* BatchProcessor.ts — Handles batch operations with retry logic.
|
|
96
|
+
*
|
|
97
|
+
* Provides exponential backoff, partial failure tracking, and
|
|
98
|
+
* configurable batch sizing for efficient bulk operations.
|
|
99
|
+
*/
|
|
100
|
+
interface BatchOptions {
|
|
101
|
+
/** Maximum number of items per batch */
|
|
102
|
+
batchSize?: number;
|
|
103
|
+
/** Maximum number of retries for transient failures */
|
|
104
|
+
maxRetries?: number;
|
|
105
|
+
/** Initial delay before retry in milliseconds */
|
|
106
|
+
initialDelayMs?: number;
|
|
107
|
+
/** Maximum delay between retries in milliseconds */
|
|
108
|
+
maxDelayMs?: number;
|
|
109
|
+
/** Multiplier for exponential backoff */
|
|
110
|
+
backoffMultiplier?: number;
|
|
111
|
+
/** Whether to throw on any partial failure */
|
|
112
|
+
throwOnPartialFailure?: boolean;
|
|
113
|
+
}
|
|
114
|
+
interface BatchResult<T> {
|
|
115
|
+
results: T[];
|
|
116
|
+
errors: Array<{
|
|
117
|
+
index: number;
|
|
118
|
+
error: Error;
|
|
119
|
+
itemCount?: number;
|
|
120
|
+
}>;
|
|
121
|
+
totalProcessed: number;
|
|
122
|
+
totalFailed: number;
|
|
123
|
+
}
|
|
124
|
+
declare class BatchProcessor {
|
|
125
|
+
/**
|
|
126
|
+
* Processes an array of items in configurable batches with retry logic.
|
|
127
|
+
*
|
|
128
|
+
* @param items - Items to process
|
|
129
|
+
* @param processor - Async function that processes a batch of items
|
|
130
|
+
* @param options - Configuration for batch size, retries, etc.
|
|
131
|
+
* @returns Object with results, errors, and statistics
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* const docs = [...];
|
|
135
|
+
* const result = await BatchProcessor.processBatch(
|
|
136
|
+
* docs,
|
|
137
|
+
* (batch) => vectorDB.batchUpsert(batch),
|
|
138
|
+
* { batchSize: 100, maxRetries: 3 }
|
|
139
|
+
* );
|
|
140
|
+
*/
|
|
141
|
+
static processBatch<T, R>(items: T[], processor: (batch: T[]) => Promise<R>, options?: BatchOptions): Promise<BatchResult<R>>;
|
|
142
|
+
/**
|
|
143
|
+
* Processes items sequentially (one at a time) with retry logic.
|
|
144
|
+
* Useful for operations that don't support batching or when granular
|
|
145
|
+
* error tracking is needed.
|
|
146
|
+
*/
|
|
147
|
+
static processSequential<T, R>(items: T[], processor: (item: T) => Promise<R>, options?: BatchOptions): Promise<BatchResult<R>>;
|
|
148
|
+
/**
|
|
149
|
+
* Maps over items with retry logic, returning results in order.
|
|
150
|
+
* Like Array.map() but with async processing and automatic retries.
|
|
151
|
+
*/
|
|
152
|
+
static mapWithRetry<T, R>(items: T[], mapper: (item: T) => Promise<R>, options?: BatchOptions): Promise<R[]>;
|
|
153
|
+
/**
|
|
154
|
+
* Parallel processor with concurrency limit.
|
|
155
|
+
* Processes up to `concurrency` items at the same time.
|
|
156
|
+
*/
|
|
157
|
+
static processConcurrent<T, R>(items: T[], processor: (item: T) => Promise<R>, concurrency?: number, options?: BatchOptions): Promise<BatchResult<R>>;
|
|
158
|
+
}
|
|
159
|
+
|
|
9
160
|
/**
|
|
10
161
|
* VectorPlugin — main orchestrator class.
|
|
11
162
|
* This is the primary interface for host applications.
|
|
@@ -76,9 +227,9 @@ declare class VectorPlugin {
|
|
|
76
227
|
* Features:
|
|
77
228
|
* - Lazy initialization of providers
|
|
78
229
|
* - Batch processing with retry logic
|
|
79
|
-
* -
|
|
230
|
+
* - Smart embedding strategy (integrated / separate / external)
|
|
80
231
|
* - Error recovery for transient failures
|
|
81
|
-
* -
|
|
232
|
+
* - Multi-tenancy support via namespacing
|
|
82
233
|
*/
|
|
83
234
|
declare class Pipeline {
|
|
84
235
|
private vectorDB;
|
|
@@ -90,7 +241,7 @@ declare class Pipeline {
|
|
|
90
241
|
constructor(config: RagConfig);
|
|
91
242
|
initialize(): Promise<void>;
|
|
92
243
|
/**
|
|
93
|
-
* Ingest documents with automatic chunking, embedding, and batch
|
|
244
|
+
* Ingest documents with automatic chunking, embedding, and batch upsert.
|
|
94
245
|
* Handles retries for transient failures.
|
|
95
246
|
*/
|
|
96
247
|
ingest(documents: IngestDocument[], namespace?: string): Promise<Array<{
|
|
@@ -160,15 +311,24 @@ declare abstract class BaseVectorProvider {
|
|
|
160
311
|
|
|
161
312
|
/**
|
|
162
313
|
* ProviderRegistry — dynamic provider loader for Vector DBs and LLMs.
|
|
314
|
+
*
|
|
315
|
+
* Supports:
|
|
316
|
+
* - Built-in providers loaded on-demand via dynamic imports (tree-shaking friendly)
|
|
317
|
+
* - Custom provider registration via registerVectorProvider()
|
|
163
318
|
*/
|
|
164
319
|
declare class ProviderRegistry {
|
|
165
320
|
private static vectorProviders;
|
|
166
321
|
/**
|
|
167
|
-
* Register a custom vector provider.
|
|
322
|
+
* Register a custom vector provider class by name.
|
|
323
|
+
* The name must match the provider value used in VectorDBConfig.provider.
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* ProviderRegistry.registerVectorProvider('my-db', MyCustomProvider);
|
|
168
327
|
*/
|
|
169
328
|
static registerVectorProvider(name: string, providerClass: new (config: VectorDBConfig) => BaseVectorProvider): void;
|
|
170
329
|
/**
|
|
171
330
|
* Creates a vector database provider based on the configuration.
|
|
331
|
+
* Built-in providers are dynamically imported to avoid bundling all SDKs.
|
|
172
332
|
*/
|
|
173
333
|
static createVectorProvider(config: VectorDBConfig): Promise<BaseVectorProvider>;
|
|
174
334
|
/**
|
|
@@ -182,10 +342,323 @@ declare class ProviderRegistry {
|
|
|
182
342
|
*
|
|
183
343
|
* This keeps secrets server-side and never exposes them to the browser.
|
|
184
344
|
* Consumer projects set these env vars in their .env.local file.
|
|
345
|
+
*
|
|
346
|
+
* Supported VECTOR_DB_PROVIDER values and their required env vars:
|
|
347
|
+
* pinecone → PINECONE_API_KEY, PINECONE_INDEX
|
|
348
|
+
* pgvector /
|
|
349
|
+
* postgresql → PGVECTOR_CONNECTION_STRING, VECTOR_DB_INDEX
|
|
350
|
+
* mongodb → MONGODB_URI, MONGODB_DB, MONGODB_COLLECTION
|
|
351
|
+
* qdrant → QDRANT_URL, QDRANT_API_KEY
|
|
352
|
+
* milvus → MILVUS_URL (e.g. http://localhost:19530)
|
|
353
|
+
* chromadb → CHROMADB_URL (e.g. http://localhost:8000)
|
|
354
|
+
* weaviate → WEAVIATE_URL, WEAVIATE_API_KEY
|
|
355
|
+
* redis → REDIS_URL, REDIS_API_KEY
|
|
356
|
+
* rest /
|
|
357
|
+
* universal_rest→ VECTOR_BASE_URL, VECTOR_DB_REST_API_KEY
|
|
185
358
|
*/
|
|
186
359
|
|
|
187
360
|
declare function getRagConfig(env?: Record<string, string | undefined>): RagConfig;
|
|
188
361
|
|
|
362
|
+
/**
|
|
363
|
+
* ConfigBuilder — Fluent, type-safe configuration builder for RagConfig
|
|
364
|
+
*
|
|
365
|
+
* Simplifies host application setup with a builder pattern while maintaining
|
|
366
|
+
* type safety and validation.
|
|
367
|
+
*
|
|
368
|
+
* Features:
|
|
369
|
+
* - Fluent API for easy configuration
|
|
370
|
+
* - Type-safe provider selection
|
|
371
|
+
* - Automatic environment variable resolution
|
|
372
|
+
* - Built-in validation
|
|
373
|
+
* - Support for presets
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
* const config = new ConfigBuilder()
|
|
377
|
+
* .vectorDb('pinecone', { apiKey: process.env.PINECONE_API_KEY })
|
|
378
|
+
* .llm('openai', 'gpt-4o', process.env.OPENAI_API_KEY)
|
|
379
|
+
* .embedding('openai', 'text-embedding-3-small')
|
|
380
|
+
* .projectId('my-app')
|
|
381
|
+
* .build();
|
|
382
|
+
*
|
|
383
|
+
* const plugin = new VectorPlugin(config);
|
|
384
|
+
*/
|
|
385
|
+
|
|
386
|
+
declare class ConfigBuilder {
|
|
387
|
+
private config;
|
|
388
|
+
/**
|
|
389
|
+
* Set the project/application ID for namespacing
|
|
390
|
+
*/
|
|
391
|
+
projectId(id: string): this;
|
|
392
|
+
/**
|
|
393
|
+
* Configure the vector database provider
|
|
394
|
+
*/
|
|
395
|
+
vectorDb(provider: VectorDBProvider | 'universal-rest' | 'auto', options?: Record<string, unknown>): this;
|
|
396
|
+
/**
|
|
397
|
+
* Configure the LLM provider for chat
|
|
398
|
+
*/
|
|
399
|
+
llm(provider: LLMProvider | 'auto', model?: string, apiKey?: string, options?: Record<string, unknown>): this;
|
|
400
|
+
/**
|
|
401
|
+
* Configure the embedding provider
|
|
402
|
+
*/
|
|
403
|
+
embedding(provider: EmbeddingProvider | 'auto', model?: string, apiKey?: string, options?: Record<string, unknown>): this;
|
|
404
|
+
/**
|
|
405
|
+
* Set RAG-specific parameters
|
|
406
|
+
*/
|
|
407
|
+
rag(options: {
|
|
408
|
+
chunkSize?: number;
|
|
409
|
+
chunkOverlap?: number;
|
|
410
|
+
topK?: number;
|
|
411
|
+
}): this;
|
|
412
|
+
/**
|
|
413
|
+
* Set UI/UX parameters
|
|
414
|
+
*/
|
|
415
|
+
ui(options: {
|
|
416
|
+
branding?: string;
|
|
417
|
+
primaryColor?: string;
|
|
418
|
+
darkMode?: boolean;
|
|
419
|
+
}): this;
|
|
420
|
+
/**
|
|
421
|
+
* Build and return the configuration
|
|
422
|
+
*/
|
|
423
|
+
build(): RagConfig;
|
|
424
|
+
/**
|
|
425
|
+
* Build and return as JSON for serialization
|
|
426
|
+
*/
|
|
427
|
+
toJSON(): string;
|
|
428
|
+
private autoDetectVectorDb;
|
|
429
|
+
private autoDetectLLM;
|
|
430
|
+
private autoDetectEmbedding;
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Preset configurations for common provider combinations
|
|
434
|
+
*/
|
|
435
|
+
declare const PRESETS: {
|
|
436
|
+
/**
|
|
437
|
+
* OpenAI + Pinecone: Production-ready cloud setup
|
|
438
|
+
*/
|
|
439
|
+
readonly 'openai-pinecone': {
|
|
440
|
+
readonly vectorDb: "pinecone";
|
|
441
|
+
readonly llm: "openai";
|
|
442
|
+
readonly embedding: "openai";
|
|
443
|
+
};
|
|
444
|
+
/**
|
|
445
|
+
* Claude + Qdrant: Open-source vector DB + proprietary LLM
|
|
446
|
+
*/
|
|
447
|
+
readonly 'claude-qdrant': {
|
|
448
|
+
readonly vectorDb: "qdrant";
|
|
449
|
+
readonly llm: "anthropic";
|
|
450
|
+
readonly embedding: "openai";
|
|
451
|
+
};
|
|
452
|
+
/**
|
|
453
|
+
* Local development: Ollama + local Qdrant
|
|
454
|
+
*/
|
|
455
|
+
readonly 'local-dev': {
|
|
456
|
+
readonly vectorDb: "qdrant";
|
|
457
|
+
readonly llm: "ollama";
|
|
458
|
+
readonly embedding: "ollama";
|
|
459
|
+
};
|
|
460
|
+
/**
|
|
461
|
+
* Fully open-source: Ollama LLM + Qdrant vector DB + Ollama embeddings
|
|
462
|
+
*/
|
|
463
|
+
readonly 'fully-open-source': {
|
|
464
|
+
readonly vectorDb: "qdrant";
|
|
465
|
+
readonly llm: "ollama";
|
|
466
|
+
readonly embedding: "ollama";
|
|
467
|
+
};
|
|
468
|
+
/**
|
|
469
|
+
* PostgreSQL stack: pgvector + OpenAI
|
|
470
|
+
*/
|
|
471
|
+
readonly 'postgres-openai': {
|
|
472
|
+
readonly vectorDb: "postgresql";
|
|
473
|
+
readonly llm: "openai";
|
|
474
|
+
readonly embedding: "openai";
|
|
475
|
+
};
|
|
476
|
+
/**
|
|
477
|
+
* Enterprise MongoDB: MongoDB Atlas with OpenAI
|
|
478
|
+
*/
|
|
479
|
+
readonly 'mongodb-openai': {
|
|
480
|
+
readonly vectorDb: "mongodb";
|
|
481
|
+
readonly llm: "openai";
|
|
482
|
+
readonly embedding: "openai";
|
|
483
|
+
};
|
|
484
|
+
/**
|
|
485
|
+
* Redis stack for caching + search
|
|
486
|
+
*/
|
|
487
|
+
readonly 'redis-openai': {
|
|
488
|
+
readonly vectorDb: "redis";
|
|
489
|
+
readonly llm: "openai";
|
|
490
|
+
readonly embedding: "openai";
|
|
491
|
+
};
|
|
492
|
+
};
|
|
493
|
+
type PresetName = keyof typeof PRESETS;
|
|
494
|
+
/**
|
|
495
|
+
* Helper to create config from preset
|
|
496
|
+
*/
|
|
497
|
+
declare function createFromPreset(presetName: PresetName): ConfigBuilder;
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* EmbeddingStrategy — Unified strategy for handling different embedding scenarios
|
|
501
|
+
*
|
|
502
|
+
* Automatically determines whether to:
|
|
503
|
+
* 1. Use the LLM provider's built-in embedding (integrated)
|
|
504
|
+
* 2. Use a separate embedding provider (fallback)
|
|
505
|
+
* 3. Use an external embedding service
|
|
506
|
+
*
|
|
507
|
+
* This removes special-case handling from Pipeline and consolidates embedding logic.
|
|
508
|
+
*/
|
|
509
|
+
|
|
510
|
+
declare enum EmbeddingStrategy {
|
|
511
|
+
/**
|
|
512
|
+
* LLM provider handles both chat and embeddings
|
|
513
|
+
* Example: OpenAI for both GPT and embeddings
|
|
514
|
+
*/
|
|
515
|
+
INTEGRATED = "integrated",
|
|
516
|
+
/**
|
|
517
|
+
* Use separate embedding provider different from LLM
|
|
518
|
+
* Example: Anthropic (chat) + OpenAI (embeddings)
|
|
519
|
+
*/
|
|
520
|
+
SEPARATE = "separate",
|
|
521
|
+
/**
|
|
522
|
+
* Use standalone embedding service
|
|
523
|
+
* Example: Dedicated embedding API
|
|
524
|
+
*/
|
|
525
|
+
EXTERNAL = "external"
|
|
526
|
+
}
|
|
527
|
+
interface EmbeddingStrategyResult {
|
|
528
|
+
strategy: EmbeddingStrategy;
|
|
529
|
+
embeddingProvider: ILLMProvider;
|
|
530
|
+
llmProvider: ILLMProvider;
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Determines the optimal embedding strategy and initializes providers
|
|
534
|
+
*/
|
|
535
|
+
declare class EmbeddingStrategyResolver {
|
|
536
|
+
/**
|
|
537
|
+
* Determine strategy based on LLM and embedding configs
|
|
538
|
+
*/
|
|
539
|
+
static determineStrategy(llmConfig: LLMConfig, embeddingConfig?: EmbeddingConfig): EmbeddingStrategy;
|
|
540
|
+
/**
|
|
541
|
+
* Resolve and initialize providers according to the strategy
|
|
542
|
+
*/
|
|
543
|
+
static resolve(llmConfig: LLMConfig, embeddingConfig?: EmbeddingConfig): Promise<EmbeddingStrategyResult>;
|
|
544
|
+
/**
|
|
545
|
+
* Check if an LLM provider natively supports embeddings
|
|
546
|
+
*/
|
|
547
|
+
private static supportsEmbedding;
|
|
548
|
+
/**
|
|
549
|
+
* Get a human-readable description of the strategy
|
|
550
|
+
*/
|
|
551
|
+
static getDescription(strategy: EmbeddingStrategy): string;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* Pre-configured templates for popular AI and Vector services.
|
|
556
|
+
* Use these as defaults in the Universal Adapters.
|
|
557
|
+
*/
|
|
558
|
+
declare const LLM_PROFILES: {
|
|
559
|
+
'openai-compatible': {
|
|
560
|
+
chatPath: string;
|
|
561
|
+
embedPath: string;
|
|
562
|
+
responseExtractPath: string;
|
|
563
|
+
embedExtractPath: string;
|
|
564
|
+
chatPayloadTemplate: string;
|
|
565
|
+
};
|
|
566
|
+
litellm: {
|
|
567
|
+
chatPayloadTemplate: string;
|
|
568
|
+
chatPath: string;
|
|
569
|
+
embedPath: string;
|
|
570
|
+
responseExtractPath: string;
|
|
571
|
+
embedExtractPath: string;
|
|
572
|
+
};
|
|
573
|
+
'anthropic-claude': {
|
|
574
|
+
chatPath: string;
|
|
575
|
+
responseExtractPath: string;
|
|
576
|
+
headers: {
|
|
577
|
+
'anthropic-version': string;
|
|
578
|
+
};
|
|
579
|
+
chatPayloadTemplate: string;
|
|
580
|
+
};
|
|
581
|
+
'google-gemini': {
|
|
582
|
+
chatPath: string;
|
|
583
|
+
responseExtractPath: string;
|
|
584
|
+
chatPayloadTemplate: string;
|
|
585
|
+
};
|
|
586
|
+
'github-copilot': {
|
|
587
|
+
chatPayloadTemplate: string;
|
|
588
|
+
chatPath: string;
|
|
589
|
+
embedPath: string;
|
|
590
|
+
responseExtractPath: string;
|
|
591
|
+
embedExtractPath: string;
|
|
592
|
+
};
|
|
593
|
+
'ollama-standard': {
|
|
594
|
+
chatPath: string;
|
|
595
|
+
embedPath: string;
|
|
596
|
+
responseExtractPath: string;
|
|
597
|
+
embedExtractPath: string;
|
|
598
|
+
chatPayloadTemplate: string;
|
|
599
|
+
embedPayloadTemplate: string;
|
|
600
|
+
};
|
|
601
|
+
};
|
|
602
|
+
declare const VECTOR_PROFILES: {
|
|
603
|
+
'pinecone-rest': {
|
|
604
|
+
queryPath: string;
|
|
605
|
+
upsertPath: string;
|
|
606
|
+
responseExtractPath: string;
|
|
607
|
+
idPath: string;
|
|
608
|
+
scorePath: string;
|
|
609
|
+
contentPath: string;
|
|
610
|
+
metadataPath: string;
|
|
611
|
+
queryPayloadTemplate: string;
|
|
612
|
+
};
|
|
613
|
+
'mongodb-atlas': {
|
|
614
|
+
queryPath: string;
|
|
615
|
+
responseExtractPath: string;
|
|
616
|
+
idPath: string;
|
|
617
|
+
scorePath: string;
|
|
618
|
+
contentPath: string;
|
|
619
|
+
metadataPath: string;
|
|
620
|
+
queryPayloadTemplate: string;
|
|
621
|
+
};
|
|
622
|
+
chromadb: {
|
|
623
|
+
queryPath: string;
|
|
624
|
+
upsertPath: string;
|
|
625
|
+
responseExtractPath: string;
|
|
626
|
+
idPath: string;
|
|
627
|
+
scorePath: string;
|
|
628
|
+
contentPath: string;
|
|
629
|
+
metadataPath: string;
|
|
630
|
+
};
|
|
631
|
+
qdrant: {
|
|
632
|
+
queryPath: string;
|
|
633
|
+
upsertPath: string;
|
|
634
|
+
responseExtractPath: string;
|
|
635
|
+
idPath: string;
|
|
636
|
+
scorePath: string;
|
|
637
|
+
contentPath: string;
|
|
638
|
+
metadataPath: string;
|
|
639
|
+
};
|
|
640
|
+
};
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* DocumentParser — handles text extraction from various file formats.
|
|
644
|
+
* Supported: .txt, .md, .json, .csv, .pdf (requires pdf-parse), .docx (requires mammoth)
|
|
645
|
+
*/
|
|
646
|
+
declare class DocumentParser {
|
|
647
|
+
/**
|
|
648
|
+
* Extract text from a File or Buffer based on its type.
|
|
649
|
+
*/
|
|
650
|
+
static parse(file: File | Buffer, fileName: string, mimeType: string): Promise<string>;
|
|
651
|
+
private static readAsText;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* PineconeProvider — Pinecone vector database implementation.
|
|
656
|
+
*
|
|
657
|
+
* Compatible with @pinecone-database/pinecone v7.x SDK.
|
|
658
|
+
*
|
|
659
|
+
* Required options: { apiKey: string }
|
|
660
|
+
* The `environment` option is no longer needed (removed in SDK v5+).
|
|
661
|
+
*/
|
|
189
662
|
declare class PineconeProvider extends BaseVectorProvider {
|
|
190
663
|
private client;
|
|
191
664
|
private readonly apiKey;
|
|
@@ -220,6 +693,41 @@ declare class PostgreSQLProvider extends BaseVectorProvider {
|
|
|
220
693
|
disconnect(): Promise<void>;
|
|
221
694
|
}
|
|
222
695
|
|
|
696
|
+
/**
|
|
697
|
+
* MultiTablePostgresProvider — PostgreSQL implementation that searches across
|
|
698
|
+
* multiple existing tables with pre-existing embeddings.
|
|
699
|
+
*
|
|
700
|
+
* Extends BaseVectorProvider so it can be registered with ProviderRegistry.
|
|
701
|
+
* Upsert operations are not supported — data is assumed to be managed externally
|
|
702
|
+
* or via custom ingestion scripts that write directly to each table.
|
|
703
|
+
*/
|
|
704
|
+
declare class MultiTablePostgresProvider extends BaseVectorProvider {
|
|
705
|
+
private pool;
|
|
706
|
+
private readonly dimensions;
|
|
707
|
+
private readonly connectionString;
|
|
708
|
+
private readonly tables;
|
|
709
|
+
constructor(config: VectorDBConfig);
|
|
710
|
+
initialize(): Promise<void>;
|
|
711
|
+
/**
|
|
712
|
+
* Upsert is not supported for MultiTablePostgresProvider as it's designed for
|
|
713
|
+
* searching across pre-existing tables with varying schemas.
|
|
714
|
+
*/
|
|
715
|
+
upsert(_doc: UpsertDocument, _namespace?: string): Promise<void>;
|
|
716
|
+
/**
|
|
717
|
+
* Batch upsert is not supported for MultiTablePostgresProvider.
|
|
718
|
+
*/
|
|
719
|
+
batchUpsert(_docs: UpsertDocument[], _namespace?: string): Promise<void>;
|
|
720
|
+
/**
|
|
721
|
+
* Query all configured tables and merge results, sorted by cosine similarity score.
|
|
722
|
+
*/
|
|
723
|
+
query(vector: number[], topK: number, _namespace?: string, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
724
|
+
_filter?: Record<string, unknown>): Promise<VectorMatch[]>;
|
|
725
|
+
delete(_id: string | number, _namespace?: string): Promise<void>;
|
|
726
|
+
deleteNamespace(_namespace: string): Promise<void>;
|
|
727
|
+
ping(): Promise<boolean>;
|
|
728
|
+
disconnect(): Promise<void>;
|
|
729
|
+
}
|
|
730
|
+
|
|
223
731
|
/**
|
|
224
732
|
* MongoDBProvider — MongoDB Atlas Vector Search implementation.
|
|
225
733
|
*/
|
|
@@ -244,7 +752,14 @@ declare class MongoDBProvider extends BaseVectorProvider {
|
|
|
244
752
|
}
|
|
245
753
|
|
|
246
754
|
/**
|
|
247
|
-
* MilvusProvider — implementation
|
|
755
|
+
* MilvusProvider — Milvus implementation using its REST API v1.
|
|
756
|
+
*
|
|
757
|
+
* Required options:
|
|
758
|
+
* { baseUrl: string } — e.g. "http://localhost:19530"
|
|
759
|
+
* OR { uri: string } — alias for baseUrl
|
|
760
|
+
* OR { host: string, port: number } — auto-constructs baseUrl
|
|
761
|
+
*
|
|
762
|
+
* Optional: { apiKey?: string, headers?: Record<string, string> }
|
|
248
763
|
*/
|
|
249
764
|
declare class MilvusProvider extends BaseVectorProvider {
|
|
250
765
|
private http;
|
|
@@ -254,7 +769,7 @@ declare class MilvusProvider extends BaseVectorProvider {
|
|
|
254
769
|
batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
|
|
255
770
|
query(vector: number[], topK: number, namespace?: string, _filter?: Record<string, unknown>): Promise<VectorMatch[]>;
|
|
256
771
|
delete(id: string | number, _namespace?: string): Promise<void>;
|
|
257
|
-
deleteNamespace(
|
|
772
|
+
deleteNamespace(namespace: string): Promise<void>;
|
|
258
773
|
ping(): Promise<boolean>;
|
|
259
774
|
disconnect(): Promise<void>;
|
|
260
775
|
}
|
|
@@ -290,24 +805,41 @@ declare class QdrantProvider extends BaseVectorProvider {
|
|
|
290
805
|
}
|
|
291
806
|
|
|
292
807
|
/**
|
|
293
|
-
* ChromaDBProvider — implementation
|
|
808
|
+
* ChromaDBProvider — ChromaDB implementation using its REST API.
|
|
809
|
+
*
|
|
810
|
+
* Required options: { baseUrl: string } — e.g. "http://localhost:8000"
|
|
811
|
+
* Optional: { host?: string, port?: number } — used to construct baseUrl when baseUrl not set
|
|
294
812
|
*/
|
|
295
813
|
declare class ChromaDBProvider extends BaseVectorProvider {
|
|
296
814
|
private http;
|
|
297
815
|
private collectionId;
|
|
298
816
|
constructor(config: VectorDBConfig);
|
|
817
|
+
/**
|
|
818
|
+
* Get or create the ChromaDB collection.
|
|
819
|
+
*/
|
|
299
820
|
initialize(): Promise<void>;
|
|
300
821
|
upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
|
|
301
822
|
batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
|
|
302
823
|
query(vector: number[], topK: number, namespace?: string, _filter?: Record<string, unknown>): Promise<VectorMatch[]>;
|
|
303
|
-
delete(id: string,
|
|
304
|
-
deleteNamespace(
|
|
824
|
+
delete(id: string, namespace?: string): Promise<void>;
|
|
825
|
+
deleteNamespace(namespace: string): Promise<void>;
|
|
305
826
|
ping(): Promise<boolean>;
|
|
306
827
|
disconnect(): Promise<void>;
|
|
307
828
|
}
|
|
308
829
|
|
|
309
830
|
/**
|
|
310
|
-
* RedisProvider —
|
|
831
|
+
* RedisProvider — Redis Vector Search implementation using Upstash REST API.
|
|
832
|
+
*
|
|
833
|
+
* Required options:
|
|
834
|
+
* { baseUrl: string } — Upstash REST endpoint
|
|
835
|
+
* OR { url: string } — alias for baseUrl
|
|
836
|
+
* OR { host: string, port: number } — auto-constructs baseUrl
|
|
837
|
+
*
|
|
838
|
+
* Optional: { apiKey?: string } — bearer token (required for Upstash)
|
|
839
|
+
*
|
|
840
|
+
* Note: This provider targets the Upstash Vector REST API.
|
|
841
|
+
* For bare Redis with RediSearch, use a custom REST wrapper or the
|
|
842
|
+
* UniversalVectorProvider with custom templates.
|
|
311
843
|
*/
|
|
312
844
|
declare class RedisProvider extends BaseVectorProvider {
|
|
313
845
|
private http;
|
|
@@ -317,13 +849,23 @@ declare class RedisProvider extends BaseVectorProvider {
|
|
|
317
849
|
batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
|
|
318
850
|
query(vector: number[], topK: number, namespace?: string, _filter?: Record<string, unknown>): Promise<VectorMatch[]>;
|
|
319
851
|
delete(id: string, namespace?: string): Promise<void>;
|
|
320
|
-
deleteNamespace(
|
|
852
|
+
deleteNamespace(namespace: string): Promise<void>;
|
|
853
|
+
/**
|
|
854
|
+
* Redis is TCP-based and has no HTTP health endpoint.
|
|
855
|
+
* Returns true; actual connectivity is validated on the first operation.
|
|
856
|
+
*/
|
|
321
857
|
ping(): Promise<boolean>;
|
|
322
858
|
disconnect(): Promise<void>;
|
|
323
859
|
}
|
|
324
860
|
|
|
325
861
|
/**
|
|
326
|
-
* WeaviateProvider — implementation
|
|
862
|
+
* WeaviateProvider — Weaviate implementation using its REST/GraphQL API.
|
|
863
|
+
*
|
|
864
|
+
* Required options:
|
|
865
|
+
* { baseUrl: string } — e.g. "http://localhost:8080"
|
|
866
|
+
* OR { url: string } — alias accepted for backwards compatibility
|
|
867
|
+
*
|
|
868
|
+
* Optional: { apiKey?: string }
|
|
327
869
|
*/
|
|
328
870
|
declare class WeaviateProvider extends BaseVectorProvider {
|
|
329
871
|
private http;
|
|
@@ -338,6 +880,34 @@ declare class WeaviateProvider extends BaseVectorProvider {
|
|
|
338
880
|
disconnect(): Promise<void>;
|
|
339
881
|
}
|
|
340
882
|
|
|
883
|
+
/**
|
|
884
|
+
* UniversalVectorProvider — Template-based REST integration for any vector database
|
|
885
|
+
*
|
|
886
|
+
* Enables connecting to any REST-based vector database with minimal configuration
|
|
887
|
+
* through request/response mapping templates.
|
|
888
|
+
*
|
|
889
|
+
* Features:
|
|
890
|
+
* - Template-based request/response mapping
|
|
891
|
+
* - Automatic JSON path extraction
|
|
892
|
+
* - Retry logic with exponential backoff
|
|
893
|
+
* - Request batching
|
|
894
|
+
* - Custom header support
|
|
895
|
+
*/
|
|
896
|
+
|
|
897
|
+
declare class UniversalVectorProvider extends BaseVectorProvider {
|
|
898
|
+
private http;
|
|
899
|
+
private readonly opts;
|
|
900
|
+
constructor(config: VectorDBConfig);
|
|
901
|
+
initialize(): Promise<void>;
|
|
902
|
+
upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
|
|
903
|
+
batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
|
|
904
|
+
query(vector: number[], topK: number, namespace?: string, filter?: Record<string, unknown>): Promise<VectorMatch[]>;
|
|
905
|
+
delete(id: string | number, namespace?: string): Promise<void>;
|
|
906
|
+
deleteNamespace(namespace: string): Promise<void>;
|
|
907
|
+
ping(): Promise<boolean>;
|
|
908
|
+
disconnect(): Promise<void>;
|
|
909
|
+
}
|
|
910
|
+
|
|
341
911
|
/**
|
|
342
912
|
* LLMFactory — instantiates the correct ILLMProvider based on llmConfig.provider.
|
|
343
913
|
*
|
|
@@ -431,4 +1001,18 @@ declare class OllamaProvider implements ILLMProvider {
|
|
|
431
1001
|
ping(): Promise<boolean>;
|
|
432
1002
|
}
|
|
433
1003
|
|
|
434
|
-
|
|
1004
|
+
declare class UniversalLLMAdapter implements ILLMProvider {
|
|
1005
|
+
private readonly http;
|
|
1006
|
+
private readonly model;
|
|
1007
|
+
private readonly opts;
|
|
1008
|
+
private readonly systemPrompt;
|
|
1009
|
+
private readonly maxTokens;
|
|
1010
|
+
private readonly temperature;
|
|
1011
|
+
constructor(config: LLMConfig | EmbeddingConfig);
|
|
1012
|
+
chat(messages: ChatMessage[], context?: string): Promise<string>;
|
|
1013
|
+
embed(text: string): Promise<number[]>;
|
|
1014
|
+
batchEmbed(texts: string[]): Promise<number[][]>;
|
|
1015
|
+
ping(): Promise<boolean>;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
export { AnthropicProvider, BaseVectorProvider, type BatchOptions, BatchProcessor, type BatchResult, ChatMessage, ChatOptions, ChatResponse, ChromaDBProvider, ConfigBuilder, ConfigResolver, ConfigValidator, DocumentParser, EmbedOptions, EmbeddingConfig, EmbeddingProvider, EmbeddingStrategy, EmbeddingStrategyResolver, HealthCheckResult, ILLMProvider, IngestDocument, LLMConfig, LLMFactory, LLMProvider, LLM_PROFILES, MilvusProvider, MongoDBProvider, MultiTablePostgresProvider, OllamaProvider, OpenAIProvider, PRESETS, PineconeProvider, Pipeline, PostgreSQLProvider, ProviderRegistry, QdrantProvider, RagConfig, RedisProvider, UniversalLLMAdapter, UniversalVectorProvider, UpsertDocument, VECTOR_PROFILES, type ValidationError, VectorDBConfig, VectorDBProvider, VectorMatch, VectorPlugin, WeaviateProvider, createFromPreset, getRagConfig };
|