@retrivora-ai/rag-engine 0.1.2 → 0.1.4
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 +8 -0
- package/dist/DocumentChunker-BQ5kQD7B.d.ts +155 -0
- package/dist/DocumentChunker-D9-fObJp.d.mts +155 -0
- package/dist/LLMFactory-XC55FTD2.mjs +7 -0
- package/dist/MilvusProvider-OO6QGZDZ.mjs +8 -0
- package/dist/MongoDBProvider-WWVJG3WT.mjs +8 -0
- package/dist/PineconeProvider-NJ675H7U.mjs +8 -0
- package/dist/{RAGPipeline-BmkIv1HD.d.mts → Pipeline-Bo6CUCox.d.mts} +76 -159
- package/dist/{RAGPipeline-BmkIv1HD.d.ts → Pipeline-Bo6CUCox.d.ts} +76 -159
- package/dist/PostgreSQLProvider-ISNMD3BE.mjs +8 -0
- package/dist/QdrantProvider-LJWOIGES.mjs +8 -0
- package/dist/RedisProvider-ASONNYBI.mjs +8 -0
- package/dist/WeaviateProvider-PSDCUGC7.mjs +8 -0
- package/dist/chunk-6FODXNUF.mjs +91 -0
- package/dist/chunk-7NXI6ZWX.mjs +89 -0
- package/dist/chunk-AALIF3AL.mjs +91 -0
- package/dist/chunk-AIAB2IEE.mjs +394 -0
- package/dist/chunk-FGGSVVSY.mjs +162 -0
- package/dist/chunk-GD3QJFNN.mjs +424 -0
- package/dist/chunk-HUGLYKD6.mjs +84 -0
- package/dist/chunk-I4E63NIC.mjs +24 -0
- package/dist/chunk-QEYVWVT5.mjs +102 -0
- package/dist/chunk-S5DRHETN.mjs +110 -0
- package/dist/chunk-V75V7BT2.mjs +117 -0
- package/dist/chunk-VOIWNO5O.mjs +11 -0
- package/dist/chunk-VPNRDXIA.mjs +74 -0
- package/dist/handlers/index.d.mts +9 -33
- package/dist/handlers/index.d.ts +9 -33
- package/dist/handlers/index.js +1477 -959
- package/dist/handlers/index.mjs +4 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1646 -19
- package/dist/index.mjs +14 -2
- package/dist/server.d.mts +93 -56
- package/dist/server.d.ts +93 -56
- package/dist/server.js +1531 -1096
- package/dist/server.mjs +56 -131
- package/package.json +1 -1
- package/src/app/page.tsx +1 -1
- package/src/components/MessageBubble.tsx +1 -1
- package/src/components/SourceCard.tsx +1 -1
- package/src/config/RagConfig.ts +1 -1
- package/src/config/serverConfig.ts +2 -2
- package/src/core/ConfigResolver.ts +69 -0
- package/src/core/Pipeline.ts +109 -0
- package/src/core/ProviderRegistry.ts +71 -0
- package/src/core/VectorPlugin.ts +51 -0
- package/src/handlers/index.ts +21 -100
- package/src/hooks/useRagChat.ts +1 -1
- package/src/index.ts +8 -6
- package/src/providers/vectordb/BaseVectorProvider.ts +61 -0
- package/src/providers/vectordb/ChromaDBProvider.ts +94 -0
- package/src/providers/vectordb/MilvusProvider.ts +100 -0
- package/src/providers/vectordb/MongoDBProvider.ts +118 -0
- package/src/{vectordb/adapters/PineconeAdapter.ts → providers/vectordb/PineconeProvider.ts} +21 -56
- package/src/{vectordb/adapters/PgVectorAdapter.ts → providers/vectordb/PostgreSQLProvider.ts} +23 -58
- package/src/providers/vectordb/QdrantProvider.ts +95 -0
- package/src/providers/vectordb/RedisProvider.ts +84 -0
- package/src/providers/vectordb/WeaviateProvider.ts +124 -0
- package/src/server.ts +16 -8
- package/src/test-refactor.ts +59 -0
- package/src/types/index.ts +13 -0
- package/src/utils/templateUtils.ts +6 -6
- package/dist/DocumentChunker-BUrIrcPk.d.mts +0 -43
- package/dist/DocumentChunker-BUrIrcPk.d.ts +0 -43
- package/dist/chunk-W57OWMJK.mjs +0 -1256
- package/dist/chunk-ZPXLQR5Q.mjs +0 -67
- package/src/rag/RAGPipeline.ts +0 -196
- package/src/vectordb/IVectorDB.ts +0 -75
- package/src/vectordb/VectorDBFactory.ts +0 -41
- package/src/vectordb/adapters/MongoDbAdapter.ts +0 -175
- package/src/vectordb/adapters/UniversalVectorDBAdapter.ts +0 -177
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { VectorPlugin } from './core/VectorPlugin';
|
|
2
|
+
|
|
3
|
+
async function testRefactor() {
|
|
4
|
+
console.log('🚀 Starting VectorPlugin Refactor Test...\n');
|
|
5
|
+
|
|
6
|
+
// Test 1: Initialization with Empty Config (should use env defaults or fallbacks)
|
|
7
|
+
console.log('--- Test 1: Default Config ---');
|
|
8
|
+
try {
|
|
9
|
+
const pluginDefault = new VectorPlugin();
|
|
10
|
+
const config = pluginDefault.getConfig();
|
|
11
|
+
console.log('✅ Resolved Project ID:', config.projectId);
|
|
12
|
+
console.log('✅ Resolved Vector DB Provider:', config.vectorDb.provider);
|
|
13
|
+
} catch (err) {
|
|
14
|
+
console.error('❌ Test 1 Failed:', (err as Error).message);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Test 2: Overriding Config from Host
|
|
18
|
+
console.log('\n--- Test 2: Host Override Config ---');
|
|
19
|
+
try {
|
|
20
|
+
const pluginOverride = new VectorPlugin({
|
|
21
|
+
projectId: 'host-override-test',
|
|
22
|
+
vectorDb: {
|
|
23
|
+
provider: 'milvus',
|
|
24
|
+
indexName: 'milvus-index',
|
|
25
|
+
options: { uri: 'http://localhost:19530' }
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const config = pluginOverride.getConfig();
|
|
29
|
+
console.log('✅ Resolved Project ID (Overridden):', config.projectId);
|
|
30
|
+
console.log('✅ Resolved Vector DB Provider (Overridden):', config.vectorDb.provider);
|
|
31
|
+
} catch (err) {
|
|
32
|
+
console.error('❌ Test 2 Failed:', (err as Error).message);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Test 3: Provider Registry Loading
|
|
36
|
+
console.log('\n--- Test 3: Provider Registry Loading ---');
|
|
37
|
+
try {
|
|
38
|
+
const { ProviderRegistry } = await import('./core/ProviderRegistry');
|
|
39
|
+
const milvusProvider = await ProviderRegistry.createVectorProvider({
|
|
40
|
+
provider: 'milvus',
|
|
41
|
+
indexName: 'test',
|
|
42
|
+
options: { uri: 'http://localhost' }
|
|
43
|
+
});
|
|
44
|
+
console.log('✅ Milvus Provider Instantiated:', milvusProvider.constructor.name);
|
|
45
|
+
|
|
46
|
+
const redisProvider = await ProviderRegistry.createVectorProvider({
|
|
47
|
+
provider: 'redis',
|
|
48
|
+
indexName: 'test',
|
|
49
|
+
options: { baseUrl: 'http://localhost', apiKey: 'test' }
|
|
50
|
+
});
|
|
51
|
+
console.log('✅ Redis Provider Instantiated:', redisProvider.constructor.name);
|
|
52
|
+
} catch (err) {
|
|
53
|
+
console.error('❌ Test 3 Failed:', (err as Error).message);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
console.log('\n✨ Refactor Test Completed.');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
testRefactor().catch(console.error);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface VectorMatch {
|
|
2
|
+
id: string;
|
|
3
|
+
score: number;
|
|
4
|
+
content: string;
|
|
5
|
+
metadata?: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface UpsertDocument {
|
|
9
|
+
id: string;
|
|
10
|
+
vector: number[];
|
|
11
|
+
content: string;
|
|
12
|
+
metadata?: Record<string, unknown>;
|
|
13
|
+
}
|
|
@@ -58,19 +58,19 @@ export function buildPayload(template: string, vars: Record<string, unknown>): u
|
|
|
58
58
|
/**
|
|
59
59
|
* Merges two objects, ignoring undefined, null, or empty string values in the override.
|
|
60
60
|
*/
|
|
61
|
-
export function mergeDefined<T extends
|
|
62
|
-
base: T,
|
|
61
|
+
export function mergeDefined<T extends object>(
|
|
62
|
+
base: T | undefined | null,
|
|
63
63
|
override?: Partial<T>
|
|
64
64
|
): T {
|
|
65
|
+
const merged = { ...(base || {}) } as T;
|
|
66
|
+
|
|
65
67
|
if (!override) {
|
|
66
|
-
return
|
|
68
|
+
return merged;
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
const merged = { ...base };
|
|
70
|
-
|
|
71
71
|
for (const [key, value] of Object.entries(override)) {
|
|
72
72
|
if (value !== undefined && value !== null && value !== '') {
|
|
73
|
-
merged
|
|
73
|
+
(merged as Record<string, unknown>)[key] = value;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DocumentChunker — splits long text into overlapping chunks
|
|
3
|
-
* suitable for vector embedding and retrieval.
|
|
4
|
-
*
|
|
5
|
-
* Strategy: sentence-aware sliding window
|
|
6
|
-
* 1. Split on sentence boundaries
|
|
7
|
-
* 2. Accumulate sentences into chunks up to `chunkSize` characters
|
|
8
|
-
* 3. Carry over `chunkOverlap` characters from the previous chunk
|
|
9
|
-
*/
|
|
10
|
-
interface Chunk {
|
|
11
|
-
id: string;
|
|
12
|
-
content: string;
|
|
13
|
-
metadata?: Record<string, unknown>;
|
|
14
|
-
}
|
|
15
|
-
interface ChunkOptions {
|
|
16
|
-
/** Target chunk size in characters (default 1000) */
|
|
17
|
-
chunkSize?: number;
|
|
18
|
-
/** Overlap between consecutive chunks in characters (default 200) */
|
|
19
|
-
chunkOverlap?: number;
|
|
20
|
-
/** Source document identifier used as ID prefix */
|
|
21
|
-
docId?: string;
|
|
22
|
-
/** Extra metadata to attach to every chunk */
|
|
23
|
-
metadata?: Record<string, unknown>;
|
|
24
|
-
}
|
|
25
|
-
declare class DocumentChunker {
|
|
26
|
-
private readonly chunkSize;
|
|
27
|
-
private readonly chunkOverlap;
|
|
28
|
-
constructor(chunkSize?: number, chunkOverlap?: number);
|
|
29
|
-
/**
|
|
30
|
-
* Split a single text string into overlapping chunks.
|
|
31
|
-
*/
|
|
32
|
-
chunk(text: string, options?: ChunkOptions): Chunk[];
|
|
33
|
-
/**
|
|
34
|
-
* Chunk multiple documents at once.
|
|
35
|
-
*/
|
|
36
|
-
chunkMany(documents: Array<{
|
|
37
|
-
content: string;
|
|
38
|
-
docId?: string;
|
|
39
|
-
metadata?: Record<string, unknown>;
|
|
40
|
-
}>): Chunk[];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export { type Chunk as C, DocumentChunker as D, type ChunkOptions as a };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DocumentChunker — splits long text into overlapping chunks
|
|
3
|
-
* suitable for vector embedding and retrieval.
|
|
4
|
-
*
|
|
5
|
-
* Strategy: sentence-aware sliding window
|
|
6
|
-
* 1. Split on sentence boundaries
|
|
7
|
-
* 2. Accumulate sentences into chunks up to `chunkSize` characters
|
|
8
|
-
* 3. Carry over `chunkOverlap` characters from the previous chunk
|
|
9
|
-
*/
|
|
10
|
-
interface Chunk {
|
|
11
|
-
id: string;
|
|
12
|
-
content: string;
|
|
13
|
-
metadata?: Record<string, unknown>;
|
|
14
|
-
}
|
|
15
|
-
interface ChunkOptions {
|
|
16
|
-
/** Target chunk size in characters (default 1000) */
|
|
17
|
-
chunkSize?: number;
|
|
18
|
-
/** Overlap between consecutive chunks in characters (default 200) */
|
|
19
|
-
chunkOverlap?: number;
|
|
20
|
-
/** Source document identifier used as ID prefix */
|
|
21
|
-
docId?: string;
|
|
22
|
-
/** Extra metadata to attach to every chunk */
|
|
23
|
-
metadata?: Record<string, unknown>;
|
|
24
|
-
}
|
|
25
|
-
declare class DocumentChunker {
|
|
26
|
-
private readonly chunkSize;
|
|
27
|
-
private readonly chunkOverlap;
|
|
28
|
-
constructor(chunkSize?: number, chunkOverlap?: number);
|
|
29
|
-
/**
|
|
30
|
-
* Split a single text string into overlapping chunks.
|
|
31
|
-
*/
|
|
32
|
-
chunk(text: string, options?: ChunkOptions): Chunk[];
|
|
33
|
-
/**
|
|
34
|
-
* Chunk multiple documents at once.
|
|
35
|
-
*/
|
|
36
|
-
chunkMany(documents: Array<{
|
|
37
|
-
content: string;
|
|
38
|
-
docId?: string;
|
|
39
|
-
metadata?: Record<string, unknown>;
|
|
40
|
-
}>): Chunk[];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export { type Chunk as C, DocumentChunker as D, type ChunkOptions as a };
|