@retrivora-ai/rag-engine 1.8.1 → 1.8.3
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/{ILLMProvider-BfRgI1Xh.d.mts → ILLMProvider-BOJFz3Na.d.mts} +47 -1
- package/dist/{ILLMProvider-BfRgI1Xh.d.ts → ILLMProvider-BOJFz3Na.d.ts} +47 -1
- package/dist/handlers/index.d.mts +2 -2
- package/dist/handlers/index.d.ts +2 -2
- package/dist/handlers/index.js +509 -162
- package/dist/handlers/index.mjs +5849 -15
- package/dist/{index-1Z4GuYBi.d.ts → index-BwpcaziY.d.ts} +4 -2
- package/dist/{index-BV0z5mb6.d.mts → index-D3V9Et2M.d.mts} +4 -2
- package/dist/index.d.mts +30 -16
- package/dist/index.d.ts +30 -16
- package/dist/index.js +1999 -1210
- package/dist/index.mjs +2041 -1205
- package/dist/server.d.mts +21 -25
- package/dist/server.d.ts +21 -25
- package/dist/server.js +536 -163
- package/dist/server.mjs +5923 -67
- package/package.json +9 -7
- package/src/app/api/upload/route.ts +4 -0
- package/src/app/constants.tsx +2 -2
- package/src/app/globals.css +35 -11
- package/src/app/page.tsx +12 -321
- package/src/components/AmbientBackground.tsx +29 -0
- package/src/components/ArchitectureCard.tsx +17 -0
- package/src/components/ArchitectureCardsSection.tsx +15 -0
- package/src/components/ChatWidget.tsx +0 -1
- package/src/components/ChatWindow.tsx +32 -0
- package/src/components/CodeViewer.tsx +51 -0
- package/src/components/ConfigProvider.tsx +1 -0
- package/src/components/DocViewer.tsx +37 -0
- package/src/components/DocumentUpload.tsx +44 -1
- package/src/components/Documentation.tsx +58 -0
- package/src/components/DynamicChart.tsx +27 -2
- package/src/components/Hero.tsx +59 -0
- package/src/components/HourglassLoader.tsx +87 -0
- package/src/components/Lifecycle.tsx +37 -0
- package/src/components/MarkdownComponents.tsx +143 -0
- package/src/components/MessageBubble.tsx +91 -1012
- package/src/components/Navbar.tsx +55 -0
- package/src/components/ObservabilityPanel.tsx +374 -0
- package/src/components/ProductCard.tsx +3 -1
- package/src/components/UIDispatcher.tsx +341 -0
- package/src/components/VisualizationRenderer.tsx +48 -26
- package/src/config/ConfigBuilder.ts +38 -1
- package/src/core/LangChainAgent.ts +1 -4
- package/src/core/Pipeline.ts +209 -86
- package/src/core/QueryProcessor.ts +65 -0
- package/src/handlers/index.ts +72 -12
- package/src/hooks/useRagChat.ts +19 -9
- package/src/index.ts +9 -1
- package/src/providers/vectordb/MultiTablePostgresProvider.ts +150 -64
- package/src/rag/Reranker.ts +99 -6
- package/src/types/chat.ts +2 -0
- package/src/types/index.ts +52 -0
- package/src/types/props.ts +9 -1
- package/src/utils/ProductExtractor.ts +347 -0
- package/src/utils/UITransformer.ts +4 -53
- package/src/utils/synonyms.ts +78 -0
- package/dist/ChromaDBProvider-MIDOR4FW.mjs +0 -8
- package/dist/MilvusProvider-U7SKC27V.mjs +0 -8
- package/dist/MongoDBProvider-YNKC7EJ6.mjs +0 -8
- package/dist/MultiTablePostgresProvider-YY7LPNJK.mjs +0 -8
- package/dist/PineconeProvider-QZNRKTN2.mjs +0 -8
- package/dist/QdrantProvider-RLJTNGPY.mjs +0 -8
- package/dist/RedisProvider-SR65SCKV.mjs +0 -8
- package/dist/SimpleGraphProvider-SLOXO4M7.mjs +0 -62
- package/dist/UniversalVectorProvider-IN67OS56.mjs +0 -9
- package/dist/WeaviateProvider-5FWDFITI.mjs +0 -8
- package/dist/chunk-5AJ4XHLW.mjs +0 -201
- package/dist/chunk-5YGUXK7Z.mjs +0 -80
- package/dist/chunk-BFYLQYQU.mjs +0 -3985
- package/dist/chunk-CFVEZTBJ.mjs +0 -102
- package/dist/chunk-IMP6FUCY.mjs +0 -30
- package/dist/chunk-LR3VMDVK.mjs +0 -157
- package/dist/chunk-M6JSPGAR.mjs +0 -117
- package/dist/chunk-PSFPZXHX.mjs +0 -245
- package/dist/chunk-R3RGUMHE.mjs +0 -218
- package/dist/chunk-U55XRW3U.mjs +0 -96
- package/dist/chunk-VUQJVIJT.mjs +0 -148
- package/dist/chunk-X4TOT24V.mjs +0 -89
- package/dist/chunk-YLTMFW4M.mjs +0 -49
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import "./chunk-X4TOT24V.mjs";
|
|
2
|
-
|
|
3
|
-
// src/providers/graphdb/BaseGraphProvider.ts
|
|
4
|
-
var BaseGraphProvider = class {
|
|
5
|
-
constructor(config) {
|
|
6
|
-
this.config = config;
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
// src/providers/graphdb/SimpleGraphProvider.ts
|
|
11
|
-
var SimpleGraphProvider = class extends BaseGraphProvider {
|
|
12
|
-
constructor() {
|
|
13
|
-
super(...arguments);
|
|
14
|
-
this.nodes = /* @__PURE__ */ new Map();
|
|
15
|
-
this.edges = [];
|
|
16
|
-
}
|
|
17
|
-
async initialize() {
|
|
18
|
-
console.log("[SimpleGraphProvider] Initialised in-memory graph store.");
|
|
19
|
-
}
|
|
20
|
-
async addNodes(nodes) {
|
|
21
|
-
for (const node of nodes) {
|
|
22
|
-
this.nodes.set(node.id, node);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
async addEdges(edges) {
|
|
26
|
-
this.edges.push(...edges);
|
|
27
|
-
}
|
|
28
|
-
async query(queryText, limit = 5) {
|
|
29
|
-
const q = queryText.toLowerCase();
|
|
30
|
-
const matchedNodes = Array.from(this.nodes.values()).filter(
|
|
31
|
-
(node) => node.id.toLowerCase().includes(q) || node.label.toLowerCase().includes(q) || JSON.stringify(node.properties).toLowerCase().includes(q)
|
|
32
|
-
).slice(0, limit);
|
|
33
|
-
const matchedNodeIds = new Set(matchedNodes.map((n) => n.id));
|
|
34
|
-
const matchedEdges = this.edges.filter(
|
|
35
|
-
(edge) => matchedNodeIds.has(edge.source) || matchedNodeIds.has(edge.target)
|
|
36
|
-
);
|
|
37
|
-
for (const edge of matchedEdges) {
|
|
38
|
-
if (!matchedNodeIds.has(edge.source)) {
|
|
39
|
-
const source = this.nodes.get(edge.source);
|
|
40
|
-
if (source) matchedNodes.push(source);
|
|
41
|
-
}
|
|
42
|
-
if (!matchedNodeIds.has(edge.target)) {
|
|
43
|
-
const target = this.nodes.get(edge.target);
|
|
44
|
-
if (target) matchedNodes.push(target);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
nodes: Array.from(new Set(matchedNodes)),
|
|
49
|
-
edges: matchedEdges
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
async ping() {
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
async disconnect() {
|
|
56
|
-
this.nodes.clear();
|
|
57
|
-
this.edges = [];
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
export {
|
|
61
|
-
SimpleGraphProvider
|
|
62
|
-
};
|
package/dist/chunk-5AJ4XHLW.mjs
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseVectorProvider
|
|
3
|
-
} from "./chunk-IMP6FUCY.mjs";
|
|
4
|
-
import {
|
|
5
|
-
__spreadValues
|
|
6
|
-
} from "./chunk-X4TOT24V.mjs";
|
|
7
|
-
|
|
8
|
-
// src/providers/vectordb/MongoDBProvider.ts
|
|
9
|
-
import { MongoClient } from "mongodb";
|
|
10
|
-
var MongoDBProvider = class extends BaseVectorProvider {
|
|
11
|
-
constructor(config) {
|
|
12
|
-
super(config);
|
|
13
|
-
const opts = config.options;
|
|
14
|
-
if (!opts.uri || !opts.database || !opts.collection) {
|
|
15
|
-
throw new Error("[MongoDBProvider] options uri, database, and collection are required.");
|
|
16
|
-
}
|
|
17
|
-
this.client = new MongoClient(opts.uri, { serverSelectionTimeoutMS: 5e3 });
|
|
18
|
-
this.dbName = opts.database;
|
|
19
|
-
this.collectionName = opts.collection;
|
|
20
|
-
this.embeddingKey = opts.embeddingKey || "embedding";
|
|
21
|
-
this.contentKey = opts.contentKey || "content";
|
|
22
|
-
this.metadataKey = opts.metadataKey || "metadata";
|
|
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
|
-
}
|
|
89
|
-
async initialize() {
|
|
90
|
-
await this.client.connect();
|
|
91
|
-
this.db = this.client.db(this.dbName);
|
|
92
|
-
this.collection = this.db.collection(this.collectionName);
|
|
93
|
-
}
|
|
94
|
-
async upsert(doc, namespace) {
|
|
95
|
-
const document = __spreadValues({
|
|
96
|
-
_id: doc.id,
|
|
97
|
-
[this.embeddingKey]: doc.vector,
|
|
98
|
-
[this.contentKey]: doc.content,
|
|
99
|
-
[this.metadataKey]: doc.metadata || {}
|
|
100
|
-
}, namespace ? { namespace } : {});
|
|
101
|
-
await this.collection.updateOne({ _id: doc.id }, { $set: document }, { upsert: true });
|
|
102
|
-
}
|
|
103
|
-
async batchUpsert(docs, namespace) {
|
|
104
|
-
const operations = docs.map((doc) => ({
|
|
105
|
-
updateOne: {
|
|
106
|
-
filter: { _id: doc.id },
|
|
107
|
-
update: {
|
|
108
|
-
$set: __spreadValues({
|
|
109
|
-
[this.embeddingKey]: doc.vector,
|
|
110
|
-
[this.contentKey]: doc.content,
|
|
111
|
-
[this.metadataKey]: doc.metadata || {}
|
|
112
|
-
}, namespace ? { namespace } : {})
|
|
113
|
-
},
|
|
114
|
-
upsert: true
|
|
115
|
-
}
|
|
116
|
-
}));
|
|
117
|
-
await this.collection.bulkWrite(operations);
|
|
118
|
-
}
|
|
119
|
-
async query(vector, topK, namespace, filter) {
|
|
120
|
-
const publicFilter = this.sanitizeFilter(filter);
|
|
121
|
-
const vectorSearchFilter = {};
|
|
122
|
-
const matchFilter = {};
|
|
123
|
-
if (namespace) {
|
|
124
|
-
vectorSearchFilter.namespace = namespace;
|
|
125
|
-
}
|
|
126
|
-
for (const [key, value] of Object.entries(publicFilter)) {
|
|
127
|
-
if (key === "namespace") {
|
|
128
|
-
vectorSearchFilter.namespace = value;
|
|
129
|
-
} else {
|
|
130
|
-
matchFilter[key] = value;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
const pipeline = [
|
|
134
|
-
{
|
|
135
|
-
$vectorSearch: __spreadValues({
|
|
136
|
-
index: this.config.indexName || "vector_index",
|
|
137
|
-
path: this.embeddingKey,
|
|
138
|
-
queryVector: vector,
|
|
139
|
-
numCandidates: this.config.options.numCandidates || Math.max(topK * 20, 200),
|
|
140
|
-
limit: topK * 2
|
|
141
|
-
}, Object.keys(vectorSearchFilter).length > 0 ? { filter: vectorSearchFilter } : {})
|
|
142
|
-
}
|
|
143
|
-
];
|
|
144
|
-
if (Object.keys(matchFilter).length > 0) {
|
|
145
|
-
pipeline.push({ $match: matchFilter });
|
|
146
|
-
}
|
|
147
|
-
pipeline.push(
|
|
148
|
-
{ $limit: topK },
|
|
149
|
-
{
|
|
150
|
-
$project: {
|
|
151
|
-
_id: 1,
|
|
152
|
-
[this.contentKey]: 1,
|
|
153
|
-
[this.metadataKey]: 1,
|
|
154
|
-
namespace: 1,
|
|
155
|
-
score: { $meta: "vectorSearchScore" }
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
);
|
|
159
|
-
const results = await this.collection.aggregate(pipeline).toArray();
|
|
160
|
-
return results.map((res) => ({
|
|
161
|
-
id: res._id,
|
|
162
|
-
content: res[this.contentKey],
|
|
163
|
-
metadata: res[this.metadataKey] || {},
|
|
164
|
-
score: res.score
|
|
165
|
-
}));
|
|
166
|
-
}
|
|
167
|
-
async delete(id, namespace) {
|
|
168
|
-
await this.collection.deleteOne(__spreadValues({ _id: id }, namespace ? { namespace } : {}));
|
|
169
|
-
}
|
|
170
|
-
async deleteNamespace(namespace) {
|
|
171
|
-
await this.collection.deleteMany({ namespace });
|
|
172
|
-
}
|
|
173
|
-
sanitizeFilter(filter) {
|
|
174
|
-
const sanitized = super.sanitizeFilter(filter);
|
|
175
|
-
const mongoFilter = {};
|
|
176
|
-
for (const [key, value] of Object.entries(sanitized)) {
|
|
177
|
-
if (key.startsWith("__") || key === "keywords" || key === "queryText") continue;
|
|
178
|
-
if (key === "namespace") {
|
|
179
|
-
mongoFilter[key] = value;
|
|
180
|
-
} else {
|
|
181
|
-
mongoFilter[`${this.metadataKey}.${key}`] = value;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return mongoFilter;
|
|
185
|
-
}
|
|
186
|
-
async ping() {
|
|
187
|
-
try {
|
|
188
|
-
await this.db.command({ ping: 1 });
|
|
189
|
-
return true;
|
|
190
|
-
} catch (e) {
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
async disconnect() {
|
|
195
|
-
await this.client.close();
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
export {
|
|
200
|
-
MongoDBProvider
|
|
201
|
-
};
|
package/dist/chunk-5YGUXK7Z.mjs
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseVectorProvider
|
|
3
|
-
} from "./chunk-IMP6FUCY.mjs";
|
|
4
|
-
import {
|
|
5
|
-
__spreadValues
|
|
6
|
-
} from "./chunk-X4TOT24V.mjs";
|
|
7
|
-
|
|
8
|
-
// src/providers/vectordb/RedisProvider.ts
|
|
9
|
-
import axios from "axios";
|
|
10
|
-
var RedisProvider = class extends BaseVectorProvider {
|
|
11
|
-
constructor(config) {
|
|
12
|
-
super(config);
|
|
13
|
-
const opts = config.options;
|
|
14
|
-
const baseUrl = opts.baseUrl || opts.url || (opts.host ? `http://${opts.host}:${opts.port || 6379}` : void 0);
|
|
15
|
-
if (!baseUrl) throw new Error("[RedisProvider] options.baseUrl is required");
|
|
16
|
-
this.http = axios.create({
|
|
17
|
-
baseURL: baseUrl,
|
|
18
|
-
headers: __spreadValues({
|
|
19
|
-
"Content-Type": "application/json"
|
|
20
|
-
}, opts.apiKey ? { Authorization: `Bearer ${opts.apiKey}` } : {})
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
async initialize() {
|
|
24
|
-
await this.ping();
|
|
25
|
-
}
|
|
26
|
-
async upsert(doc, namespace) {
|
|
27
|
-
const key = namespace ? `${namespace}:${doc.id}` : String(doc.id);
|
|
28
|
-
await this.http.post("/", ["JSON.SET", key, "$", JSON.stringify({
|
|
29
|
-
vector: doc.vector,
|
|
30
|
-
content: doc.content,
|
|
31
|
-
metadata: doc.metadata || {}
|
|
32
|
-
})]);
|
|
33
|
-
}
|
|
34
|
-
async batchUpsert(docs, namespace) {
|
|
35
|
-
for (const doc of docs) {
|
|
36
|
-
await this.upsert(doc, namespace);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
40
|
-
async query(vector, topK, namespace, _filter) {
|
|
41
|
-
const payload = {
|
|
42
|
-
index: this.indexName,
|
|
43
|
-
vector,
|
|
44
|
-
topK,
|
|
45
|
-
namespace
|
|
46
|
-
};
|
|
47
|
-
const { data } = await this.http.post("/search", payload);
|
|
48
|
-
return (data.results || []).map((res) => ({
|
|
49
|
-
id: res["id"],
|
|
50
|
-
score: res["score"],
|
|
51
|
-
content: res["content"],
|
|
52
|
-
metadata: res["metadata"] || {}
|
|
53
|
-
}));
|
|
54
|
-
}
|
|
55
|
-
async delete(id, namespace) {
|
|
56
|
-
const key = namespace ? `${namespace}:${id}` : id;
|
|
57
|
-
await this.http.post("/", ["DEL", key]);
|
|
58
|
-
}
|
|
59
|
-
async deleteNamespace(namespace) {
|
|
60
|
-
console.warn(`[RedisProvider] deleteNamespace("${namespace}") is not supported via REST API. Use Redis CLI: SCAN + DEL`);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Redis is TCP-based and has no HTTP health endpoint.
|
|
64
|
-
* Returns true; actual connectivity is validated on the first operation.
|
|
65
|
-
*/
|
|
66
|
-
async ping() {
|
|
67
|
-
try {
|
|
68
|
-
await this.http.post("/", ["PING"]);
|
|
69
|
-
return true;
|
|
70
|
-
} catch (e) {
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
async disconnect() {
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export {
|
|
79
|
-
RedisProvider
|
|
80
|
-
};
|