@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.
Files changed (49) hide show
  1. package/dist/handlers/index.js +142 -16
  2. package/dist/handlers/index.mjs +5848 -17
  3. package/dist/index.css +3162 -0
  4. package/dist/index.d.mts +9 -15
  5. package/dist/index.d.ts +9 -15
  6. package/dist/index.js +1355 -919
  7. package/dist/index.mjs +1437 -896
  8. package/dist/server.d.mts +6 -0
  9. package/dist/server.d.ts +6 -0
  10. package/dist/server.js +171 -17
  11. package/dist/server.mjs +5923 -68
  12. package/package.json +8 -6
  13. package/src/app/globals.css +35 -11
  14. package/src/components/ChatWidget.tsx +0 -1
  15. package/src/components/MarkdownComponents.tsx +3 -0
  16. package/src/components/MessageBubble.tsx +3 -2
  17. package/src/components/ObservabilityPanel.tsx +1 -1
  18. package/src/components/UIDispatcher.tsx +0 -3
  19. package/src/config/ConfigBuilder.ts +38 -1
  20. package/src/core/LangChainAgent.ts +1 -4
  21. package/src/core/Pipeline.ts +31 -18
  22. package/src/core/QueryProcessor.ts +65 -0
  23. package/src/rag/Reranker.ts +99 -6
  24. package/src/tailwind.css +2 -0
  25. package/src/utils/ProductExtractor.ts +3 -3
  26. package/dist/ChromaDBProvider-MIDOR4FW.mjs +0 -8
  27. package/dist/MilvusProvider-U7SKC27V.mjs +0 -8
  28. package/dist/MongoDBProvider-YNKC7EJ6.mjs +0 -8
  29. package/dist/MultiTablePostgresProvider-ZLGSKTJR.mjs +0 -8
  30. package/dist/PineconeProvider-QZNRKTN2.mjs +0 -8
  31. package/dist/QdrantProvider-RLJTNGPY.mjs +0 -8
  32. package/dist/RedisProvider-SR65SCKV.mjs +0 -8
  33. package/dist/SimpleGraphProvider-SLOXO4M7.mjs +0 -62
  34. package/dist/UniversalVectorProvider-IN67OS56.mjs +0 -9
  35. package/dist/WeaviateProvider-5FWDFITI.mjs +0 -8
  36. package/dist/chunk-5AJ4XHLW.mjs +0 -201
  37. package/dist/chunk-5YGUXK7Z.mjs +0 -80
  38. package/dist/chunk-CFVEZTBJ.mjs +0 -102
  39. package/dist/chunk-ICKRMZQK.mjs +0 -76
  40. package/dist/chunk-IMP6FUCY.mjs +0 -30
  41. package/dist/chunk-LR3VMDVK.mjs +0 -157
  42. package/dist/chunk-LZVVLSDN.mjs +0 -4077
  43. package/dist/chunk-M6JSPGAR.mjs +0 -117
  44. package/dist/chunk-OZFBG4BA.mjs +0 -291
  45. package/dist/chunk-PSFPZXHX.mjs +0 -245
  46. package/dist/chunk-U55XRW3U.mjs +0 -96
  47. package/dist/chunk-VUQJVIJT.mjs +0 -148
  48. package/dist/chunk-X4TOT24V.mjs +0 -89
  49. package/dist/chunk-YLTMFW4M.mjs +0 -49
@@ -1,96 +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/MilvusProvider.ts
9
- import axios from "axios";
10
- var MilvusProvider = class extends BaseVectorProvider {
11
- constructor(config) {
12
- super(config);
13
- const opts = config.options;
14
- const baseUrl = opts.baseUrl || opts.uri || (opts.host ? `http://${opts.host}:${opts.port || 19530}` : void 0);
15
- if (!baseUrl) throw new Error("[MilvusProvider] options.baseUrl (or uri / host+port) is required");
16
- this.http = axios.create({
17
- baseURL: baseUrl,
18
- headers: __spreadValues(__spreadValues({
19
- "Content-Type": "application/json"
20
- }, opts.headers || {}), opts.apiKey ? { Authorization: `Bearer ${opts.apiKey}` } : {})
21
- });
22
- }
23
- async initialize() {
24
- await this.ping();
25
- }
26
- async upsert(doc, namespace) {
27
- const payload = {
28
- collectionName: this.indexName,
29
- data: [__spreadValues({
30
- vector: doc.vector,
31
- content: doc.content,
32
- metadata: doc.metadata || {}
33
- }, namespace ? { namespace } : {})]
34
- };
35
- await this.http.post("/v1/vector/upsert", payload);
36
- }
37
- async batchUpsert(docs, namespace) {
38
- const payload = {
39
- collectionName: this.indexName,
40
- data: docs.map((doc) => __spreadValues({
41
- vector: doc.vector,
42
- content: doc.content,
43
- metadata: doc.metadata || {}
44
- }, namespace ? { namespace } : {}))
45
- };
46
- await this.http.post("/v1/vector/upsert", payload);
47
- }
48
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
49
- async query(vector, topK, namespace, _filter) {
50
- const payload = {
51
- collectionName: this.indexName,
52
- vector,
53
- limit: topK,
54
- filter: namespace ? `namespace == "${namespace}"` : void 0,
55
- outputFields: ["content", "metadata"],
56
- searchParams: {
57
- nprobe: this.config.options.nprobe || 16,
58
- ef: this.config.options.efSearch || Math.max(topK * 10, 64)
59
- }
60
- };
61
- const { data } = await this.http.post("/v1/vector/search", payload);
62
- return (data.data || []).map((res) => ({
63
- id: String(res["id"]),
64
- score: res["distance"],
65
- content: res["content"],
66
- metadata: res["metadata"] || {}
67
- }));
68
- }
69
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
70
- async delete(id, _namespace) {
71
- await this.http.post("/v1/vector/delete", {
72
- collectionName: this.indexName,
73
- id
74
- });
75
- }
76
- async deleteNamespace(namespace) {
77
- await this.http.post("/v1/vector/delete", {
78
- collectionName: this.indexName,
79
- filter: `namespace == "${namespace}"`
80
- });
81
- }
82
- async ping() {
83
- try {
84
- await this.http.get("/v1/health");
85
- return true;
86
- } catch (e) {
87
- return false;
88
- }
89
- }
90
- async disconnect() {
91
- }
92
- };
93
-
94
- export {
95
- MilvusProvider
96
- };
@@ -1,148 +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/PineconeProvider.ts
9
- import { Pinecone } from "@pinecone-database/pinecone";
10
- var PineconeProvider = class extends BaseVectorProvider {
11
- constructor(config) {
12
- super(config);
13
- const opts = config.options;
14
- if (!opts.apiKey) throw new Error("[PineconeProvider] options.apiKey is required");
15
- this.apiKey = opts.apiKey;
16
- }
17
- static getValidator() {
18
- return {
19
- validate(config) {
20
- const errors = [];
21
- const opts = config.options || {};
22
- if (!opts.apiKey) {
23
- errors.push({
24
- field: "vectorDb.options.apiKey",
25
- message: "Pinecone API key is required",
26
- suggestion: "Set PINECONE_API_KEY environment variable",
27
- severity: "error"
28
- });
29
- }
30
- return errors;
31
- }
32
- };
33
- }
34
- static getHealthChecker() {
35
- return {
36
- async check(config) {
37
- var _a, _b;
38
- const opts = config.options || {};
39
- const indexName = config.indexName;
40
- const timestamp = Date.now();
41
- try {
42
- const { Pinecone: Pinecone2 } = await import("@pinecone-database/pinecone");
43
- const client = new Pinecone2({ apiKey: opts.apiKey });
44
- const indexes = await client.listIndexes();
45
- const indexNames = (_b = (_a = indexes.indexes) == null ? void 0 : _a.map((i) => i.name)) != null ? _b : [];
46
- if (!indexNames.includes(indexName)) {
47
- return {
48
- healthy: false,
49
- provider: "pinecone",
50
- error: `Index "${indexName}" not found. Available: ${indexNames.join(", ")}`,
51
- timestamp
52
- };
53
- }
54
- return {
55
- healthy: true,
56
- provider: "pinecone",
57
- capabilities: { indexes: indexNames.length, targetIndex: indexName },
58
- timestamp
59
- };
60
- } catch (error) {
61
- return {
62
- healthy: false,
63
- provider: "pinecone",
64
- error: `Connection failed: ${error instanceof Error ? error.message : String(error)}`,
65
- timestamp
66
- };
67
- }
68
- }
69
- };
70
- }
71
- async initialize() {
72
- var _a, _b;
73
- this.client = new Pinecone({ apiKey: this.apiKey });
74
- const indexes = await this.client.listIndexes();
75
- const names = (_b = (_a = indexes.indexes) == null ? void 0 : _a.map((i) => i.name)) != null ? _b : [];
76
- if (!names.includes(this.indexName)) {
77
- throw new Error(
78
- `[PineconeProvider] Index "${this.indexName}" not found. Available: ${names.join(", ")}`
79
- );
80
- }
81
- }
82
- index(namespace) {
83
- const idx = this.client.index(this.indexName);
84
- return namespace ? idx.namespace(namespace) : idx.namespace("");
85
- }
86
- async upsert(doc, namespace) {
87
- var _a;
88
- await this.index(namespace).upsert({
89
- records: [{
90
- id: String(doc.id),
91
- values: doc.vector,
92
- metadata: __spreadValues({ content: doc.content }, (_a = doc.metadata) != null ? _a : {})
93
- }]
94
- });
95
- }
96
- async batchUpsert(docs, namespace) {
97
- const BATCH = 100;
98
- for (let i = 0; i < docs.length; i += BATCH) {
99
- const records = docs.slice(i, i + BATCH).map((d) => {
100
- var _a;
101
- return {
102
- id: String(d.id),
103
- values: d.vector,
104
- metadata: __spreadValues({ content: d.content }, (_a = d.metadata) != null ? _a : {})
105
- };
106
- });
107
- await this.index(namespace).upsert({ records });
108
- }
109
- }
110
- async query(vector, topK, namespace, filter) {
111
- var _a;
112
- const pineconeFilter = this.sanitizeFilter(filter);
113
- const result = await this.index(namespace).query(__spreadValues({
114
- vector,
115
- topK,
116
- includeMetadata: true
117
- }, Object.keys(pineconeFilter).length > 0 ? { filter: pineconeFilter } : {}));
118
- return ((_a = result.matches) != null ? _a : []).map((m) => {
119
- var _a2, _b;
120
- return {
121
- id: m.id,
122
- score: (_a2 = m.score) != null ? _a2 : 0,
123
- content: ((_b = m.metadata) == null ? void 0 : _b.content) || "",
124
- metadata: m.metadata
125
- };
126
- });
127
- }
128
- async delete(id, namespace) {
129
- await this.index(namespace).deleteOne({ id: String(id) });
130
- }
131
- async deleteNamespace(namespace) {
132
- await this.client.index(this.indexName).namespace(namespace).deleteAll();
133
- }
134
- async ping() {
135
- try {
136
- await this.client.listIndexes();
137
- return true;
138
- } catch (e) {
139
- return false;
140
- }
141
- }
142
- async disconnect() {
143
- }
144
- };
145
-
146
- export {
147
- PineconeProvider
148
- };
@@ -1,89 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
8
- var __typeError = (msg) => {
9
- throw TypeError(msg);
10
- };
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
- var __objRest = (source, exclude) => {
25
- var target = {};
26
- for (var prop in source)
27
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
28
- target[prop] = source[prop];
29
- if (source != null && __getOwnPropSymbols)
30
- for (var prop of __getOwnPropSymbols(source)) {
31
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
32
- target[prop] = source[prop];
33
- }
34
- return target;
35
- };
36
- var __await = function(promise, isYieldStar) {
37
- this[0] = promise;
38
- this[1] = isYieldStar;
39
- };
40
- var __asyncGenerator = (__this, __arguments, generator) => {
41
- var resume = (k, v, yes, no) => {
42
- try {
43
- var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done;
44
- Promise.resolve(isAwait ? v[0] : v).then((y) => isAwait ? resume(k === "return" ? k : "next", v[1] ? { done: y.done, value: y.value } : y, yes, no) : yes({ value: y, done })).catch((e) => resume("throw", e, yes, no));
45
- } catch (e) {
46
- no(e);
47
- }
48
- }, method = (k, call, wait, clear) => it[k] = (x) => (call = new Promise((yes, no, run) => (run = () => resume(k, x, yes, no), q ? q.then(run) : run())), clear = () => q === wait && (q = 0), q = wait = call.then(clear, clear), call), q, it = {};
49
- return generator = generator.apply(__this, __arguments), it[__knownSymbol("asyncIterator")] = () => it, method("next"), method("throw"), method("return"), it;
50
- };
51
- var __yieldStar = (value) => {
52
- var obj = value[__knownSymbol("asyncIterator")], isAwait = false, method, it = {};
53
- if (obj == null) {
54
- obj = value[__knownSymbol("iterator")]();
55
- method = (k) => it[k] = (x) => obj[k](x);
56
- } else {
57
- obj = obj.call(value);
58
- method = (k) => it[k] = (v) => {
59
- if (isAwait) {
60
- isAwait = false;
61
- if (k === "throw") throw v;
62
- return v;
63
- }
64
- isAwait = true;
65
- return {
66
- done: false,
67
- value: new __await(new Promise((resolve) => {
68
- var x = obj[k](v);
69
- if (!(x instanceof Object)) __typeError("Object expected");
70
- resolve(x);
71
- }), 1)
72
- };
73
- };
74
- }
75
- return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => {
76
- throw x;
77
- }, "return" in obj && method("return"), it;
78
- };
79
- var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")]) ? it.call(obj) : (obj = obj[__knownSymbol("iterator")](), it = {}, method = (key, fn) => (fn = obj[key]) && (it[key] = (arg) => new Promise((yes, no, done) => (arg = fn.call(obj, arg), done = arg.done, Promise.resolve(arg.value).then((value) => yes({ value, done }), no)))), method("next"), method("return"), it);
80
-
81
- export {
82
- __spreadValues,
83
- __spreadProps,
84
- __objRest,
85
- __await,
86
- __asyncGenerator,
87
- __yieldStar,
88
- __forAwait
89
- };
@@ -1,49 +0,0 @@
1
- import {
2
- __spreadValues
3
- } from "./chunk-X4TOT24V.mjs";
4
-
5
- // src/utils/templateUtils.ts
6
- function isRecord(value) {
7
- return typeof value === "object" && value !== null;
8
- }
9
- function resolvePath(obj, path) {
10
- if (!path || !obj) return void 0;
11
- return path.replace(/\[(\w+)\]/g, ".$1").replace(/^\./, "").split(".").reduce((current, segment) => {
12
- if (!isRecord(current) && !Array.isArray(current)) {
13
- return void 0;
14
- }
15
- return current[segment];
16
- }, obj);
17
- }
18
- function buildPayload(template, vars) {
19
- let raw = template;
20
- for (const [key, val] of Object.entries(vars)) {
21
- const stringifiedVal = val === void 0 ? "null" : JSON.stringify(val);
22
- raw = raw.replace(new RegExp(`"\\{\\{${key}\\}\\}"`, "g"), stringifiedVal);
23
- raw = raw.replace(new RegExp(`\\{\\{${key}\\}\\}`, "g"), stringifiedVal);
24
- }
25
- try {
26
- return JSON.parse(raw);
27
- } catch (err) {
28
- throw new Error(`Failed to parse payload template: ${err.message}
29
- Raw payload: ${raw}`);
30
- }
31
- }
32
- function mergeDefined(base, override) {
33
- const merged = __spreadValues({}, base || {});
34
- if (!override) {
35
- return merged;
36
- }
37
- for (const [key, value] of Object.entries(override)) {
38
- if (value !== void 0 && value !== null && value !== "") {
39
- merged[key] = value;
40
- }
41
- }
42
- return merged;
43
- }
44
-
45
- export {
46
- resolvePath,
47
- buildPayload,
48
- mergeDefined
49
- };