@retrivora-ai/rag-engine 2.2.1 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/handlers/index.js +92 -61
- package/dist/handlers/index.mjs +92 -61
- package/dist/index.css +44 -0
- package/dist/index.js +199 -128
- package/dist/index.mjs +224 -153
- package/dist/server.d.mts +1 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.js +92 -61
- package/dist/server.mjs +92 -61
- package/package.json +1 -1
- package/src/components/DocumentUpload.tsx +192 -116
- package/src/config/serverConfig.ts +20 -6
- package/src/core/ConfigFetcher.ts +5 -0
- package/src/core/LicenseVerifier.ts +8 -2
- package/src/core/Pipeline.ts +5 -7
- package/src/handlers/index.ts +1 -1
- package/src/hooks/useRagChat.ts +30 -14
- package/src/index.css +44 -0
- package/src/providers/vectordb/BaseVectorProvider.ts +1 -0
- package/src/providers/vectordb/PineconeProvider.ts +16 -1
package/dist/server.d.mts
CHANGED
|
@@ -199,6 +199,7 @@ declare class ConfigResolver {
|
|
|
199
199
|
declare abstract class BaseVectorProvider {
|
|
200
200
|
protected readonly config: VectorDBConfig;
|
|
201
201
|
protected indexName: string;
|
|
202
|
+
protected projectId?: string;
|
|
202
203
|
constructor(config: VectorDBConfig);
|
|
203
204
|
/**
|
|
204
205
|
* Initialise the connection (create tables, verify index, etc.)
|
package/dist/server.d.ts
CHANGED
|
@@ -199,6 +199,7 @@ declare class ConfigResolver {
|
|
|
199
199
|
declare abstract class BaseVectorProvider {
|
|
200
200
|
protected readonly config: VectorDBConfig;
|
|
201
201
|
protected indexName: string;
|
|
202
|
+
protected projectId?: string;
|
|
202
203
|
constructor(config: VectorDBConfig);
|
|
203
204
|
/**
|
|
204
205
|
* Initialise the connection (create tables, verify index, etc.)
|
package/dist/server.js
CHANGED
|
@@ -696,7 +696,7 @@ async function dispatchEmbedding(req, apiKeyOverride) {
|
|
|
696
696
|
}
|
|
697
697
|
}
|
|
698
698
|
const geminiKey = process.env.GEMINI_API_KEY || effectiveKey;
|
|
699
|
-
const isGeminiKeyValid = Boolean(geminiKey &&
|
|
699
|
+
const isGeminiKeyValid = Boolean(geminiKey && !geminiKey.startsWith("eyJ"));
|
|
700
700
|
if (isGeminiKeyValid) {
|
|
701
701
|
try {
|
|
702
702
|
return await handleGeminiEmbedding(req, effectiveKey);
|
|
@@ -831,11 +831,14 @@ var init_ConfigFetcher = __esm({
|
|
|
831
831
|
if (res.ok) {
|
|
832
832
|
const data = await res.json();
|
|
833
833
|
if ((data == null ? void 0 : data.success) && ((_a2 = data == null ? void 0 : data.vectorDb) == null ? void 0 : _a2.apiKey)) {
|
|
834
|
+
const fetchedProjectId = data.projectId || projectId;
|
|
834
835
|
const config = {
|
|
836
|
+
projectId: fetchedProjectId,
|
|
835
837
|
vectorDb: {
|
|
836
838
|
apiKey: data.vectorDb.apiKey,
|
|
837
839
|
indexName: data.vectorDb.indexName || "retrivora-free",
|
|
838
|
-
provider: data.vectorDb.provider || "pinecone"
|
|
840
|
+
provider: data.vectorDb.provider || "pinecone",
|
|
841
|
+
projectId: fetchedProjectId
|
|
839
842
|
},
|
|
840
843
|
embedding: {
|
|
841
844
|
provider: ((_b = data.embedding) == null ? void 0 : _b.provider) || "universal_rest",
|
|
@@ -953,8 +956,20 @@ var init_PineconeProvider = __esm({
|
|
|
953
956
|
if (this.client) return;
|
|
954
957
|
let key = this.apiKey || process.env.PINECONE_API_KEY || "";
|
|
955
958
|
if (!key) {
|
|
956
|
-
const projectId = process.env.RAG_PROJECT_ID || process.env.NEXT_PUBLIC_RAG_PROJECT_ID || "my-rag-app";
|
|
957
959
|
const licenseKey = process.env.RETRIVORA_LICENSE_KEY || process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY;
|
|
960
|
+
const jwtProjectId = (() => {
|
|
961
|
+
if (!licenseKey) return void 0;
|
|
962
|
+
try {
|
|
963
|
+
const parts = licenseKey.split(".");
|
|
964
|
+
if (parts.length >= 2) {
|
|
965
|
+
const payload = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf8"));
|
|
966
|
+
return payload == null ? void 0 : payload.projectId;
|
|
967
|
+
}
|
|
968
|
+
} catch (e) {
|
|
969
|
+
}
|
|
970
|
+
return void 0;
|
|
971
|
+
})();
|
|
972
|
+
const projectId = process.env.RAG_PROJECT_ID || process.env.NEXT_PUBLIC_RAG_PROJECT_ID || jwtProjectId || this.projectId || "default";
|
|
958
973
|
const remoteConfig = await ConfigFetcher.fetchRemoteVectorConfig(projectId, licenseKey);
|
|
959
974
|
if (remoteConfig == null ? void 0 : remoteConfig.apiKey) {
|
|
960
975
|
key = remoteConfig.apiKey;
|
|
@@ -962,6 +977,9 @@ var init_PineconeProvider = __esm({
|
|
|
962
977
|
if (remoteConfig.indexName) {
|
|
963
978
|
this.indexName = remoteConfig.indexName;
|
|
964
979
|
}
|
|
980
|
+
if (remoteConfig.projectId) {
|
|
981
|
+
this.projectId = remoteConfig.projectId;
|
|
982
|
+
}
|
|
965
983
|
}
|
|
966
984
|
}
|
|
967
985
|
if (!key) {
|
|
@@ -3023,7 +3041,8 @@ var LicenseVerifier = class {
|
|
|
3023
3041
|
};
|
|
3024
3042
|
}
|
|
3025
3043
|
try {
|
|
3026
|
-
const
|
|
3044
|
+
const rawToken = licenseKey.replace(/^rtv_/i, "").trim();
|
|
3045
|
+
const parts = rawToken.split(".");
|
|
3027
3046
|
if (parts.length !== 3) {
|
|
3028
3047
|
throw new Error("Malformed token structure (expected 3 parts).");
|
|
3029
3048
|
}
|
|
@@ -3047,7 +3066,8 @@ var LicenseVerifier = class {
|
|
|
3047
3066
|
if (!payload.projectId) {
|
|
3048
3067
|
throw new Error('License payload is missing "projectId".');
|
|
3049
3068
|
}
|
|
3050
|
-
|
|
3069
|
+
const isProjectMatch = payload.projectId === currentProjectId || payload.projectId === `retrivora-${currentProjectId}` || `retrivora-${payload.projectId}` === currentProjectId;
|
|
3070
|
+
if (!isProjectMatch) {
|
|
3051
3071
|
throw new Error(
|
|
3052
3072
|
`Project ID mismatch. License is bound to project namespace "${payload.projectId}" but configuration has "${currentProjectId}".`
|
|
3053
3073
|
);
|
|
@@ -3258,46 +3278,58 @@ function getRagConfig(baseConfig, env = process.env) {
|
|
|
3258
3278
|
return getEnvConfig(env, baseConfig);
|
|
3259
3279
|
}
|
|
3260
3280
|
function getEnvConfig(env = process.env, base) {
|
|
3261
|
-
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;
|
|
3262
|
-
const
|
|
3263
|
-
const
|
|
3264
|
-
|
|
3281
|
+
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, _Jb, _Kb;
|
|
3282
|
+
const licenseKey = (_d = (_c = (_b = (_a2 = readString(env, "RAG_LICENSE_KEY")) != null ? _a2 : readString(env, "RETRIVORA_LICENSE_KEY")) != null ? _b : readString(env, "NEXT_PUBLIC_RETRIVORA_LICENSE_KEY")) != null ? _c : readString(env, "LICENSE_KEY")) != null ? _d : base == null ? void 0 : base.licenseKey;
|
|
3283
|
+
const jwtProjectId = (() => {
|
|
3284
|
+
if (!licenseKey) return void 0;
|
|
3285
|
+
try {
|
|
3286
|
+
const parts = licenseKey.split(".");
|
|
3287
|
+
if (parts.length >= 2) {
|
|
3288
|
+
const payload = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf8"));
|
|
3289
|
+
return payload == null ? void 0 : payload.projectId;
|
|
3290
|
+
}
|
|
3291
|
+
} catch (e) {
|
|
3292
|
+
}
|
|
3293
|
+
return void 0;
|
|
3294
|
+
})();
|
|
3295
|
+
const projectId = (_i = (_h = (_g2 = (_f = (_e = readString(env, "RAG_PROJECT_ID")) != null ? _e : readString(env, "NEXT_PUBLIC_RAG_PROJECT_ID")) != null ? _f : readString(env, "NEXT_PUBLIC_PROJECT_ID")) != null ? _g2 : base == null ? void 0 : base.projectId) != null ? _h : jwtProjectId) != null ? _i : "default";
|
|
3296
|
+
const telemetryEnabled = readString(env, "TELEMETRY_ENABLED") === "true" || readString(env, "NEXT_PUBLIC_TELEMETRY_ENABLED") === "true" || ((_j = base == null ? void 0 : base.telemetry) == null ? void 0 : _j.enabled) || Boolean(licenseKey);
|
|
3265
3297
|
const vectorProvider = readEnum(env, "VECTOR_DB_PROVIDER", "pinecone", VECTOR_DB_PROVIDERS);
|
|
3266
3298
|
const embeddingDimensions = readNumber(env, "EMBEDDING_DIMENSIONS", 768);
|
|
3267
3299
|
const vectorDbOptions = {};
|
|
3268
3300
|
if (vectorProvider === "pinecone") {
|
|
3269
|
-
vectorDbOptions.apiKey = (
|
|
3270
|
-
vectorDbOptions.indexName = (
|
|
3301
|
+
vectorDbOptions.apiKey = (_o = (_n = (_m = readString(env, "PINECONE_API_KEY")) != null ? _m : (_l = (_k = base == null ? void 0 : base.vectorDb) == null ? void 0 : _k.options) == null ? void 0 : _l.apiKey) != null ? _n : process.env.PINECONE_API_KEY) != null ? _o : "";
|
|
3302
|
+
vectorDbOptions.indexName = (_v = (_u = (_t = (_q = readString(env, "PINECONE_INDEX")) != null ? _q : (_p = base == null ? void 0 : base.vectorDb) == null ? void 0 : _p.indexName) != null ? _t : (_s = (_r = base == null ? void 0 : base.vectorDb) == null ? void 0 : _r.options) == null ? void 0 : _s.indexName) != null ? _u : process.env.PINECONE_INDEX) != null ? _v : "retrivora-free";
|
|
3271
3303
|
} else if (vectorProvider === "pgvector" || vectorProvider === "postgresql") {
|
|
3272
|
-
vectorDbOptions.connectionString = (
|
|
3273
|
-
vectorDbOptions.tables = (
|
|
3274
|
-
vectorDbOptions.searchFields = (
|
|
3304
|
+
vectorDbOptions.connectionString = (_A = (_z = (_w = readString(env, "PGVECTOR_CONNECTION_STRING")) != null ? _w : readString(env, "POSTGRES_URL")) != null ? _z : (_y = (_x = base == null ? void 0 : base.vectorDb) == null ? void 0 : _x.options) == null ? void 0 : _y.connectionString) != null ? _A : "";
|
|
3305
|
+
vectorDbOptions.tables = (_F = (_C = (_B = readString(env, "VECTOR_DB_TABLES")) != null ? _B : readString(env, "POSTGRES_TABLES")) == null ? void 0 : _C.split(",").map((t) => t.trim())) != null ? _F : (_E = (_D = base == null ? void 0 : base.vectorDb) == null ? void 0 : _D.options) == null ? void 0 : _E.tables;
|
|
3306
|
+
vectorDbOptions.searchFields = (_J = (_G = readString(env, "POSTGRES_SEARCH_FIELDS")) == null ? void 0 : _G.split(",").map((f) => f.trim())) != null ? _J : (_I = (_H = base == null ? void 0 : base.vectorDb) == null ? void 0 : _H.options) == null ? void 0 : _I.searchFields;
|
|
3275
3307
|
vectorDbOptions.dimensions = embeddingDimensions;
|
|
3276
3308
|
} else if (vectorProvider === "mongodb") {
|
|
3277
|
-
vectorDbOptions.uri = (
|
|
3278
|
-
vectorDbOptions.database = (
|
|
3279
|
-
vectorDbOptions.collection = (
|
|
3280
|
-
vectorDbOptions.indexName = (
|
|
3309
|
+
vectorDbOptions.uri = (_N = (_M = readString(env, "MONGODB_URI")) != null ? _M : (_L = (_K = base == null ? void 0 : base.vectorDb) == null ? void 0 : _K.options) == null ? void 0 : _L.uri) != null ? _N : "";
|
|
3310
|
+
vectorDbOptions.database = (_R = (_Q = readString(env, "MONGODB_DB")) != null ? _Q : (_P = (_O = base == null ? void 0 : base.vectorDb) == null ? void 0 : _O.options) == null ? void 0 : _P.database) != null ? _R : "";
|
|
3311
|
+
vectorDbOptions.collection = (_V = (_U = readString(env, "MONGODB_COLLECTION")) != null ? _U : (_T = (_S = base == null ? void 0 : base.vectorDb) == null ? void 0 : _S.options) == null ? void 0 : _T.collection) != null ? _V : "";
|
|
3312
|
+
vectorDbOptions.indexName = (_$ = (__ = (_X = readString(env, "MONGODB_INDEX_NAME")) != null ? _X : (_W = base == null ? void 0 : base.vectorDb) == null ? void 0 : _W.indexName) != null ? __ : (_Z = (_Y = base == null ? void 0 : base.vectorDb) == null ? void 0 : _Y.options) == null ? void 0 : _Z.indexName) != null ? _$ : "vector_index";
|
|
3281
3313
|
} else if (vectorProvider === "qdrant") {
|
|
3282
|
-
vectorDbOptions.baseUrl = (
|
|
3283
|
-
vectorDbOptions.apiKey = (
|
|
3314
|
+
vectorDbOptions.baseUrl = (_da = (_ca = readString(env, "QDRANT_URL")) != null ? _ca : (_ba = (_aa = base == null ? void 0 : base.vectorDb) == null ? void 0 : _aa.options) == null ? void 0 : _ba.baseUrl) != null ? _da : "http://localhost:6333";
|
|
3315
|
+
vectorDbOptions.apiKey = (_ga = readString(env, "QDRANT_API_KEY")) != null ? _ga : (_fa = (_ea = base == null ? void 0 : base.vectorDb) == null ? void 0 : _ea.options) == null ? void 0 : _fa.apiKey;
|
|
3284
3316
|
vectorDbOptions.dimensions = embeddingDimensions;
|
|
3285
3317
|
} else if (vectorProvider === "milvus") {
|
|
3286
|
-
vectorDbOptions.baseUrl = (
|
|
3318
|
+
vectorDbOptions.baseUrl = (_ha = readString(env, "MILVUS_URL")) != null ? _ha : "http://localhost:19530";
|
|
3287
3319
|
vectorDbOptions.apiKey = readString(env, "MILVUS_API_KEY");
|
|
3288
3320
|
} else if (vectorProvider === "chromadb") {
|
|
3289
|
-
vectorDbOptions.baseUrl = (
|
|
3321
|
+
vectorDbOptions.baseUrl = (_ia = readString(env, "CHROMADB_URL")) != null ? _ia : "http://localhost:8000";
|
|
3290
3322
|
} else if (vectorProvider === "weaviate") {
|
|
3291
|
-
vectorDbOptions.baseUrl = (
|
|
3323
|
+
vectorDbOptions.baseUrl = (_ja = readString(env, "WEAVIATE_URL")) != null ? _ja : "http://localhost:8080";
|
|
3292
3324
|
vectorDbOptions.apiKey = readString(env, "WEAVIATE_API_KEY");
|
|
3293
3325
|
} else if (vectorProvider === "redis") {
|
|
3294
|
-
vectorDbOptions.baseUrl = (
|
|
3326
|
+
vectorDbOptions.baseUrl = (_ka = readString(env, "REDIS_URL")) != null ? _ka : "";
|
|
3295
3327
|
vectorDbOptions.apiKey = readString(env, "REDIS_API_KEY");
|
|
3296
3328
|
} else if (vectorProvider === "rest") {
|
|
3297
|
-
vectorDbOptions.baseUrl = (
|
|
3329
|
+
vectorDbOptions.baseUrl = (_la = readString(env, "VECTOR_DB_REST_URL")) != null ? _la : "";
|
|
3298
3330
|
vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { "api-key": readString(env, "VECTOR_DB_REST_API_KEY") } : {};
|
|
3299
3331
|
} else if (vectorProvider === "universal_rest") {
|
|
3300
|
-
vectorDbOptions.baseUrl = (
|
|
3332
|
+
vectorDbOptions.baseUrl = (_na = (_ma = readString(env, "VECTOR_BASE_URL")) != null ? _ma : readString(env, "VECTOR_DB_REST_URL")) != null ? _na : "";
|
|
3301
3333
|
vectorDbOptions.profile = readString(env, "VECTOR_UNIVERSAL_PROFILE");
|
|
3302
3334
|
vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { Authorization: `Bearer ${readString(env, "VECTOR_DB_REST_API_KEY")}` } : {};
|
|
3303
3335
|
}
|
|
@@ -3316,8 +3348,8 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3316
3348
|
// Anthropic needs a separate embedding provider; key kept for completeness
|
|
3317
3349
|
gemini: readString(env, "GEMINI_API_KEY"),
|
|
3318
3350
|
ollama: void 0,
|
|
3319
|
-
universal_rest: (
|
|
3320
|
-
custom: (
|
|
3351
|
+
universal_rest: (_oa = readString(env, "EMBEDDING_API_KEY")) != null ? _oa : readString(env, "OPENAI_API_KEY"),
|
|
3352
|
+
custom: (_pa = readString(env, "EMBEDDING_API_KEY")) != null ? _pa : readString(env, "OPENAI_API_KEY")
|
|
3321
3353
|
};
|
|
3322
3354
|
const DEFAULT_MODEL_BY_PROVIDER = {
|
|
3323
3355
|
openai: "gpt-4o",
|
|
@@ -3338,25 +3370,25 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3338
3370
|
return true;
|
|
3339
3371
|
}
|
|
3340
3372
|
})();
|
|
3341
|
-
const defaultGatewayUrl = (
|
|
3373
|
+
const defaultGatewayUrl = (_ra = (_qa = readString(env, "LITELLM_BASE_URL")) != null ? _qa : readString(env, "LLM_BASE_URL")) != null ? _ra : "https://www.retrivora.com/api/v1";
|
|
3342
3374
|
const defaultLlmProvider = isFreeTier ? "universal_rest" : "universal_rest";
|
|
3343
|
-
const llmProvider = (
|
|
3344
|
-
const llmBaseUrl = (
|
|
3345
|
-
const llmModel = (
|
|
3346
|
-
const llmApiKey = (
|
|
3347
|
-
const llmProfile = (
|
|
3375
|
+
const llmProvider = (_ua = (_ta = readEnum(env, "LLM_PROVIDER", defaultLlmProvider, LLM_PROVIDERS)) != null ? _ta : (_sa = base == null ? void 0 : base.llm) == null ? void 0 : _sa.provider) != null ? _ua : defaultLlmProvider;
|
|
3376
|
+
const llmBaseUrl = (_ya = (_xa = (_va = readString(env, "LITELLM_BASE_URL")) != null ? _va : readString(env, "LLM_BASE_URL")) != null ? _xa : (_wa = base == null ? void 0 : base.llm) == null ? void 0 : _wa.baseUrl) != null ? _ya : defaultGatewayUrl;
|
|
3377
|
+
const llmModel = (_Ca = (_Aa = readString(env, "LLM_MODEL")) != null ? _Aa : (_za = base == null ? void 0 : base.llm) == null ? void 0 : _za.model) != null ? _Ca : isFreeTier ? "llama-3.1-8b-instant" : (_Ba = DEFAULT_MODEL_BY_PROVIDER[llmProvider]) != null ? _Ba : "gpt-4o";
|
|
3378
|
+
const llmApiKey = (_Ia = (_Ha = (_Fa = (_Ea = (_Da = llmApiKeyByProvider[llmProvider]) != null ? _Da : readString(env, "LLM_API_KEY")) != null ? _Ea : readString(env, "LITELLM_MASTER_KEY")) != null ? _Fa : readString(env, "LITELLM_API_KEY")) != null ? _Ha : (_Ga = base == null ? void 0 : base.llm) == null ? void 0 : _Ga.apiKey) != null ? _Ia : licenseKey;
|
|
3379
|
+
const llmProfile = (_Ma = (_La = readString(env, "LLM_UNIVERSAL_PROFILE")) != null ? _La : (_Ka = (_Ja = base == null ? void 0 : base.llm) == null ? void 0 : _Ja.options) == null ? void 0 : _Ka.profile) != null ? _Ma : "litellm";
|
|
3348
3380
|
const defaultEmbeddingProvider = isFreeTier ? "universal_rest" : "universal_rest";
|
|
3349
|
-
const embeddingProvider = (
|
|
3350
|
-
const embeddingBaseUrl = (
|
|
3351
|
-
const embeddingModel = (
|
|
3352
|
-
const embeddingApiKey = (
|
|
3353
|
-
const embeddingProfile = (
|
|
3381
|
+
const embeddingProvider = (_Pa = (_Oa = readEnum(env, "EMBEDDING_PROVIDER", defaultEmbeddingProvider, EMBEDDING_PROVIDERS)) != null ? _Oa : (_Na = base == null ? void 0 : base.embedding) == null ? void 0 : _Na.provider) != null ? _Pa : defaultEmbeddingProvider;
|
|
3382
|
+
const embeddingBaseUrl = (_Ua = (_Ta = (_Ra = (_Qa = readString(env, "LITELLM_BASE_URL")) != null ? _Qa : readString(env, "EMBEDDING_BASE_URL")) != null ? _Ra : readString(env, "LLM_BASE_URL")) != null ? _Ta : (_Sa = base == null ? void 0 : base.embedding) == null ? void 0 : _Sa.baseUrl) != null ? _Ua : defaultGatewayUrl;
|
|
3383
|
+
const embeddingModel = (_Xa = (_Wa = readString(env, "EMBEDDING_MODEL")) != null ? _Wa : (_Va = base == null ? void 0 : base.embedding) == null ? void 0 : _Va.model) != null ? _Xa : "text-embedding-004";
|
|
3384
|
+
const embeddingApiKey = (_cb = (_bb = (_$a = (__a = (_Za = (_Ya = embeddingApiKeyByProvider[embeddingProvider]) != null ? _Ya : readString(env, "EMBEDDING_API_KEY")) != null ? _Za : readString(env, "LLM_API_KEY")) != null ? __a : readString(env, "LITELLM_MASTER_KEY")) != null ? _$a : readString(env, "LITELLM_API_KEY")) != null ? _bb : (_ab = base == null ? void 0 : base.embedding) == null ? void 0 : _ab.apiKey) != null ? _cb : licenseKey;
|
|
3385
|
+
const embeddingProfile = (_gb = (_fb = readString(env, "EMBEDDING_UNIVERSAL_PROFILE")) != null ? _fb : (_eb = (_db = base == null ? void 0 : base.embedding) == null ? void 0 : _db.options) == null ? void 0 : _eb.profile) != null ? _gb : "litellm";
|
|
3354
3386
|
return __spreadProps(__spreadValues({
|
|
3355
3387
|
projectId,
|
|
3356
3388
|
licenseKey,
|
|
3357
3389
|
vectorDb: {
|
|
3358
3390
|
provider: vectorProvider,
|
|
3359
|
-
indexName: (
|
|
3391
|
+
indexName: (_ib = (_hb = readString(env, "VECTOR_DB_INDEX")) != null ? _hb : vectorDbOptions.indexName) != null ? _ib : "rag-index",
|
|
3360
3392
|
options: vectorDbOptions
|
|
3361
3393
|
},
|
|
3362
3394
|
llm: {
|
|
@@ -3386,30 +3418,30 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3386
3418
|
}
|
|
3387
3419
|
},
|
|
3388
3420
|
ui: {
|
|
3389
|
-
title: (
|
|
3390
|
-
subtitle: (
|
|
3391
|
-
primaryColor: (
|
|
3392
|
-
accentColor: (
|
|
3393
|
-
logoUrl: (
|
|
3394
|
-
placeholder: (
|
|
3395
|
-
showSources: ((
|
|
3396
|
-
welcomeMessage: (
|
|
3397
|
-
visualStyle: (
|
|
3398
|
-
borderRadius: (
|
|
3399
|
-
allowUpload: ((
|
|
3421
|
+
title: (_kb = (_jb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _jb : readString(env, "UI_TITLE")) != null ? _kb : "AI Assistant",
|
|
3422
|
+
subtitle: (_mb = (_lb = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _lb : readString(env, "UI_SUBTITLE")) != null ? _mb : "Powered by RAG",
|
|
3423
|
+
primaryColor: (_ob = (_nb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _nb : readString(env, "UI_PRIMARY_COLOR")) != null ? _ob : "#10b981",
|
|
3424
|
+
accentColor: (_qb = (_pb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _pb : readString(env, "UI_ACCENT_COLOR")) != null ? _qb : "#3b82f6",
|
|
3425
|
+
logoUrl: (_rb = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _rb : readString(env, "UI_LOGO_URL"),
|
|
3426
|
+
placeholder: (_tb = (_sb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _sb : readString(env, "UI_PLACEHOLDER")) != null ? _tb : "Ask me anything\u2026",
|
|
3427
|
+
showSources: ((_vb = (_ub = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _ub : readString(env, "UI_SHOW_SOURCES")) != null ? _vb : "true") !== "false",
|
|
3428
|
+
welcomeMessage: (_xb = (_wb = readString(env, "NEXT_PUBLIC_WELCOME_MESSAGE")) != null ? _wb : readString(env, "UI_WELCOME_MESSAGE")) != null ? _xb : "Hello! I'm your AI assistant. Ask me anything about your documents.",
|
|
3429
|
+
visualStyle: (_zb = (_yb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _yb : readString(env, "UI_VISUAL_STYLE")) != null ? _zb : "glass",
|
|
3430
|
+
borderRadius: (_Bb = (_Ab = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _Ab : readString(env, "UI_BORDER_RADIUS")) != null ? _Bb : "xl",
|
|
3431
|
+
allowUpload: ((_Db = (_Cb = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _Cb : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Db : "false") === "true"
|
|
3400
3432
|
},
|
|
3401
3433
|
rag: {
|
|
3402
3434
|
topK: readNumber(env, "RAG_TOP_K", 5),
|
|
3403
3435
|
scoreThreshold: readNumber(env, "RAG_SCORE_THRESHOLD", 0),
|
|
3404
3436
|
chunkSize: readNumber(env, "RAG_CHUNK_SIZE", 1e3),
|
|
3405
3437
|
chunkOverlap: readNumber(env, "RAG_CHUNK_OVERLAP", 200),
|
|
3406
|
-
filterableFields: (
|
|
3438
|
+
filterableFields: (_Eb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Eb.split(",").map((f) => f.trim()),
|
|
3407
3439
|
// Query pipeline toggles — read from .env.local
|
|
3408
3440
|
useQueryTransformation: readString(env, "RAG_USE_QUERY_TRANSFORMATION") === "true",
|
|
3409
3441
|
useReranking: readString(env, "RAG_USE_RERANKING") === "true",
|
|
3410
3442
|
useGraphRetrieval: readString(env, "RAG_USE_GRAPH_RETRIEVAL") === "true",
|
|
3411
|
-
architecture: (
|
|
3412
|
-
chunkingStrategy: (
|
|
3443
|
+
architecture: (_Fb = readString(env, "RAG_ARCHITECTURE")) != null ? _Fb : "simple",
|
|
3444
|
+
chunkingStrategy: (_Gb = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Gb : "recursive",
|
|
3413
3445
|
uiMapping: (() => {
|
|
3414
3446
|
const raw = readString(env, "RAG_UI_MAPPING");
|
|
3415
3447
|
if (!raw) return void 0;
|
|
@@ -3422,7 +3454,7 @@ function getEnvConfig(env = process.env, base) {
|
|
|
3422
3454
|
},
|
|
3423
3455
|
telemetry: {
|
|
3424
3456
|
enabled: telemetryEnabled,
|
|
3425
|
-
url: (
|
|
3457
|
+
url: (_Kb = (_Jb = (_Hb = readString(env, "TELEMETRY_URL")) != null ? _Hb : readString(env, "NEXT_PUBLIC_TELEMETRY_URL")) != null ? _Jb : (_Ib = base == null ? void 0 : base.telemetry) == null ? void 0 : _Ib.url) != null ? _Kb : process.env.NODE_ENV === "development" ? "http://localhost:3001/api/telemetry" : "https://retrivora.com/api/telemetry"
|
|
3426
3458
|
}
|
|
3427
3459
|
}, readString(env, "GRAPH_DB_PROVIDER") ? {
|
|
3428
3460
|
graphDb: {
|
|
@@ -5464,7 +5496,7 @@ var ConfigValidator = class {
|
|
|
5464
5496
|
// package.json
|
|
5465
5497
|
var package_default = {
|
|
5466
5498
|
name: "@retrivora-ai/rag-engine",
|
|
5467
|
-
version: "2.2.
|
|
5499
|
+
version: "2.2.3",
|
|
5468
5500
|
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
5469
5501
|
author: "Abhinav Alkuchi",
|
|
5470
5502
|
license: "UNLICENSED",
|
|
@@ -9124,11 +9156,10 @@ SchemaMapper.TARGET_PROPERTIES = {
|
|
|
9124
9156
|
|
|
9125
9157
|
// src/core/Pipeline.ts
|
|
9126
9158
|
function formatNamespace(raw) {
|
|
9127
|
-
if (!raw || !raw.trim()) return "
|
|
9159
|
+
if (!raw || !raw.trim()) return "default";
|
|
9128
9160
|
const trimmed = raw.trim();
|
|
9129
|
-
|
|
9130
|
-
|
|
9131
|
-
return `retrivora-${sanitized}`;
|
|
9161
|
+
const sanitized = trimmed.replace(/[^a-zA-Z0-9_-]/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
|
|
9162
|
+
return sanitized || "default";
|
|
9132
9163
|
}
|
|
9133
9164
|
var LRUEmbeddingCache = class {
|
|
9134
9165
|
constructor(maxSize = 500) {
|
|
@@ -11323,7 +11354,7 @@ function reportTelemetry(req, plugin, action, status, details, trace) {
|
|
|
11323
11354
|
const licenseKey = config.licenseKey || process.env.RAG_LICENSE_KEY || process.env.RETRIVORA_LICENSE_KEY || process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY;
|
|
11324
11355
|
const telemetryConfig = config.telemetry;
|
|
11325
11356
|
const enabled = (_a2 = telemetryConfig == null ? void 0 : telemetryConfig.enabled) != null ? _a2 : Boolean(licenseKey);
|
|
11326
|
-
const defaultUrl = process.env.NODE_ENV === "development" && !process.env.TELEMETRY_URL && !process.env.NEXT_PUBLIC_TELEMETRY_URL ? "http://localhost:3001/api/telemetry" : "https://retrivora.com/api/telemetry";
|
|
11357
|
+
const defaultUrl = process.env.NODE_ENV === "development" && !process.env.TELEMETRY_URL && !process.env.NEXT_PUBLIC_TELEMETRY_URL ? "http://localhost:3001/api/telemetry" : "https://www.retrivora.com/api/telemetry";
|
|
11327
11358
|
const telemetryUrl = (telemetryConfig == null ? void 0 : telemetryConfig.url) || process.env.TELEMETRY_URL || process.env.NEXT_PUBLIC_TELEMETRY_URL || defaultUrl;
|
|
11328
11359
|
const host = req.headers.get("host") || "localhost";
|
|
11329
11360
|
const userAgent = req.headers.get("user-agent") || `Retrivora-SDK/${SDK_VERSION}`;
|