@retrivora-ai/rag-engine 2.6.0 → 2.6.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 (58) hide show
  1. package/README.md +8 -6
  2. package/dist/ChromaDBProvider-NDA2IBOH.mjs +8 -0
  3. package/dist/{ILLMProvider-DUCL1r75.d.mts → ILLMProvider-CzXcTA6d.d.mts} +21 -3
  4. package/dist/{ILLMProvider-DUCL1r75.d.ts → ILLMProvider-CzXcTA6d.d.ts} +21 -3
  5. package/dist/MilvusProvider-H6GGL5FQ.mjs +8 -0
  6. package/dist/MongoDBProvider-KC3GF3FH.mjs +8 -0
  7. package/dist/MultiTablePostgresProvider-6LJBFZL2.mjs +9 -0
  8. package/dist/PineconeProvider-22RF2QPF.mjs +10 -0
  9. package/dist/PineconeProvider-HBBIXLT3.mjs +10 -0
  10. package/dist/PostgreSQLProvider-VWFL4OIP.mjs +8 -0
  11. package/dist/QdrantProvider-UU7RGXBI.mjs +8 -0
  12. package/dist/RedisProvider-MIIPSAAE.mjs +8 -0
  13. package/dist/SimpleGraphProvider-HJIS4S7Y.mjs +70 -0
  14. package/dist/UniversalVectorProvider-NO3L255G.mjs +9 -0
  15. package/dist/WeaviateProvider-YRZDZFAC.mjs +8 -0
  16. package/dist/chunk-23PFNEBF.mjs +107 -0
  17. package/dist/chunk-3E4GZGDX.mjs +10851 -0
  18. package/dist/chunk-3SQ4DODU.mjs +238 -0
  19. package/dist/chunk-AHMMUZ4W.mjs +152 -0
  20. package/dist/chunk-ASBNNEVI.mjs +81 -0
  21. package/dist/chunk-AT4TFUQN.mjs +219 -0
  22. package/dist/chunk-BEPLYQBS.mjs +89 -0
  23. package/dist/chunk-G7MJRFCO.mjs +340 -0
  24. package/dist/chunk-IHWKVAUR.mjs +112 -0
  25. package/dist/chunk-IMP6FUCY.mjs +30 -0
  26. package/dist/chunk-LFNV6DEL.mjs +281 -0
  27. package/dist/chunk-MAXMVO7B.mjs +211 -0
  28. package/dist/chunk-MGJ6V2IT.mjs +203 -0
  29. package/dist/chunk-N3TI27LG.mjs +334 -0
  30. package/dist/chunk-NWYE4Q7B.mjs +334 -0
  31. package/dist/chunk-OJMAT4EG.mjs +219 -0
  32. package/dist/chunk-QKZM3RSJ.mjs +10851 -0
  33. package/dist/chunk-QUY3E6HJ.mjs +168 -0
  34. package/dist/chunk-SG6XYLQE.mjs +53 -0
  35. package/dist/chunk-UT6SZZEC.mjs +69 -0
  36. package/dist/chunk-VW3U4MMX.mjs +157 -0
  37. package/dist/chunk-WOJCOTXI.mjs +281 -0
  38. package/dist/chunk-XP6NJMX4.mjs +168 -0
  39. package/dist/chunk-XYBKDJDW.mjs +696 -0
  40. package/dist/handlers/index.d.mts +2 -2
  41. package/dist/handlers/index.d.ts +2 -2
  42. package/dist/handlers/index.js +9736 -9354
  43. package/dist/handlers/index.mjs +24 -13686
  44. package/dist/{index-CsBcqng1.d.ts → index-BBbt5A2y.d.mts} +61 -47
  45. package/dist/{index-BVSHblli.d.mts → index-BST9Gzsv.d.mts} +8 -7
  46. package/dist/{index-D6Oq2zyc.d.mts → index-BZ_rR6V8.d.ts} +61 -47
  47. package/dist/{index-DGW0NNmR.d.ts → index-qLvtMUr-.d.ts} +8 -7
  48. package/dist/index.css +23 -0
  49. package/dist/index.d.mts +4 -4
  50. package/dist/index.d.ts +4 -4
  51. package/dist/index.js +278 -190
  52. package/dist/index.min.css +1 -1
  53. package/dist/index.mjs +218 -1558
  54. package/dist/server.d.mts +58 -12
  55. package/dist/server.d.ts +58 -12
  56. package/dist/server.js +968 -577
  57. package/dist/server.mjs +395 -14244
  58. package/package.json +1 -1
@@ -0,0 +1,281 @@
1
+ import {
2
+ ConfigFetcher
3
+ } from "./chunk-NWYE4Q7B.mjs";
4
+ import {
5
+ BaseVectorProvider
6
+ } from "./chunk-IMP6FUCY.mjs";
7
+ import {
8
+ __spreadValues
9
+ } from "./chunk-UT6SZZEC.mjs";
10
+
11
+ // src/providers/vectordb/PineconeProvider.ts
12
+ import { Pinecone } from "@pinecone-database/pinecone";
13
+ var PineconeProvider = class extends BaseVectorProvider {
14
+ constructor(config) {
15
+ super(config);
16
+ const opts = config.options || {};
17
+ this.apiKey = opts.apiKey || process.env.PINECONE_API_KEY || "";
18
+ }
19
+ getControlPlaneUrl() {
20
+ const urls = [
21
+ process.env.RETRIVORA_CONTROL_PLANE_URL,
22
+ process.env.NEXT_PUBLIC_RETRIVORA_CONTROL_PLANE_URL,
23
+ "https://www.retrivora.com"
24
+ ].filter((url) => Boolean(url));
25
+ return urls[0].replace(/\/$/, "");
26
+ }
27
+ static getValidator() {
28
+ return {
29
+ validate(config) {
30
+ const errors = [];
31
+ const opts = config.options || {};
32
+ const hasLicenseKey = Boolean(
33
+ config.licenseKey || process.env.RETRIVORA_LICENSE_KEY
34
+ );
35
+ if (!opts.apiKey && !hasLicenseKey) {
36
+ errors.push({
37
+ field: "vectorDb.options.apiKey",
38
+ message: "Pinecone API key is required when RETRIVORA_LICENSE_KEY is not set",
39
+ suggestion: "Set PINECONE_API_KEY environment variable or supply RETRIVORA_LICENSE_KEY for keyless vector storage",
40
+ severity: "error"
41
+ });
42
+ }
43
+ return errors;
44
+ }
45
+ };
46
+ }
47
+ static getHealthChecker() {
48
+ return {
49
+ async check(config) {
50
+ var _a, _b;
51
+ const opts = config.options || {};
52
+ const indexName = config.indexName;
53
+ const timestamp = Date.now();
54
+ try {
55
+ const { Pinecone: Pinecone2 } = await import("@pinecone-database/pinecone");
56
+ const client = new Pinecone2({ apiKey: opts.apiKey });
57
+ const indexes = await client.listIndexes();
58
+ const indexNames = (_b = (_a = indexes.indexes) == null ? void 0 : _a.map((i) => i.name)) != null ? _b : [];
59
+ if (!indexNames.includes(indexName)) {
60
+ return {
61
+ healthy: false,
62
+ provider: "pinecone",
63
+ error: `Index "${indexName}" not found. Available: ${indexNames.join(", ")}`,
64
+ timestamp
65
+ };
66
+ }
67
+ return {
68
+ healthy: true,
69
+ provider: "pinecone",
70
+ capabilities: { indexes: indexNames.length, targetIndex: indexName },
71
+ timestamp
72
+ };
73
+ } catch (error) {
74
+ return {
75
+ healthy: false,
76
+ provider: "pinecone",
77
+ error: `Connection failed: ${error instanceof Error ? error.message : String(error)}`,
78
+ timestamp
79
+ };
80
+ }
81
+ }
82
+ };
83
+ }
84
+ async initialize() {
85
+ var _a, _b;
86
+ if (this.client) return;
87
+ let key = this.apiKey || process.env.PINECONE_API_KEY || "";
88
+ if (!key) {
89
+ const licenseKey = process.env.RETRIVORA_LICENSE_KEY;
90
+ this.licenseKey = licenseKey;
91
+ const projectId = process.env.RAG_PROJECT_ID || process.env.NEXT_PUBLIC_RAG_PROJECT_ID || this.projectId || "default";
92
+ this.projectId = projectId;
93
+ const remoteConfig = await ConfigFetcher.fetchRemoteVectorConfig(projectId, licenseKey);
94
+ if (remoteConfig) {
95
+ if (remoteConfig.apiKey) {
96
+ key = remoteConfig.apiKey;
97
+ this.apiKey = key;
98
+ }
99
+ if (remoteConfig.indexName) {
100
+ this.indexName = remoteConfig.indexName;
101
+ }
102
+ if (remoteConfig.projectId) {
103
+ this.projectId = remoteConfig.projectId;
104
+ }
105
+ if (remoteConfig.namespace) {
106
+ this.namespace = remoteConfig.namespace;
107
+ }
108
+ }
109
+ }
110
+ if (!key) {
111
+ console.warn(
112
+ "[PineconeProvider] Warning: No Pinecone API key available. Set PINECONE_API_KEY in your environment, or ensure the Retrivora Control Plane (https://www.retrivora.com) is reachable for proxy-based vector operations."
113
+ );
114
+ return;
115
+ }
116
+ this.client = new Pinecone({ apiKey: key });
117
+ try {
118
+ const indexes = await this.client.listIndexes();
119
+ const names = (_b = (_a = indexes.indexes) == null ? void 0 : _a.map((i) => i.name)) != null ? _b : [];
120
+ if (!names.includes(this.indexName)) {
121
+ console.warn(`[PineconeProvider] Target index "${this.indexName}" not listed. Proceeding with configured index name.`);
122
+ }
123
+ } catch (err) {
124
+ console.warn("[PineconeProvider] List index verification warning:", err instanceof Error ? err.message : String(err));
125
+ }
126
+ }
127
+ async getActiveIndex(namespace) {
128
+ if (!this.client) {
129
+ await this.initialize();
130
+ }
131
+ if (!this.client) {
132
+ throw new Error("[PineconeProvider] Cannot execute vector operation: Pinecone client failed to initialize.");
133
+ }
134
+ const idx = this.client.index(this.indexName);
135
+ return namespace ? idx.namespace(namespace) : idx.namespace("");
136
+ }
137
+ async upsert(doc, namespace) {
138
+ var _a, _b;
139
+ if (!this.client) {
140
+ if (!this.licenseKey) throw new Error("[PineconeProvider] Cannot execute vector operation: Missing API key and License key.");
141
+ const res = await fetch(`${this.getControlPlaneUrl()}/api/v1/vectors/upsert`, {
142
+ method: "POST",
143
+ headers: __spreadValues({
144
+ "Content-Type": "application/json",
145
+ "x-license-key": this.licenseKey
146
+ }, this.projectId ? { "x-project-id": this.projectId } : {}),
147
+ body: JSON.stringify({
148
+ projectId: this.projectId,
149
+ indexName: this.indexName,
150
+ namespace: namespace || this.projectId,
151
+ records: [{ id: String(doc.id), values: doc.vector, metadata: __spreadValues({ content: doc.content }, (_a = doc.metadata) != null ? _a : {}) }]
152
+ })
153
+ });
154
+ if (!res.ok) throw new Error(`[PineconeProvider] Proxy upsert failed: ${await res.text()}`);
155
+ return;
156
+ }
157
+ const targetIdx = await this.getActiveIndex(namespace);
158
+ await targetIdx.upsert({
159
+ records: [{
160
+ id: String(doc.id),
161
+ values: doc.vector,
162
+ metadata: __spreadValues({ content: doc.content }, (_b = doc.metadata) != null ? _b : {})
163
+ }]
164
+ });
165
+ }
166
+ async batchUpsert(docs, namespace) {
167
+ const BATCH = 100;
168
+ if (!this.client) {
169
+ if (!this.licenseKey) throw new Error("[PineconeProvider] Cannot execute vector operation: Missing API key and License key.");
170
+ for (let i = 0; i < docs.length; i += BATCH) {
171
+ const records = docs.slice(i, i + BATCH).map((d) => {
172
+ var _a;
173
+ return {
174
+ id: String(d.id),
175
+ values: d.vector,
176
+ metadata: __spreadValues({ content: d.content }, (_a = d.metadata) != null ? _a : {})
177
+ };
178
+ });
179
+ const res = await fetch(`${this.getControlPlaneUrl()}/api/v1/vectors/upsert`, {
180
+ method: "POST",
181
+ headers: __spreadValues({
182
+ "Content-Type": "application/json",
183
+ "x-license-key": this.licenseKey
184
+ }, this.projectId ? { "x-project-id": this.projectId } : {}),
185
+ body: JSON.stringify({
186
+ projectId: this.projectId,
187
+ indexName: this.indexName,
188
+ namespace: namespace || this.projectId,
189
+ records
190
+ })
191
+ });
192
+ if (!res.ok) throw new Error(`[PineconeProvider] Proxy batch upsert failed: ${await res.text()}`);
193
+ }
194
+ return;
195
+ }
196
+ const targetIdx = await this.getActiveIndex(namespace);
197
+ for (let i = 0; i < docs.length; i += BATCH) {
198
+ const records = docs.slice(i, i + BATCH).map((d) => {
199
+ var _a;
200
+ return {
201
+ id: String(d.id),
202
+ values: d.vector,
203
+ metadata: __spreadValues({ content: d.content }, (_a = d.metadata) != null ? _a : {})
204
+ };
205
+ });
206
+ await targetIdx.upsert({ records });
207
+ }
208
+ }
209
+ async query(vector, topK, namespace, filter) {
210
+ var _a, _b;
211
+ const pineconeFilter = this.sanitizeFilter(filter);
212
+ if (!this.client) {
213
+ if (!this.licenseKey) throw new Error("[PineconeProvider] Cannot execute vector operation: Missing API key and License key.");
214
+ const res = await fetch(`${this.getControlPlaneUrl()}/api/v1/vectors/query`, {
215
+ method: "POST",
216
+ headers: __spreadValues({
217
+ "Content-Type": "application/json",
218
+ "x-license-key": this.licenseKey
219
+ }, this.projectId ? { "x-project-id": this.projectId } : {}),
220
+ body: JSON.stringify({
221
+ projectId: this.projectId,
222
+ indexName: this.indexName,
223
+ namespace: namespace || this.projectId,
224
+ vector,
225
+ topK,
226
+ filter: pineconeFilter
227
+ })
228
+ });
229
+ if (!res.ok) throw new Error(`[PineconeProvider] Proxy query failed: ${await res.text()}`);
230
+ const data = await res.json();
231
+ return ((_a = data.matches) != null ? _a : []).map((m) => {
232
+ var _a2, _b2;
233
+ return {
234
+ id: m.id,
235
+ score: (_a2 = m.score) != null ? _a2 : 0,
236
+ content: ((_b2 = m.metadata) == null ? void 0 : _b2.content) || "",
237
+ metadata: m.metadata
238
+ };
239
+ });
240
+ }
241
+ const targetIdx = await this.getActiveIndex(namespace);
242
+ const result = await targetIdx.query(__spreadValues({
243
+ vector,
244
+ topK,
245
+ includeMetadata: true
246
+ }, Object.keys(pineconeFilter).length > 0 ? { filter: pineconeFilter } : {}));
247
+ return ((_b = result.matches) != null ? _b : []).map((m) => {
248
+ var _a2, _b2;
249
+ return {
250
+ id: m.id,
251
+ score: (_a2 = m.score) != null ? _a2 : 0,
252
+ content: ((_b2 = m.metadata) == null ? void 0 : _b2.content) || "",
253
+ metadata: m.metadata
254
+ };
255
+ });
256
+ }
257
+ async delete(id, namespace) {
258
+ const targetIdx = await this.getActiveIndex(namespace);
259
+ await targetIdx.deleteOne({ id: String(id) });
260
+ }
261
+ async deleteNamespace(namespace) {
262
+ const targetIdx = await this.getActiveIndex(namespace);
263
+ await targetIdx.deleteAll();
264
+ }
265
+ async ping() {
266
+ try {
267
+ if (!this.client) await this.initialize();
268
+ if (!this.client) return false;
269
+ await this.client.listIndexes();
270
+ return true;
271
+ } catch (e) {
272
+ return false;
273
+ }
274
+ }
275
+ async disconnect() {
276
+ }
277
+ };
278
+
279
+ export {
280
+ PineconeProvider
281
+ };
@@ -0,0 +1,168 @@
1
+ // package.json
2
+ var package_default = {
3
+ name: "@retrivora-ai/rag-engine",
4
+ version: "2.6.3",
5
+ description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
6
+ author: "Abhinav Alkuchi",
7
+ license: "UNLICENSED",
8
+ keywords: [
9
+ "rag",
10
+ "retrieval-augmented-generation",
11
+ "chatbot",
12
+ "vector-database",
13
+ "pinecone",
14
+ "pgvector",
15
+ "postgresql",
16
+ "milvus",
17
+ "qdrant",
18
+ "chromadb",
19
+ "redis",
20
+ "weaviate",
21
+ "mongodb",
22
+ "openai",
23
+ "anthropic",
24
+ "ollama",
25
+ "nextjs",
26
+ "react",
27
+ "ai",
28
+ "llm",
29
+ "embeddings"
30
+ ],
31
+ main: "dist/index.js",
32
+ module: "dist/index.mjs",
33
+ types: "dist/index.d.ts",
34
+ exports: {
35
+ ".": {
36
+ types: "./dist/index.d.ts",
37
+ require: "./dist/index.js",
38
+ import: "./dist/index.mjs"
39
+ },
40
+ "./style.css": "./dist/index.css",
41
+ "./style.min.css": "./dist/index.min.css",
42
+ "./index.css": "./dist/index.css",
43
+ "./index.min.css": "./dist/index.min.css",
44
+ "./styles.css": "./dist/index.css",
45
+ "./styles.min.css": "./dist/index.min.css",
46
+ "./handlers": {
47
+ types: "./dist/handlers/index.d.ts",
48
+ require: "./dist/handlers/index.js",
49
+ import: "./dist/handlers/index.mjs"
50
+ },
51
+ "./server": {
52
+ types: "./dist/server.d.ts",
53
+ require: "./dist/server.js",
54
+ import: "./dist/server.mjs"
55
+ }
56
+ },
57
+ browser: {
58
+ child_process: false,
59
+ fs: false,
60
+ net: false,
61
+ tls: false,
62
+ crypto: false,
63
+ os: false,
64
+ path: false,
65
+ stream: false,
66
+ http: false,
67
+ https: false,
68
+ zlib: false,
69
+ mongodb: false,
70
+ pg: false,
71
+ "pdf-parse": false,
72
+ mammoth: false
73
+ },
74
+ files: [
75
+ "dist",
76
+ "README.md",
77
+ "FREE_TIER_ARCHITECTURE.md"
78
+ ],
79
+ scripts: {
80
+ dev: "npx @tailwindcss/cli -i src/tailwind.css -o src/index.css && tsup src/index.ts src/handlers/index.ts src/server.ts --format cjs,esm --watch --tsconfig tsconfig.build.json --external react,react-dom,next,mongodb,pg,openai,@anthropic-ai/sdk,@pinecone-database/pinecone,axios,lucide-react,mammoth,pdf-parse,xlsx,react-markdown,remark-gfm,next-themes,langchain,@langchain/core,@langchain/openai,llamaindex --inject-style",
81
+ build: "npm run build:pkg",
82
+ "build:pkg": "npx @tailwindcss/cli -i src/tailwind.css -o src/index.css && tsup src/index.ts src/handlers/index.ts src/server.ts --format cjs,esm --dts --clean --no-splitting --tsconfig tsconfig.build.json --external react,react-dom,next,mongodb,pg,openai,@anthropic-ai/sdk,@pinecone-database/pinecone,axios,lucide-react,mammoth,pdf-parse,xlsx,react-markdown,remark-gfm,next-themes,langchain,@langchain/core,@langchain/openai,llamaindex --inject-style && npx @tailwindcss/cli -i src/tailwind.css -o dist/index.css && npx @tailwindcss/cli -i src/tailwind.css -o dist/index.min.css --minify",
83
+ lint: "eslint",
84
+ typecheck: "tsc --noEmit -p tsconfig.build.json",
85
+ test: "jest",
86
+ clean: `node -e "require('fs').rmSync('dist', { recursive: true, force: true })"`
87
+ },
88
+ peerDependencies: {
89
+ axios: ">=1.0.0",
90
+ next: ">=15.0.0",
91
+ react: ">=18.0.0",
92
+ "react-dom": ">=18.0.0"
93
+ },
94
+ peerDependenciesMeta: {
95
+ axios: {
96
+ optional: true
97
+ },
98
+ next: {
99
+ optional: true
100
+ }
101
+ },
102
+ dependencies: {
103
+ "@anthropic-ai/sdk": "^0.95.1",
104
+ "@google/genai": "^0.8.0",
105
+ "@google/generative-ai": "^0.24.1",
106
+ "@pinecone-database/pinecone": "^7.2.0",
107
+ "@retrivora-ai/billing-guards": "file:../billing-guards",
108
+ "@types/papaparse": "^5.5.2",
109
+ exceljs: "^4.4.0",
110
+ "framer-motion": "^13.1.0",
111
+ jszip: "^3.10.1",
112
+ katex: "^0.18.4",
113
+ "lucide-react": "^1.8.0",
114
+ "next-themes": "^0.4.6",
115
+ openai: "^6.34.0",
116
+ papaparse: "^5.5.3",
117
+ "react-is": "^18.3.1",
118
+ "react-markdown": "^10.1.0",
119
+ "react-syntax-highlighter": "^16.1.1",
120
+ recharts: "^3.8.1",
121
+ "rehype-katex": "^7.0.1",
122
+ "remark-gfm": "^4.0.1",
123
+ "remark-math": "^6.0.0",
124
+ xlsx: "^0.18.5",
125
+ zod: "^4.4.3"
126
+ },
127
+ optionalDependencies: {
128
+ "@langchain/core": "^1.1.42",
129
+ "@langchain/openai": "^1.4.5",
130
+ langchain: "^1.3.5",
131
+ llamaindex: "^0.11.9",
132
+ mammoth: "^1.8.0",
133
+ mongodb: "^7.1.1",
134
+ "pdf-parse": "^1.1.1",
135
+ pg: "^8.20.0"
136
+ },
137
+ devDependencies: {
138
+ "@tailwindcss/cli": "^4",
139
+ "@tailwindcss/postcss": "^4",
140
+ "@types/estree": "^1.0.9",
141
+ "@types/jest": "^30.0.0",
142
+ "@types/jszip": "^3.4.1",
143
+ "@types/katex": "^0.16.8",
144
+ "@types/node": "^20",
145
+ "@types/pdf-parse": "^1.1.5",
146
+ "@types/pg": "^8.20.0",
147
+ "@types/react": "^19.2.14",
148
+ "@types/react-dom": "^19.2.3",
149
+ "@types/react-syntax-highlighter": "^15.5.13",
150
+ axios: "^1.15.0",
151
+ dotenv: "^17.4.2",
152
+ eslint: "^9",
153
+ "eslint-config-next": "16.3.2",
154
+ jest: "^30.4.2",
155
+ next: "^16.3.2",
156
+ tailwindcss: "^4",
157
+ "ts-jest": "^29.4.12",
158
+ tsup: "^8.5.1",
159
+ typescript: "^5"
160
+ }
161
+ };
162
+
163
+ // src/version.ts
164
+ var SDK_VERSION = package_default.version || "2.1.3";
165
+
166
+ export {
167
+ SDK_VERSION
168
+ };