@retrivora-ai/rag-engine 1.8.2 → 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.
Files changed (47) hide show
  1. package/dist/handlers/index.js +142 -16
  2. package/dist/handlers/index.mjs +5848 -17
  3. package/dist/index.d.mts +9 -15
  4. package/dist/index.d.ts +9 -15
  5. package/dist/index.js +1355 -919
  6. package/dist/index.mjs +1437 -896
  7. package/dist/server.d.mts +6 -0
  8. package/dist/server.d.ts +6 -0
  9. package/dist/server.js +171 -17
  10. package/dist/server.mjs +5923 -68
  11. package/package.json +6 -6
  12. package/src/app/globals.css +35 -11
  13. package/src/components/ChatWidget.tsx +0 -1
  14. package/src/components/MarkdownComponents.tsx +3 -0
  15. package/src/components/MessageBubble.tsx +3 -2
  16. package/src/components/ObservabilityPanel.tsx +1 -1
  17. package/src/components/UIDispatcher.tsx +0 -3
  18. package/src/config/ConfigBuilder.ts +38 -1
  19. package/src/core/LangChainAgent.ts +1 -4
  20. package/src/core/Pipeline.ts +31 -18
  21. package/src/core/QueryProcessor.ts +65 -0
  22. package/src/rag/Reranker.ts +99 -6
  23. package/src/utils/ProductExtractor.ts +3 -3
  24. package/dist/ChromaDBProvider-MIDOR4FW.mjs +0 -8
  25. package/dist/MilvusProvider-U7SKC27V.mjs +0 -8
  26. package/dist/MongoDBProvider-YNKC7EJ6.mjs +0 -8
  27. package/dist/MultiTablePostgresProvider-ZLGSKTJR.mjs +0 -8
  28. package/dist/PineconeProvider-QZNRKTN2.mjs +0 -8
  29. package/dist/QdrantProvider-RLJTNGPY.mjs +0 -8
  30. package/dist/RedisProvider-SR65SCKV.mjs +0 -8
  31. package/dist/SimpleGraphProvider-SLOXO4M7.mjs +0 -62
  32. package/dist/UniversalVectorProvider-IN67OS56.mjs +0 -9
  33. package/dist/WeaviateProvider-5FWDFITI.mjs +0 -8
  34. package/dist/chunk-5AJ4XHLW.mjs +0 -201
  35. package/dist/chunk-5YGUXK7Z.mjs +0 -80
  36. package/dist/chunk-CFVEZTBJ.mjs +0 -102
  37. package/dist/chunk-ICKRMZQK.mjs +0 -76
  38. package/dist/chunk-IMP6FUCY.mjs +0 -30
  39. package/dist/chunk-LR3VMDVK.mjs +0 -157
  40. package/dist/chunk-LZVVLSDN.mjs +0 -4077
  41. package/dist/chunk-M6JSPGAR.mjs +0 -117
  42. package/dist/chunk-OZFBG4BA.mjs +0 -291
  43. package/dist/chunk-PSFPZXHX.mjs +0 -245
  44. package/dist/chunk-U55XRW3U.mjs +0 -96
  45. package/dist/chunk-VUQJVIJT.mjs +0 -148
  46. package/dist/chunk-X4TOT24V.mjs +0 -89
  47. package/dist/chunk-YLTMFW4M.mjs +0 -49
@@ -1,8 +0,0 @@
1
- import {
2
- MongoDBProvider
3
- } from "./chunk-5AJ4XHLW.mjs";
4
- import "./chunk-IMP6FUCY.mjs";
5
- import "./chunk-X4TOT24V.mjs";
6
- export {
7
- MongoDBProvider
8
- };
@@ -1,8 +0,0 @@
1
- import {
2
- MultiTablePostgresProvider
3
- } from "./chunk-OZFBG4BA.mjs";
4
- import "./chunk-IMP6FUCY.mjs";
5
- import "./chunk-X4TOT24V.mjs";
6
- export {
7
- MultiTablePostgresProvider
8
- };
@@ -1,8 +0,0 @@
1
- import {
2
- PineconeProvider
3
- } from "./chunk-VUQJVIJT.mjs";
4
- import "./chunk-IMP6FUCY.mjs";
5
- import "./chunk-X4TOT24V.mjs";
6
- export {
7
- PineconeProvider
8
- };
@@ -1,8 +0,0 @@
1
- import {
2
- QdrantProvider
3
- } from "./chunk-PSFPZXHX.mjs";
4
- import "./chunk-IMP6FUCY.mjs";
5
- import "./chunk-X4TOT24V.mjs";
6
- export {
7
- QdrantProvider
8
- };
@@ -1,8 +0,0 @@
1
- import {
2
- RedisProvider
3
- } from "./chunk-5YGUXK7Z.mjs";
4
- import "./chunk-IMP6FUCY.mjs";
5
- import "./chunk-X4TOT24V.mjs";
6
- export {
7
- RedisProvider
8
- };
@@ -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
- };
@@ -1,9 +0,0 @@
1
- import {
2
- UniversalVectorProvider
3
- } from "./chunk-LR3VMDVK.mjs";
4
- import "./chunk-YLTMFW4M.mjs";
5
- import "./chunk-IMP6FUCY.mjs";
6
- import "./chunk-X4TOT24V.mjs";
7
- export {
8
- UniversalVectorProvider
9
- };
@@ -1,8 +0,0 @@
1
- import {
2
- WeaviateProvider
3
- } from "./chunk-M6JSPGAR.mjs";
4
- import "./chunk-IMP6FUCY.mjs";
5
- import "./chunk-X4TOT24V.mjs";
6
- export {
7
- WeaviateProvider
8
- };
@@ -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
- };
@@ -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
- };
@@ -1,102 +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/ChromaDBProvider.ts
9
- import axios from "axios";
10
- var ChromaDBProvider = class extends BaseVectorProvider {
11
- constructor(config) {
12
- super(config);
13
- this.collectionId = "";
14
- const opts = config.options;
15
- const baseUrl = opts.baseUrl || (opts.host ? `http://${opts.host}:${opts.port || 8e3}` : void 0);
16
- if (!baseUrl) throw new Error("[ChromaDBProvider] options.baseUrl is required");
17
- this.http = axios.create({
18
- baseURL: baseUrl,
19
- headers: { "Content-Type": "application/json" }
20
- });
21
- }
22
- /**
23
- * Get or create the ChromaDB collection.
24
- */
25
- async initialize() {
26
- var _a;
27
- try {
28
- const { data } = await this.http.get(`/api/v1/collections/${this.indexName}`);
29
- this.collectionId = data.id;
30
- console.log(`[ChromaDBProvider] \u2705 Collection "${this.indexName}" found (id: ${this.collectionId})`);
31
- } catch (err) {
32
- if (axios.isAxiosError(err) && ((_a = err.response) == null ? void 0 : _a.status) === 404) {
33
- console.log(`[ChromaDBProvider] \u23F3 Collection "${this.indexName}" not found. Creating...`);
34
- const { data } = await this.http.post("/api/v1/collections", {
35
- name: this.indexName
36
- });
37
- this.collectionId = data.id;
38
- console.log(`[ChromaDBProvider] \u2705 Created collection "${this.indexName}" (id: ${this.collectionId})`);
39
- } else {
40
- throw err;
41
- }
42
- }
43
- }
44
- async upsert(doc, namespace) {
45
- await this.batchUpsert([doc], namespace);
46
- }
47
- async batchUpsert(docs, namespace) {
48
- const payload = {
49
- ids: docs.map((d) => String(d.id)),
50
- embeddings: docs.map((d) => d.vector),
51
- documents: docs.map((d) => d.content),
52
- metadatas: docs.map((d) => __spreadValues(__spreadValues({}, d.metadata || {}), namespace ? { namespace } : {}))
53
- };
54
- await this.http.post(`/api/v1/collections/${this.collectionId}/add`, payload);
55
- }
56
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
57
- async query(vector, topK, namespace, _filter) {
58
- const payload = {
59
- query_embeddings: [vector],
60
- n_results: topK,
61
- where: namespace ? { namespace: { $eq: namespace } } : void 0
62
- };
63
- const { data } = await this.http.post(`/api/v1/collections/${this.collectionId}/query`, payload);
64
- const matches = [];
65
- if (data.ids && data.ids[0]) {
66
- for (let i = 0; i < data.ids[0].length; i++) {
67
- matches.push({
68
- id: data.ids[0][i],
69
- score: data.distances ? 1 - data.distances[0][i] : 0,
70
- content: data.documents ? data.documents[0][i] : "",
71
- metadata: data.metadatas ? data.metadatas[0][i] : {}
72
- });
73
- }
74
- }
75
- return matches;
76
- }
77
- async delete(id, namespace) {
78
- await this.http.post(`/api/v1/collections/${this.collectionId}/delete`, {
79
- ids: [id],
80
- where: namespace ? { namespace: { $eq: namespace } } : void 0
81
- });
82
- }
83
- async deleteNamespace(namespace) {
84
- await this.http.post(`/api/v1/collections/${this.collectionId}/delete`, {
85
- where: { namespace: { $eq: namespace } }
86
- });
87
- }
88
- async ping() {
89
- try {
90
- await this.http.get("/api/v1/heartbeat");
91
- return true;
92
- } catch (e) {
93
- return false;
94
- }
95
- }
96
- async disconnect() {
97
- }
98
- };
99
-
100
- export {
101
- ChromaDBProvider
102
- };
@@ -1,76 +0,0 @@
1
- // src/utils/synonyms.ts
2
- var FIELD_SYNONYMS = {
3
- name: ["product", "item", "title", "label", "heading", "subject", "product name", "item name"],
4
- price: ["cost", "amount", "msrp", "price", "rate", "value", "price_usd"],
5
- brand: ["manufacturer", "vendor", "make", "company", "brand_name", "supplier"],
6
- image: [
7
- "imageUrl",
8
- "thumbnail",
9
- "img",
10
- "url",
11
- "photo",
12
- "picture",
13
- "media",
14
- "image_url",
15
- "main_image",
16
- "product_image",
17
- "thumb"
18
- ],
19
- stock: [
20
- "inventory",
21
- "quantity",
22
- "count",
23
- "availability",
24
- "stock_level",
25
- "inStock",
26
- "is_available",
27
- "in stock",
28
- "status"
29
- ],
30
- description: ["summary", "content", "body", "text", "info", "details"],
31
- link: ["url", "href", "product_url", "page_url", "link"]
32
- };
33
- function addSynonyms(customSynonyms) {
34
- for (const [key, aliases] of Object.entries(customSynonyms)) {
35
- if (!FIELD_SYNONYMS[key]) {
36
- FIELD_SYNONYMS[key] = [];
37
- }
38
- const existing = new Set(FIELD_SYNONYMS[key].map((s) => s.toLowerCase()));
39
- for (const alias of aliases) {
40
- if (!existing.has(alias.toLowerCase())) {
41
- FIELD_SYNONYMS[key].push(alias);
42
- existing.add(alias.toLowerCase());
43
- }
44
- }
45
- }
46
- }
47
- function resolveMetadataValue(meta, uiKey) {
48
- var _a;
49
- const synonyms = (_a = FIELD_SYNONYMS[uiKey]) != null ? _a : [];
50
- const keys = Object.keys(meta);
51
- const systemKeys = ["namespace", "filename", "filesize", "filetype", "docid", "uploadedat", "dimension", "chunkindex"];
52
- let match = keys.find((k) => k.toLowerCase() === uiKey.toLowerCase());
53
- if (match !== void 0) return meta[match];
54
- match = keys.find((k) => synonyms.map((s) => s.toLowerCase()).includes(k.toLowerCase()));
55
- if (match !== void 0) return meta[match];
56
- const isBlacklisted = (kl) => {
57
- return systemKeys.includes(kl) || kl.startsWith("option1") || kl.startsWith("option2") || kl.startsWith("option3");
58
- };
59
- match = keys.find((k) => {
60
- const kl = k.toLowerCase();
61
- if (isBlacklisted(kl)) return false;
62
- return kl.includes(uiKey.toLowerCase());
63
- });
64
- if (match !== void 0) return meta[match];
65
- match = keys.find((k) => {
66
- const kl = k.toLowerCase();
67
- if (isBlacklisted(kl)) return false;
68
- return synonyms.some((sk) => kl.includes(sk.toLowerCase()) || sk.toLowerCase().includes(kl));
69
- });
70
- return match !== void 0 ? meta[match] : void 0;
71
- }
72
-
73
- export {
74
- addSynonyms,
75
- resolveMetadataValue
76
- };
@@ -1,30 +0,0 @@
1
- // src/providers/vectordb/BaseVectorProvider.ts
2
- var BaseVectorProvider = class {
3
- constructor(config) {
4
- this.config = config;
5
- this.indexName = config.indexName || "default";
6
- }
7
- /**
8
- * Remove internal keys (starting with __) and queryText from a filter object
9
- * before passing it to an external provider that might not support them.
10
- */
11
- sanitizeFilter(filter) {
12
- if (!filter) return {};
13
- const result = {};
14
- for (const [key, value] of Object.entries(filter)) {
15
- if (key.startsWith("__") || key === "queryText" || key === "keywords") {
16
- continue;
17
- }
18
- if (key === "metadata" && typeof value === "object" && value !== null) {
19
- Object.assign(result, value);
20
- } else {
21
- result[key] = value;
22
- }
23
- }
24
- return result;
25
- }
26
- };
27
-
28
- export {
29
- BaseVectorProvider
30
- };