@retrivora-ai/rag-engine 0.1.4 → 0.1.5

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/index.mjs CHANGED
@@ -1,12 +1,6 @@
1
- import {
2
- ConfigResolver,
3
- Pipeline,
4
- ProviderRegistry,
5
- VectorPlugin
6
- } from "./chunk-AIAB2IEE.mjs";
7
1
  import {
8
2
  mergeDefined
9
- } from "./chunk-GD3QJFNN.mjs";
3
+ } from "./chunk-UKDXCXW7.mjs";
10
4
  import {
11
5
  __spreadValues
12
6
  } from "./chunk-I4E63NIC.mjs";
@@ -553,12 +547,8 @@ export {
553
547
  ChatWidget,
554
548
  ChatWindow,
555
549
  ConfigProvider,
556
- ConfigResolver,
557
550
  MessageBubble,
558
- Pipeline,
559
- ProviderRegistry,
560
551
  SourceCard,
561
- VectorPlugin,
562
552
  useConfig,
563
553
  useRagChat
564
554
  };
package/dist/server.d.mts CHANGED
@@ -1,10 +1,140 @@
1
- import { e as RagConfig, g as VectorDBConfig, f as UpsertDocument, V as VectorMatch, L as LLMConfig, c as EmbeddingConfig, I as ILLMProvider, C as ChatMessage, a as ChatOptions, E as EmbedOptions } from './Pipeline-Bo6CUCox.mjs';
2
- export { b as ChatResponse, d as IngestDocument, P as Pipeline, R as RAGConfig, U as UIConfig } from './Pipeline-Bo6CUCox.mjs';
3
- import { B as BaseVectorProvider } from './DocumentChunker-D9-fObJp.mjs';
4
- export { C as Chunk, a as ChunkOptions, b as ConfigResolver, D as DocumentChunker, P as ProviderRegistry, V as VectorPlugin } from './DocumentChunker-D9-fObJp.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-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
5
  export { createChatHandler, createHealthHandler, createIngestHandler, createUploadHandler } from './handlers/index.mjs';
6
6
  import 'next/server';
7
7
 
8
+ /**
9
+ * VectorPlugin — main orchestrator class.
10
+ * This is the primary interface for host applications.
11
+ */
12
+ declare class VectorPlugin {
13
+ private config;
14
+ private pipeline;
15
+ /**
16
+ * Initializes the plugin with the host configuration.
17
+ * @param hostConfig - Configuration object passed from the host application.
18
+ */
19
+ constructor(hostConfig?: Partial<RagConfig>);
20
+ /**
21
+ * Get the current resolved configuration.
22
+ */
23
+ getConfig(): RagConfig;
24
+ /**
25
+ * Run a chat query.
26
+ */
27
+ chat(message: string, history?: ChatMessage[], namespace?: string): Promise<ChatResponse>;
28
+ /**
29
+ * Ingest documents into the vector database.
30
+ */
31
+ ingest(documents: IngestDocument[], namespace?: string): Promise<Array<{
32
+ docId: string;
33
+ chunksIngested: number;
34
+ }>>;
35
+ /**
36
+ * Check the health of the connected providers.
37
+ */
38
+ health(): Promise<Record<string, boolean>>;
39
+ }
40
+
41
+ /**
42
+ * Pipeline — orchestrates the RAG flow: Embed → Search → Augment → Generate.
43
+ */
44
+ declare class Pipeline {
45
+ private vectorDB;
46
+ private llmProvider;
47
+ private embeddingProvider;
48
+ private chunker;
49
+ private config;
50
+ private initialised;
51
+ constructor(config: RagConfig);
52
+ initialize(): Promise<void>;
53
+ ingest(documents: IngestDocument[], namespace?: string): Promise<Array<{
54
+ docId: string;
55
+ chunksIngested: number;
56
+ }>>;
57
+ ask(question: string, history?: ChatMessage[], namespace?: string): Promise<ChatResponse>;
58
+ health(): Promise<Record<string, boolean>>;
59
+ }
60
+
61
+ /**
62
+ * ConfigResolver — validates and normalizes host configuration.
63
+ * It merges host-provided config with environment defaults.
64
+ */
65
+ declare class ConfigResolver {
66
+ /**
67
+ * Resolves the final configuration by merging host-provided config with defaults.
68
+ * @param hostConfig - Partial configuration passed from the host application.
69
+ */
70
+ static resolve(hostConfig?: Partial<RagConfig>): RagConfig;
71
+ /**
72
+ * Validates the configuration for required fields.
73
+ */
74
+ static validate(config: RagConfig): void;
75
+ }
76
+
77
+ /**
78
+ * BaseVectorProvider — Abstract base class for all vector database providers.
79
+ * Each provider (Pinecone, Milvus, Redis, etc.) must extend this class.
80
+ */
81
+ declare abstract class BaseVectorProvider {
82
+ protected readonly config: VectorDBConfig;
83
+ protected readonly indexName: string;
84
+ constructor(config: VectorDBConfig);
85
+ /**
86
+ * Initialise the connection (create tables, verify index, etc.)
87
+ */
88
+ abstract initialize(): Promise<void>;
89
+ /**
90
+ * Insert or update a single vector + content pair.
91
+ */
92
+ abstract upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
93
+ /**
94
+ * Batch upsert for efficient ingestion of many documents.
95
+ */
96
+ abstract batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
97
+ /**
98
+ * Find the top-K most similar vectors to the query vector.
99
+ */
100
+ abstract query(vector: number[], topK: number, namespace?: string, filter?: Record<string, unknown>): Promise<VectorMatch[]>;
101
+ /**
102
+ * Delete a stored vector by ID.
103
+ */
104
+ abstract delete(id: string, namespace?: string): Promise<void>;
105
+ /**
106
+ * Delete all vectors in a namespace (full data reset for a project).
107
+ */
108
+ abstract deleteNamespace(namespace: string): Promise<void>;
109
+ /**
110
+ * Check if the underlying DB is reachable.
111
+ */
112
+ abstract ping(): Promise<boolean>;
113
+ /**
114
+ * Gracefully close the connection.
115
+ */
116
+ abstract disconnect(): Promise<void>;
117
+ }
118
+
119
+ /**
120
+ * ProviderRegistry — dynamic provider loader for Vector DBs and LLMs.
121
+ */
122
+ declare class ProviderRegistry {
123
+ private static vectorProviders;
124
+ /**
125
+ * Register a custom vector provider.
126
+ */
127
+ static registerVectorProvider(name: string, providerClass: new (config: VectorDBConfig) => BaseVectorProvider): void;
128
+ /**
129
+ * Creates a vector database provider based on the configuration.
130
+ */
131
+ static createVectorProvider(config: VectorDBConfig): Promise<BaseVectorProvider>;
132
+ /**
133
+ * Creates an LLM provider based on the configuration.
134
+ */
135
+ static createLLMProvider(llmConfig: LLMConfig, embeddingConfig?: EmbeddingConfig): ILLMProvider;
136
+ }
137
+
8
138
  /**
9
139
  * serverConfig.ts — reads RagConfig from environment variables at runtime.
10
140
  *
@@ -245,4 +375,4 @@ declare class OllamaProvider implements ILLMProvider {
245
375
  ping(): Promise<boolean>;
246
376
  }
247
377
 
248
- export { AnthropicProvider, BaseVectorProvider, ChatMessage, ChatOptions, ChromaDBProvider, EmbedOptions, EmbeddingConfig, ILLMProvider, LLMConfig, LLMFactory, MilvusProvider, MongoDBProvider, OllamaProvider, OpenAIProvider, PineconeProvider, PostgreSQLProvider, QdrantProvider, RagConfig, RedisProvider, UpsertDocument, VectorDBConfig, VectorMatch, WeaviateProvider, getRagConfig };
378
+ export { AnthropicProvider, BaseVectorProvider, ChatMessage, ChatOptions, ChatResponse, ChromaDBProvider, ConfigResolver, EmbedOptions, EmbeddingConfig, ILLMProvider, IngestDocument, LLMConfig, LLMFactory, MilvusProvider, MongoDBProvider, OllamaProvider, OpenAIProvider, PineconeProvider, Pipeline, PostgreSQLProvider, ProviderRegistry, QdrantProvider, RagConfig, RedisProvider, UpsertDocument, VectorDBConfig, VectorMatch, VectorPlugin, WeaviateProvider, getRagConfig };
package/dist/server.d.ts CHANGED
@@ -1,10 +1,140 @@
1
- import { e as RagConfig, g as VectorDBConfig, f as UpsertDocument, V as VectorMatch, L as LLMConfig, c as EmbeddingConfig, I as ILLMProvider, C as ChatMessage, a as ChatOptions, E as EmbedOptions } from './Pipeline-Bo6CUCox.js';
2
- export { b as ChatResponse, d as IngestDocument, P as Pipeline, R as RAGConfig, U as UIConfig } from './Pipeline-Bo6CUCox.js';
3
- import { B as BaseVectorProvider } from './DocumentChunker-BQ5kQD7B.js';
4
- export { C as Chunk, a as ChunkOptions, b as ConfigResolver, D as DocumentChunker, P as ProviderRegistry, V as VectorPlugin } from './DocumentChunker-BQ5kQD7B.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-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
5
  export { createChatHandler, createHealthHandler, createIngestHandler, createUploadHandler } from './handlers/index.js';
6
6
  import 'next/server';
7
7
 
8
+ /**
9
+ * VectorPlugin — main orchestrator class.
10
+ * This is the primary interface for host applications.
11
+ */
12
+ declare class VectorPlugin {
13
+ private config;
14
+ private pipeline;
15
+ /**
16
+ * Initializes the plugin with the host configuration.
17
+ * @param hostConfig - Configuration object passed from the host application.
18
+ */
19
+ constructor(hostConfig?: Partial<RagConfig>);
20
+ /**
21
+ * Get the current resolved configuration.
22
+ */
23
+ getConfig(): RagConfig;
24
+ /**
25
+ * Run a chat query.
26
+ */
27
+ chat(message: string, history?: ChatMessage[], namespace?: string): Promise<ChatResponse>;
28
+ /**
29
+ * Ingest documents into the vector database.
30
+ */
31
+ ingest(documents: IngestDocument[], namespace?: string): Promise<Array<{
32
+ docId: string;
33
+ chunksIngested: number;
34
+ }>>;
35
+ /**
36
+ * Check the health of the connected providers.
37
+ */
38
+ health(): Promise<Record<string, boolean>>;
39
+ }
40
+
41
+ /**
42
+ * Pipeline — orchestrates the RAG flow: Embed → Search → Augment → Generate.
43
+ */
44
+ declare class Pipeline {
45
+ private vectorDB;
46
+ private llmProvider;
47
+ private embeddingProvider;
48
+ private chunker;
49
+ private config;
50
+ private initialised;
51
+ constructor(config: RagConfig);
52
+ initialize(): Promise<void>;
53
+ ingest(documents: IngestDocument[], namespace?: string): Promise<Array<{
54
+ docId: string;
55
+ chunksIngested: number;
56
+ }>>;
57
+ ask(question: string, history?: ChatMessage[], namespace?: string): Promise<ChatResponse>;
58
+ health(): Promise<Record<string, boolean>>;
59
+ }
60
+
61
+ /**
62
+ * ConfigResolver — validates and normalizes host configuration.
63
+ * It merges host-provided config with environment defaults.
64
+ */
65
+ declare class ConfigResolver {
66
+ /**
67
+ * Resolves the final configuration by merging host-provided config with defaults.
68
+ * @param hostConfig - Partial configuration passed from the host application.
69
+ */
70
+ static resolve(hostConfig?: Partial<RagConfig>): RagConfig;
71
+ /**
72
+ * Validates the configuration for required fields.
73
+ */
74
+ static validate(config: RagConfig): void;
75
+ }
76
+
77
+ /**
78
+ * BaseVectorProvider — Abstract base class for all vector database providers.
79
+ * Each provider (Pinecone, Milvus, Redis, etc.) must extend this class.
80
+ */
81
+ declare abstract class BaseVectorProvider {
82
+ protected readonly config: VectorDBConfig;
83
+ protected readonly indexName: string;
84
+ constructor(config: VectorDBConfig);
85
+ /**
86
+ * Initialise the connection (create tables, verify index, etc.)
87
+ */
88
+ abstract initialize(): Promise<void>;
89
+ /**
90
+ * Insert or update a single vector + content pair.
91
+ */
92
+ abstract upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
93
+ /**
94
+ * Batch upsert for efficient ingestion of many documents.
95
+ */
96
+ abstract batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
97
+ /**
98
+ * Find the top-K most similar vectors to the query vector.
99
+ */
100
+ abstract query(vector: number[], topK: number, namespace?: string, filter?: Record<string, unknown>): Promise<VectorMatch[]>;
101
+ /**
102
+ * Delete a stored vector by ID.
103
+ */
104
+ abstract delete(id: string, namespace?: string): Promise<void>;
105
+ /**
106
+ * Delete all vectors in a namespace (full data reset for a project).
107
+ */
108
+ abstract deleteNamespace(namespace: string): Promise<void>;
109
+ /**
110
+ * Check if the underlying DB is reachable.
111
+ */
112
+ abstract ping(): Promise<boolean>;
113
+ /**
114
+ * Gracefully close the connection.
115
+ */
116
+ abstract disconnect(): Promise<void>;
117
+ }
118
+
119
+ /**
120
+ * ProviderRegistry — dynamic provider loader for Vector DBs and LLMs.
121
+ */
122
+ declare class ProviderRegistry {
123
+ private static vectorProviders;
124
+ /**
125
+ * Register a custom vector provider.
126
+ */
127
+ static registerVectorProvider(name: string, providerClass: new (config: VectorDBConfig) => BaseVectorProvider): void;
128
+ /**
129
+ * Creates a vector database provider based on the configuration.
130
+ */
131
+ static createVectorProvider(config: VectorDBConfig): Promise<BaseVectorProvider>;
132
+ /**
133
+ * Creates an LLM provider based on the configuration.
134
+ */
135
+ static createLLMProvider(llmConfig: LLMConfig, embeddingConfig?: EmbeddingConfig): ILLMProvider;
136
+ }
137
+
8
138
  /**
9
139
  * serverConfig.ts — reads RagConfig from environment variables at runtime.
10
140
  *
@@ -245,4 +375,4 @@ declare class OllamaProvider implements ILLMProvider {
245
375
  ping(): Promise<boolean>;
246
376
  }
247
377
 
248
- export { AnthropicProvider, BaseVectorProvider, ChatMessage, ChatOptions, ChromaDBProvider, EmbedOptions, EmbeddingConfig, ILLMProvider, LLMConfig, LLMFactory, MilvusProvider, MongoDBProvider, OllamaProvider, OpenAIProvider, PineconeProvider, PostgreSQLProvider, QdrantProvider, RagConfig, RedisProvider, UpsertDocument, VectorDBConfig, VectorMatch, WeaviateProvider, getRagConfig };
378
+ export { AnthropicProvider, BaseVectorProvider, ChatMessage, ChatOptions, ChatResponse, ChromaDBProvider, ConfigResolver, EmbedOptions, EmbeddingConfig, ILLMProvider, IngestDocument, LLMConfig, LLMFactory, MilvusProvider, MongoDBProvider, OllamaProvider, OpenAIProvider, PineconeProvider, Pipeline, PostgreSQLProvider, ProviderRegistry, QdrantProvider, RagConfig, RedisProvider, UpsertDocument, VectorDBConfig, VectorMatch, VectorPlugin, WeaviateProvider, getRagConfig };
package/dist/server.mjs CHANGED
@@ -10,26 +10,25 @@ import {
10
10
  import {
11
11
  WeaviateProvider
12
12
  } from "./chunk-V75V7BT2.mjs";
13
- import {
14
- createChatHandler,
15
- createHealthHandler,
16
- createIngestHandler,
17
- createUploadHandler
18
- } from "./chunk-FGGSVVSY.mjs";
19
13
  import {
20
14
  ConfigResolver,
21
15
  DocumentChunker,
22
16
  Pipeline,
23
17
  ProviderRegistry,
24
18
  VectorPlugin,
19
+ createChatHandler,
20
+ createHealthHandler,
21
+ createIngestHandler,
22
+ createUploadHandler,
25
23
  getRagConfig
26
- } from "./chunk-AIAB2IEE.mjs";
24
+ } from "./chunk-BP4U4TT5.mjs";
27
25
  import {
28
26
  AnthropicProvider,
29
27
  LLMFactory,
30
28
  OllamaProvider,
31
29
  OpenAIProvider
32
- } from "./chunk-GD3QJFNN.mjs";
30
+ } from "./chunk-JI6VD5TJ.mjs";
31
+ import "./chunk-UKDXCXW7.mjs";
33
32
  import {
34
33
  PineconeProvider
35
34
  } from "./chunk-AALIF3AL.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retrivora-ai/rag-engine",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Retrivora AI is a plug-and-play AI engine for RAG chat experiences — generic vector DB + LLM provider, embeddable or standalone.",
5
5
  "author": "Abhinav Alkuchi",
6
6
  "license": "MIT",
@@ -38,6 +38,23 @@
38
38
  "import": "./dist/server.mjs"
39
39
  }
40
40
  },
41
+ "browser": {
42
+ "child_process": false,
43
+ "fs": false,
44
+ "net": false,
45
+ "tls": false,
46
+ "crypto": false,
47
+ "os": false,
48
+ "path": false,
49
+ "stream": false,
50
+ "http": false,
51
+ "https": false,
52
+ "zlib": false,
53
+ "mongodb": false,
54
+ "pg": false,
55
+ "pdf-parse": false,
56
+ "mammoth": false
57
+ },
41
58
  "files": [
42
59
  "dist",
43
60
  "src",
@@ -47,7 +64,7 @@
47
64
  "scripts": {
48
65
  "dev": "next dev",
49
66
  "build": "next build",
50
- "build:pkg": "tsup src/index.ts src/handlers/index.ts src/server.ts --format cjs,esm --dts --clean --tsconfig tsconfig.build.json --external react,react-dom,next",
67
+ "build:pkg": "tsup src/index.ts src/handlers/index.ts src/server.ts --format cjs,esm --dts --clean --tsconfig tsconfig.build.json --external react,react-dom,next,mongodb,pg,openai,@anthropic-ai/sdk,@pinecone-database/pinecone,axios,lucide-react,mammoth,pdf-parse,react-markdown,remark-gfm,next-themes",
51
68
  "start": "next start",
52
69
  "lint": "eslint",
53
70
  "prepublishOnly": "npm run build:pkg"
@@ -5,16 +5,8 @@ import { RagConfig } from '../config/RagConfig';
5
5
  import { VectorMatch } from '../types';
6
6
  import { ProviderRegistry } from './ProviderRegistry';
7
7
 
8
- export interface IngestDocument {
9
- docId: string;
10
- content: string;
11
- metadata?: Record<string, unknown>;
12
- }
13
-
14
- export interface ChatResponse {
15
- reply: string;
16
- sources: VectorMatch[];
17
- }
8
+ // Moved to src/types/index.ts
9
+ import { IngestDocument, ChatResponse } from '../types';
18
10
 
19
11
  /**
20
12
  * Pipeline — orchestrates the RAG flow: Embed → Search → Augment → Generate.
@@ -1,6 +1,7 @@
1
1
  import { RagConfig } from '../config/RagConfig';
2
2
  import { ConfigResolver } from './ConfigResolver';
3
- import { Pipeline, IngestDocument, ChatResponse } from './Pipeline';
3
+ import { Pipeline } from './Pipeline';
4
+ import { IngestDocument, ChatResponse } from '../types';
4
5
  import { ChatMessage } from '../llm/ILLMProvider';
5
6
 
6
7
  /**
package/src/index.ts CHANGED
@@ -3,12 +3,6 @@
3
3
  * This entry point is CLIENT-SAFE and can be imported in React Client Components.
4
4
  */
5
5
 
6
- // ── Core Plugin Architecture ─────────────────────────────────
7
- export { VectorPlugin } from './core/VectorPlugin';
8
- export { ConfigResolver } from './core/ConfigResolver';
9
- export { ProviderRegistry } from './core/ProviderRegistry';
10
- export { Pipeline } from './core/Pipeline';
11
-
12
6
  // ── React Components ─────────────────────────────────────────
13
7
  export { ChatWidget } from './components/ChatWidget';
14
8
  export { ChatWindow } from './components/ChatWindow';
@@ -23,7 +17,7 @@ export { useRagChat } from './hooks/useRagChat';
23
17
  export type { RagConfig, VectorDBConfig, LLMConfig, EmbeddingConfig, UIConfig, RAGConfig } from './config/RagConfig';
24
18
  export type { VectorMatch, UpsertDocument } from './types';
25
19
  export type { ILLMProvider, ChatMessage, ChatOptions, EmbedOptions } from './llm/ILLMProvider';
26
- export type { IngestDocument, ChatResponse } from './core/Pipeline';
20
+ export type { IngestDocument, ChatResponse } from './types';
27
21
  export type { Chunk, ChunkOptions } from './rag/DocumentChunker';
28
22
  export type { ClientConfig } from './components/ConfigProvider';
29
23
  export type { RagMessage, UseRagChatOptions, UseRagChatReturn } from './hooks/useRagChat';
package/src/server.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  export type { RagConfig, VectorDBConfig, LLMConfig, EmbeddingConfig, UIConfig, RAGConfig } from './config/RagConfig';
8
8
  export type { VectorMatch, UpsertDocument } from './types';
9
9
  export type { ILLMProvider, ChatMessage, ChatOptions, EmbedOptions } from './llm/ILLMProvider';
10
- export type { IngestDocument, ChatResponse } from './core/Pipeline';
10
+ export type { IngestDocument, ChatResponse } from './types';
11
11
  export type { Chunk, ChunkOptions } from './rag/DocumentChunker';
12
12
 
13
13
  // ── Server-Only Logic (Node.js dependent) ─────────────────────
@@ -11,3 +11,14 @@ export interface UpsertDocument {
11
11
  content: string;
12
12
  metadata?: Record<string, unknown>;
13
13
  }
14
+
15
+ export interface IngestDocument {
16
+ docId: string;
17
+ content: string;
18
+ metadata?: Record<string, unknown>;
19
+ }
20
+
21
+ export interface ChatResponse {
22
+ reply: string;
23
+ sources: VectorMatch[];
24
+ }
@@ -1,155 +0,0 @@
1
- import { e as RagConfig, C as ChatMessage, b as ChatResponse, d as IngestDocument, g as VectorDBConfig, f as UpsertDocument, V as VectorMatch, L as LLMConfig, c as EmbeddingConfig, I as ILLMProvider } from './Pipeline-Bo6CUCox.js';
2
-
3
- /**
4
- * VectorPlugin — main orchestrator class.
5
- * This is the primary interface for host applications.
6
- */
7
- declare class VectorPlugin {
8
- private config;
9
- private pipeline;
10
- /**
11
- * Initializes the plugin with the host configuration.
12
- * @param hostConfig - Configuration object passed from the host application.
13
- */
14
- constructor(hostConfig?: Partial<RagConfig>);
15
- /**
16
- * Get the current resolved configuration.
17
- */
18
- getConfig(): RagConfig;
19
- /**
20
- * Run a chat query.
21
- */
22
- chat(message: string, history?: ChatMessage[], namespace?: string): Promise<ChatResponse>;
23
- /**
24
- * Ingest documents into the vector database.
25
- */
26
- ingest(documents: IngestDocument[], namespace?: string): Promise<Array<{
27
- docId: string;
28
- chunksIngested: number;
29
- }>>;
30
- /**
31
- * Check the health of the connected providers.
32
- */
33
- health(): Promise<Record<string, boolean>>;
34
- }
35
-
36
- /**
37
- * ConfigResolver — validates and normalizes host configuration.
38
- * It merges host-provided config with environment defaults.
39
- */
40
- declare class ConfigResolver {
41
- /**
42
- * Resolves the final configuration by merging host-provided config with defaults.
43
- * @param hostConfig - Partial configuration passed from the host application.
44
- */
45
- static resolve(hostConfig?: Partial<RagConfig>): RagConfig;
46
- /**
47
- * Validates the configuration for required fields.
48
- */
49
- static validate(config: RagConfig): void;
50
- }
51
-
52
- /**
53
- * BaseVectorProvider — Abstract base class for all vector database providers.
54
- * Each provider (Pinecone, Milvus, Redis, etc.) must extend this class.
55
- */
56
- declare abstract class BaseVectorProvider {
57
- protected readonly config: VectorDBConfig;
58
- protected readonly indexName: string;
59
- constructor(config: VectorDBConfig);
60
- /**
61
- * Initialise the connection (create tables, verify index, etc.)
62
- */
63
- abstract initialize(): Promise<void>;
64
- /**
65
- * Insert or update a single vector + content pair.
66
- */
67
- abstract upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
68
- /**
69
- * Batch upsert for efficient ingestion of many documents.
70
- */
71
- abstract batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
72
- /**
73
- * Find the top-K most similar vectors to the query vector.
74
- */
75
- abstract query(vector: number[], topK: number, namespace?: string, filter?: Record<string, unknown>): Promise<VectorMatch[]>;
76
- /**
77
- * Delete a stored vector by ID.
78
- */
79
- abstract delete(id: string, namespace?: string): Promise<void>;
80
- /**
81
- * Delete all vectors in a namespace (full data reset for a project).
82
- */
83
- abstract deleteNamespace(namespace: string): Promise<void>;
84
- /**
85
- * Check if the underlying DB is reachable.
86
- */
87
- abstract ping(): Promise<boolean>;
88
- /**
89
- * Gracefully close the connection.
90
- */
91
- abstract disconnect(): Promise<void>;
92
- }
93
-
94
- /**
95
- * ProviderRegistry — dynamic provider loader for Vector DBs and LLMs.
96
- */
97
- declare class ProviderRegistry {
98
- private static vectorProviders;
99
- /**
100
- * Register a custom vector provider.
101
- */
102
- static registerVectorProvider(name: string, providerClass: new (config: VectorDBConfig) => BaseVectorProvider): void;
103
- /**
104
- * Creates a vector database provider based on the configuration.
105
- */
106
- static createVectorProvider(config: VectorDBConfig): Promise<BaseVectorProvider>;
107
- /**
108
- * Creates an LLM provider based on the configuration.
109
- */
110
- static createLLMProvider(llmConfig: LLMConfig, embeddingConfig?: EmbeddingConfig): ILLMProvider;
111
- }
112
-
113
- /**
114
- * DocumentChunker — splits long text into overlapping chunks
115
- * suitable for vector embedding and retrieval.
116
- *
117
- * Strategy: sentence-aware sliding window
118
- * 1. Split on sentence boundaries
119
- * 2. Accumulate sentences into chunks up to `chunkSize` characters
120
- * 3. Carry over `chunkOverlap` characters from the previous chunk
121
- */
122
- interface Chunk {
123
- id: string;
124
- content: string;
125
- metadata?: Record<string, unknown>;
126
- }
127
- interface ChunkOptions {
128
- /** Target chunk size in characters (default 1000) */
129
- chunkSize?: number;
130
- /** Overlap between consecutive chunks in characters (default 200) */
131
- chunkOverlap?: number;
132
- /** Source document identifier used as ID prefix */
133
- docId?: string;
134
- /** Extra metadata to attach to every chunk */
135
- metadata?: Record<string, unknown>;
136
- }
137
- declare class DocumentChunker {
138
- private readonly chunkSize;
139
- private readonly chunkOverlap;
140
- constructor(chunkSize?: number, chunkOverlap?: number);
141
- /**
142
- * Split a single text string into overlapping chunks.
143
- */
144
- chunk(text: string, options?: ChunkOptions): Chunk[];
145
- /**
146
- * Chunk multiple documents at once.
147
- */
148
- chunkMany(documents: Array<{
149
- content: string;
150
- docId?: string;
151
- metadata?: Record<string, unknown>;
152
- }>): Chunk[];
153
- }
154
-
155
- export { BaseVectorProvider as B, type Chunk as C, DocumentChunker as D, ProviderRegistry as P, VectorPlugin as V, type ChunkOptions as a, ConfigResolver as b };