@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.mjs
CHANGED
|
@@ -778,6 +778,84 @@ var init_BaseVectorProvider = __esm({
|
|
|
778
778
|
}
|
|
779
779
|
});
|
|
780
780
|
|
|
781
|
+
// src/core/ConfigFetcher.ts
|
|
782
|
+
var ConfigFetcher;
|
|
783
|
+
var init_ConfigFetcher = __esm({
|
|
784
|
+
"src/core/ConfigFetcher.ts"() {
|
|
785
|
+
"use strict";
|
|
786
|
+
ConfigFetcher = class {
|
|
787
|
+
// 5-minute in-memory session cache
|
|
788
|
+
/**
|
|
789
|
+
* Fetch full project configuration (vectorDb + embedding + llm) from Retrivora Control Plane.
|
|
790
|
+
*/
|
|
791
|
+
static async fetchRemoteConfig(projectId, licenseKey) {
|
|
792
|
+
var _a2, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k;
|
|
793
|
+
const cacheKey = `${projectId}:${licenseKey || ""}`;
|
|
794
|
+
const now = Date.now();
|
|
795
|
+
const cached = this.cache.get(cacheKey);
|
|
796
|
+
if (cached && now - cached.cachedAt < this.TTL_MS) {
|
|
797
|
+
return cached.config;
|
|
798
|
+
}
|
|
799
|
+
const controlPlaneUrls = [
|
|
800
|
+
process.env.RETRIVORA_CONTROL_PLANE_URL,
|
|
801
|
+
process.env.NEXT_PUBLIC_RETRIVORA_CONTROL_PLANE_URL,
|
|
802
|
+
"https://retrivora.com",
|
|
803
|
+
"http://localhost:3000"
|
|
804
|
+
].filter(Boolean);
|
|
805
|
+
for (const baseUrl of controlPlaneUrls) {
|
|
806
|
+
try {
|
|
807
|
+
const url = `${baseUrl.replace(/\/$/, "")}/api/v1/config?projectId=${encodeURIComponent(projectId)}${licenseKey ? `&licenseKey=${encodeURIComponent(licenseKey)}` : ""}`;
|
|
808
|
+
const res = await fetch(url, {
|
|
809
|
+
method: "GET",
|
|
810
|
+
headers: __spreadValues({
|
|
811
|
+
"Content-Type": "application/json"
|
|
812
|
+
}, licenseKey ? { "x-license-key": licenseKey } : {})
|
|
813
|
+
});
|
|
814
|
+
if (res.ok) {
|
|
815
|
+
const data = await res.json();
|
|
816
|
+
if ((data == null ? void 0 : data.success) && ((_a2 = data == null ? void 0 : data.vectorDb) == null ? void 0 : _a2.apiKey)) {
|
|
817
|
+
const config = {
|
|
818
|
+
vectorDb: {
|
|
819
|
+
apiKey: data.vectorDb.apiKey,
|
|
820
|
+
indexName: data.vectorDb.indexName || "retrivora-free",
|
|
821
|
+
provider: data.vectorDb.provider || "pinecone"
|
|
822
|
+
},
|
|
823
|
+
embedding: {
|
|
824
|
+
provider: ((_b = data.embedding) == null ? void 0 : _b.provider) || "universal_rest",
|
|
825
|
+
model: ((_c = data.embedding) == null ? void 0 : _c.model) || "text-embedding-004",
|
|
826
|
+
baseUrl: ((_d = data.embedding) == null ? void 0 : _d.baseUrl) || "https://llm.retrivora.com/api/v1",
|
|
827
|
+
apiKey: ((_e = data.embedding) == null ? void 0 : _e.apiKey) || licenseKey || "",
|
|
828
|
+
profile: ((_f = data.embedding) == null ? void 0 : _f.profile) || "litellm"
|
|
829
|
+
},
|
|
830
|
+
llm: {
|
|
831
|
+
provider: ((_g2 = data.llm) == null ? void 0 : _g2.provider) || "universal_rest",
|
|
832
|
+
model: ((_h = data.llm) == null ? void 0 : _h.model) || "llama-3.1-8b-instant",
|
|
833
|
+
baseUrl: ((_i = data.llm) == null ? void 0 : _i.baseUrl) || "https://llm.retrivora.com/api/v1",
|
|
834
|
+
apiKey: ((_j = data.llm) == null ? void 0 : _j.apiKey) || licenseKey || "",
|
|
835
|
+
profile: ((_k = data.llm) == null ? void 0 : _k.profile) || "litellm"
|
|
836
|
+
}
|
|
837
|
+
};
|
|
838
|
+
this.cache.set(cacheKey, { config, cachedAt: now });
|
|
839
|
+
return config;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
} catch (e) {
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
return null;
|
|
846
|
+
}
|
|
847
|
+
/** Convenience: fetch only vector DB config (backwards compat). */
|
|
848
|
+
static async fetchRemoteVectorConfig(projectId, licenseKey) {
|
|
849
|
+
var _a2;
|
|
850
|
+
const config = await this.fetchRemoteConfig(projectId, licenseKey);
|
|
851
|
+
return (_a2 = config == null ? void 0 : config.vectorDb) != null ? _a2 : null;
|
|
852
|
+
}
|
|
853
|
+
};
|
|
854
|
+
ConfigFetcher.cache = /* @__PURE__ */ new Map();
|
|
855
|
+
ConfigFetcher.TTL_MS = 5 * 60 * 1e3;
|
|
856
|
+
}
|
|
857
|
+
});
|
|
858
|
+
|
|
781
859
|
// src/providers/vectordb/PineconeProvider.ts
|
|
782
860
|
var PineconeProvider_exports = {};
|
|
783
861
|
__export(PineconeProvider_exports, {
|
|
@@ -789,23 +867,26 @@ var init_PineconeProvider = __esm({
|
|
|
789
867
|
"src/providers/vectordb/PineconeProvider.ts"() {
|
|
790
868
|
"use strict";
|
|
791
869
|
init_BaseVectorProvider();
|
|
870
|
+
init_ConfigFetcher();
|
|
792
871
|
PineconeProvider = class extends BaseVectorProvider {
|
|
793
872
|
constructor(config) {
|
|
794
873
|
super(config);
|
|
795
|
-
const opts = config.options;
|
|
796
|
-
|
|
797
|
-
this.apiKey = opts.apiKey;
|
|
874
|
+
const opts = config.options || {};
|
|
875
|
+
this.apiKey = opts.apiKey || process.env.PINECONE_API_KEY || "";
|
|
798
876
|
}
|
|
799
877
|
static getValidator() {
|
|
800
878
|
return {
|
|
801
879
|
validate(config) {
|
|
802
880
|
const errors = [];
|
|
803
881
|
const opts = config.options || {};
|
|
804
|
-
|
|
882
|
+
const hasLicenseKey = Boolean(
|
|
883
|
+
config.licenseKey || process.env.RETRIVORA_LICENSE_KEY || process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY
|
|
884
|
+
);
|
|
885
|
+
if (!opts.apiKey && !hasLicenseKey) {
|
|
805
886
|
errors.push({
|
|
806
887
|
field: "vectorDb.options.apiKey",
|
|
807
|
-
message: "Pinecone API key is required",
|
|
808
|
-
suggestion: "Set PINECONE_API_KEY environment variable",
|
|
888
|
+
message: "Pinecone API key is required when RETRIVORA_LICENSE_KEY is not set",
|
|
889
|
+
suggestion: "Set PINECONE_API_KEY environment variable or supply RETRIVORA_LICENSE_KEY for keyless vector storage",
|
|
809
890
|
severity: "error"
|
|
810
891
|
});
|
|
811
892
|
}
|
|
@@ -852,22 +933,49 @@ var init_PineconeProvider = __esm({
|
|
|
852
933
|
}
|
|
853
934
|
async initialize() {
|
|
854
935
|
var _a2, _b;
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
)
|
|
936
|
+
if (this.client) return;
|
|
937
|
+
let key = this.apiKey || process.env.PINECONE_API_KEY || "";
|
|
938
|
+
if (!key) {
|
|
939
|
+
const projectId = process.env.RAG_PROJECT_ID || process.env.NEXT_PUBLIC_RAG_PROJECT_ID || "my-rag-app";
|
|
940
|
+
const licenseKey = process.env.RETRIVORA_LICENSE_KEY || process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY;
|
|
941
|
+
const remoteConfig = await ConfigFetcher.fetchRemoteVectorConfig(projectId, licenseKey);
|
|
942
|
+
if (remoteConfig == null ? void 0 : remoteConfig.apiKey) {
|
|
943
|
+
key = remoteConfig.apiKey;
|
|
944
|
+
this.apiKey = key;
|
|
945
|
+
if (remoteConfig.indexName) {
|
|
946
|
+
this.indexName = remoteConfig.indexName;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
if (!key) {
|
|
951
|
+
console.warn("[PineconeProvider] Warning: No Pinecone API key available locally or remotely.");
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
954
|
+
this.client = new Pinecone({ apiKey: key });
|
|
955
|
+
try {
|
|
956
|
+
const indexes = await this.client.listIndexes();
|
|
957
|
+
const names = (_b = (_a2 = indexes.indexes) == null ? void 0 : _a2.map((i) => i.name)) != null ? _b : [];
|
|
958
|
+
if (!names.includes(this.indexName)) {
|
|
959
|
+
console.warn(`[PineconeProvider] Target index "${this.indexName}" not listed. Proceeding with configured index name.`);
|
|
960
|
+
}
|
|
961
|
+
} catch (err) {
|
|
962
|
+
console.warn("[PineconeProvider] List index verification warning:", err instanceof Error ? err.message : String(err));
|
|
862
963
|
}
|
|
863
964
|
}
|
|
864
|
-
|
|
965
|
+
async getActiveIndex(namespace) {
|
|
966
|
+
if (!this.client) {
|
|
967
|
+
await this.initialize();
|
|
968
|
+
}
|
|
969
|
+
if (!this.client) {
|
|
970
|
+
throw new Error("[PineconeProvider] Cannot execute vector operation: Pinecone client failed to initialize.");
|
|
971
|
+
}
|
|
865
972
|
const idx = this.client.index(this.indexName);
|
|
866
973
|
return namespace ? idx.namespace(namespace) : idx.namespace("");
|
|
867
974
|
}
|
|
868
975
|
async upsert(doc, namespace) {
|
|
869
976
|
var _a2;
|
|
870
|
-
await this.
|
|
977
|
+
const targetIdx = await this.getActiveIndex(namespace);
|
|
978
|
+
await targetIdx.upsert({
|
|
871
979
|
records: [{
|
|
872
980
|
id: String(doc.id),
|
|
873
981
|
values: doc.vector,
|
|
@@ -876,6 +984,7 @@ var init_PineconeProvider = __esm({
|
|
|
876
984
|
});
|
|
877
985
|
}
|
|
878
986
|
async batchUpsert(docs, namespace) {
|
|
987
|
+
const targetIdx = await this.getActiveIndex(namespace);
|
|
879
988
|
const BATCH = 100;
|
|
880
989
|
for (let i = 0; i < docs.length; i += BATCH) {
|
|
881
990
|
const records = docs.slice(i, i + BATCH).map((d) => {
|
|
@@ -886,13 +995,14 @@ var init_PineconeProvider = __esm({
|
|
|
886
995
|
metadata: __spreadValues({ content: d.content }, (_a2 = d.metadata) != null ? _a2 : {})
|
|
887
996
|
};
|
|
888
997
|
});
|
|
889
|
-
await
|
|
998
|
+
await targetIdx.upsert({ records });
|
|
890
999
|
}
|
|
891
1000
|
}
|
|
892
1001
|
async query(vector, topK, namespace, filter) {
|
|
893
1002
|
var _a2;
|
|
1003
|
+
const targetIdx = await this.getActiveIndex(namespace);
|
|
894
1004
|
const pineconeFilter = this.sanitizeFilter(filter);
|
|
895
|
-
const result = await
|
|
1005
|
+
const result = await targetIdx.query(__spreadValues({
|
|
896
1006
|
vector,
|
|
897
1007
|
topK,
|
|
898
1008
|
includeMetadata: true
|
|
@@ -908,13 +1018,17 @@ var init_PineconeProvider = __esm({
|
|
|
908
1018
|
});
|
|
909
1019
|
}
|
|
910
1020
|
async delete(id, namespace) {
|
|
911
|
-
await this.
|
|
1021
|
+
const targetIdx = await this.getActiveIndex(namespace);
|
|
1022
|
+
await targetIdx.deleteOne({ id: String(id) });
|
|
912
1023
|
}
|
|
913
1024
|
async deleteNamespace(namespace) {
|
|
914
|
-
await this.
|
|
1025
|
+
const targetIdx = await this.getActiveIndex(namespace);
|
|
1026
|
+
await targetIdx.deleteAll();
|
|
915
1027
|
}
|
|
916
1028
|
async ping() {
|
|
917
1029
|
try {
|
|
1030
|
+
if (!this.client) await this.initialize();
|
|
1031
|
+
if (!this.client) return false;
|
|
918
1032
|
await this.client.listIndexes();
|
|
919
1033
|
return true;
|
|
920
1034
|
} catch (e) {
|
|
@@ -3045,7 +3159,7 @@ function readEnum(env, name, fallback, allowed) {
|
|
|
3045
3159
|
throw new Error(`[getRagConfig] ${name} must be one of: ${allowed.join(", ")}`);
|
|
3046
3160
|
}
|
|
3047
3161
|
function getEnvConfig(env = process.env, base) {
|
|
3048
|
-
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;
|
|
3162
|
+
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;
|
|
3049
3163
|
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__";
|
|
3050
3164
|
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;
|
|
3051
3165
|
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);
|
|
@@ -3053,39 +3167,38 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3053
3167
|
const embeddingDimensions = readNumber(env, "EMBEDDING_DIMENSIONS", 768);
|
|
3054
3168
|
const vectorDbOptions = {};
|
|
3055
3169
|
if (vectorProvider === "pinecone") {
|
|
3056
|
-
|
|
3057
|
-
vectorDbOptions.
|
|
3058
|
-
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";
|
|
3170
|
+
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 : "";
|
|
3171
|
+
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";
|
|
3059
3172
|
} else if (vectorProvider === "pgvector" || vectorProvider === "postgresql") {
|
|
3060
|
-
vectorDbOptions.connectionString = (
|
|
3061
|
-
vectorDbOptions.tables = (
|
|
3062
|
-
vectorDbOptions.searchFields = (
|
|
3173
|
+
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 : "";
|
|
3174
|
+
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;
|
|
3175
|
+
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;
|
|
3063
3176
|
vectorDbOptions.dimensions = embeddingDimensions;
|
|
3064
3177
|
} else if (vectorProvider === "mongodb") {
|
|
3065
|
-
vectorDbOptions.uri = (
|
|
3066
|
-
vectorDbOptions.database = (
|
|
3067
|
-
vectorDbOptions.collection = (
|
|
3068
|
-
vectorDbOptions.indexName = (
|
|
3178
|
+
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 : "";
|
|
3179
|
+
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 : "";
|
|
3180
|
+
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 : "";
|
|
3181
|
+
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";
|
|
3069
3182
|
} else if (vectorProvider === "qdrant") {
|
|
3070
|
-
vectorDbOptions.baseUrl = (
|
|
3071
|
-
vectorDbOptions.apiKey = (
|
|
3183
|
+
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";
|
|
3184
|
+
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;
|
|
3072
3185
|
vectorDbOptions.dimensions = embeddingDimensions;
|
|
3073
3186
|
} else if (vectorProvider === "milvus") {
|
|
3074
|
-
vectorDbOptions.baseUrl = (
|
|
3187
|
+
vectorDbOptions.baseUrl = (_fa = readString(env, "MILVUS_URL")) != null ? _fa : "http://localhost:19530";
|
|
3075
3188
|
vectorDbOptions.apiKey = readString(env, "MILVUS_API_KEY");
|
|
3076
3189
|
} else if (vectorProvider === "chromadb") {
|
|
3077
|
-
vectorDbOptions.baseUrl = (
|
|
3190
|
+
vectorDbOptions.baseUrl = (_ga = readString(env, "CHROMADB_URL")) != null ? _ga : "http://localhost:8000";
|
|
3078
3191
|
} else if (vectorProvider === "weaviate") {
|
|
3079
|
-
vectorDbOptions.baseUrl = (
|
|
3192
|
+
vectorDbOptions.baseUrl = (_ha = readString(env, "WEAVIATE_URL")) != null ? _ha : "http://localhost:8080";
|
|
3080
3193
|
vectorDbOptions.apiKey = readString(env, "WEAVIATE_API_KEY");
|
|
3081
3194
|
} else if (vectorProvider === "redis") {
|
|
3082
|
-
vectorDbOptions.baseUrl = (
|
|
3195
|
+
vectorDbOptions.baseUrl = (_ia = readString(env, "REDIS_URL")) != null ? _ia : "";
|
|
3083
3196
|
vectorDbOptions.apiKey = readString(env, "REDIS_API_KEY");
|
|
3084
3197
|
} else if (vectorProvider === "rest") {
|
|
3085
|
-
vectorDbOptions.baseUrl = (
|
|
3198
|
+
vectorDbOptions.baseUrl = (_ja = readString(env, "VECTOR_DB_REST_URL")) != null ? _ja : "";
|
|
3086
3199
|
vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { "api-key": readString(env, "VECTOR_DB_REST_API_KEY") } : {};
|
|
3087
3200
|
} else if (vectorProvider === "universal_rest") {
|
|
3088
|
-
vectorDbOptions.baseUrl = (
|
|
3201
|
+
vectorDbOptions.baseUrl = (_la = (_ka = readString(env, "VECTOR_BASE_URL")) != null ? _ka : readString(env, "VECTOR_DB_REST_URL")) != null ? _la : "";
|
|
3089
3202
|
vectorDbOptions.profile = readString(env, "VECTOR_UNIVERSAL_PROFILE");
|
|
3090
3203
|
vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { Authorization: `Bearer ${readString(env, "VECTOR_DB_REST_API_KEY")}` } : {};
|
|
3091
3204
|
}
|
|
@@ -3104,8 +3217,8 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3104
3217
|
// Anthropic needs a separate embedding provider; key kept for completeness
|
|
3105
3218
|
gemini: readString(env, "GEMINI_API_KEY"),
|
|
3106
3219
|
ollama: void 0,
|
|
3107
|
-
universal_rest: (
|
|
3108
|
-
custom: (
|
|
3220
|
+
universal_rest: (_ma = readString(env, "EMBEDDING_API_KEY")) != null ? _ma : readString(env, "OPENAI_API_KEY"),
|
|
3221
|
+
custom: (_na = readString(env, "EMBEDDING_API_KEY")) != null ? _na : readString(env, "OPENAI_API_KEY")
|
|
3109
3222
|
};
|
|
3110
3223
|
const DEFAULT_MODEL_BY_PROVIDER = {
|
|
3111
3224
|
openai: "gpt-4o",
|
|
@@ -3126,25 +3239,25 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3126
3239
|
return true;
|
|
3127
3240
|
}
|
|
3128
3241
|
})();
|
|
3129
|
-
const defaultGatewayUrl = (
|
|
3242
|
+
const defaultGatewayUrl = (_pa = (_oa = readString(env, "LITELLM_BASE_URL")) != null ? _oa : readString(env, "LLM_BASE_URL")) != null ? _pa : "https://retrivora.com/api/v1";
|
|
3130
3243
|
const defaultLlmProvider = isFreeTier ? "universal_rest" : "universal_rest";
|
|
3131
|
-
const llmProvider = (
|
|
3132
|
-
const llmBaseUrl = (
|
|
3133
|
-
const llmModel = (
|
|
3134
|
-
const llmApiKey = (
|
|
3135
|
-
const llmProfile = (
|
|
3244
|
+
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;
|
|
3245
|
+
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;
|
|
3246
|
+
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";
|
|
3247
|
+
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;
|
|
3248
|
+
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";
|
|
3136
3249
|
const defaultEmbeddingProvider = isFreeTier ? "universal_rest" : "universal_rest";
|
|
3137
|
-
const embeddingProvider = (
|
|
3138
|
-
const embeddingBaseUrl = (
|
|
3139
|
-
const embeddingModel = (
|
|
3140
|
-
const embeddingApiKey = (_$a = (
|
|
3141
|
-
const embeddingProfile = (
|
|
3250
|
+
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;
|
|
3251
|
+
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;
|
|
3252
|
+
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";
|
|
3253
|
+
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;
|
|
3254
|
+
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";
|
|
3142
3255
|
return __spreadProps(__spreadValues({
|
|
3143
3256
|
projectId,
|
|
3144
3257
|
licenseKey,
|
|
3145
3258
|
vectorDb: {
|
|
3146
3259
|
provider: vectorProvider,
|
|
3147
|
-
indexName: (
|
|
3260
|
+
indexName: (_gb = (_fb = readString(env, "VECTOR_DB_INDEX")) != null ? _fb : vectorDbOptions.indexName) != null ? _gb : "rag-index",
|
|
3148
3261
|
options: vectorDbOptions
|
|
3149
3262
|
},
|
|
3150
3263
|
llm: {
|
|
@@ -3174,30 +3287,30 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3174
3287
|
}
|
|
3175
3288
|
},
|
|
3176
3289
|
ui: {
|
|
3177
|
-
title: (
|
|
3178
|
-
subtitle: (
|
|
3179
|
-
primaryColor: (
|
|
3180
|
-
accentColor: (
|
|
3181
|
-
logoUrl: (
|
|
3182
|
-
placeholder: (
|
|
3183
|
-
showSources: ((
|
|
3184
|
-
welcomeMessage: (
|
|
3185
|
-
visualStyle: (
|
|
3186
|
-
borderRadius: (
|
|
3187
|
-
allowUpload: ((
|
|
3290
|
+
title: (_ib = (_hb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _hb : readString(env, "UI_TITLE")) != null ? _ib : "AI Assistant",
|
|
3291
|
+
subtitle: (_kb = (_jb = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _jb : readString(env, "UI_SUBTITLE")) != null ? _kb : "Powered by RAG",
|
|
3292
|
+
primaryColor: (_mb = (_lb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _lb : readString(env, "UI_PRIMARY_COLOR")) != null ? _mb : "#10b981",
|
|
3293
|
+
accentColor: (_ob = (_nb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _nb : readString(env, "UI_ACCENT_COLOR")) != null ? _ob : "#3b82f6",
|
|
3294
|
+
logoUrl: (_pb = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _pb : readString(env, "UI_LOGO_URL"),
|
|
3295
|
+
placeholder: (_rb = (_qb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _qb : readString(env, "UI_PLACEHOLDER")) != null ? _rb : "Ask me anything\u2026",
|
|
3296
|
+
showSources: ((_tb = (_sb = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _sb : readString(env, "UI_SHOW_SOURCES")) != null ? _tb : "true") !== "false",
|
|
3297
|
+
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.",
|
|
3298
|
+
visualStyle: (_xb = (_wb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _wb : readString(env, "UI_VISUAL_STYLE")) != null ? _xb : "glass",
|
|
3299
|
+
borderRadius: (_zb = (_yb = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _yb : readString(env, "UI_BORDER_RADIUS")) != null ? _zb : "xl",
|
|
3300
|
+
allowUpload: ((_Bb = (_Ab = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _Ab : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Bb : "false") === "true"
|
|
3188
3301
|
},
|
|
3189
3302
|
rag: {
|
|
3190
3303
|
topK: readNumber(env, "RAG_TOP_K", 5),
|
|
3191
3304
|
scoreThreshold: readNumber(env, "RAG_SCORE_THRESHOLD", 0),
|
|
3192
3305
|
chunkSize: readNumber(env, "RAG_CHUNK_SIZE", 1e3),
|
|
3193
3306
|
chunkOverlap: readNumber(env, "RAG_CHUNK_OVERLAP", 200),
|
|
3194
|
-
filterableFields: (
|
|
3307
|
+
filterableFields: (_Cb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Cb.split(",").map((f) => f.trim()),
|
|
3195
3308
|
// Query pipeline toggles — read from .env.local
|
|
3196
3309
|
useQueryTransformation: readString(env, "RAG_USE_QUERY_TRANSFORMATION") === "true",
|
|
3197
3310
|
useReranking: readString(env, "RAG_USE_RERANKING") === "true",
|
|
3198
3311
|
useGraphRetrieval: readString(env, "RAG_USE_GRAPH_RETRIEVAL") === "true",
|
|
3199
|
-
architecture: (
|
|
3200
|
-
chunkingStrategy: (
|
|
3312
|
+
architecture: (_Db = readString(env, "RAG_ARCHITECTURE")) != null ? _Db : "simple",
|
|
3313
|
+
chunkingStrategy: (_Eb = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Eb : "recursive",
|
|
3201
3314
|
uiMapping: (() => {
|
|
3202
3315
|
const raw = readString(env, "RAG_UI_MAPPING");
|
|
3203
3316
|
if (!raw) return void 0;
|
|
@@ -3210,7 +3323,7 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3210
3323
|
},
|
|
3211
3324
|
telemetry: {
|
|
3212
3325
|
enabled: telemetryEnabled,
|
|
3213
|
-
url: (
|
|
3326
|
+
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"
|
|
3214
3327
|
}
|
|
3215
3328
|
}, readString(env, "GRAPH_DB_PROVIDER") ? {
|
|
3216
3329
|
graphDb: {
|
|
@@ -5213,7 +5326,7 @@ var ConfigValidator = class {
|
|
|
5213
5326
|
// package.json
|
|
5214
5327
|
var package_default = {
|
|
5215
5328
|
name: "@retrivora-ai/rag-engine",
|
|
5216
|
-
version: "2.1.
|
|
5329
|
+
version: "2.1.9",
|
|
5217
5330
|
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
5218
5331
|
author: "Abhinav Alkuchi",
|
|
5219
5332
|
license: "UNLICENSED",
|
package/dist/index.js
CHANGED
|
@@ -3563,7 +3563,7 @@ function ChatWidget({ position = "bottom-right", onAddToCart, apiUrl, retrivoraA
|
|
|
3563
3563
|
// package.json
|
|
3564
3564
|
var package_default = {
|
|
3565
3565
|
name: "@retrivora-ai/rag-engine",
|
|
3566
|
-
version: "2.1.
|
|
3566
|
+
version: "2.1.9",
|
|
3567
3567
|
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
3568
3568
|
author: "Abhinav Alkuchi",
|
|
3569
3569
|
license: "UNLICENSED",
|
package/dist/index.mjs
CHANGED
|
@@ -3564,7 +3564,7 @@ function ChatWidget({ position = "bottom-right", onAddToCart, apiUrl, retrivoraA
|
|
|
3564
3564
|
// package.json
|
|
3565
3565
|
var package_default = {
|
|
3566
3566
|
name: "@retrivora-ai/rag-engine",
|
|
3567
|
-
version: "2.1.
|
|
3567
|
+
version: "2.1.9",
|
|
3568
3568
|
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
3569
3569
|
author: "Abhinav Alkuchi",
|
|
3570
3570
|
license: "UNLICENSED",
|
package/dist/server.d.mts
CHANGED
|
@@ -198,7 +198,7 @@ declare class ConfigResolver {
|
|
|
198
198
|
*/
|
|
199
199
|
declare abstract class BaseVectorProvider {
|
|
200
200
|
protected readonly config: VectorDBConfig;
|
|
201
|
-
protected
|
|
201
|
+
protected indexName: string;
|
|
202
202
|
constructor(config: VectorDBConfig);
|
|
203
203
|
/**
|
|
204
204
|
* Initialise the connection (create tables, verify index, etc.)
|
|
@@ -615,12 +615,12 @@ declare class DocumentParser {
|
|
|
615
615
|
*/
|
|
616
616
|
declare class PineconeProvider extends BaseVectorProvider {
|
|
617
617
|
private client;
|
|
618
|
-
private
|
|
618
|
+
private apiKey;
|
|
619
619
|
constructor(config: VectorDBConfig);
|
|
620
620
|
static getValidator(): IProviderValidator;
|
|
621
621
|
static getHealthChecker(): IProviderHealthChecker;
|
|
622
622
|
initialize(): Promise<void>;
|
|
623
|
-
private
|
|
623
|
+
private getActiveIndex;
|
|
624
624
|
upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
|
|
625
625
|
batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
|
|
626
626
|
query(vector: number[], topK: number, namespace?: string, filter?: Record<string, unknown>): Promise<VectorMatch[]>;
|
package/dist/server.d.ts
CHANGED
|
@@ -198,7 +198,7 @@ declare class ConfigResolver {
|
|
|
198
198
|
*/
|
|
199
199
|
declare abstract class BaseVectorProvider {
|
|
200
200
|
protected readonly config: VectorDBConfig;
|
|
201
|
-
protected
|
|
201
|
+
protected indexName: string;
|
|
202
202
|
constructor(config: VectorDBConfig);
|
|
203
203
|
/**
|
|
204
204
|
* Initialise the connection (create tables, verify index, etc.)
|
|
@@ -615,12 +615,12 @@ declare class DocumentParser {
|
|
|
615
615
|
*/
|
|
616
616
|
declare class PineconeProvider extends BaseVectorProvider {
|
|
617
617
|
private client;
|
|
618
|
-
private
|
|
618
|
+
private apiKey;
|
|
619
619
|
constructor(config: VectorDBConfig);
|
|
620
620
|
static getValidator(): IProviderValidator;
|
|
621
621
|
static getHealthChecker(): IProviderHealthChecker;
|
|
622
622
|
initialize(): Promise<void>;
|
|
623
|
-
private
|
|
623
|
+
private getActiveIndex;
|
|
624
624
|
upsert(doc: UpsertDocument, namespace?: string): Promise<void>;
|
|
625
625
|
batchUpsert(docs: UpsertDocument[], namespace?: string): Promise<void>;
|
|
626
626
|
query(vector: number[], topK: number, namespace?: string, filter?: Record<string, unknown>): Promise<VectorMatch[]>;
|