@retrivora-ai/rag-engine 2.1.7 → 2.2.0

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/server.js CHANGED
@@ -793,6 +793,84 @@ var init_BaseVectorProvider = __esm({
793
793
  }
794
794
  });
795
795
 
796
+ // src/core/ConfigFetcher.ts
797
+ var ConfigFetcher;
798
+ var init_ConfigFetcher = __esm({
799
+ "src/core/ConfigFetcher.ts"() {
800
+ "use strict";
801
+ ConfigFetcher = class {
802
+ // 5-minute in-memory session cache
803
+ /**
804
+ * Fetch full project configuration (vectorDb + embedding + llm) from Retrivora Control Plane.
805
+ */
806
+ static async fetchRemoteConfig(projectId, licenseKey) {
807
+ var _a2, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k;
808
+ const cacheKey = `${projectId}:${licenseKey || ""}`;
809
+ const now = Date.now();
810
+ const cached = this.cache.get(cacheKey);
811
+ if (cached && now - cached.cachedAt < this.TTL_MS) {
812
+ return cached.config;
813
+ }
814
+ const controlPlaneUrls = [
815
+ process.env.RETRIVORA_CONTROL_PLANE_URL,
816
+ process.env.NEXT_PUBLIC_RETRIVORA_CONTROL_PLANE_URL,
817
+ "https://retrivora.com",
818
+ "http://localhost:3000"
819
+ ].filter(Boolean);
820
+ for (const baseUrl of controlPlaneUrls) {
821
+ try {
822
+ const url = `${baseUrl.replace(/\/$/, "")}/api/v1/config?projectId=${encodeURIComponent(projectId)}${licenseKey ? `&licenseKey=${encodeURIComponent(licenseKey)}` : ""}`;
823
+ const res = await fetch(url, {
824
+ method: "GET",
825
+ headers: __spreadValues({
826
+ "Content-Type": "application/json"
827
+ }, licenseKey ? { "x-license-key": licenseKey } : {})
828
+ });
829
+ if (res.ok) {
830
+ const data = await res.json();
831
+ if ((data == null ? void 0 : data.success) && ((_a2 = data == null ? void 0 : data.vectorDb) == null ? void 0 : _a2.apiKey)) {
832
+ const config = {
833
+ vectorDb: {
834
+ apiKey: data.vectorDb.apiKey,
835
+ indexName: data.vectorDb.indexName || "retrivora-free",
836
+ provider: data.vectorDb.provider || "pinecone"
837
+ },
838
+ embedding: {
839
+ provider: ((_b = data.embedding) == null ? void 0 : _b.provider) || "universal_rest",
840
+ model: ((_c = data.embedding) == null ? void 0 : _c.model) || "text-embedding-004",
841
+ baseUrl: ((_d = data.embedding) == null ? void 0 : _d.baseUrl) || "https://llm.retrivora.com/api/v1",
842
+ apiKey: ((_e = data.embedding) == null ? void 0 : _e.apiKey) || licenseKey || "",
843
+ profile: ((_f = data.embedding) == null ? void 0 : _f.profile) || "litellm"
844
+ },
845
+ llm: {
846
+ provider: ((_g2 = data.llm) == null ? void 0 : _g2.provider) || "universal_rest",
847
+ model: ((_h = data.llm) == null ? void 0 : _h.model) || "llama-3.1-8b-instant",
848
+ baseUrl: ((_i = data.llm) == null ? void 0 : _i.baseUrl) || "https://llm.retrivora.com/api/v1",
849
+ apiKey: ((_j = data.llm) == null ? void 0 : _j.apiKey) || licenseKey || "",
850
+ profile: ((_k = data.llm) == null ? void 0 : _k.profile) || "litellm"
851
+ }
852
+ };
853
+ this.cache.set(cacheKey, { config, cachedAt: now });
854
+ return config;
855
+ }
856
+ }
857
+ } catch (e) {
858
+ }
859
+ }
860
+ return null;
861
+ }
862
+ /** Convenience: fetch only vector DB config (backwards compat). */
863
+ static async fetchRemoteVectorConfig(projectId, licenseKey) {
864
+ var _a2;
865
+ const config = await this.fetchRemoteConfig(projectId, licenseKey);
866
+ return (_a2 = config == null ? void 0 : config.vectorDb) != null ? _a2 : null;
867
+ }
868
+ };
869
+ ConfigFetcher.cache = /* @__PURE__ */ new Map();
870
+ ConfigFetcher.TTL_MS = 5 * 60 * 1e3;
871
+ }
872
+ });
873
+
796
874
  // src/providers/vectordb/PineconeProvider.ts
797
875
  var PineconeProvider_exports = {};
798
876
  __export(PineconeProvider_exports, {
@@ -804,23 +882,26 @@ var init_PineconeProvider = __esm({
804
882
  "use strict";
805
883
  import_pinecone = require("@pinecone-database/pinecone");
806
884
  init_BaseVectorProvider();
885
+ init_ConfigFetcher();
807
886
  PineconeProvider = class extends BaseVectorProvider {
808
887
  constructor(config) {
809
888
  super(config);
810
- const opts = config.options;
811
- if (!opts.apiKey) throw new Error("[PineconeProvider] options.apiKey is required");
812
- this.apiKey = opts.apiKey;
889
+ const opts = config.options || {};
890
+ this.apiKey = opts.apiKey || process.env.PINECONE_API_KEY || "";
813
891
  }
814
892
  static getValidator() {
815
893
  return {
816
894
  validate(config) {
817
895
  const errors = [];
818
896
  const opts = config.options || {};
819
- if (!opts.apiKey) {
897
+ const hasLicenseKey = Boolean(
898
+ config.licenseKey || process.env.RETRIVORA_LICENSE_KEY || process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY
899
+ );
900
+ if (!opts.apiKey && !hasLicenseKey) {
820
901
  errors.push({
821
902
  field: "vectorDb.options.apiKey",
822
- message: "Pinecone API key is required",
823
- suggestion: "Set PINECONE_API_KEY environment variable",
903
+ message: "Pinecone API key is required when RETRIVORA_LICENSE_KEY is not set",
904
+ suggestion: "Set PINECONE_API_KEY environment variable or supply RETRIVORA_LICENSE_KEY for keyless vector storage",
824
905
  severity: "error"
825
906
  });
826
907
  }
@@ -867,22 +948,49 @@ var init_PineconeProvider = __esm({
867
948
  }
868
949
  async initialize() {
869
950
  var _a2, _b;
870
- this.client = new import_pinecone.Pinecone({ apiKey: this.apiKey });
871
- const indexes = await this.client.listIndexes();
872
- const names = (_b = (_a2 = indexes.indexes) == null ? void 0 : _a2.map((i) => i.name)) != null ? _b : [];
873
- if (!names.includes(this.indexName)) {
874
- throw new Error(
875
- `[PineconeProvider] Index "${this.indexName}" not found. Available: ${names.join(", ")}`
876
- );
951
+ if (this.client) return;
952
+ let key = this.apiKey || process.env.PINECONE_API_KEY || "";
953
+ if (!key) {
954
+ const projectId = process.env.RAG_PROJECT_ID || process.env.NEXT_PUBLIC_RAG_PROJECT_ID || "my-rag-app";
955
+ const licenseKey = process.env.RETRIVORA_LICENSE_KEY || process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY;
956
+ const remoteConfig = await ConfigFetcher.fetchRemoteVectorConfig(projectId, licenseKey);
957
+ if (remoteConfig == null ? void 0 : remoteConfig.apiKey) {
958
+ key = remoteConfig.apiKey;
959
+ this.apiKey = key;
960
+ if (remoteConfig.indexName) {
961
+ this.indexName = remoteConfig.indexName;
962
+ }
963
+ }
964
+ }
965
+ if (!key) {
966
+ console.warn("[PineconeProvider] Warning: No Pinecone API key available locally or remotely.");
967
+ return;
968
+ }
969
+ this.client = new import_pinecone.Pinecone({ apiKey: key });
970
+ try {
971
+ const indexes = await this.client.listIndexes();
972
+ const names = (_b = (_a2 = indexes.indexes) == null ? void 0 : _a2.map((i) => i.name)) != null ? _b : [];
973
+ if (!names.includes(this.indexName)) {
974
+ console.warn(`[PineconeProvider] Target index "${this.indexName}" not listed. Proceeding with configured index name.`);
975
+ }
976
+ } catch (err) {
977
+ console.warn("[PineconeProvider] List index verification warning:", err instanceof Error ? err.message : String(err));
877
978
  }
878
979
  }
879
- index(namespace) {
980
+ async getActiveIndex(namespace) {
981
+ if (!this.client) {
982
+ await this.initialize();
983
+ }
984
+ if (!this.client) {
985
+ throw new Error("[PineconeProvider] Cannot execute vector operation: Pinecone client failed to initialize.");
986
+ }
880
987
  const idx = this.client.index(this.indexName);
881
988
  return namespace ? idx.namespace(namespace) : idx.namespace("");
882
989
  }
883
990
  async upsert(doc, namespace) {
884
991
  var _a2;
885
- await this.index(namespace).upsert({
992
+ const targetIdx = await this.getActiveIndex(namespace);
993
+ await targetIdx.upsert({
886
994
  records: [{
887
995
  id: String(doc.id),
888
996
  values: doc.vector,
@@ -891,6 +999,7 @@ var init_PineconeProvider = __esm({
891
999
  });
892
1000
  }
893
1001
  async batchUpsert(docs, namespace) {
1002
+ const targetIdx = await this.getActiveIndex(namespace);
894
1003
  const BATCH = 100;
895
1004
  for (let i = 0; i < docs.length; i += BATCH) {
896
1005
  const records = docs.slice(i, i + BATCH).map((d) => {
@@ -901,13 +1010,14 @@ var init_PineconeProvider = __esm({
901
1010
  metadata: __spreadValues({ content: d.content }, (_a2 = d.metadata) != null ? _a2 : {})
902
1011
  };
903
1012
  });
904
- await this.index(namespace).upsert({ records });
1013
+ await targetIdx.upsert({ records });
905
1014
  }
906
1015
  }
907
1016
  async query(vector, topK, namespace, filter) {
908
1017
  var _a2;
1018
+ const targetIdx = await this.getActiveIndex(namespace);
909
1019
  const pineconeFilter = this.sanitizeFilter(filter);
910
- const result = await this.index(namespace).query(__spreadValues({
1020
+ const result = await targetIdx.query(__spreadValues({
911
1021
  vector,
912
1022
  topK,
913
1023
  includeMetadata: true
@@ -923,13 +1033,17 @@ var init_PineconeProvider = __esm({
923
1033
  });
924
1034
  }
925
1035
  async delete(id, namespace) {
926
- await this.index(namespace).deleteOne({ id: String(id) });
1036
+ const targetIdx = await this.getActiveIndex(namespace);
1037
+ await targetIdx.deleteOne({ id: String(id) });
927
1038
  }
928
1039
  async deleteNamespace(namespace) {
929
- await this.client.index(this.indexName).namespace(namespace).deleteAll();
1040
+ const targetIdx = await this.getActiveIndex(namespace);
1041
+ await targetIdx.deleteAll();
930
1042
  }
931
1043
  async ping() {
932
1044
  try {
1045
+ if (!this.client) await this.initialize();
1046
+ if (!this.client) return false;
933
1047
  await this.client.listIndexes();
934
1048
  return true;
935
1049
  } catch (e) {
@@ -3142,7 +3256,7 @@ function getRagConfig(baseConfig, env = process.env) {
3142
3256
  return getEnvConfig(env, baseConfig);
3143
3257
  }
3144
3258
  function getEnvConfig(env = process.env, base) {
3145
- var _a2, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa, _Ya, _Za, __a, _$a, _ab, _bb, _cb, _db, _eb, _fb, _gb, _hb, _ib, _jb, _kb, _lb, _mb, _nb, _ob, _pb, _qb, _rb, _sb, _tb, _ub, _vb, _wb, _xb, _yb, _zb, _Ab, _Bb, _Cb, _Db, _Eb, _Fb, _Gb, _Hb;
3259
+ var _a2, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa, _Ya, _Za, __a, _$a, _ab, _bb, _cb, _db, _eb, _fb, _gb, _hb, _ib, _jb, _kb, _lb, _mb, _nb, _ob, _pb, _qb, _rb, _sb, _tb, _ub, _vb, _wb, _xb, _yb, _zb, _Ab, _Bb, _Cb, _Db, _Eb, _Fb, _Gb, _Hb, _Ib;
3146
3260
  const projectId = (_c = (_b = (_a2 = readString(env, "RAG_PROJECT_ID")) != null ? _a2 : readString(env, "NEXT_PUBLIC_PROJECT_ID")) != null ? _b : base == null ? void 0 : base.projectId) != null ? _c : "__default__";
3147
3261
  const licenseKey = (_g2 = (_f = (_e = (_d = readString(env, "RAG_LICENSE_KEY")) != null ? _d : readString(env, "RETRIVORA_LICENSE_KEY")) != null ? _e : readString(env, "NEXT_PUBLIC_RETRIVORA_LICENSE_KEY")) != null ? _f : readString(env, "LICENSE_KEY")) != null ? _g2 : base == null ? void 0 : base.licenseKey;
3148
3262
  const telemetryEnabled = readString(env, "TELEMETRY_ENABLED") === "true" || readString(env, "NEXT_PUBLIC_TELEMETRY_ENABLED") === "true" || ((_h = base == null ? void 0 : base.telemetry) == null ? void 0 : _h.enabled) || Boolean(licenseKey);
@@ -3150,39 +3264,38 @@ function getEnvConfig(env = process.env, base) {
3150
3264
  const embeddingDimensions = readNumber(env, "EMBEDDING_DIMENSIONS", 768);
3151
3265
  const vectorDbOptions = {};
3152
3266
  if (vectorProvider === "pinecone") {
3153
- const rawApiKey = (_l = (_k = readString(env, "PINECONE_API_KEY")) != null ? _k : (_j = (_i = base == null ? void 0 : base.vectorDb) == null ? void 0 : _i.options) == null ? void 0 : _j.apiKey) != null ? _l : process.env.PINECONE_API_KEY;
3154
- vectorDbOptions.apiKey = rawApiKey || (licenseKey ? "retrivora-keyless-gateway" : "keyless-free-tier");
3155
- vectorDbOptions.indexName = (_s = (_r = (_q = (_n = readString(env, "PINECONE_INDEX")) != null ? _n : (_m = base == null ? void 0 : base.vectorDb) == null ? void 0 : _m.indexName) != null ? _q : (_p = (_o = base == null ? void 0 : base.vectorDb) == null ? void 0 : _o.options) == null ? void 0 : _p.indexName) != null ? _r : process.env.PINECONE_INDEX) != null ? _s : "retrivora-free";
3267
+ vectorDbOptions.apiKey = (_m = (_l = (_k = readString(env, "PINECONE_API_KEY")) != null ? _k : (_j = (_i = base == null ? void 0 : base.vectorDb) == null ? void 0 : _i.options) == null ? void 0 : _j.apiKey) != null ? _l : process.env.PINECONE_API_KEY) != null ? _m : "";
3268
+ vectorDbOptions.indexName = (_t = (_s = (_r = (_o = readString(env, "PINECONE_INDEX")) != null ? _o : (_n = base == null ? void 0 : base.vectorDb) == null ? void 0 : _n.indexName) != null ? _r : (_q = (_p = base == null ? void 0 : base.vectorDb) == null ? void 0 : _p.options) == null ? void 0 : _q.indexName) != null ? _s : process.env.PINECONE_INDEX) != null ? _t : "retrivora-free";
3156
3269
  } else if (vectorProvider === "pgvector" || vectorProvider === "postgresql") {
3157
- vectorDbOptions.connectionString = (_x = (_w = (_t = readString(env, "PGVECTOR_CONNECTION_STRING")) != null ? _t : readString(env, "POSTGRES_URL")) != null ? _w : (_v = (_u = base == null ? void 0 : base.vectorDb) == null ? void 0 : _u.options) == null ? void 0 : _v.connectionString) != null ? _x : "";
3158
- vectorDbOptions.tables = (_C = (_z = (_y = readString(env, "VECTOR_DB_TABLES")) != null ? _y : readString(env, "POSTGRES_TABLES")) == null ? void 0 : _z.split(",").map((t) => t.trim())) != null ? _C : (_B = (_A = base == null ? void 0 : base.vectorDb) == null ? void 0 : _A.options) == null ? void 0 : _B.tables;
3159
- vectorDbOptions.searchFields = (_G = (_D = readString(env, "POSTGRES_SEARCH_FIELDS")) == null ? void 0 : _D.split(",").map((f) => f.trim())) != null ? _G : (_F = (_E = base == null ? void 0 : base.vectorDb) == null ? void 0 : _E.options) == null ? void 0 : _F.searchFields;
3270
+ vectorDbOptions.connectionString = (_y = (_x = (_u = readString(env, "PGVECTOR_CONNECTION_STRING")) != null ? _u : readString(env, "POSTGRES_URL")) != null ? _x : (_w = (_v = base == null ? void 0 : base.vectorDb) == null ? void 0 : _v.options) == null ? void 0 : _w.connectionString) != null ? _y : "";
3271
+ vectorDbOptions.tables = (_D = (_A = (_z = readString(env, "VECTOR_DB_TABLES")) != null ? _z : readString(env, "POSTGRES_TABLES")) == null ? void 0 : _A.split(",").map((t) => t.trim())) != null ? _D : (_C = (_B = base == null ? void 0 : base.vectorDb) == null ? void 0 : _B.options) == null ? void 0 : _C.tables;
3272
+ vectorDbOptions.searchFields = (_H = (_E = readString(env, "POSTGRES_SEARCH_FIELDS")) == null ? void 0 : _E.split(",").map((f) => f.trim())) != null ? _H : (_G = (_F = base == null ? void 0 : base.vectorDb) == null ? void 0 : _F.options) == null ? void 0 : _G.searchFields;
3160
3273
  vectorDbOptions.dimensions = embeddingDimensions;
3161
3274
  } else if (vectorProvider === "mongodb") {
3162
- vectorDbOptions.uri = (_K = (_J = readString(env, "MONGODB_URI")) != null ? _J : (_I = (_H = base == null ? void 0 : base.vectorDb) == null ? void 0 : _H.options) == null ? void 0 : _I.uri) != null ? _K : "";
3163
- vectorDbOptions.database = (_O = (_N = readString(env, "MONGODB_DB")) != null ? _N : (_M = (_L = base == null ? void 0 : base.vectorDb) == null ? void 0 : _L.options) == null ? void 0 : _M.database) != null ? _O : "";
3164
- vectorDbOptions.collection = (_S = (_R = readString(env, "MONGODB_COLLECTION")) != null ? _R : (_Q = (_P = base == null ? void 0 : base.vectorDb) == null ? void 0 : _P.options) == null ? void 0 : _Q.collection) != null ? _S : "";
3165
- vectorDbOptions.indexName = (_Y = (_X = (_U = readString(env, "MONGODB_INDEX_NAME")) != null ? _U : (_T = base == null ? void 0 : base.vectorDb) == null ? void 0 : _T.indexName) != null ? _X : (_W = (_V = base == null ? void 0 : base.vectorDb) == null ? void 0 : _V.options) == null ? void 0 : _W.indexName) != null ? _Y : "vector_index";
3275
+ vectorDbOptions.uri = (_L = (_K = readString(env, "MONGODB_URI")) != null ? _K : (_J = (_I = base == null ? void 0 : base.vectorDb) == null ? void 0 : _I.options) == null ? void 0 : _J.uri) != null ? _L : "";
3276
+ vectorDbOptions.database = (_P = (_O = readString(env, "MONGODB_DB")) != null ? _O : (_N = (_M = base == null ? void 0 : base.vectorDb) == null ? void 0 : _M.options) == null ? void 0 : _N.database) != null ? _P : "";
3277
+ vectorDbOptions.collection = (_T = (_S = readString(env, "MONGODB_COLLECTION")) != null ? _S : (_R = (_Q = base == null ? void 0 : base.vectorDb) == null ? void 0 : _Q.options) == null ? void 0 : _R.collection) != null ? _T : "";
3278
+ vectorDbOptions.indexName = (_Z = (_Y = (_V = readString(env, "MONGODB_INDEX_NAME")) != null ? _V : (_U = base == null ? void 0 : base.vectorDb) == null ? void 0 : _U.indexName) != null ? _Y : (_X = (_W = base == null ? void 0 : base.vectorDb) == null ? void 0 : _W.options) == null ? void 0 : _X.indexName) != null ? _Z : "vector_index";
3166
3279
  } else if (vectorProvider === "qdrant") {
3167
- vectorDbOptions.baseUrl = (_aa = (_$ = readString(env, "QDRANT_URL")) != null ? _$ : (__ = (_Z = base == null ? void 0 : base.vectorDb) == null ? void 0 : _Z.options) == null ? void 0 : __.baseUrl) != null ? _aa : "http://localhost:6333";
3168
- vectorDbOptions.apiKey = (_da = readString(env, "QDRANT_API_KEY")) != null ? _da : (_ca = (_ba = base == null ? void 0 : base.vectorDb) == null ? void 0 : _ba.options) == null ? void 0 : _ca.apiKey;
3280
+ vectorDbOptions.baseUrl = (_ba = (_aa = readString(env, "QDRANT_URL")) != null ? _aa : (_$ = (__ = base == null ? void 0 : base.vectorDb) == null ? void 0 : __.options) == null ? void 0 : _$.baseUrl) != null ? _ba : "http://localhost:6333";
3281
+ vectorDbOptions.apiKey = (_ea = readString(env, "QDRANT_API_KEY")) != null ? _ea : (_da = (_ca = base == null ? void 0 : base.vectorDb) == null ? void 0 : _ca.options) == null ? void 0 : _da.apiKey;
3169
3282
  vectorDbOptions.dimensions = embeddingDimensions;
3170
3283
  } else if (vectorProvider === "milvus") {
3171
- vectorDbOptions.baseUrl = (_ea = readString(env, "MILVUS_URL")) != null ? _ea : "http://localhost:19530";
3284
+ vectorDbOptions.baseUrl = (_fa = readString(env, "MILVUS_URL")) != null ? _fa : "http://localhost:19530";
3172
3285
  vectorDbOptions.apiKey = readString(env, "MILVUS_API_KEY");
3173
3286
  } else if (vectorProvider === "chromadb") {
3174
- vectorDbOptions.baseUrl = (_fa = readString(env, "CHROMADB_URL")) != null ? _fa : "http://localhost:8000";
3287
+ vectorDbOptions.baseUrl = (_ga = readString(env, "CHROMADB_URL")) != null ? _ga : "http://localhost:8000";
3175
3288
  } else if (vectorProvider === "weaviate") {
3176
- vectorDbOptions.baseUrl = (_ga = readString(env, "WEAVIATE_URL")) != null ? _ga : "http://localhost:8080";
3289
+ vectorDbOptions.baseUrl = (_ha = readString(env, "WEAVIATE_URL")) != null ? _ha : "http://localhost:8080";
3177
3290
  vectorDbOptions.apiKey = readString(env, "WEAVIATE_API_KEY");
3178
3291
  } else if (vectorProvider === "redis") {
3179
- vectorDbOptions.baseUrl = (_ha = readString(env, "REDIS_URL")) != null ? _ha : "";
3292
+ vectorDbOptions.baseUrl = (_ia = readString(env, "REDIS_URL")) != null ? _ia : "";
3180
3293
  vectorDbOptions.apiKey = readString(env, "REDIS_API_KEY");
3181
3294
  } else if (vectorProvider === "rest") {
3182
- vectorDbOptions.baseUrl = (_ia = readString(env, "VECTOR_DB_REST_URL")) != null ? _ia : "";
3295
+ vectorDbOptions.baseUrl = (_ja = readString(env, "VECTOR_DB_REST_URL")) != null ? _ja : "";
3183
3296
  vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { "api-key": readString(env, "VECTOR_DB_REST_API_KEY") } : {};
3184
3297
  } else if (vectorProvider === "universal_rest") {
3185
- vectorDbOptions.baseUrl = (_ka = (_ja = readString(env, "VECTOR_BASE_URL")) != null ? _ja : readString(env, "VECTOR_DB_REST_URL")) != null ? _ka : "";
3298
+ vectorDbOptions.baseUrl = (_la = (_ka = readString(env, "VECTOR_BASE_URL")) != null ? _ka : readString(env, "VECTOR_DB_REST_URL")) != null ? _la : "";
3186
3299
  vectorDbOptions.profile = readString(env, "VECTOR_UNIVERSAL_PROFILE");
3187
3300
  vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { Authorization: `Bearer ${readString(env, "VECTOR_DB_REST_API_KEY")}` } : {};
3188
3301
  }
@@ -3201,8 +3314,8 @@ function getEnvConfig(env = process.env, base) {
3201
3314
  // Anthropic needs a separate embedding provider; key kept for completeness
3202
3315
  gemini: readString(env, "GEMINI_API_KEY"),
3203
3316
  ollama: void 0,
3204
- universal_rest: (_la = readString(env, "EMBEDDING_API_KEY")) != null ? _la : readString(env, "OPENAI_API_KEY"),
3205
- custom: (_ma = readString(env, "EMBEDDING_API_KEY")) != null ? _ma : readString(env, "OPENAI_API_KEY")
3317
+ universal_rest: (_ma = readString(env, "EMBEDDING_API_KEY")) != null ? _ma : readString(env, "OPENAI_API_KEY"),
3318
+ custom: (_na = readString(env, "EMBEDDING_API_KEY")) != null ? _na : readString(env, "OPENAI_API_KEY")
3206
3319
  };
3207
3320
  const DEFAULT_MODEL_BY_PROVIDER = {
3208
3321
  openai: "gpt-4o",
@@ -3223,25 +3336,25 @@ function getEnvConfig(env = process.env, base) {
3223
3336
  return true;
3224
3337
  }
3225
3338
  })();
3226
- const defaultGatewayUrl = (_oa = (_na = readString(env, "LITELLM_BASE_URL")) != null ? _na : readString(env, "LLM_BASE_URL")) != null ? _oa : "https://llm.retrivora.com/api/v1";
3339
+ const defaultGatewayUrl = (_pa = (_oa = readString(env, "LITELLM_BASE_URL")) != null ? _oa : readString(env, "LLM_BASE_URL")) != null ? _pa : "https://retrivora.com/api/v1";
3227
3340
  const defaultLlmProvider = isFreeTier ? "universal_rest" : "universal_rest";
3228
- const llmProvider = (_ra = (_qa = readEnum(env, "LLM_PROVIDER", defaultLlmProvider, LLM_PROVIDERS)) != null ? _qa : (_pa = base == null ? void 0 : base.llm) == null ? void 0 : _pa.provider) != null ? _ra : defaultLlmProvider;
3229
- const llmBaseUrl = (_va = (_ua = (_sa = readString(env, "LITELLM_BASE_URL")) != null ? _sa : readString(env, "LLM_BASE_URL")) != null ? _ua : (_ta = base == null ? void 0 : base.llm) == null ? void 0 : _ta.baseUrl) != null ? _va : defaultGatewayUrl;
3230
- const llmModel = (_za = (_xa = readString(env, "LLM_MODEL")) != null ? _xa : (_wa = base == null ? void 0 : base.llm) == null ? void 0 : _wa.model) != null ? _za : isFreeTier ? "llama-3.1-8b-instant" : (_ya = DEFAULT_MODEL_BY_PROVIDER[llmProvider]) != null ? _ya : "gpt-4o";
3231
- const llmApiKey = (_Fa = (_Ea = (_Ca = (_Ba = (_Aa = llmApiKeyByProvider[llmProvider]) != null ? _Aa : readString(env, "LLM_API_KEY")) != null ? _Ba : readString(env, "LITELLM_MASTER_KEY")) != null ? _Ca : readString(env, "LITELLM_API_KEY")) != null ? _Ea : (_Da = base == null ? void 0 : base.llm) == null ? void 0 : _Da.apiKey) != null ? _Fa : licenseKey;
3232
- const llmProfile = (_Ja = (_Ia = readString(env, "LLM_UNIVERSAL_PROFILE")) != null ? _Ia : (_Ha = (_Ga = base == null ? void 0 : base.llm) == null ? void 0 : _Ga.options) == null ? void 0 : _Ha.profile) != null ? _Ja : "litellm";
3341
+ const llmProvider = (_sa = (_ra = readEnum(env, "LLM_PROVIDER", defaultLlmProvider, LLM_PROVIDERS)) != null ? _ra : (_qa = base == null ? void 0 : base.llm) == null ? void 0 : _qa.provider) != null ? _sa : defaultLlmProvider;
3342
+ const llmBaseUrl = (_wa = (_va = (_ta = readString(env, "LITELLM_BASE_URL")) != null ? _ta : readString(env, "LLM_BASE_URL")) != null ? _va : (_ua = base == null ? void 0 : base.llm) == null ? void 0 : _ua.baseUrl) != null ? _wa : defaultGatewayUrl;
3343
+ const llmModel = (_Aa = (_ya = readString(env, "LLM_MODEL")) != null ? _ya : (_xa = base == null ? void 0 : base.llm) == null ? void 0 : _xa.model) != null ? _Aa : isFreeTier ? "llama-3.1-8b-instant" : (_za = DEFAULT_MODEL_BY_PROVIDER[llmProvider]) != null ? _za : "gpt-4o";
3344
+ const llmApiKey = (_Ga = (_Fa = (_Da = (_Ca = (_Ba = llmApiKeyByProvider[llmProvider]) != null ? _Ba : readString(env, "LLM_API_KEY")) != null ? _Ca : readString(env, "LITELLM_MASTER_KEY")) != null ? _Da : readString(env, "LITELLM_API_KEY")) != null ? _Fa : (_Ea = base == null ? void 0 : base.llm) == null ? void 0 : _Ea.apiKey) != null ? _Ga : licenseKey;
3345
+ const llmProfile = (_Ka = (_Ja = readString(env, "LLM_UNIVERSAL_PROFILE")) != null ? _Ja : (_Ia = (_Ha = base == null ? void 0 : base.llm) == null ? void 0 : _Ha.options) == null ? void 0 : _Ia.profile) != null ? _Ka : "litellm";
3233
3346
  const defaultEmbeddingProvider = isFreeTier ? "universal_rest" : "universal_rest";
3234
- const embeddingProvider = (_Ma = (_La = readEnum(env, "EMBEDDING_PROVIDER", defaultEmbeddingProvider, EMBEDDING_PROVIDERS)) != null ? _La : (_Ka = base == null ? void 0 : base.embedding) == null ? void 0 : _Ka.provider) != null ? _Ma : defaultEmbeddingProvider;
3235
- const embeddingBaseUrl = (_Ra = (_Qa = (_Oa = (_Na = readString(env, "LITELLM_BASE_URL")) != null ? _Na : readString(env, "EMBEDDING_BASE_URL")) != null ? _Oa : readString(env, "LLM_BASE_URL")) != null ? _Qa : (_Pa = base == null ? void 0 : base.embedding) == null ? void 0 : _Pa.baseUrl) != null ? _Ra : defaultGatewayUrl;
3236
- const embeddingModel = (_Ua = (_Ta = readString(env, "EMBEDDING_MODEL")) != null ? _Ta : (_Sa = base == null ? void 0 : base.embedding) == null ? void 0 : _Sa.model) != null ? _Ua : "text-embedding-004";
3237
- const embeddingApiKey = (_$a = (__a = (_Ya = (_Xa = (_Wa = (_Va = embeddingApiKeyByProvider[embeddingProvider]) != null ? _Va : readString(env, "EMBEDDING_API_KEY")) != null ? _Wa : readString(env, "LLM_API_KEY")) != null ? _Xa : readString(env, "LITELLM_MASTER_KEY")) != null ? _Ya : readString(env, "LITELLM_API_KEY")) != null ? __a : (_Za = base == null ? void 0 : base.embedding) == null ? void 0 : _Za.apiKey) != null ? _$a : licenseKey;
3238
- const embeddingProfile = (_db = (_cb = readString(env, "EMBEDDING_UNIVERSAL_PROFILE")) != null ? _cb : (_bb = (_ab = base == null ? void 0 : base.embedding) == null ? void 0 : _ab.options) == null ? void 0 : _bb.profile) != null ? _db : "litellm";
3347
+ const embeddingProvider = (_Na = (_Ma = readEnum(env, "EMBEDDING_PROVIDER", defaultEmbeddingProvider, EMBEDDING_PROVIDERS)) != null ? _Ma : (_La = base == null ? void 0 : base.embedding) == null ? void 0 : _La.provider) != null ? _Na : defaultEmbeddingProvider;
3348
+ const embeddingBaseUrl = (_Sa = (_Ra = (_Pa = (_Oa = readString(env, "LITELLM_BASE_URL")) != null ? _Oa : readString(env, "EMBEDDING_BASE_URL")) != null ? _Pa : readString(env, "LLM_BASE_URL")) != null ? _Ra : (_Qa = base == null ? void 0 : base.embedding) == null ? void 0 : _Qa.baseUrl) != null ? _Sa : defaultGatewayUrl;
3349
+ const embeddingModel = (_Va = (_Ua = readString(env, "EMBEDDING_MODEL")) != null ? _Ua : (_Ta = base == null ? void 0 : base.embedding) == null ? void 0 : _Ta.model) != null ? _Va : "text-embedding-004";
3350
+ const embeddingApiKey = (_ab = (_$a = (_Za = (_Ya = (_Xa = (_Wa = embeddingApiKeyByProvider[embeddingProvider]) != null ? _Wa : readString(env, "EMBEDDING_API_KEY")) != null ? _Xa : readString(env, "LLM_API_KEY")) != null ? _Ya : readString(env, "LITELLM_MASTER_KEY")) != null ? _Za : readString(env, "LITELLM_API_KEY")) != null ? _$a : (__a = base == null ? void 0 : base.embedding) == null ? void 0 : __a.apiKey) != null ? _ab : licenseKey;
3351
+ const embeddingProfile = (_eb = (_db = readString(env, "EMBEDDING_UNIVERSAL_PROFILE")) != null ? _db : (_cb = (_bb = base == null ? void 0 : base.embedding) == null ? void 0 : _bb.options) == null ? void 0 : _cb.profile) != null ? _eb : "litellm";
3239
3352
  return __spreadProps(__spreadValues({
3240
3353
  projectId,
3241
3354
  licenseKey,
3242
3355
  vectorDb: {
3243
3356
  provider: vectorProvider,
3244
- indexName: (_fb = (_eb = readString(env, "VECTOR_DB_INDEX")) != null ? _eb : vectorDbOptions.indexName) != null ? _fb : "rag-index",
3357
+ indexName: (_gb = (_fb = readString(env, "VECTOR_DB_INDEX")) != null ? _fb : vectorDbOptions.indexName) != null ? _gb : "rag-index",
3245
3358
  options: vectorDbOptions
3246
3359
  },
3247
3360
  llm: {
@@ -3271,30 +3384,30 @@ function getEnvConfig(env = process.env, base) {
3271
3384
  }
3272
3385
  },
3273
3386
  ui: {
3274
- title: (_hb = (_gb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _gb : readString(env, "UI_TITLE")) != null ? _hb : "AI Assistant",
3275
- subtitle: (_jb = (_ib = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _ib : readString(env, "UI_SUBTITLE")) != null ? _jb : "Powered by RAG",
3276
- primaryColor: (_lb = (_kb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _kb : readString(env, "UI_PRIMARY_COLOR")) != null ? _lb : "#10b981",
3277
- accentColor: (_nb = (_mb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _mb : readString(env, "UI_ACCENT_COLOR")) != null ? _nb : "#3b82f6",
3278
- logoUrl: (_ob = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _ob : readString(env, "UI_LOGO_URL"),
3279
- placeholder: (_qb = (_pb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _pb : readString(env, "UI_PLACEHOLDER")) != null ? _qb : "Ask me anything\u2026",
3280
- showSources: ((_sb = (_rb = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _rb : readString(env, "UI_SHOW_SOURCES")) != null ? _sb : "true") !== "false",
3281
- welcomeMessage: (_ub = (_tb = readString(env, "NEXT_PUBLIC_WELCOME_MESSAGE")) != null ? _tb : readString(env, "UI_WELCOME_MESSAGE")) != null ? _ub : "Hello! I'm your AI assistant. Ask me anything about your documents.",
3282
- visualStyle: (_wb = (_vb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _vb : readString(env, "UI_VISUAL_STYLE")) != null ? _wb : "glass",
3283
- borderRadius: (_yb = (_xb = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _xb : readString(env, "UI_BORDER_RADIUS")) != null ? _yb : "xl",
3284
- allowUpload: ((_Ab = (_zb = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _zb : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Ab : "false") === "true"
3387
+ title: (_ib = (_hb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _hb : readString(env, "UI_TITLE")) != null ? _ib : "AI Assistant",
3388
+ subtitle: (_kb = (_jb = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _jb : readString(env, "UI_SUBTITLE")) != null ? _kb : "Powered by RAG",
3389
+ primaryColor: (_mb = (_lb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _lb : readString(env, "UI_PRIMARY_COLOR")) != null ? _mb : "#10b981",
3390
+ accentColor: (_ob = (_nb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _nb : readString(env, "UI_ACCENT_COLOR")) != null ? _ob : "#3b82f6",
3391
+ logoUrl: (_pb = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _pb : readString(env, "UI_LOGO_URL"),
3392
+ placeholder: (_rb = (_qb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _qb : readString(env, "UI_PLACEHOLDER")) != null ? _rb : "Ask me anything\u2026",
3393
+ showSources: ((_tb = (_sb = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _sb : readString(env, "UI_SHOW_SOURCES")) != null ? _tb : "true") !== "false",
3394
+ welcomeMessage: (_vb = (_ub = readString(env, "NEXT_PUBLIC_WELCOME_MESSAGE")) != null ? _ub : readString(env, "UI_WELCOME_MESSAGE")) != null ? _vb : "Hello! I'm your AI assistant. Ask me anything about your documents.",
3395
+ visualStyle: (_xb = (_wb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _wb : readString(env, "UI_VISUAL_STYLE")) != null ? _xb : "glass",
3396
+ borderRadius: (_zb = (_yb = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _yb : readString(env, "UI_BORDER_RADIUS")) != null ? _zb : "xl",
3397
+ allowUpload: ((_Bb = (_Ab = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _Ab : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Bb : "false") === "true"
3285
3398
  },
3286
3399
  rag: {
3287
3400
  topK: readNumber(env, "RAG_TOP_K", 5),
3288
3401
  scoreThreshold: readNumber(env, "RAG_SCORE_THRESHOLD", 0),
3289
3402
  chunkSize: readNumber(env, "RAG_CHUNK_SIZE", 1e3),
3290
3403
  chunkOverlap: readNumber(env, "RAG_CHUNK_OVERLAP", 200),
3291
- filterableFields: (_Bb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Bb.split(",").map((f) => f.trim()),
3404
+ filterableFields: (_Cb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Cb.split(",").map((f) => f.trim()),
3292
3405
  // Query pipeline toggles — read from .env.local
3293
3406
  useQueryTransformation: readString(env, "RAG_USE_QUERY_TRANSFORMATION") === "true",
3294
3407
  useReranking: readString(env, "RAG_USE_RERANKING") === "true",
3295
3408
  useGraphRetrieval: readString(env, "RAG_USE_GRAPH_RETRIEVAL") === "true",
3296
- architecture: (_Cb = readString(env, "RAG_ARCHITECTURE")) != null ? _Cb : "simple",
3297
- chunkingStrategy: (_Db = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Db : "recursive",
3409
+ architecture: (_Db = readString(env, "RAG_ARCHITECTURE")) != null ? _Db : "simple",
3410
+ chunkingStrategy: (_Eb = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Eb : "recursive",
3298
3411
  uiMapping: (() => {
3299
3412
  const raw = readString(env, "RAG_UI_MAPPING");
3300
3413
  if (!raw) return void 0;
@@ -3307,7 +3420,7 @@ function getEnvConfig(env = process.env, base) {
3307
3420
  },
3308
3421
  telemetry: {
3309
3422
  enabled: telemetryEnabled,
3310
- url: (_Hb = (_Gb = (_Eb = readString(env, "TELEMETRY_URL")) != null ? _Eb : readString(env, "NEXT_PUBLIC_TELEMETRY_URL")) != null ? _Gb : (_Fb = base == null ? void 0 : base.telemetry) == null ? void 0 : _Fb.url) != null ? _Hb : process.env.NODE_ENV === "development" ? "http://localhost:3001/api/telemetry" : "https://retrivora.com/api/telemetry"
3423
+ url: (_Ib = (_Hb = (_Fb = readString(env, "TELEMETRY_URL")) != null ? _Fb : readString(env, "NEXT_PUBLIC_TELEMETRY_URL")) != null ? _Hb : (_Gb = base == null ? void 0 : base.telemetry) == null ? void 0 : _Gb.url) != null ? _Ib : process.env.NODE_ENV === "development" ? "http://localhost:3001/api/telemetry" : "https://retrivora.com/api/telemetry"
3311
3424
  }
3312
3425
  }, readString(env, "GRAPH_DB_PROVIDER") ? {
3313
3426
  graphDb: {
@@ -5349,7 +5462,7 @@ var ConfigValidator = class {
5349
5462
  // package.json
5350
5463
  var package_default = {
5351
5464
  name: "@retrivora-ai/rag-engine",
5352
- version: "2.1.7",
5465
+ version: "2.1.9",
5353
5466
  description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
5354
5467
  author: "Abhinav Alkuchi",
5355
5468
  license: "UNLICENSED",