@retrivora-ai/rag-engine 0.1.5 → 0.1.7

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 (41) hide show
  1. package/dist/{DocumentChunker-cfaMidtA.d.mts → DocumentChunker-BEyzadsv.d.mts} +2 -2
  2. package/dist/{DocumentChunker-cfaMidtA.d.ts → DocumentChunker-BEyzadsv.d.ts} +2 -2
  3. package/dist/{PineconeProvider-NJ675H7U.mjs → PineconeProvider-ZRAFNFEC.mjs} +1 -1
  4. package/dist/{PostgreSQLProvider-ISNMD3BE.mjs → PostgreSQLProvider-ZNXA67IM.mjs} +1 -1
  5. package/dist/{QdrantProvider-LJWOIGES.mjs → QdrantProvider-VAED5VA7.mjs} +1 -1
  6. package/dist/{RagConfig-DG_0f8ka.d.mts → RagConfig-hBGXJmSx.d.mts} +3 -3
  7. package/dist/{RagConfig-DG_0f8ka.d.ts → RagConfig-hBGXJmSx.d.ts} +3 -3
  8. package/dist/chunk-7YQWGERZ.mjs +1764 -0
  9. package/dist/chunk-CWQQHAF6.mjs +157 -0
  10. package/dist/{chunk-S5DRHETN.mjs → chunk-IUTAZ7QR.mjs} +31 -2
  11. package/dist/{chunk-AALIF3AL.mjs → chunk-ZM6TYIDH.mjs} +3 -3
  12. package/dist/handlers/index.d.mts +3 -44
  13. package/dist/handlers/index.d.ts +3 -44
  14. package/dist/handlers/index.js +1371 -60
  15. package/dist/handlers/index.mjs +1 -1
  16. package/dist/index-Bx182KKn.d.ts +64 -0
  17. package/dist/index-Ck2pt7-8.d.mts +64 -0
  18. package/dist/index.d.mts +4 -4
  19. package/dist/index.d.ts +4 -4
  20. package/dist/server.d.mts +74 -18
  21. package/dist/server.d.ts +74 -18
  22. package/dist/server.js +1371 -60
  23. package/dist/server.mjs +4 -4
  24. package/package.json +2 -1
  25. package/src/config/serverConfig.ts +4 -0
  26. package/src/core/BatchProcessor.ts +347 -0
  27. package/src/core/ConfigValidator.ts +568 -0
  28. package/src/core/Pipeline.ts +89 -39
  29. package/src/core/ProviderHealthCheck.ts +568 -0
  30. package/src/core/VectorPlugin.ts +49 -8
  31. package/src/handlers/index.ts +2 -2
  32. package/src/providers/vectordb/BaseVectorProvider.ts +1 -1
  33. package/src/providers/vectordb/MilvusProvider.ts +1 -1
  34. package/src/providers/vectordb/MongoDBProvider.ts +1 -1
  35. package/src/providers/vectordb/PineconeProvider.ts +4 -4
  36. package/src/providers/vectordb/PostgreSQLProvider.ts +35 -3
  37. package/src/providers/vectordb/QdrantProvider.ts +81 -4
  38. package/src/rag/DocumentChunker.ts +2 -2
  39. package/src/types/index.ts +3 -3
  40. package/dist/chunk-6FODXNUF.mjs +0 -91
  41. package/dist/chunk-BP4U4TT5.mjs +0 -548
@@ -3,7 +3,7 @@ import {
3
3
  createHealthHandler,
4
4
  createIngestHandler,
5
5
  createUploadHandler
6
- } from "../chunk-BP4U4TT5.mjs";
6
+ } from "../chunk-7YQWGERZ.mjs";
7
7
  import "../chunk-JI6VD5TJ.mjs";
8
8
  import "../chunk-UKDXCXW7.mjs";
9
9
  import "../chunk-I4E63NIC.mjs";
@@ -0,0 +1,64 @@
1
+ import { a as RagConfig, C as ChatResponse } from './RagConfig-hBGXJmSx.js';
2
+ import { NextRequest, NextResponse } from 'next/server';
3
+
4
+ /**
5
+ * ProviderHealthCheck.ts — Pre-flight validation for vector DB and LLM providers.
6
+ *
7
+ * Performs connectivity tests, credential validation, and capability checks
8
+ * before initializing providers.
9
+ */
10
+
11
+ interface HealthCheckResult {
12
+ healthy: boolean;
13
+ provider: string;
14
+ version?: string;
15
+ capabilities?: Record<string, unknown>;
16
+ error?: string;
17
+ timestamp: number;
18
+ }
19
+
20
+ /**
21
+ * createChatHandler — factory that returns a Next.js App Router POST handler
22
+ */
23
+ declare function createChatHandler(config?: Partial<RagConfig>): (req: NextRequest) => Promise<NextResponse<{
24
+ error: string;
25
+ }> | NextResponse<ChatResponse>>;
26
+ /**
27
+ * createIngestHandler — factory for the document ingestion endpoint.
28
+ */
29
+ declare function createIngestHandler(config?: Partial<RagConfig>): (req: NextRequest) => Promise<NextResponse<{
30
+ error: string;
31
+ }> | NextResponse<{
32
+ results: {
33
+ docId: string | number;
34
+ chunksIngested: number;
35
+ }[];
36
+ }>>;
37
+ /**
38
+ * createHealthHandler — factory for the health-check endpoint.
39
+ */
40
+ declare function createHealthHandler(config?: Partial<RagConfig>): () => Promise<NextResponse<{
41
+ timestamp: string;
42
+ vectorDb: HealthCheckResult;
43
+ llm: HealthCheckResult;
44
+ embedding?: HealthCheckResult;
45
+ allHealthy: boolean;
46
+ status: string;
47
+ }> | NextResponse<{
48
+ status: string;
49
+ error: string;
50
+ }>>;
51
+ /**
52
+ * createUploadHandler — factory for the file upload ingestion endpoint.
53
+ */
54
+ declare function createUploadHandler(config?: Partial<RagConfig>): (req: NextRequest) => Promise<NextResponse<{
55
+ error: string;
56
+ }> | NextResponse<{
57
+ message: string;
58
+ results: {
59
+ docId: string | number;
60
+ chunksIngested: number;
61
+ }[];
62
+ }>>;
63
+
64
+ export { type HealthCheckResult as H, createHealthHandler as a, createIngestHandler as b, createChatHandler as c, createUploadHandler as d };
@@ -0,0 +1,64 @@
1
+ import { a as RagConfig, C as ChatResponse } from './RagConfig-hBGXJmSx.mjs';
2
+ import { NextRequest, NextResponse } from 'next/server';
3
+
4
+ /**
5
+ * ProviderHealthCheck.ts — Pre-flight validation for vector DB and LLM providers.
6
+ *
7
+ * Performs connectivity tests, credential validation, and capability checks
8
+ * before initializing providers.
9
+ */
10
+
11
+ interface HealthCheckResult {
12
+ healthy: boolean;
13
+ provider: string;
14
+ version?: string;
15
+ capabilities?: Record<string, unknown>;
16
+ error?: string;
17
+ timestamp: number;
18
+ }
19
+
20
+ /**
21
+ * createChatHandler — factory that returns a Next.js App Router POST handler
22
+ */
23
+ declare function createChatHandler(config?: Partial<RagConfig>): (req: NextRequest) => Promise<NextResponse<{
24
+ error: string;
25
+ }> | NextResponse<ChatResponse>>;
26
+ /**
27
+ * createIngestHandler — factory for the document ingestion endpoint.
28
+ */
29
+ declare function createIngestHandler(config?: Partial<RagConfig>): (req: NextRequest) => Promise<NextResponse<{
30
+ error: string;
31
+ }> | NextResponse<{
32
+ results: {
33
+ docId: string | number;
34
+ chunksIngested: number;
35
+ }[];
36
+ }>>;
37
+ /**
38
+ * createHealthHandler — factory for the health-check endpoint.
39
+ */
40
+ declare function createHealthHandler(config?: Partial<RagConfig>): () => Promise<NextResponse<{
41
+ timestamp: string;
42
+ vectorDb: HealthCheckResult;
43
+ llm: HealthCheckResult;
44
+ embedding?: HealthCheckResult;
45
+ allHealthy: boolean;
46
+ status: string;
47
+ }> | NextResponse<{
48
+ status: string;
49
+ error: string;
50
+ }>>;
51
+ /**
52
+ * createUploadHandler — factory for the file upload ingestion endpoint.
53
+ */
54
+ declare function createUploadHandler(config?: Partial<RagConfig>): (req: NextRequest) => Promise<NextResponse<{
55
+ error: string;
56
+ }> | NextResponse<{
57
+ message: string;
58
+ results: {
59
+ docId: string | number;
60
+ chunksIngested: number;
61
+ }[];
62
+ }>>;
63
+
64
+ export { type HealthCheckResult as H, createHealthHandler as a, createIngestHandler as b, createChatHandler as c, createUploadHandler as d };
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React$1, { ReactNode } from 'react';
3
- import { C as ChatMessage } from './DocumentChunker-cfaMidtA.mjs';
4
- export { a as ChatOptions, b as Chunk, c as ChunkOptions, E as EmbedOptions, I as ILLMProvider } from './DocumentChunker-cfaMidtA.mjs';
5
- import { V as VectorMatch, U as UIConfig } from './RagConfig-DG_0f8ka.mjs';
6
- export { C as ChatResponse, E as EmbeddingConfig, I as IngestDocument, L as LLMConfig, R as RAGConfig, a as RagConfig, b as UpsertDocument, c as VectorDBConfig } from './RagConfig-DG_0f8ka.mjs';
3
+ import { C as ChatMessage } from './DocumentChunker-BEyzadsv.mjs';
4
+ export { a as ChatOptions, b as Chunk, c as ChunkOptions, E as EmbedOptions, I as ILLMProvider } from './DocumentChunker-BEyzadsv.mjs';
5
+ import { V as VectorMatch, U as UIConfig } from './RagConfig-hBGXJmSx.mjs';
6
+ export { C as ChatResponse, E as EmbeddingConfig, I as IngestDocument, L as LLMConfig, R as RAGConfig, a as RagConfig, b as UpsertDocument, c as VectorDBConfig } from './RagConfig-hBGXJmSx.mjs';
7
7
 
8
8
  interface ChatWidgetProps {
9
9
  /** Position of the floating button. Defaults to bottom-right. */
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React$1, { ReactNode } from 'react';
3
- import { C as ChatMessage } from './DocumentChunker-cfaMidtA.js';
4
- export { a as ChatOptions, b as Chunk, c as ChunkOptions, E as EmbedOptions, I as ILLMProvider } from './DocumentChunker-cfaMidtA.js';
5
- import { V as VectorMatch, U as UIConfig } from './RagConfig-DG_0f8ka.js';
6
- export { C as ChatResponse, E as EmbeddingConfig, I as IngestDocument, L as LLMConfig, R as RAGConfig, a as RagConfig, b as UpsertDocument, c as VectorDBConfig } from './RagConfig-DG_0f8ka.js';
3
+ import { C as ChatMessage } from './DocumentChunker-BEyzadsv.js';
4
+ export { a as ChatOptions, b as Chunk, c as ChunkOptions, E as EmbedOptions, I as ILLMProvider } from './DocumentChunker-BEyzadsv.js';
5
+ import { V as VectorMatch, U as UIConfig } from './RagConfig-hBGXJmSx.js';
6
+ export { C as ChatResponse, E as EmbeddingConfig, I as IngestDocument, L as LLMConfig, R as RAGConfig, a as RagConfig, b as UpsertDocument, c as VectorDBConfig } from './RagConfig-hBGXJmSx.js';
7
7
 
8
8
  interface ChatWidgetProps {
9
9
  /** Position of the floating button. Defaults to bottom-right. */
package/dist/server.d.mts CHANGED
@@ -1,13 +1,21 @@
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-DG_0f8ka.mjs';
2
- export { R as RAGConfig, U as UIConfig } from './RagConfig-DG_0f8ka.mjs';
3
- import { C as ChatMessage, I as ILLMProvider, a as ChatOptions, E as EmbedOptions } from './DocumentChunker-cfaMidtA.mjs';
4
- export { b as Chunk, c as ChunkOptions, D as DocumentChunker } from './DocumentChunker-cfaMidtA.mjs';
5
- export { createChatHandler, createHealthHandler, createIngestHandler, createUploadHandler } from './handlers/index.mjs';
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-hBGXJmSx.mjs';
2
+ export { R as RAGConfig, U as UIConfig } from './RagConfig-hBGXJmSx.mjs';
3
+ import { C as ChatMessage, I as ILLMProvider, a as ChatOptions, E as EmbedOptions } from './DocumentChunker-BEyzadsv.mjs';
4
+ export { b as Chunk, c as ChunkOptions, D as DocumentChunker } from './DocumentChunker-BEyzadsv.mjs';
5
+ import { H as HealthCheckResult } from './index-Ck2pt7-8.mjs';
6
+ export { c as createChatHandler, a as createHealthHandler, b as createIngestHandler, d as createUploadHandler } from './index-Ck2pt7-8.mjs';
6
7
  import 'next/server';
7
8
 
8
9
  /**
9
10
  * VectorPlugin — main orchestrator class.
10
11
  * This is the primary interface for host applications.
12
+ *
13
+ * Features:
14
+ * - Configuration resolution from host + environment
15
+ * - Configuration validation with detailed error messages
16
+ * - Provider health checks before initialization
17
+ * - Multi-provider support (Vector DBs & LLMs)
18
+ * - Per-tenant data isolation via namespacing
11
19
  */
12
20
  declare class VectorPlugin {
13
21
  private config;
@@ -15,12 +23,40 @@ declare class VectorPlugin {
15
23
  /**
16
24
  * Initializes the plugin with the host configuration.
17
25
  * @param hostConfig - Configuration object passed from the host application.
26
+ * @throws Error if configuration is invalid or providers are unhealthy
27
+ *
28
+ * @example
29
+ * const plugin = new VectorPlugin({
30
+ * projectId: 'my-app',
31
+ * vectorDb: {
32
+ * provider: 'pinecone',
33
+ * indexName: 'my-index',
34
+ * options: { apiKey: process.env.PINECONE_API_KEY }
35
+ * },
36
+ * llm: {
37
+ * provider: 'openai',
38
+ * model: 'gpt-4o',
39
+ * apiKey: process.env.OPENAI_API_KEY
40
+ * }
41
+ * });
18
42
  */
19
43
  constructor(hostConfig?: Partial<RagConfig>);
20
44
  /**
21
45
  * Get the current resolved configuration.
22
46
  */
23
47
  getConfig(): RagConfig;
48
+ /**
49
+ * Perform pre-flight health checks on all configured providers.
50
+ * Useful to verify connectivity before running operations.
51
+ *
52
+ * @returns Health status for vector DB, LLM, and embedding providers
53
+ */
54
+ checkHealth(): Promise<{
55
+ vectorDb: HealthCheckResult;
56
+ llm: HealthCheckResult;
57
+ embedding?: HealthCheckResult;
58
+ allHealthy: boolean;
59
+ }>;
24
60
  /**
25
61
  * Run a chat query.
26
62
  */
@@ -29,17 +65,20 @@ declare class VectorPlugin {
29
65
  * Ingest documents into the vector database.
30
66
  */
31
67
  ingest(documents: IngestDocument[], namespace?: string): Promise<Array<{
32
- docId: string;
68
+ docId: string | number;
33
69
  chunksIngested: number;
34
70
  }>>;
35
- /**
36
- * Check the health of the connected providers.
37
- */
38
- health(): Promise<Record<string, boolean>>;
39
71
  }
40
72
 
41
73
  /**
42
74
  * Pipeline — orchestrates the RAG flow: Embed → Search → Augment → Generate.
75
+ *
76
+ * Features:
77
+ * - Lazy initialization of providers
78
+ * - Batch processing with retry logic
79
+ * - Configurable embedding strategies
80
+ * - Error recovery for transient failures
81
+ * - Support for multi-tenancy via namespacing
43
82
  */
44
83
  declare class Pipeline {
45
84
  private vectorDB;
@@ -50,12 +89,15 @@ declare class Pipeline {
50
89
  private initialised;
51
90
  constructor(config: RagConfig);
52
91
  initialize(): Promise<void>;
92
+ /**
93
+ * Ingest documents with automatic chunking, embedding, and batch processing.
94
+ * Handles retries for transient failures.
95
+ */
53
96
  ingest(documents: IngestDocument[], namespace?: string): Promise<Array<{
54
- docId: string;
97
+ docId: string | number;
55
98
  chunksIngested: number;
56
99
  }>>;
57
100
  ask(question: string, history?: ChatMessage[], namespace?: string): Promise<ChatResponse>;
58
- health(): Promise<Record<string, boolean>>;
59
101
  }
60
102
 
61
103
  /**
@@ -101,7 +143,7 @@ declare abstract class BaseVectorProvider {
101
143
  /**
102
144
  * Delete a stored vector by ID.
103
145
  */
104
- abstract delete(id: string, namespace?: string): Promise<void>;
146
+ abstract delete(id: string | number, namespace?: string): Promise<void>;
105
147
  /**
106
148
  * Delete all vectors in a namespace (full data reset for a project).
107
149
  */
@@ -153,7 +195,7 @@ declare class PineconeProvider extends BaseVectorProvider {
153
195
  upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
154
196
  batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
155
197
  query(vector: number[], topK: number, namespace?: string, filter?: Record<string, unknown>): Promise<VectorMatch[]>;
156
- delete(id: string, namespace?: string): Promise<void>;
198
+ delete(id: string | number, namespace?: string): Promise<void>;
157
199
  deleteNamespace(namespace: string): Promise<void>;
158
200
  ping(): Promise<boolean>;
159
201
  disconnect(): Promise<void>;
@@ -172,7 +214,7 @@ declare class PostgreSQLProvider extends BaseVectorProvider {
172
214
  upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
173
215
  batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
174
216
  query(vector: number[], topK: number, namespace?: string, filter?: Record<string, unknown>): Promise<VectorMatch[]>;
175
- delete(id: string, namespace?: string): Promise<void>;
217
+ delete(id: string | number, namespace?: string): Promise<void>;
176
218
  deleteNamespace(namespace: string): Promise<void>;
177
219
  ping(): Promise<boolean>;
178
220
  disconnect(): Promise<void>;
@@ -195,7 +237,7 @@ declare class MongoDBProvider extends BaseVectorProvider {
195
237
  upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
196
238
  batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
197
239
  query(vector: number[], topK: number, namespace?: string, filter?: Record<string, unknown>): Promise<VectorMatch[]>;
198
- delete(id: string, namespace?: string): Promise<void>;
240
+ delete(id: string | number, namespace?: string): Promise<void>;
199
241
  deleteNamespace(namespace: string): Promise<void>;
200
242
  ping(): Promise<boolean>;
201
243
  disconnect(): Promise<void>;
@@ -211,7 +253,7 @@ declare class MilvusProvider extends BaseVectorProvider {
211
253
  upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
212
254
  batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
213
255
  query(vector: number[], topK: number, namespace?: string, _filter?: Record<string, unknown>): Promise<VectorMatch[]>;
214
- delete(id: string, _namespace?: string): Promise<void>;
256
+ delete(id: string | number, _namespace?: string): Promise<void>;
215
257
  deleteNamespace(_namespace: string): Promise<void>;
216
258
  ping(): Promise<boolean>;
217
259
  disconnect(): Promise<void>;
@@ -224,12 +266,26 @@ declare class QdrantProvider extends BaseVectorProvider {
224
266
  private http;
225
267
  constructor(config: VectorDBConfig);
226
268
  initialize(): Promise<void>;
269
+ /**
270
+ * Ensures the collection exists. Creates it if missing.
271
+ */
272
+ private ensureCollection;
273
+ /**
274
+ * Ensures that the 'namespace' field has a keyword index for efficient filtering.
275
+ * Qdrant requires this for search filters to work in many configurations.
276
+ */
277
+ private ensureIndex;
227
278
  upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
228
279
  batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
229
280
  query(vector: number[], topK: number, namespace?: string, _filter?: Record<string, unknown>): Promise<VectorMatch[]>;
230
- delete(id: string, _namespace?: string): Promise<void>;
281
+ delete(id: string | number, _namespace?: string): Promise<void>;
231
282
  deleteNamespace(_namespace: string): Promise<void>;
232
283
  ping(): Promise<boolean>;
284
+ /**
285
+ * Normalizes an ID into a format Qdrant accepts (UUID or integer).
286
+ * For string IDs that aren't UUIDs, it generates a deterministic UUID v5-like hash.
287
+ */
288
+ private normalizeId;
233
289
  disconnect(): Promise<void>;
234
290
  }
235
291
 
package/dist/server.d.ts CHANGED
@@ -1,13 +1,21 @@
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-DG_0f8ka.js';
2
- export { R as RAGConfig, U as UIConfig } from './RagConfig-DG_0f8ka.js';
3
- import { C as ChatMessage, I as ILLMProvider, a as ChatOptions, E as EmbedOptions } from './DocumentChunker-cfaMidtA.js';
4
- export { b as Chunk, c as ChunkOptions, D as DocumentChunker } from './DocumentChunker-cfaMidtA.js';
5
- export { createChatHandler, createHealthHandler, createIngestHandler, createUploadHandler } from './handlers/index.js';
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-hBGXJmSx.js';
2
+ export { R as RAGConfig, U as UIConfig } from './RagConfig-hBGXJmSx.js';
3
+ import { C as ChatMessage, I as ILLMProvider, a as ChatOptions, E as EmbedOptions } from './DocumentChunker-BEyzadsv.js';
4
+ export { b as Chunk, c as ChunkOptions, D as DocumentChunker } from './DocumentChunker-BEyzadsv.js';
5
+ import { H as HealthCheckResult } from './index-Bx182KKn.js';
6
+ export { c as createChatHandler, a as createHealthHandler, b as createIngestHandler, d as createUploadHandler } from './index-Bx182KKn.js';
6
7
  import 'next/server';
7
8
 
8
9
  /**
9
10
  * VectorPlugin — main orchestrator class.
10
11
  * This is the primary interface for host applications.
12
+ *
13
+ * Features:
14
+ * - Configuration resolution from host + environment
15
+ * - Configuration validation with detailed error messages
16
+ * - Provider health checks before initialization
17
+ * - Multi-provider support (Vector DBs & LLMs)
18
+ * - Per-tenant data isolation via namespacing
11
19
  */
12
20
  declare class VectorPlugin {
13
21
  private config;
@@ -15,12 +23,40 @@ declare class VectorPlugin {
15
23
  /**
16
24
  * Initializes the plugin with the host configuration.
17
25
  * @param hostConfig - Configuration object passed from the host application.
26
+ * @throws Error if configuration is invalid or providers are unhealthy
27
+ *
28
+ * @example
29
+ * const plugin = new VectorPlugin({
30
+ * projectId: 'my-app',
31
+ * vectorDb: {
32
+ * provider: 'pinecone',
33
+ * indexName: 'my-index',
34
+ * options: { apiKey: process.env.PINECONE_API_KEY }
35
+ * },
36
+ * llm: {
37
+ * provider: 'openai',
38
+ * model: 'gpt-4o',
39
+ * apiKey: process.env.OPENAI_API_KEY
40
+ * }
41
+ * });
18
42
  */
19
43
  constructor(hostConfig?: Partial<RagConfig>);
20
44
  /**
21
45
  * Get the current resolved configuration.
22
46
  */
23
47
  getConfig(): RagConfig;
48
+ /**
49
+ * Perform pre-flight health checks on all configured providers.
50
+ * Useful to verify connectivity before running operations.
51
+ *
52
+ * @returns Health status for vector DB, LLM, and embedding providers
53
+ */
54
+ checkHealth(): Promise<{
55
+ vectorDb: HealthCheckResult;
56
+ llm: HealthCheckResult;
57
+ embedding?: HealthCheckResult;
58
+ allHealthy: boolean;
59
+ }>;
24
60
  /**
25
61
  * Run a chat query.
26
62
  */
@@ -29,17 +65,20 @@ declare class VectorPlugin {
29
65
  * Ingest documents into the vector database.
30
66
  */
31
67
  ingest(documents: IngestDocument[], namespace?: string): Promise<Array<{
32
- docId: string;
68
+ docId: string | number;
33
69
  chunksIngested: number;
34
70
  }>>;
35
- /**
36
- * Check the health of the connected providers.
37
- */
38
- health(): Promise<Record<string, boolean>>;
39
71
  }
40
72
 
41
73
  /**
42
74
  * Pipeline — orchestrates the RAG flow: Embed → Search → Augment → Generate.
75
+ *
76
+ * Features:
77
+ * - Lazy initialization of providers
78
+ * - Batch processing with retry logic
79
+ * - Configurable embedding strategies
80
+ * - Error recovery for transient failures
81
+ * - Support for multi-tenancy via namespacing
43
82
  */
44
83
  declare class Pipeline {
45
84
  private vectorDB;
@@ -50,12 +89,15 @@ declare class Pipeline {
50
89
  private initialised;
51
90
  constructor(config: RagConfig);
52
91
  initialize(): Promise<void>;
92
+ /**
93
+ * Ingest documents with automatic chunking, embedding, and batch processing.
94
+ * Handles retries for transient failures.
95
+ */
53
96
  ingest(documents: IngestDocument[], namespace?: string): Promise<Array<{
54
- docId: string;
97
+ docId: string | number;
55
98
  chunksIngested: number;
56
99
  }>>;
57
100
  ask(question: string, history?: ChatMessage[], namespace?: string): Promise<ChatResponse>;
58
- health(): Promise<Record<string, boolean>>;
59
101
  }
60
102
 
61
103
  /**
@@ -101,7 +143,7 @@ declare abstract class BaseVectorProvider {
101
143
  /**
102
144
  * Delete a stored vector by ID.
103
145
  */
104
- abstract delete(id: string, namespace?: string): Promise<void>;
146
+ abstract delete(id: string | number, namespace?: string): Promise<void>;
105
147
  /**
106
148
  * Delete all vectors in a namespace (full data reset for a project).
107
149
  */
@@ -153,7 +195,7 @@ declare class PineconeProvider extends BaseVectorProvider {
153
195
  upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
154
196
  batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
155
197
  query(vector: number[], topK: number, namespace?: string, filter?: Record<string, unknown>): Promise<VectorMatch[]>;
156
- delete(id: string, namespace?: string): Promise<void>;
198
+ delete(id: string | number, namespace?: string): Promise<void>;
157
199
  deleteNamespace(namespace: string): Promise<void>;
158
200
  ping(): Promise<boolean>;
159
201
  disconnect(): Promise<void>;
@@ -172,7 +214,7 @@ declare class PostgreSQLProvider extends BaseVectorProvider {
172
214
  upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
173
215
  batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
174
216
  query(vector: number[], topK: number, namespace?: string, filter?: Record<string, unknown>): Promise<VectorMatch[]>;
175
- delete(id: string, namespace?: string): Promise<void>;
217
+ delete(id: string | number, namespace?: string): Promise<void>;
176
218
  deleteNamespace(namespace: string): Promise<void>;
177
219
  ping(): Promise<boolean>;
178
220
  disconnect(): Promise<void>;
@@ -195,7 +237,7 @@ declare class MongoDBProvider extends BaseVectorProvider {
195
237
  upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
196
238
  batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
197
239
  query(vector: number[], topK: number, namespace?: string, filter?: Record<string, unknown>): Promise<VectorMatch[]>;
198
- delete(id: string, namespace?: string): Promise<void>;
240
+ delete(id: string | number, namespace?: string): Promise<void>;
199
241
  deleteNamespace(namespace: string): Promise<void>;
200
242
  ping(): Promise<boolean>;
201
243
  disconnect(): Promise<void>;
@@ -211,7 +253,7 @@ declare class MilvusProvider extends BaseVectorProvider {
211
253
  upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
212
254
  batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
213
255
  query(vector: number[], topK: number, namespace?: string, _filter?: Record<string, unknown>): Promise<VectorMatch[]>;
214
- delete(id: string, _namespace?: string): Promise<void>;
256
+ delete(id: string | number, _namespace?: string): Promise<void>;
215
257
  deleteNamespace(_namespace: string): Promise<void>;
216
258
  ping(): Promise<boolean>;
217
259
  disconnect(): Promise<void>;
@@ -224,12 +266,26 @@ declare class QdrantProvider extends BaseVectorProvider {
224
266
  private http;
225
267
  constructor(config: VectorDBConfig);
226
268
  initialize(): Promise<void>;
269
+ /**
270
+ * Ensures the collection exists. Creates it if missing.
271
+ */
272
+ private ensureCollection;
273
+ /**
274
+ * Ensures that the 'namespace' field has a keyword index for efficient filtering.
275
+ * Qdrant requires this for search filters to work in many configurations.
276
+ */
277
+ private ensureIndex;
227
278
  upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
228
279
  batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
229
280
  query(vector: number[], topK: number, namespace?: string, _filter?: Record<string, unknown>): Promise<VectorMatch[]>;
230
- delete(id: string, _namespace?: string): Promise<void>;
281
+ delete(id: string | number, _namespace?: string): Promise<void>;
231
282
  deleteNamespace(_namespace: string): Promise<void>;
232
283
  ping(): Promise<boolean>;
284
+ /**
285
+ * Normalizes an ID into a format Qdrant accepts (UUID or integer).
286
+ * For string IDs that aren't UUIDs, it generates a deterministic UUID v5-like hash.
287
+ */
288
+ private normalizeId;
233
289
  disconnect(): Promise<void>;
234
290
  }
235
291