@retrivora-ai/rag-engine 0.4.4 → 1.0.0

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 (73) hide show
  1. package/README.md +32 -57
  2. package/dist/{ChromaDBProvider-GI7TB7GJ.mjs → ChromaDBProvider-APQVJ5F7.mjs} +2 -2
  3. package/dist/{DocumentChunker-3yElxTO3.d.mts → DocumentChunker-C-sCZPhi.d.mts} +6 -6
  4. package/dist/{DocumentChunker-3yElxTO3.d.ts → DocumentChunker-C-sCZPhi.d.ts} +6 -6
  5. package/dist/{MilvusProvider-WDVTFB7D.mjs → MilvusProvider-35US67MS.mjs} +2 -2
  6. package/dist/{MongoDBProvider-ZKW34AEL.mjs → MongoDBProvider-COVYZDP6.mjs} +2 -2
  7. package/dist/{PineconeProvider-BE2JWSPD.mjs → PineconeProvider-AWFJQDZL.mjs} +2 -2
  8. package/dist/{PostgreSQLProvider-5HHTK4SU.mjs → PostgreSQLProvider-IEYRJ7XJ.mjs} +2 -2
  9. package/dist/{QdrantProvider-XVDVBNIG.mjs → QdrantProvider-M6TQYZRO.mjs} +2 -2
  10. package/dist/{RagConfig-BgRDL9Vy.d.mts → RagConfig-DRJO4hGU.d.mts} +12 -1
  11. package/dist/{RagConfig-BgRDL9Vy.d.ts → RagConfig-DRJO4hGU.d.ts} +12 -1
  12. package/dist/{RedisProvider-EK2R2PQH.mjs → RedisProvider-3G5PBLZ4.mjs} +2 -2
  13. package/dist/{SimpleGraphProvider-M6T7SE7D.mjs → SimpleGraphProvider-UK7DJW37.mjs} +1 -1
  14. package/dist/{UniversalVectorProvider-YIDRX6VT.mjs → UniversalVectorProvider-FYQ3B2PW.mjs} +3 -3
  15. package/dist/{WeaviateProvider-4CAPQ7UY.mjs → WeaviateProvider-ITHO36IL.mjs} +2 -2
  16. package/dist/{chunk-5KNBWQM6.mjs → chunk-4A47RCG2.mjs} +5 -1
  17. package/dist/{chunk-EDLTMSNY.mjs → chunk-67AJ6SMD.mjs} +1 -1
  18. package/dist/{chunk-IWHCAQEA.mjs → chunk-7SOSCZGS.mjs} +68 -7
  19. package/dist/{chunk-LJWWPTWE.mjs → chunk-FLOSGE6A.mjs} +76 -14
  20. package/dist/{chunk-H6RKMU7W.mjs → chunk-NXUCKY5L.mjs} +1 -1
  21. package/dist/{chunk-KTS3LLHY.mjs → chunk-OOQXNLXD.mjs} +5 -5
  22. package/dist/{chunk-OKY5P6RA.mjs → chunk-P4HAQ7KB.mjs} +1186 -1345
  23. package/dist/chunk-QMIKLALV.mjs +57 -0
  24. package/dist/{chunk-3QWAK3RZ.mjs → chunk-TYHTZIDP.mjs} +6 -2
  25. package/dist/{chunk-GQT5LF4G.mjs → chunk-U6KHVZLF.mjs} +2 -2
  26. package/dist/{chunk-RK2UDJA2.mjs → chunk-WGSZNY3X.mjs} +1 -1
  27. package/dist/{chunk-XCNXPECE.mjs → chunk-ZNBKHNJ4.mjs} +55 -1
  28. package/dist/handlers/index.d.mts +2 -2
  29. package/dist/handlers/index.d.ts +2 -2
  30. package/dist/handlers/index.js +1417 -1377
  31. package/dist/handlers/index.mjs +3 -3
  32. package/dist/index-CrGMwXfO.d.ts +112 -0
  33. package/dist/index-v669iV-k.d.mts +112 -0
  34. package/dist/index.d.mts +5 -5
  35. package/dist/index.d.ts +5 -5
  36. package/dist/index.mjs +2 -2
  37. package/dist/server.d.mts +104 -158
  38. package/dist/server.d.ts +104 -158
  39. package/dist/server.js +1419 -1379
  40. package/dist/server.mjs +12 -12
  41. package/package.json +5 -1
  42. package/src/components/DocumentUpload.tsx +1 -1
  43. package/src/config/RagConfig.ts +7 -0
  44. package/src/core/ConfigValidator.ts +66 -492
  45. package/src/core/LangChainAgent.ts +78 -0
  46. package/src/core/Pipeline.ts +210 -222
  47. package/src/core/ProviderHealthCheck.ts +35 -406
  48. package/src/core/ProviderInterfaces.ts +37 -0
  49. package/src/core/ProviderRegistry.ts +70 -55
  50. package/src/core/QueryProcessor.ts +173 -0
  51. package/src/llm/ILLMProvider.ts +10 -0
  52. package/src/llm/LLMFactory.ts +33 -13
  53. package/src/llm/providers/AnthropicProvider.ts +55 -15
  54. package/src/llm/providers/GeminiProvider.ts +51 -0
  55. package/src/llm/providers/OllamaProvider.ts +100 -15
  56. package/src/llm/providers/OpenAIProvider.ts +60 -11
  57. package/src/providers/vectordb/BaseVectorProvider.ts +11 -0
  58. package/src/providers/vectordb/MilvusProvider.ts +4 -0
  59. package/src/providers/vectordb/MongoDBProvider.ts +75 -11
  60. package/src/providers/vectordb/PineconeProvider.ts +60 -5
  61. package/src/providers/vectordb/PostgreSQLProvider.ts +84 -14
  62. package/src/providers/vectordb/QdrantProvider.ts +4 -0
  63. package/src/providers/vectordb/WeaviateProvider.ts +8 -4
  64. package/src/rag/DocumentChunker.ts +15 -19
  65. package/src/rag/EntityExtractor.ts +1 -1
  66. package/src/rag/LlamaIndexIngestor.ts +61 -0
  67. package/src/rag/Reranker.ts +20 -0
  68. package/src/server.ts +1 -1
  69. package/src/types/index.ts +9 -0
  70. package/src/utils/DocumentParser.ts +1 -1
  71. package/dist/chunk-FWCSY2DS.mjs +0 -37
  72. package/dist/index-7qeLTPBL.d.mts +0 -114
  73. package/dist/index-DowY4_K0.d.ts +0 -114
package/README.md CHANGED
@@ -10,44 +10,42 @@
10
10
 
11
11
  ---
12
12
 
13
- ## ✨ Features
13
+ ## ✨ Features (v1.0.0)
14
14
 
15
15
  | Category | Options |
16
16
  |---|---|
17
- | **Vector DBs** | Pinecone, pgVector (PostgreSQL), MongoDB Atlas, ChromaDB, Qdrant, universal REST adapters |
18
- | **LLM Providers** | OpenAI, Anthropic Claude, Google Gemini, Ollama, LiteLLM, universal REST adapters |
17
+ | **Vector DBs** | Pinecone, pgVector (PostgreSQL), MongoDB Atlas, ChromaDB, Qdrant, Milvus, Weaviate, Redis |
18
+ | **LLM Providers** | OpenAI, Anthropic Claude, Google Gemini, Ollama, LiteLLM, Universal REST |
19
+ | **Integrations** | **LangChain** (Agentic orchestration), **LlamaIndex** (Semantic chunking) |
19
20
  | **Document Ingestion** | Universal support for **PDF**, **DOCX**, **CSV**, **JSON**, **MD**, **TXT** |
20
- | **UI** | Full-page `ChatWindow` + floating `ChatWidget`, fully branded & responsive |
21
- | **RAG** | Configurable chunk size/overlap, top-K retrieval, score threshold, namespaced multi-tenancy |
21
+ | **Architecture** | **Modular & Pluggable** registry-based system with static health checks & validators |
22
+ | **RAG Patterns** | Simple, Hybrid, Graph-based, and Agentic workflows |
22
23
 
23
24
  ---
24
25
 
25
26
  ## 🚀 How it Works
26
27
 
27
- Retrivora AI acts as a universal bridge between your data and your users. It normalizes different AI providers and Vector databases into a single interface.
28
+ Retrivora AI acts as a universal bridge between your data and your users. It normalizes different AI providers and Vector databases into a single interface using a **registry-based architecture**.
28
29
 
29
- 1. **Ingest**: Upload or send documents to the `/api/upload` endpoint. They are automatically parsed, chunked, and embedded.
30
- 2. **Retrieve**: When a user asks a question, the system converts it to a vector and searches your configured database.
31
- 3. **Generate**: The retrieved context is combined with the user query and sent to your configured LLM (OpenAI, Claude, etc.) to generate a grounded response.
30
+ 1. **Ingest**: Upload or send documents to the `/api/upload` endpoint. They are parsed and chunked using **LlamaIndex** strategies if configured.
31
+ 2. **Retrieve**: Queries are processed via the [QueryProcessor](file:///src/core/QueryProcessor.ts) to extract semantic hints and filter criteria.
32
+ 3. **Generate**: Context is retrieved and processed through a [Pipeline](file:///src/core/Pipeline.ts) (or [LangChainAgent](file:///src/core/LangChainAgent.ts)) to produce grounded, streaming responses.
32
33
 
33
- ### 📦 How to Install
34
-
35
- To integrate Retrivora AI into your existing Next.js project, simply run:
34
+ ### 📦 Installation
36
35
 
37
36
  ```bash
38
37
  npm install @retrivora-ai/rag-engine
39
38
  ```
40
39
 
41
- Alternatively, if you want to run the standalone demo application:
40
+ ---
42
41
 
43
- ```bash
44
- git clone https://github.com/abhinav1201/ai-accelerator
45
- cd ai-accelerator
46
- npm install
47
- cp .env.example .env.local
48
- # Fill in your API keys in .env.local
49
- npm run dev
50
- ```
42
+ ## 🛠️ Pluggable Architecture
43
+
44
+ Starting with v1.0.0, the engine uses a modular registry for all providers. Every provider now exposes:
45
+ - **Static Validators**: `getValidator()` for deep configuration schema checks.
46
+ - **Static Health Checkers**: `getHealthChecker()` for real-time connectivity and capability validation.
47
+
48
+ This decoupling allows you to add custom providers without modifying the core engine logic.
51
49
 
52
50
  ---
53
51
 
@@ -55,8 +53,6 @@ npm run dev
55
53
 
56
54
  ### 1. Embed the ChatWidget
57
55
 
58
- Wrap your application in the `ConfigProvider` and add the `ChatWidget`.
59
-
60
56
  ```tsx
61
57
  import { ConfigProvider, ChatWidget } from '@retrivora-ai/rag-engine';
62
58
 
@@ -82,25 +78,28 @@ export default function Layout({ children }) {
82
78
 
83
79
  ### 2. Mount the API routes
84
80
 
85
- Create standard Next.js route handlers and plug in the library's factories.
86
-
87
81
  ```ts
88
82
  // src/app/api/chat/route.ts
89
83
  import { createChatHandler, getRagConfig } from '@retrivora-ai/rag-engine/server';
90
84
  export const POST = createChatHandler(getRagConfig());
91
85
 
92
- // src/app/api/upload/route.ts (Handles PDF, DOCX, etc.)
86
+ // src/app/api/upload/route.ts
93
87
  import { createUploadHandler, getRagConfig } from '@retrivora-ai/rag-engine/server';
94
88
  export const POST = createUploadHandler(getRagConfig());
95
89
  ```
96
90
 
97
- ### 3. Use RAGPipeline programmatically
91
+ ### 3. Use Pipeline programmatically
98
92
 
99
93
  ```ts
100
- import { RAGPipeline } from '@retrivora-ai/rag-engine/server';
94
+ import { Pipeline, getRagConfig } from '@retrivora-ai/rag-engine/server';
101
95
 
102
- const pipeline = new RAGPipeline(config);
96
+ const config = getRagConfig();
97
+ const pipeline = new Pipeline(config);
98
+
99
+ // Ingest documents
103
100
  await pipeline.ingest([{ docId: 'readme', content: 'Your document text here' }]);
101
+
102
+ // Ask questions
104
103
  const { reply, sources } = await pipeline.ask('What is the refund policy?');
105
104
  ```
106
105
 
@@ -113,34 +112,10 @@ The library is entirely dynamic. You can switch between providers simply by upda
113
112
  | Variable | Description |
114
113
  |---|---|
115
114
  | `RAG_PROJECT_ID` | Project namespace for data isolation |
116
- | `VECTOR_DB_PROVIDER` | `pinecone`, `pgvector`, `mongodb`, or `universal_rest` |
117
- | `VECTOR_UNIVERSAL_PROFILE` | `pinecone-rest`, `mongodb-atlas`, `chromadb`, `qdrant` |
118
- | `LLM_PROVIDER` | `openai`, `anthropic`, `ollama`, or `universal_rest` |
119
- | `LLM_UNIVERSAL_PROFILE` | `openai-compatible`, `litellm`, `anthropic-claude`, `google-gemini` |
120
- | `EMBEDDING_PROVIDER` | `openai`, `ollama`, or `rest` |
121
-
122
- ---
123
-
124
- ## Architecture
125
-
126
- ```
127
- User Query
128
- |
129
- v
130
- [embed query] <-- EmbeddingProvider (OpenAI / Ollama / Custom)
131
- |
132
- v
133
- [vector search] <-- IVectorDB (Pinecone / pgVector / MongoDB / Chroma / REST)
134
- |
135
- v
136
- [build context]
137
- |
138
- v
139
- [LLM chat] <-- ILLMProvider (OpenAI / Anthropic / Gemini / LiteLLM)
140
- |
141
- v
142
- ChatResponse { reply, sources[] }
143
- ```
115
+ | `VECTOR_DB_PROVIDER` | `pinecone`, `pgvector`, `mongodb`, `milvus`, `qdrant`, `weaviate` |
116
+ | `LLM_PROVIDER` | `openai`, `anthropic`, `gemini`, `ollama` |
117
+ | `EMBEDDING_PROVIDER` | `openai`, `ollama`, `google-gemini` |
118
+ | `RAG_ARCHITECTURE` | `simple`, `hybrid`, `graph`, `agentic` |
144
119
 
145
120
  ---
146
121
 
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  ChromaDBProvider
3
- } from "./chunk-RK2UDJA2.mjs";
3
+ } from "./chunk-WGSZNY3X.mjs";
4
4
  import "./chunk-IMP6FUCY.mjs";
5
- import "./chunk-FWCSY2DS.mjs";
5
+ import "./chunk-QMIKLALV.mjs";
6
6
  export {
7
7
  ChromaDBProvider
8
8
  };
@@ -30,6 +30,11 @@ interface ILLMProvider {
30
30
  * @returns – the assistant's reply text
31
31
  */
32
32
  chat(messages: ChatMessage[], context: string, options?: ChatOptions): Promise<string>;
33
+ /**
34
+ * Send a streaming chat completion request.
35
+ * @returns – an async iterable of text chunks
36
+ */
37
+ chatStream?(messages: ChatMessage[], context: string, options?: ChatOptions): AsyncIterable<string>;
33
38
  /**
34
39
  * Generate an embedding vector for the given text.
35
40
  * @param text – text to embed
@@ -83,15 +88,10 @@ declare class DocumentChunker {
83
88
  constructor(chunkSize?: number, chunkOverlap?: number, separators?: string[]);
84
89
  /**
85
90
  * Split a single text string into overlapping chunks using a recursive strategy.
91
+ * Preserves structural boundaries (Markdown headers) where possible.
86
92
  */
87
93
  chunk(text: string, options?: ChunkOptions): Chunk[];
88
- /**
89
- * Recursively split text based on separators.
90
- */
91
94
  private recursiveSplit;
92
- /**
93
- * Chunk multiple documents at once.
94
- */
95
95
  chunkMany(documents: Array<{
96
96
  content: string;
97
97
  docId?: string | number;
@@ -30,6 +30,11 @@ interface ILLMProvider {
30
30
  * @returns – the assistant's reply text
31
31
  */
32
32
  chat(messages: ChatMessage[], context: string, options?: ChatOptions): Promise<string>;
33
+ /**
34
+ * Send a streaming chat completion request.
35
+ * @returns – an async iterable of text chunks
36
+ */
37
+ chatStream?(messages: ChatMessage[], context: string, options?: ChatOptions): AsyncIterable<string>;
33
38
  /**
34
39
  * Generate an embedding vector for the given text.
35
40
  * @param text – text to embed
@@ -83,15 +88,10 @@ declare class DocumentChunker {
83
88
  constructor(chunkSize?: number, chunkOverlap?: number, separators?: string[]);
84
89
  /**
85
90
  * Split a single text string into overlapping chunks using a recursive strategy.
91
+ * Preserves structural boundaries (Markdown headers) where possible.
86
92
  */
87
93
  chunk(text: string, options?: ChunkOptions): Chunk[];
88
- /**
89
- * Recursively split text based on separators.
90
- */
91
94
  private recursiveSplit;
92
- /**
93
- * Chunk multiple documents at once.
94
- */
95
95
  chunkMany(documents: Array<{
96
96
  content: string;
97
97
  docId?: string | number;
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  MilvusProvider
3
- } from "./chunk-3QWAK3RZ.mjs";
3
+ } from "./chunk-TYHTZIDP.mjs";
4
4
  import "./chunk-IMP6FUCY.mjs";
5
- import "./chunk-FWCSY2DS.mjs";
5
+ import "./chunk-QMIKLALV.mjs";
6
6
  export {
7
7
  MilvusProvider
8
8
  };
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  MongoDBProvider
3
- } from "./chunk-IWHCAQEA.mjs";
3
+ } from "./chunk-7SOSCZGS.mjs";
4
4
  import "./chunk-IMP6FUCY.mjs";
5
- import "./chunk-FWCSY2DS.mjs";
5
+ import "./chunk-QMIKLALV.mjs";
6
6
  export {
7
7
  MongoDBProvider
8
8
  };
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  PineconeProvider
3
- } from "./chunk-XCNXPECE.mjs";
3
+ } from "./chunk-ZNBKHNJ4.mjs";
4
4
  import "./chunk-IMP6FUCY.mjs";
5
- import "./chunk-FWCSY2DS.mjs";
5
+ import "./chunk-QMIKLALV.mjs";
6
6
  export {
7
7
  PineconeProvider
8
8
  };
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  PostgreSQLProvider
3
- } from "./chunk-LJWWPTWE.mjs";
3
+ } from "./chunk-FLOSGE6A.mjs";
4
4
  import "./chunk-IMP6FUCY.mjs";
5
- import "./chunk-FWCSY2DS.mjs";
5
+ import "./chunk-QMIKLALV.mjs";
6
6
  export {
7
7
  PostgreSQLProvider
8
8
  };
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  QdrantProvider
3
- } from "./chunk-5KNBWQM6.mjs";
3
+ } from "./chunk-4A47RCG2.mjs";
4
4
  import "./chunk-IMP6FUCY.mjs";
5
- import "./chunk-FWCSY2DS.mjs";
5
+ import "./chunk-QMIKLALV.mjs";
6
6
  export {
7
7
  QdrantProvider
8
8
  };
@@ -35,6 +35,10 @@ interface GraphSearchResult {
35
35
  nodes: GraphNode[];
36
36
  edges: Edge[];
37
37
  }
38
+ interface RetrievalResult {
39
+ sources: VectorMatch[];
40
+ graphData?: GraphSearchResult;
41
+ }
38
42
 
39
43
  /**
40
44
  * constants.ts — Centralized definitions of acceptable configuration values.
@@ -73,6 +77,9 @@ interface VectorDBConfig {
73
77
  * - scorePath?: string (e.g. 'similarity')
74
78
  * - contentPath?: string (e.g. 'text')
75
79
  *
80
+ * For 'mongodb', the following options are also supported:
81
+ * - numCandidates?: number // controls search recall depth
82
+ *
76
83
  * For multi-table PostgreSQL search, the following options are also supported:
77
84
  * - tables?: string[] | string
78
85
  * - searchFields?: string[] | string // optional override for which columns receive exact-match boosts
@@ -170,6 +177,10 @@ interface RAGConfig {
170
177
  chunkOverlap?: number;
171
178
  /** Characters used to split text, in order of priority */
172
179
  separators?: string[];
180
+ /** Overall RAG architecture pattern */
181
+ architecture?: 'simple' | 'graph' | 'hybrid' | 'agentic';
182
+ /** Chunking strategy to use during ingestion */
183
+ chunkingStrategy?: 'recursive' | 'markdown' | 'semantic' | 'llamaindex';
173
184
  /** Whether to use query transformation (e.g. HyDE) */
174
185
  useQueryTransformation?: boolean;
175
186
  /** Whether to use graph-based retrieval */
@@ -197,4 +208,4 @@ interface RagConfig {
197
208
  graphDb?: GraphDBConfig;
198
209
  }
199
210
 
200
- export type { ChatResponse as C, EmbeddingConfig as E, GraphDBConfig as G, IngestDocument as I, LLMConfig as L, RAGConfig as R, UIConfig as U, VectorMatch as V, EmbeddingProvider as a, LLMProvider as b, RagConfig as c, UpsertDocument as d, VectorDBConfig as e, VectorDBProvider as f, GraphNode as g, Edge as h, GraphSearchResult as i };
211
+ export type { ChatResponse as C, EmbeddingConfig as E, GraphDBConfig as G, IngestDocument as I, LLMConfig as L, RAGConfig as R, UIConfig as U, VectorMatch as V, EmbeddingProvider as a, LLMProvider as b, RagConfig as c, UpsertDocument as d, VectorDBConfig as e, VectorDBProvider as f, RetrievalResult as g, GraphNode as h, Edge as i, GraphSearchResult as j };
@@ -35,6 +35,10 @@ interface GraphSearchResult {
35
35
  nodes: GraphNode[];
36
36
  edges: Edge[];
37
37
  }
38
+ interface RetrievalResult {
39
+ sources: VectorMatch[];
40
+ graphData?: GraphSearchResult;
41
+ }
38
42
 
39
43
  /**
40
44
  * constants.ts — Centralized definitions of acceptable configuration values.
@@ -73,6 +77,9 @@ interface VectorDBConfig {
73
77
  * - scorePath?: string (e.g. 'similarity')
74
78
  * - contentPath?: string (e.g. 'text')
75
79
  *
80
+ * For 'mongodb', the following options are also supported:
81
+ * - numCandidates?: number // controls search recall depth
82
+ *
76
83
  * For multi-table PostgreSQL search, the following options are also supported:
77
84
  * - tables?: string[] | string
78
85
  * - searchFields?: string[] | string // optional override for which columns receive exact-match boosts
@@ -170,6 +177,10 @@ interface RAGConfig {
170
177
  chunkOverlap?: number;
171
178
  /** Characters used to split text, in order of priority */
172
179
  separators?: string[];
180
+ /** Overall RAG architecture pattern */
181
+ architecture?: 'simple' | 'graph' | 'hybrid' | 'agentic';
182
+ /** Chunking strategy to use during ingestion */
183
+ chunkingStrategy?: 'recursive' | 'markdown' | 'semantic' | 'llamaindex';
173
184
  /** Whether to use query transformation (e.g. HyDE) */
174
185
  useQueryTransformation?: boolean;
175
186
  /** Whether to use graph-based retrieval */
@@ -197,4 +208,4 @@ interface RagConfig {
197
208
  graphDb?: GraphDBConfig;
198
209
  }
199
210
 
200
- export type { ChatResponse as C, EmbeddingConfig as E, GraphDBConfig as G, IngestDocument as I, LLMConfig as L, RAGConfig as R, UIConfig as U, VectorMatch as V, EmbeddingProvider as a, LLMProvider as b, RagConfig as c, UpsertDocument as d, VectorDBConfig as e, VectorDBProvider as f, GraphNode as g, Edge as h, GraphSearchResult as i };
211
+ export type { ChatResponse as C, EmbeddingConfig as E, GraphDBConfig as G, IngestDocument as I, LLMConfig as L, RAGConfig as R, UIConfig as U, VectorMatch as V, EmbeddingProvider as a, LLMProvider as b, RagConfig as c, UpsertDocument as d, VectorDBConfig as e, VectorDBProvider as f, RetrievalResult as g, GraphNode as h, Edge as i, GraphSearchResult as j };
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  RedisProvider
3
- } from "./chunk-H6RKMU7W.mjs";
3
+ } from "./chunk-NXUCKY5L.mjs";
4
4
  import "./chunk-IMP6FUCY.mjs";
5
- import "./chunk-FWCSY2DS.mjs";
5
+ import "./chunk-QMIKLALV.mjs";
6
6
  export {
7
7
  RedisProvider
8
8
  };
@@ -1,4 +1,4 @@
1
- import "./chunk-FWCSY2DS.mjs";
1
+ import "./chunk-QMIKLALV.mjs";
2
2
 
3
3
  // src/providers/graphdb/BaseGraphProvider.ts
4
4
  var BaseGraphProvider = class {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  UniversalVectorProvider
3
- } from "./chunk-GQT5LF4G.mjs";
4
- import "./chunk-EDLTMSNY.mjs";
3
+ } from "./chunk-U6KHVZLF.mjs";
4
+ import "./chunk-67AJ6SMD.mjs";
5
5
  import "./chunk-IMP6FUCY.mjs";
6
- import "./chunk-FWCSY2DS.mjs";
6
+ import "./chunk-QMIKLALV.mjs";
7
7
  export {
8
8
  UniversalVectorProvider
9
9
  };
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  WeaviateProvider
3
- } from "./chunk-KTS3LLHY.mjs";
3
+ } from "./chunk-OOQXNLXD.mjs";
4
4
  import "./chunk-IMP6FUCY.mjs";
5
- import "./chunk-FWCSY2DS.mjs";
5
+ import "./chunk-QMIKLALV.mjs";
6
6
  export {
7
7
  WeaviateProvider
8
8
  };
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-IMP6FUCY.mjs";
4
4
  import {
5
5
  __spreadValues
6
- } from "./chunk-FWCSY2DS.mjs";
6
+ } from "./chunk-QMIKLALV.mjs";
7
7
 
8
8
  // src/providers/vectordb/QdrantProvider.ts
9
9
  import axios from "axios";
@@ -99,6 +99,10 @@ var QdrantProvider = class extends BaseVectorProvider {
99
99
  vector,
100
100
  limit: topK,
101
101
  with_payload: true,
102
+ params: {
103
+ hnsw_ef: this.config.options.efSearch || Math.max(topK * 20, 128),
104
+ exact: false
105
+ },
102
106
  filter: namespace ? {
103
107
  must: [{ key: "namespace", match: { value: namespace } }]
104
108
  } : void 0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __spreadValues
3
- } from "./chunk-FWCSY2DS.mjs";
3
+ } from "./chunk-QMIKLALV.mjs";
4
4
 
5
5
  // src/utils/templateUtils.ts
6
6
  function isRecord(value) {
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-IMP6FUCY.mjs";
4
4
  import {
5
5
  __spreadValues
6
- } from "./chunk-FWCSY2DS.mjs";
6
+ } from "./chunk-QMIKLALV.mjs";
7
7
 
8
8
  // src/providers/vectordb/MongoDBProvider.ts
9
9
  import { MongoClient } from "mongodb";
@@ -21,6 +21,71 @@ var MongoDBProvider = class extends BaseVectorProvider {
21
21
  this.contentKey = opts.contentKey || "content";
22
22
  this.metadataKey = opts.metadataKey || "metadata";
23
23
  }
24
+ static getValidator() {
25
+ return {
26
+ validate(config) {
27
+ const errors = [];
28
+ const opts = config.options || {};
29
+ if (!opts.uri) {
30
+ errors.push({
31
+ field: "vectorDb.options.uri",
32
+ message: "MongoDB connection URI is required",
33
+ suggestion: "Set MONGODB_URI environment variable",
34
+ severity: "error"
35
+ });
36
+ }
37
+ if (!opts.database) {
38
+ errors.push({
39
+ field: "vectorDb.options.database",
40
+ message: "MongoDB database name is required",
41
+ severity: "error"
42
+ });
43
+ }
44
+ if (!opts.collection) {
45
+ errors.push({
46
+ field: "vectorDb.options.collection",
47
+ message: "MongoDB collection name is required",
48
+ severity: "error"
49
+ });
50
+ }
51
+ return errors;
52
+ }
53
+ };
54
+ }
55
+ static getHealthChecker() {
56
+ return {
57
+ async check(config) {
58
+ const opts = config.options || {};
59
+ const timestamp = Date.now();
60
+ try {
61
+ const { MongoClient: MongoClient2 } = await import("mongodb");
62
+ const client = new MongoClient2(opts.uri);
63
+ await client.connect();
64
+ const db = client.db(opts.database);
65
+ await db.command({ ping: 1 });
66
+ const collections = await db.listCollections({ name: opts.collection }).toArray();
67
+ await client.close();
68
+ return {
69
+ healthy: true,
70
+ provider: "mongodb",
71
+ capabilities: {
72
+ database: opts.database,
73
+ collection: opts.collection,
74
+ exists: collections.length > 0
75
+ },
76
+ timestamp
77
+ };
78
+ } catch (error) {
79
+ return {
80
+ healthy: false,
81
+ provider: "mongodb",
82
+ error: `Connection failed: ${error instanceof Error ? error.message : String(error)}`,
83
+ timestamp
84
+ };
85
+ }
86
+ }
87
+ };
88
+ }
24
89
  async initialize() {
25
90
  await this.client.connect();
26
91
  this.db = this.client.db(this.dbName);
@@ -59,7 +124,7 @@ var MongoDBProvider = class extends BaseVectorProvider {
59
124
  index: this.config.indexName || "vector_index",
60
125
  path: this.embeddingKey,
61
126
  queryVector: vector,
62
- numCandidates: Math.max(topK * 10, 100),
127
+ numCandidates: this.config.options.numCandidates || Math.max(topK * 20, 200),
63
128
  limit: topK
64
129
  }, Object.keys(publicFilter).length > 0 || namespace ? { filter: __spreadValues(__spreadValues({}, publicFilter), namespace ? { namespace } : {}) } : {})
65
130
  },
@@ -77,7 +142,7 @@ var MongoDBProvider = class extends BaseVectorProvider {
77
142
  return results.map((res) => ({
78
143
  id: res._id,
79
144
  content: res[this.contentKey],
80
- metadata: res[this.metadataKey],
145
+ metadata: res[this.metadataKey] || {},
81
146
  score: res.score
82
147
  }));
83
148
  }
@@ -87,10 +152,6 @@ var MongoDBProvider = class extends BaseVectorProvider {
87
152
  async deleteNamespace(namespace) {
88
153
  await this.collection.deleteMany({ namespace });
89
154
  }
90
- /**
91
- * Sanitise and flatten filter for MongoDB.
92
- * Strips internal engine fields and keywords.
93
- */
94
155
  sanitizeFilter(filter) {
95
156
  const sanitized = super.sanitizeFilter(filter);
96
157
  const mongoFilter = {};
@@ -14,6 +14,61 @@ var PostgreSQLProvider = class extends BaseVectorProvider {
14
14
  this.connectionString = opts.connectionString;
15
15
  this.dimensions = (_a = opts.dimensions) != null ? _a : 1536;
16
16
  }
17
+ static getValidator() {
18
+ return {
19
+ validate(config) {
20
+ const errors = [];
21
+ const opts = config.options || {};
22
+ if (!opts.connectionString) {
23
+ errors.push({
24
+ field: "vectorDb.options.connectionString",
25
+ message: "PostgreSQL connection string is required",
26
+ suggestion: "Set PGVECTOR_CONNECTION_STRING environment variable",
27
+ severity: "error"
28
+ });
29
+ }
30
+ if (opts.tables && typeof opts.tables !== "string" && !Array.isArray(opts.tables)) {
31
+ errors.push({
32
+ field: "vectorDb.options.tables",
33
+ message: "PostgreSQL tables must be a string or a string array",
34
+ severity: "error"
35
+ });
36
+ }
37
+ return errors;
38
+ }
39
+ };
40
+ }
41
+ static getHealthChecker() {
42
+ return {
43
+ async check(config) {
44
+ const opts = config.options || {};
45
+ const timestamp = Date.now();
46
+ try {
47
+ const { Client } = await import("pg");
48
+ const client = new Client({ connectionString: opts.connectionString });
49
+ await client.connect();
50
+ const result = await client.query(`
51
+ SELECT EXISTS(SELECT 1 FROM pg_extension WHERE extname = 'vector');
52
+ `);
53
+ const hasVector = result.rows[0].exists;
54
+ await client.end();
55
+ return {
56
+ healthy: true,
57
+ provider: "postgresql",
58
+ capabilities: { pgvectorInstalled: hasVector },
59
+ timestamp
60
+ };
61
+ } catch (error) {
62
+ return {
63
+ healthy: false,
64
+ provider: "postgresql",
65
+ error: `Connection failed: ${error instanceof Error ? error.message : String(error)}`,
66
+ timestamp
67
+ };
68
+ }
69
+ }
70
+ };
71
+ }
17
72
  async initialize() {
18
73
  this.pool = new Pool({ connectionString: this.connectionString });
19
74
  const client = await this.pool.connect();
@@ -99,20 +154,27 @@ var PostgreSQLProvider = class extends BaseVectorProvider {
99
154
  }).join(" AND ");
100
155
  whereClause = whereClause ? `${whereClause} AND ${filterConditions}` : `WHERE ${filterConditions}`;
101
156
  }
102
- const result = await this.pool.query(
103
- `SELECT id, content, metadata, 1 - (embedding <=> $1::vector) AS score
104
- FROM ${this.tableName}
105
- ${whereClause}
106
- ORDER BY embedding <=> $1::vector
107
- LIMIT $2`,
108
- params
109
- );
110
- return result.rows.map((row) => ({
111
- id: String(row["id"]),
112
- score: parseFloat(String(row["score"])),
113
- content: String(row["content"]),
114
- metadata: row["metadata"]
115
- }));
157
+ const client = await this.pool.connect();
158
+ try {
159
+ const efSearch = this.config.options.efSearch || Math.max(topK * 10, 40);
160
+ await client.query(`SET LOCAL hnsw.ef_search = ${efSearch}`);
161
+ const result = await client.query(
162
+ `SELECT id, content, metadata, 1 - (embedding <=> $1::vector) AS score
163
+ FROM ${this.tableName}
164
+ ${whereClause}
165
+ ORDER BY embedding <=> $1::vector
166
+ LIMIT $2`,
167
+ params
168
+ );
169
+ return result.rows.map((row) => ({
170
+ id: String(row["id"]),
171
+ score: parseFloat(String(row["score"])),
172
+ content: String(row["content"]),
173
+ metadata: row["metadata"]
174
+ }));
175
+ } finally {
176
+ client.release();
177
+ }
116
178
  }
117
179
  async delete(id, namespace) {
118
180
  const where = namespace ? "WHERE id = $1 AND namespace = $2" : "WHERE id = $1";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-IMP6FUCY.mjs";
4
4
  import {
5
5
  __spreadValues
6
- } from "./chunk-FWCSY2DS.mjs";
6
+ } from "./chunk-QMIKLALV.mjs";
7
7
 
8
8
  // src/providers/vectordb/RedisProvider.ts
9
9
  import axios from "axios";