@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/handlers/index.js +181 -68
- package/dist/handlers/index.mjs +181 -68
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/server.d.mts +3 -3
- package/dist/server.d.ts +3 -3
- package/dist/server.js +181 -68
- package/dist/server.mjs +181 -68
- package/package.json +1 -1
- package/src/config/serverConfig.ts +5 -3
- package/src/core/ConfigFetcher.ts +112 -0
- package/src/providers/vectordb/BaseVectorProvider.ts +1 -1
- package/src/providers/vectordb/PineconeProvider.ts +63 -20
package/dist/handlers/index.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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
|
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
|
|
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.
|
|
1036
|
+
const targetIdx = await this.getActiveIndex(namespace);
|
|
1037
|
+
await targetIdx.deleteOne({ id: String(id) });
|
|
927
1038
|
}
|
|
928
1039
|
async deleteNamespace(namespace) {
|
|
929
|
-
await this.
|
|
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) {
|
|
@@ -3080,7 +3194,7 @@ function readEnum(env, name, fallback, allowed) {
|
|
|
3080
3194
|
throw new Error(`[getRagConfig] ${name} must be one of: ${allowed.join(", ")}`);
|
|
3081
3195
|
}
|
|
3082
3196
|
function getEnvConfig(env = process.env, base) {
|
|
3083
|
-
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;
|
|
3197
|
+
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;
|
|
3084
3198
|
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__";
|
|
3085
3199
|
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;
|
|
3086
3200
|
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);
|
|
@@ -3088,39 +3202,38 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3088
3202
|
const embeddingDimensions = readNumber(env, "EMBEDDING_DIMENSIONS", 768);
|
|
3089
3203
|
const vectorDbOptions = {};
|
|
3090
3204
|
if (vectorProvider === "pinecone") {
|
|
3091
|
-
|
|
3092
|
-
vectorDbOptions.
|
|
3093
|
-
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";
|
|
3205
|
+
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 : "";
|
|
3206
|
+
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";
|
|
3094
3207
|
} else if (vectorProvider === "pgvector" || vectorProvider === "postgresql") {
|
|
3095
|
-
vectorDbOptions.connectionString = (
|
|
3096
|
-
vectorDbOptions.tables = (
|
|
3097
|
-
vectorDbOptions.searchFields = (
|
|
3208
|
+
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 : "";
|
|
3209
|
+
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;
|
|
3210
|
+
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;
|
|
3098
3211
|
vectorDbOptions.dimensions = embeddingDimensions;
|
|
3099
3212
|
} else if (vectorProvider === "mongodb") {
|
|
3100
|
-
vectorDbOptions.uri = (
|
|
3101
|
-
vectorDbOptions.database = (
|
|
3102
|
-
vectorDbOptions.collection = (
|
|
3103
|
-
vectorDbOptions.indexName = (
|
|
3213
|
+
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 : "";
|
|
3214
|
+
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 : "";
|
|
3215
|
+
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 : "";
|
|
3216
|
+
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";
|
|
3104
3217
|
} else if (vectorProvider === "qdrant") {
|
|
3105
|
-
vectorDbOptions.baseUrl = (
|
|
3106
|
-
vectorDbOptions.apiKey = (
|
|
3218
|
+
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";
|
|
3219
|
+
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;
|
|
3107
3220
|
vectorDbOptions.dimensions = embeddingDimensions;
|
|
3108
3221
|
} else if (vectorProvider === "milvus") {
|
|
3109
|
-
vectorDbOptions.baseUrl = (
|
|
3222
|
+
vectorDbOptions.baseUrl = (_fa = readString(env, "MILVUS_URL")) != null ? _fa : "http://localhost:19530";
|
|
3110
3223
|
vectorDbOptions.apiKey = readString(env, "MILVUS_API_KEY");
|
|
3111
3224
|
} else if (vectorProvider === "chromadb") {
|
|
3112
|
-
vectorDbOptions.baseUrl = (
|
|
3225
|
+
vectorDbOptions.baseUrl = (_ga = readString(env, "CHROMADB_URL")) != null ? _ga : "http://localhost:8000";
|
|
3113
3226
|
} else if (vectorProvider === "weaviate") {
|
|
3114
|
-
vectorDbOptions.baseUrl = (
|
|
3227
|
+
vectorDbOptions.baseUrl = (_ha = readString(env, "WEAVIATE_URL")) != null ? _ha : "http://localhost:8080";
|
|
3115
3228
|
vectorDbOptions.apiKey = readString(env, "WEAVIATE_API_KEY");
|
|
3116
3229
|
} else if (vectorProvider === "redis") {
|
|
3117
|
-
vectorDbOptions.baseUrl = (
|
|
3230
|
+
vectorDbOptions.baseUrl = (_ia = readString(env, "REDIS_URL")) != null ? _ia : "";
|
|
3118
3231
|
vectorDbOptions.apiKey = readString(env, "REDIS_API_KEY");
|
|
3119
3232
|
} else if (vectorProvider === "rest") {
|
|
3120
|
-
vectorDbOptions.baseUrl = (
|
|
3233
|
+
vectorDbOptions.baseUrl = (_ja = readString(env, "VECTOR_DB_REST_URL")) != null ? _ja : "";
|
|
3121
3234
|
vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { "api-key": readString(env, "VECTOR_DB_REST_API_KEY") } : {};
|
|
3122
3235
|
} else if (vectorProvider === "universal_rest") {
|
|
3123
|
-
vectorDbOptions.baseUrl = (
|
|
3236
|
+
vectorDbOptions.baseUrl = (_la = (_ka = readString(env, "VECTOR_BASE_URL")) != null ? _ka : readString(env, "VECTOR_DB_REST_URL")) != null ? _la : "";
|
|
3124
3237
|
vectorDbOptions.profile = readString(env, "VECTOR_UNIVERSAL_PROFILE");
|
|
3125
3238
|
vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { Authorization: `Bearer ${readString(env, "VECTOR_DB_REST_API_KEY")}` } : {};
|
|
3126
3239
|
}
|
|
@@ -3139,8 +3252,8 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3139
3252
|
// Anthropic needs a separate embedding provider; key kept for completeness
|
|
3140
3253
|
gemini: readString(env, "GEMINI_API_KEY"),
|
|
3141
3254
|
ollama: void 0,
|
|
3142
|
-
universal_rest: (
|
|
3143
|
-
custom: (
|
|
3255
|
+
universal_rest: (_ma = readString(env, "EMBEDDING_API_KEY")) != null ? _ma : readString(env, "OPENAI_API_KEY"),
|
|
3256
|
+
custom: (_na = readString(env, "EMBEDDING_API_KEY")) != null ? _na : readString(env, "OPENAI_API_KEY")
|
|
3144
3257
|
};
|
|
3145
3258
|
const DEFAULT_MODEL_BY_PROVIDER = {
|
|
3146
3259
|
openai: "gpt-4o",
|
|
@@ -3161,25 +3274,25 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3161
3274
|
return true;
|
|
3162
3275
|
}
|
|
3163
3276
|
})();
|
|
3164
|
-
const defaultGatewayUrl = (
|
|
3277
|
+
const defaultGatewayUrl = (_pa = (_oa = readString(env, "LITELLM_BASE_URL")) != null ? _oa : readString(env, "LLM_BASE_URL")) != null ? _pa : "https://retrivora.com/api/v1";
|
|
3165
3278
|
const defaultLlmProvider = isFreeTier ? "universal_rest" : "universal_rest";
|
|
3166
|
-
const llmProvider = (
|
|
3167
|
-
const llmBaseUrl = (
|
|
3168
|
-
const llmModel = (
|
|
3169
|
-
const llmApiKey = (
|
|
3170
|
-
const llmProfile = (
|
|
3279
|
+
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;
|
|
3280
|
+
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;
|
|
3281
|
+
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";
|
|
3282
|
+
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;
|
|
3283
|
+
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";
|
|
3171
3284
|
const defaultEmbeddingProvider = isFreeTier ? "universal_rest" : "universal_rest";
|
|
3172
|
-
const embeddingProvider = (
|
|
3173
|
-
const embeddingBaseUrl = (
|
|
3174
|
-
const embeddingModel = (
|
|
3175
|
-
const embeddingApiKey = (_$a = (
|
|
3176
|
-
const embeddingProfile = (
|
|
3285
|
+
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;
|
|
3286
|
+
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;
|
|
3287
|
+
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";
|
|
3288
|
+
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;
|
|
3289
|
+
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";
|
|
3177
3290
|
return __spreadProps(__spreadValues({
|
|
3178
3291
|
projectId,
|
|
3179
3292
|
licenseKey,
|
|
3180
3293
|
vectorDb: {
|
|
3181
3294
|
provider: vectorProvider,
|
|
3182
|
-
indexName: (
|
|
3295
|
+
indexName: (_gb = (_fb = readString(env, "VECTOR_DB_INDEX")) != null ? _fb : vectorDbOptions.indexName) != null ? _gb : "rag-index",
|
|
3183
3296
|
options: vectorDbOptions
|
|
3184
3297
|
},
|
|
3185
3298
|
llm: {
|
|
@@ -3209,30 +3322,30 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3209
3322
|
}
|
|
3210
3323
|
},
|
|
3211
3324
|
ui: {
|
|
3212
|
-
title: (
|
|
3213
|
-
subtitle: (
|
|
3214
|
-
primaryColor: (
|
|
3215
|
-
accentColor: (
|
|
3216
|
-
logoUrl: (
|
|
3217
|
-
placeholder: (
|
|
3218
|
-
showSources: ((
|
|
3219
|
-
welcomeMessage: (
|
|
3220
|
-
visualStyle: (
|
|
3221
|
-
borderRadius: (
|
|
3222
|
-
allowUpload: ((
|
|
3325
|
+
title: (_ib = (_hb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _hb : readString(env, "UI_TITLE")) != null ? _ib : "AI Assistant",
|
|
3326
|
+
subtitle: (_kb = (_jb = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _jb : readString(env, "UI_SUBTITLE")) != null ? _kb : "Powered by RAG",
|
|
3327
|
+
primaryColor: (_mb = (_lb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _lb : readString(env, "UI_PRIMARY_COLOR")) != null ? _mb : "#10b981",
|
|
3328
|
+
accentColor: (_ob = (_nb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _nb : readString(env, "UI_ACCENT_COLOR")) != null ? _ob : "#3b82f6",
|
|
3329
|
+
logoUrl: (_pb = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _pb : readString(env, "UI_LOGO_URL"),
|
|
3330
|
+
placeholder: (_rb = (_qb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _qb : readString(env, "UI_PLACEHOLDER")) != null ? _rb : "Ask me anything\u2026",
|
|
3331
|
+
showSources: ((_tb = (_sb = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _sb : readString(env, "UI_SHOW_SOURCES")) != null ? _tb : "true") !== "false",
|
|
3332
|
+
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.",
|
|
3333
|
+
visualStyle: (_xb = (_wb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _wb : readString(env, "UI_VISUAL_STYLE")) != null ? _xb : "glass",
|
|
3334
|
+
borderRadius: (_zb = (_yb = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _yb : readString(env, "UI_BORDER_RADIUS")) != null ? _zb : "xl",
|
|
3335
|
+
allowUpload: ((_Bb = (_Ab = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _Ab : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Bb : "false") === "true"
|
|
3223
3336
|
},
|
|
3224
3337
|
rag: {
|
|
3225
3338
|
topK: readNumber(env, "RAG_TOP_K", 5),
|
|
3226
3339
|
scoreThreshold: readNumber(env, "RAG_SCORE_THRESHOLD", 0),
|
|
3227
3340
|
chunkSize: readNumber(env, "RAG_CHUNK_SIZE", 1e3),
|
|
3228
3341
|
chunkOverlap: readNumber(env, "RAG_CHUNK_OVERLAP", 200),
|
|
3229
|
-
filterableFields: (
|
|
3342
|
+
filterableFields: (_Cb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Cb.split(",").map((f) => f.trim()),
|
|
3230
3343
|
// Query pipeline toggles — read from .env.local
|
|
3231
3344
|
useQueryTransformation: readString(env, "RAG_USE_QUERY_TRANSFORMATION") === "true",
|
|
3232
3345
|
useReranking: readString(env, "RAG_USE_RERANKING") === "true",
|
|
3233
3346
|
useGraphRetrieval: readString(env, "RAG_USE_GRAPH_RETRIEVAL") === "true",
|
|
3234
|
-
architecture: (
|
|
3235
|
-
chunkingStrategy: (
|
|
3347
|
+
architecture: (_Db = readString(env, "RAG_ARCHITECTURE")) != null ? _Db : "simple",
|
|
3348
|
+
chunkingStrategy: (_Eb = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Eb : "recursive",
|
|
3236
3349
|
uiMapping: (() => {
|
|
3237
3350
|
const raw = readString(env, "RAG_UI_MAPPING");
|
|
3238
3351
|
if (!raw) return void 0;
|
|
@@ -3245,7 +3358,7 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3245
3358
|
},
|
|
3246
3359
|
telemetry: {
|
|
3247
3360
|
enabled: telemetryEnabled,
|
|
3248
|
-
url: (
|
|
3361
|
+
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"
|
|
3249
3362
|
}
|
|
3250
3363
|
}, readString(env, "GRAPH_DB_PROVIDER") ? {
|
|
3251
3364
|
graphDb: {
|
|
@@ -5248,7 +5361,7 @@ var ConfigValidator = class {
|
|
|
5248
5361
|
// package.json
|
|
5249
5362
|
var package_default = {
|
|
5250
5363
|
name: "@retrivora-ai/rag-engine",
|
|
5251
|
-
version: "2.1.
|
|
5364
|
+
version: "2.1.9",
|
|
5252
5365
|
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
5253
5366
|
author: "Abhinav Alkuchi",
|
|
5254
5367
|
license: "UNLICENSED",
|