@retrivora-ai/rag-engine 1.8.2 → 1.8.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/handlers/index.js +142 -16
- package/dist/handlers/index.mjs +5848 -17
- package/dist/index.css +3162 -0
- package/dist/index.d.mts +9 -15
- package/dist/index.d.ts +9 -15
- package/dist/index.js +1355 -919
- package/dist/index.mjs +1437 -896
- package/dist/server.d.mts +6 -0
- package/dist/server.d.ts +6 -0
- package/dist/server.js +171 -17
- package/dist/server.mjs +5923 -68
- package/package.json +8 -6
- package/src/app/globals.css +35 -11
- package/src/components/ChatWidget.tsx +0 -1
- package/src/components/MarkdownComponents.tsx +3 -0
- package/src/components/MessageBubble.tsx +3 -2
- package/src/components/ObservabilityPanel.tsx +1 -1
- package/src/components/UIDispatcher.tsx +0 -3
- package/src/config/ConfigBuilder.ts +38 -1
- package/src/core/LangChainAgent.ts +1 -4
- package/src/core/Pipeline.ts +31 -18
- package/src/core/QueryProcessor.ts +65 -0
- package/src/rag/Reranker.ts +99 -6
- package/src/tailwind.css +2 -0
- package/src/utils/ProductExtractor.ts +3 -3
- package/dist/ChromaDBProvider-MIDOR4FW.mjs +0 -8
- package/dist/MilvusProvider-U7SKC27V.mjs +0 -8
- package/dist/MongoDBProvider-YNKC7EJ6.mjs +0 -8
- package/dist/MultiTablePostgresProvider-ZLGSKTJR.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-CFVEZTBJ.mjs +0 -102
- package/dist/chunk-ICKRMZQK.mjs +0 -76
- package/dist/chunk-IMP6FUCY.mjs +0 -30
- package/dist/chunk-LR3VMDVK.mjs +0 -157
- package/dist/chunk-LZVVLSDN.mjs +0 -4077
- package/dist/chunk-M6JSPGAR.mjs +0 -117
- package/dist/chunk-OZFBG4BA.mjs +0 -291
- package/dist/chunk-PSFPZXHX.mjs +0 -245
- 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
package/dist/chunk-LR3VMDVK.mjs
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
buildPayload,
|
|
3
|
-
resolvePath
|
|
4
|
-
} from "./chunk-YLTMFW4M.mjs";
|
|
5
|
-
import {
|
|
6
|
-
BaseVectorProvider
|
|
7
|
-
} from "./chunk-IMP6FUCY.mjs";
|
|
8
|
-
import {
|
|
9
|
-
__spreadValues
|
|
10
|
-
} from "./chunk-X4TOT24V.mjs";
|
|
11
|
-
|
|
12
|
-
// src/providers/vectordb/UniversalVectorProvider.ts
|
|
13
|
-
import axios from "axios";
|
|
14
|
-
var UniversalVectorProvider = class extends BaseVectorProvider {
|
|
15
|
-
constructor(config) {
|
|
16
|
-
super(config);
|
|
17
|
-
this.opts = config.options;
|
|
18
|
-
if (!this.opts.baseUrl) {
|
|
19
|
-
throw new Error("[UniversalVectorProvider] options.baseUrl is required");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
async initialize() {
|
|
23
|
-
var _a;
|
|
24
|
-
this.http = axios.create({
|
|
25
|
-
baseURL: this.opts.baseUrl,
|
|
26
|
-
headers: __spreadValues({
|
|
27
|
-
"Content-Type": "application/json"
|
|
28
|
-
}, this.opts.headers),
|
|
29
|
-
timeout: (_a = this.opts.timeout) != null ? _a : 3e4
|
|
30
|
-
});
|
|
31
|
-
if (!await this.ping()) {
|
|
32
|
-
throw new Error(`[UniversalVectorProvider] Failed to connect to ${this.opts.baseUrl}`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
async upsert(doc, namespace) {
|
|
36
|
-
var _a, _b, _c;
|
|
37
|
-
const endpoint = (_a = this.opts.upsertEndpoint) != null ? _a : "/upsert";
|
|
38
|
-
const template = (_b = this.opts.upsertTemplate) != null ? _b : JSON.stringify({
|
|
39
|
-
id: "{{id}}",
|
|
40
|
-
vector: "{{vector}}",
|
|
41
|
-
content: "{{content}}",
|
|
42
|
-
namespace: "{{namespace}}",
|
|
43
|
-
metadata: "{{metadata}}"
|
|
44
|
-
});
|
|
45
|
-
const payload = buildPayload(template, {
|
|
46
|
-
id: doc.id,
|
|
47
|
-
vector: doc.vector,
|
|
48
|
-
content: doc.content,
|
|
49
|
-
namespace: namespace != null ? namespace : this.indexName,
|
|
50
|
-
metadata: (_c = doc.metadata) != null ? _c : {}
|
|
51
|
-
});
|
|
52
|
-
try {
|
|
53
|
-
await this.http.post(endpoint, payload);
|
|
54
|
-
} catch (error) {
|
|
55
|
-
throw new Error(
|
|
56
|
-
`[UniversalVectorProvider] Upsert failed: ${error instanceof Error ? error.message : String(error)}`
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
async batchUpsert(docs, namespace) {
|
|
61
|
-
const batchSize = 50;
|
|
62
|
-
for (let i = 0; i < docs.length; i += batchSize) {
|
|
63
|
-
const batch = docs.slice(i, i + batchSize);
|
|
64
|
-
await Promise.all(
|
|
65
|
-
batch.map((doc) => this.upsert(doc, namespace))
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
async query(vector, topK, namespace, filter) {
|
|
70
|
-
var _a, _b;
|
|
71
|
-
const endpoint = (_a = this.opts.queryEndpoint) != null ? _a : "/query";
|
|
72
|
-
const template = (_b = this.opts.queryTemplate) != null ? _b : JSON.stringify({
|
|
73
|
-
vector: "{{vector}}",
|
|
74
|
-
limit: "{{topK}}",
|
|
75
|
-
namespace: "{{namespace}}",
|
|
76
|
-
filter: "{{filter}}"
|
|
77
|
-
});
|
|
78
|
-
const sanitizedFilter = this.sanitizeFilter(filter);
|
|
79
|
-
const payload = buildPayload(template, {
|
|
80
|
-
vector,
|
|
81
|
-
topK,
|
|
82
|
-
namespace: namespace != null ? namespace : this.indexName,
|
|
83
|
-
filter: sanitizedFilter
|
|
84
|
-
});
|
|
85
|
-
try {
|
|
86
|
-
const response = await this.http.post(endpoint, payload);
|
|
87
|
-
let results = response.data;
|
|
88
|
-
if (this.opts.queryResponsePath) {
|
|
89
|
-
results = resolvePath(response.data, this.opts.queryResponsePath);
|
|
90
|
-
}
|
|
91
|
-
if (!Array.isArray(results)) {
|
|
92
|
-
throw new Error(
|
|
93
|
-
`[UniversalVectorProvider] Expected array response at "${this.opts.queryResponsePath}", got ${typeof results}`
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
return results.map((item) => {
|
|
97
|
-
var _a2, _b2, _c, _d, _e, _f, _g;
|
|
98
|
-
return {
|
|
99
|
-
id: item[(_a2 = this.opts.queryIdField) != null ? _a2 : "id"],
|
|
100
|
-
score: (_c = item[(_b2 = this.opts.queryScoreField) != null ? _b2 : "score"]) != null ? _c : 0,
|
|
101
|
-
content: (_e = item[(_d = this.opts.queryContentField) != null ? _d : "content"]) != null ? _e : "",
|
|
102
|
-
metadata: (_g = item[(_f = this.opts.queryMetadataField) != null ? _f : "metadata"]) != null ? _g : {}
|
|
103
|
-
};
|
|
104
|
-
});
|
|
105
|
-
} catch (error) {
|
|
106
|
-
throw new Error(
|
|
107
|
-
`[UniversalVectorProvider] Query failed: ${error instanceof Error ? error.message : String(error)}`
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
async delete(id, namespace) {
|
|
112
|
-
var _a, _b;
|
|
113
|
-
const endpoint = (_a = this.opts.deleteEndpoint) != null ? _a : "/delete";
|
|
114
|
-
const template = (_b = this.opts.deleteTemplate) != null ? _b : JSON.stringify({
|
|
115
|
-
id: "{{id}}",
|
|
116
|
-
namespace: "{{namespace}}"
|
|
117
|
-
});
|
|
118
|
-
const payload = buildPayload(template, {
|
|
119
|
-
id,
|
|
120
|
-
namespace: namespace != null ? namespace : this.indexName
|
|
121
|
-
});
|
|
122
|
-
try {
|
|
123
|
-
await this.http.post(endpoint, payload);
|
|
124
|
-
} catch (error) {
|
|
125
|
-
throw new Error(
|
|
126
|
-
`[UniversalVectorProvider] Delete failed: ${error instanceof Error ? error.message : String(error)}`
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
async deleteNamespace(namespace) {
|
|
131
|
-
var _a;
|
|
132
|
-
const endpoint = (_a = this.opts.deleteNamespaceEndpoint) != null ? _a : "/delete-namespace";
|
|
133
|
-
try {
|
|
134
|
-
await this.http.post(endpoint, { namespace });
|
|
135
|
-
} catch (error) {
|
|
136
|
-
throw new Error(
|
|
137
|
-
`[UniversalVectorProvider] DeleteNamespace failed: ${error instanceof Error ? error.message : String(error)}`
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
async ping() {
|
|
142
|
-
var _a;
|
|
143
|
-
try {
|
|
144
|
-
const endpoint = (_a = this.opts.pingEndpoint) != null ? _a : "/health";
|
|
145
|
-
const response = await this.http.get(endpoint, { timeout: 5e3 });
|
|
146
|
-
return response.status >= 200 && response.status < 300;
|
|
147
|
-
} catch (e) {
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
async disconnect() {
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export {
|
|
156
|
-
UniversalVectorProvider
|
|
157
|
-
};
|