@retrivora-ai/rag-engine 2.1.5 → 2.1.7

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.
@@ -3080,7 +3080,7 @@ function readEnum(env, name, fallback, allowed) {
3080
3080
  throw new Error(`[getRagConfig] ${name} must be one of: ${allowed.join(", ")}`);
3081
3081
  }
3082
3082
  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, _Ib;
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;
3084
3084
  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
3085
  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
3086
  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,38 +3088,39 @@ function getEnvConfig(env = process.env, base) {
3088
3088
  const embeddingDimensions = readNumber(env, "EMBEDDING_DIMENSIONS", 768);
3089
3089
  const vectorDbOptions = {};
3090
3090
  if (vectorProvider === "pinecone") {
3091
- 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 : "";
3092
- 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";
3091
+ 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;
3092
+ vectorDbOptions.apiKey = rawApiKey || (licenseKey ? "retrivora-keyless-gateway" : "keyless-free-tier");
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";
3093
3094
  } else if (vectorProvider === "pgvector" || vectorProvider === "postgresql") {
3094
- 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 : "";
3095
- 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;
3096
- 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;
3095
+ 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 : "";
3096
+ 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;
3097
+ 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;
3097
3098
  vectorDbOptions.dimensions = embeddingDimensions;
3098
3099
  } else if (vectorProvider === "mongodb") {
3099
- 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 : "";
3100
- 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 : "";
3101
- 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 : "";
3102
- 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";
3100
+ 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 : "";
3101
+ 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 : "";
3102
+ 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 : "";
3103
+ 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";
3103
3104
  } else if (vectorProvider === "qdrant") {
3104
- 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";
3105
- 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;
3105
+ 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";
3106
+ 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;
3106
3107
  vectorDbOptions.dimensions = embeddingDimensions;
3107
3108
  } else if (vectorProvider === "milvus") {
3108
- vectorDbOptions.baseUrl = (_fa = readString(env, "MILVUS_URL")) != null ? _fa : "http://localhost:19530";
3109
+ vectorDbOptions.baseUrl = (_ea = readString(env, "MILVUS_URL")) != null ? _ea : "http://localhost:19530";
3109
3110
  vectorDbOptions.apiKey = readString(env, "MILVUS_API_KEY");
3110
3111
  } else if (vectorProvider === "chromadb") {
3111
- vectorDbOptions.baseUrl = (_ga = readString(env, "CHROMADB_URL")) != null ? _ga : "http://localhost:8000";
3112
+ vectorDbOptions.baseUrl = (_fa = readString(env, "CHROMADB_URL")) != null ? _fa : "http://localhost:8000";
3112
3113
  } else if (vectorProvider === "weaviate") {
3113
- vectorDbOptions.baseUrl = (_ha = readString(env, "WEAVIATE_URL")) != null ? _ha : "http://localhost:8080";
3114
+ vectorDbOptions.baseUrl = (_ga = readString(env, "WEAVIATE_URL")) != null ? _ga : "http://localhost:8080";
3114
3115
  vectorDbOptions.apiKey = readString(env, "WEAVIATE_API_KEY");
3115
3116
  } else if (vectorProvider === "redis") {
3116
- vectorDbOptions.baseUrl = (_ia = readString(env, "REDIS_URL")) != null ? _ia : "";
3117
+ vectorDbOptions.baseUrl = (_ha = readString(env, "REDIS_URL")) != null ? _ha : "";
3117
3118
  vectorDbOptions.apiKey = readString(env, "REDIS_API_KEY");
3118
3119
  } else if (vectorProvider === "rest") {
3119
- vectorDbOptions.baseUrl = (_ja = readString(env, "VECTOR_DB_REST_URL")) != null ? _ja : "";
3120
+ vectorDbOptions.baseUrl = (_ia = readString(env, "VECTOR_DB_REST_URL")) != null ? _ia : "";
3120
3121
  vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { "api-key": readString(env, "VECTOR_DB_REST_API_KEY") } : {};
3121
3122
  } else if (vectorProvider === "universal_rest") {
3122
- vectorDbOptions.baseUrl = (_la = (_ka = readString(env, "VECTOR_BASE_URL")) != null ? _ka : readString(env, "VECTOR_DB_REST_URL")) != null ? _la : "";
3123
+ vectorDbOptions.baseUrl = (_ka = (_ja = readString(env, "VECTOR_BASE_URL")) != null ? _ja : readString(env, "VECTOR_DB_REST_URL")) != null ? _ka : "";
3123
3124
  vectorDbOptions.profile = readString(env, "VECTOR_UNIVERSAL_PROFILE");
3124
3125
  vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { Authorization: `Bearer ${readString(env, "VECTOR_DB_REST_API_KEY")}` } : {};
3125
3126
  }
@@ -3138,8 +3139,8 @@ function getEnvConfig(env = process.env, base) {
3138
3139
  // Anthropic needs a separate embedding provider; key kept for completeness
3139
3140
  gemini: readString(env, "GEMINI_API_KEY"),
3140
3141
  ollama: void 0,
3141
- universal_rest: (_ma = readString(env, "EMBEDDING_API_KEY")) != null ? _ma : readString(env, "OPENAI_API_KEY"),
3142
- custom: (_na = readString(env, "EMBEDDING_API_KEY")) != null ? _na : readString(env, "OPENAI_API_KEY")
3142
+ universal_rest: (_la = readString(env, "EMBEDDING_API_KEY")) != null ? _la : readString(env, "OPENAI_API_KEY"),
3143
+ custom: (_ma = readString(env, "EMBEDDING_API_KEY")) != null ? _ma : readString(env, "OPENAI_API_KEY")
3143
3144
  };
3144
3145
  const DEFAULT_MODEL_BY_PROVIDER = {
3145
3146
  openai: "gpt-4o",
@@ -3160,25 +3161,25 @@ function getEnvConfig(env = process.env, base) {
3160
3161
  return true;
3161
3162
  }
3162
3163
  })();
3163
- const defaultGatewayUrl = (_pa = (_oa = readString(env, "LITELLM_BASE_URL")) != null ? _oa : readString(env, "LLM_BASE_URL")) != null ? _pa : "https://llm.retrivora.com/api/v1";
3164
+ const defaultGatewayUrl = (_oa = (_na = readString(env, "LITELLM_BASE_URL")) != null ? _na : readString(env, "LLM_BASE_URL")) != null ? _oa : "https://llm.retrivora.com/api/v1";
3164
3165
  const defaultLlmProvider = isFreeTier ? "universal_rest" : "universal_rest";
3165
- 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;
3166
- 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;
3167
- 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";
3168
- 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;
3169
- 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";
3166
+ 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;
3167
+ 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;
3168
+ 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";
3169
+ 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;
3170
+ 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";
3170
3171
  const defaultEmbeddingProvider = isFreeTier ? "universal_rest" : "universal_rest";
3171
- 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;
3172
- 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;
3173
- 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";
3174
- 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;
3175
- 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";
3172
+ 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;
3173
+ 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;
3174
+ 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";
3175
+ 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;
3176
+ 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";
3176
3177
  return __spreadProps(__spreadValues({
3177
3178
  projectId,
3178
3179
  licenseKey,
3179
3180
  vectorDb: {
3180
3181
  provider: vectorProvider,
3181
- indexName: (_gb = (_fb = readString(env, "VECTOR_DB_INDEX")) != null ? _fb : vectorDbOptions.indexName) != null ? _gb : "rag-index",
3182
+ indexName: (_fb = (_eb = readString(env, "VECTOR_DB_INDEX")) != null ? _eb : vectorDbOptions.indexName) != null ? _fb : "rag-index",
3182
3183
  options: vectorDbOptions
3183
3184
  },
3184
3185
  llm: {
@@ -3208,30 +3209,30 @@ function getEnvConfig(env = process.env, base) {
3208
3209
  }
3209
3210
  },
3210
3211
  ui: {
3211
- title: (_ib = (_hb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _hb : readString(env, "UI_TITLE")) != null ? _ib : "AI Assistant",
3212
- subtitle: (_kb = (_jb = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _jb : readString(env, "UI_SUBTITLE")) != null ? _kb : "Powered by RAG",
3213
- primaryColor: (_mb = (_lb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _lb : readString(env, "UI_PRIMARY_COLOR")) != null ? _mb : "#10b981",
3214
- accentColor: (_ob = (_nb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _nb : readString(env, "UI_ACCENT_COLOR")) != null ? _ob : "#3b82f6",
3215
- logoUrl: (_pb = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _pb : readString(env, "UI_LOGO_URL"),
3216
- placeholder: (_rb = (_qb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _qb : readString(env, "UI_PLACEHOLDER")) != null ? _rb : "Ask me anything\u2026",
3217
- showSources: ((_tb = (_sb = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _sb : readString(env, "UI_SHOW_SOURCES")) != null ? _tb : "true") !== "false",
3218
- 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.",
3219
- visualStyle: (_xb = (_wb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _wb : readString(env, "UI_VISUAL_STYLE")) != null ? _xb : "glass",
3220
- borderRadius: (_zb = (_yb = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _yb : readString(env, "UI_BORDER_RADIUS")) != null ? _zb : "xl",
3221
- allowUpload: ((_Bb = (_Ab = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _Ab : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Bb : "false") === "true"
3212
+ title: (_hb = (_gb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _gb : readString(env, "UI_TITLE")) != null ? _hb : "AI Assistant",
3213
+ subtitle: (_jb = (_ib = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _ib : readString(env, "UI_SUBTITLE")) != null ? _jb : "Powered by RAG",
3214
+ primaryColor: (_lb = (_kb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _kb : readString(env, "UI_PRIMARY_COLOR")) != null ? _lb : "#10b981",
3215
+ accentColor: (_nb = (_mb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _mb : readString(env, "UI_ACCENT_COLOR")) != null ? _nb : "#3b82f6",
3216
+ logoUrl: (_ob = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _ob : readString(env, "UI_LOGO_URL"),
3217
+ placeholder: (_qb = (_pb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _pb : readString(env, "UI_PLACEHOLDER")) != null ? _qb : "Ask me anything\u2026",
3218
+ showSources: ((_sb = (_rb = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _rb : readString(env, "UI_SHOW_SOURCES")) != null ? _sb : "true") !== "false",
3219
+ 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.",
3220
+ visualStyle: (_wb = (_vb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _vb : readString(env, "UI_VISUAL_STYLE")) != null ? _wb : "glass",
3221
+ borderRadius: (_yb = (_xb = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _xb : readString(env, "UI_BORDER_RADIUS")) != null ? _yb : "xl",
3222
+ allowUpload: ((_Ab = (_zb = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _zb : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Ab : "false") === "true"
3222
3223
  },
3223
3224
  rag: {
3224
3225
  topK: readNumber(env, "RAG_TOP_K", 5),
3225
3226
  scoreThreshold: readNumber(env, "RAG_SCORE_THRESHOLD", 0),
3226
3227
  chunkSize: readNumber(env, "RAG_CHUNK_SIZE", 1e3),
3227
3228
  chunkOverlap: readNumber(env, "RAG_CHUNK_OVERLAP", 200),
3228
- filterableFields: (_Cb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Cb.split(",").map((f) => f.trim()),
3229
+ filterableFields: (_Bb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Bb.split(",").map((f) => f.trim()),
3229
3230
  // Query pipeline toggles — read from .env.local
3230
3231
  useQueryTransformation: readString(env, "RAG_USE_QUERY_TRANSFORMATION") === "true",
3231
3232
  useReranking: readString(env, "RAG_USE_RERANKING") === "true",
3232
3233
  useGraphRetrieval: readString(env, "RAG_USE_GRAPH_RETRIEVAL") === "true",
3233
- architecture: (_Db = readString(env, "RAG_ARCHITECTURE")) != null ? _Db : "simple",
3234
- chunkingStrategy: (_Eb = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Eb : "recursive",
3234
+ architecture: (_Cb = readString(env, "RAG_ARCHITECTURE")) != null ? _Cb : "simple",
3235
+ chunkingStrategy: (_Db = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Db : "recursive",
3235
3236
  uiMapping: (() => {
3236
3237
  const raw = readString(env, "RAG_UI_MAPPING");
3237
3238
  if (!raw) return void 0;
@@ -3244,7 +3245,7 @@ function getEnvConfig(env = process.env, base) {
3244
3245
  },
3245
3246
  telemetry: {
3246
3247
  enabled: telemetryEnabled,
3247
- 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"
3248
+ 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"
3248
3249
  }
3249
3250
  }, readString(env, "GRAPH_DB_PROVIDER") ? {
3250
3251
  graphDb: {
@@ -5247,7 +5248,7 @@ var ConfigValidator = class {
5247
5248
  // package.json
5248
5249
  var package_default = {
5249
5250
  name: "@retrivora-ai/rag-engine",
5250
- version: "2.1.5",
5251
+ version: "2.1.7",
5251
5252
  description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
5252
5253
  author: "Abhinav Alkuchi",
5253
5254
  license: "UNLICENSED",
@@ -10949,10 +10950,8 @@ function createStreamHandler(configOrPlugin, options) {
10949
10950
  let body;
10950
10951
  try {
10951
10952
  if ((_a2 = req.headers.get("content-type")) == null ? void 0 : _a2.includes("multipart/form-data")) {
10952
- return new Response(JSON.stringify({ error: { code: "INVALID_ENDPOINT", message: "Multipart file upload requests must be sent to the /upload endpoint." } }), {
10953
- status: 400,
10954
- headers: { "Content-Type": "application/json" }
10955
- });
10953
+ const uploader = createUploadHandler(plugin, { onAuthorize });
10954
+ return uploader(req);
10956
10955
  }
10957
10956
  body = await req.json();
10958
10957
  } catch (e) {
@@ -3045,7 +3045,7 @@ function readEnum(env, name, fallback, allowed) {
3045
3045
  throw new Error(`[getRagConfig] ${name} must be one of: ${allowed.join(", ")}`);
3046
3046
  }
3047
3047
  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, _Ib;
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;
3049
3049
  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
3050
  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
3051
  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,38 +3053,39 @@ function getEnvConfig(env = process.env, base) {
3053
3053
  const embeddingDimensions = readNumber(env, "EMBEDDING_DIMENSIONS", 768);
3054
3054
  const vectorDbOptions = {};
3055
3055
  if (vectorProvider === "pinecone") {
3056
- 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 : "";
3057
- 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";
3056
+ 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;
3057
+ vectorDbOptions.apiKey = rawApiKey || (licenseKey ? "retrivora-keyless-gateway" : "keyless-free-tier");
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";
3058
3059
  } else if (vectorProvider === "pgvector" || vectorProvider === "postgresql") {
3059
- 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 : "";
3060
- 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;
3061
- 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;
3060
+ 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 : "";
3061
+ 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;
3062
+ 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;
3062
3063
  vectorDbOptions.dimensions = embeddingDimensions;
3063
3064
  } else if (vectorProvider === "mongodb") {
3064
- 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 : "";
3065
- 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 : "";
3066
- 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 : "";
3067
- 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";
3065
+ 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 : "";
3066
+ 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 : "";
3067
+ 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 : "";
3068
+ 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";
3068
3069
  } else if (vectorProvider === "qdrant") {
3069
- 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";
3070
- 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;
3070
+ 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";
3071
+ 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;
3071
3072
  vectorDbOptions.dimensions = embeddingDimensions;
3072
3073
  } else if (vectorProvider === "milvus") {
3073
- vectorDbOptions.baseUrl = (_fa = readString(env, "MILVUS_URL")) != null ? _fa : "http://localhost:19530";
3074
+ vectorDbOptions.baseUrl = (_ea = readString(env, "MILVUS_URL")) != null ? _ea : "http://localhost:19530";
3074
3075
  vectorDbOptions.apiKey = readString(env, "MILVUS_API_KEY");
3075
3076
  } else if (vectorProvider === "chromadb") {
3076
- vectorDbOptions.baseUrl = (_ga = readString(env, "CHROMADB_URL")) != null ? _ga : "http://localhost:8000";
3077
+ vectorDbOptions.baseUrl = (_fa = readString(env, "CHROMADB_URL")) != null ? _fa : "http://localhost:8000";
3077
3078
  } else if (vectorProvider === "weaviate") {
3078
- vectorDbOptions.baseUrl = (_ha = readString(env, "WEAVIATE_URL")) != null ? _ha : "http://localhost:8080";
3079
+ vectorDbOptions.baseUrl = (_ga = readString(env, "WEAVIATE_URL")) != null ? _ga : "http://localhost:8080";
3079
3080
  vectorDbOptions.apiKey = readString(env, "WEAVIATE_API_KEY");
3080
3081
  } else if (vectorProvider === "redis") {
3081
- vectorDbOptions.baseUrl = (_ia = readString(env, "REDIS_URL")) != null ? _ia : "";
3082
+ vectorDbOptions.baseUrl = (_ha = readString(env, "REDIS_URL")) != null ? _ha : "";
3082
3083
  vectorDbOptions.apiKey = readString(env, "REDIS_API_KEY");
3083
3084
  } else if (vectorProvider === "rest") {
3084
- vectorDbOptions.baseUrl = (_ja = readString(env, "VECTOR_DB_REST_URL")) != null ? _ja : "";
3085
+ vectorDbOptions.baseUrl = (_ia = readString(env, "VECTOR_DB_REST_URL")) != null ? _ia : "";
3085
3086
  vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { "api-key": readString(env, "VECTOR_DB_REST_API_KEY") } : {};
3086
3087
  } else if (vectorProvider === "universal_rest") {
3087
- vectorDbOptions.baseUrl = (_la = (_ka = readString(env, "VECTOR_BASE_URL")) != null ? _ka : readString(env, "VECTOR_DB_REST_URL")) != null ? _la : "";
3088
+ vectorDbOptions.baseUrl = (_ka = (_ja = readString(env, "VECTOR_BASE_URL")) != null ? _ja : readString(env, "VECTOR_DB_REST_URL")) != null ? _ka : "";
3088
3089
  vectorDbOptions.profile = readString(env, "VECTOR_UNIVERSAL_PROFILE");
3089
3090
  vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { Authorization: `Bearer ${readString(env, "VECTOR_DB_REST_API_KEY")}` } : {};
3090
3091
  }
@@ -3103,8 +3104,8 @@ function getEnvConfig(env = process.env, base) {
3103
3104
  // Anthropic needs a separate embedding provider; key kept for completeness
3104
3105
  gemini: readString(env, "GEMINI_API_KEY"),
3105
3106
  ollama: void 0,
3106
- universal_rest: (_ma = readString(env, "EMBEDDING_API_KEY")) != null ? _ma : readString(env, "OPENAI_API_KEY"),
3107
- custom: (_na = readString(env, "EMBEDDING_API_KEY")) != null ? _na : readString(env, "OPENAI_API_KEY")
3107
+ universal_rest: (_la = readString(env, "EMBEDDING_API_KEY")) != null ? _la : readString(env, "OPENAI_API_KEY"),
3108
+ custom: (_ma = readString(env, "EMBEDDING_API_KEY")) != null ? _ma : readString(env, "OPENAI_API_KEY")
3108
3109
  };
3109
3110
  const DEFAULT_MODEL_BY_PROVIDER = {
3110
3111
  openai: "gpt-4o",
@@ -3125,25 +3126,25 @@ function getEnvConfig(env = process.env, base) {
3125
3126
  return true;
3126
3127
  }
3127
3128
  })();
3128
- const defaultGatewayUrl = (_pa = (_oa = readString(env, "LITELLM_BASE_URL")) != null ? _oa : readString(env, "LLM_BASE_URL")) != null ? _pa : "https://llm.retrivora.com/api/v1";
3129
+ const defaultGatewayUrl = (_oa = (_na = readString(env, "LITELLM_BASE_URL")) != null ? _na : readString(env, "LLM_BASE_URL")) != null ? _oa : "https://llm.retrivora.com/api/v1";
3129
3130
  const defaultLlmProvider = isFreeTier ? "universal_rest" : "universal_rest";
3130
- 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;
3131
- 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;
3132
- 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";
3133
- 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;
3134
- 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";
3131
+ 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;
3132
+ 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;
3133
+ 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";
3134
+ 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;
3135
+ 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";
3135
3136
  const defaultEmbeddingProvider = isFreeTier ? "universal_rest" : "universal_rest";
3136
- 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;
3137
- 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;
3138
- 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";
3139
- 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;
3140
- 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";
3137
+ 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;
3138
+ 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;
3139
+ 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";
3140
+ 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;
3141
+ 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";
3141
3142
  return __spreadProps(__spreadValues({
3142
3143
  projectId,
3143
3144
  licenseKey,
3144
3145
  vectorDb: {
3145
3146
  provider: vectorProvider,
3146
- indexName: (_gb = (_fb = readString(env, "VECTOR_DB_INDEX")) != null ? _fb : vectorDbOptions.indexName) != null ? _gb : "rag-index",
3147
+ indexName: (_fb = (_eb = readString(env, "VECTOR_DB_INDEX")) != null ? _eb : vectorDbOptions.indexName) != null ? _fb : "rag-index",
3147
3148
  options: vectorDbOptions
3148
3149
  },
3149
3150
  llm: {
@@ -3173,30 +3174,30 @@ function getEnvConfig(env = process.env, base) {
3173
3174
  }
3174
3175
  },
3175
3176
  ui: {
3176
- title: (_ib = (_hb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _hb : readString(env, "UI_TITLE")) != null ? _ib : "AI Assistant",
3177
- subtitle: (_kb = (_jb = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _jb : readString(env, "UI_SUBTITLE")) != null ? _kb : "Powered by RAG",
3178
- primaryColor: (_mb = (_lb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _lb : readString(env, "UI_PRIMARY_COLOR")) != null ? _mb : "#10b981",
3179
- accentColor: (_ob = (_nb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _nb : readString(env, "UI_ACCENT_COLOR")) != null ? _ob : "#3b82f6",
3180
- logoUrl: (_pb = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _pb : readString(env, "UI_LOGO_URL"),
3181
- placeholder: (_rb = (_qb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _qb : readString(env, "UI_PLACEHOLDER")) != null ? _rb : "Ask me anything\u2026",
3182
- showSources: ((_tb = (_sb = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _sb : readString(env, "UI_SHOW_SOURCES")) != null ? _tb : "true") !== "false",
3183
- 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.",
3184
- visualStyle: (_xb = (_wb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _wb : readString(env, "UI_VISUAL_STYLE")) != null ? _xb : "glass",
3185
- borderRadius: (_zb = (_yb = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _yb : readString(env, "UI_BORDER_RADIUS")) != null ? _zb : "xl",
3186
- allowUpload: ((_Bb = (_Ab = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _Ab : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Bb : "false") === "true"
3177
+ title: (_hb = (_gb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _gb : readString(env, "UI_TITLE")) != null ? _hb : "AI Assistant",
3178
+ subtitle: (_jb = (_ib = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _ib : readString(env, "UI_SUBTITLE")) != null ? _jb : "Powered by RAG",
3179
+ primaryColor: (_lb = (_kb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _kb : readString(env, "UI_PRIMARY_COLOR")) != null ? _lb : "#10b981",
3180
+ accentColor: (_nb = (_mb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _mb : readString(env, "UI_ACCENT_COLOR")) != null ? _nb : "#3b82f6",
3181
+ logoUrl: (_ob = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _ob : readString(env, "UI_LOGO_URL"),
3182
+ placeholder: (_qb = (_pb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _pb : readString(env, "UI_PLACEHOLDER")) != null ? _qb : "Ask me anything\u2026",
3183
+ showSources: ((_sb = (_rb = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _rb : readString(env, "UI_SHOW_SOURCES")) != null ? _sb : "true") !== "false",
3184
+ 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.",
3185
+ visualStyle: (_wb = (_vb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _vb : readString(env, "UI_VISUAL_STYLE")) != null ? _wb : "glass",
3186
+ borderRadius: (_yb = (_xb = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _xb : readString(env, "UI_BORDER_RADIUS")) != null ? _yb : "xl",
3187
+ allowUpload: ((_Ab = (_zb = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _zb : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Ab : "false") === "true"
3187
3188
  },
3188
3189
  rag: {
3189
3190
  topK: readNumber(env, "RAG_TOP_K", 5),
3190
3191
  scoreThreshold: readNumber(env, "RAG_SCORE_THRESHOLD", 0),
3191
3192
  chunkSize: readNumber(env, "RAG_CHUNK_SIZE", 1e3),
3192
3193
  chunkOverlap: readNumber(env, "RAG_CHUNK_OVERLAP", 200),
3193
- filterableFields: (_Cb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Cb.split(",").map((f) => f.trim()),
3194
+ filterableFields: (_Bb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Bb.split(",").map((f) => f.trim()),
3194
3195
  // Query pipeline toggles — read from .env.local
3195
3196
  useQueryTransformation: readString(env, "RAG_USE_QUERY_TRANSFORMATION") === "true",
3196
3197
  useReranking: readString(env, "RAG_USE_RERANKING") === "true",
3197
3198
  useGraphRetrieval: readString(env, "RAG_USE_GRAPH_RETRIEVAL") === "true",
3198
- architecture: (_Db = readString(env, "RAG_ARCHITECTURE")) != null ? _Db : "simple",
3199
- chunkingStrategy: (_Eb = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Eb : "recursive",
3199
+ architecture: (_Cb = readString(env, "RAG_ARCHITECTURE")) != null ? _Cb : "simple",
3200
+ chunkingStrategy: (_Db = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Db : "recursive",
3200
3201
  uiMapping: (() => {
3201
3202
  const raw = readString(env, "RAG_UI_MAPPING");
3202
3203
  if (!raw) return void 0;
@@ -3209,7 +3210,7 @@ function getEnvConfig(env = process.env, base) {
3209
3210
  },
3210
3211
  telemetry: {
3211
3212
  enabled: telemetryEnabled,
3212
- 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"
3213
+ 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"
3213
3214
  }
3214
3215
  }, readString(env, "GRAPH_DB_PROVIDER") ? {
3215
3216
  graphDb: {
@@ -5212,7 +5213,7 @@ var ConfigValidator = class {
5212
5213
  // package.json
5213
5214
  var package_default = {
5214
5215
  name: "@retrivora-ai/rag-engine",
5215
- version: "2.1.5",
5216
+ version: "2.1.7",
5216
5217
  description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
5217
5218
  author: "Abhinav Alkuchi",
5218
5219
  license: "UNLICENSED",
@@ -10914,10 +10915,8 @@ function createStreamHandler(configOrPlugin, options) {
10914
10915
  let body;
10915
10916
  try {
10916
10917
  if ((_a2 = req.headers.get("content-type")) == null ? void 0 : _a2.includes("multipart/form-data")) {
10917
- return new Response(JSON.stringify({ error: { code: "INVALID_ENDPOINT", message: "Multipart file upload requests must be sent to the /upload endpoint." } }), {
10918
- status: 400,
10919
- headers: { "Content-Type": "application/json" }
10920
- });
10918
+ const uploader = createUploadHandler(plugin, { onAuthorize });
10919
+ return uploader(req);
10921
10920
  }
10922
10921
  body = await req.json();
10923
10922
  } catch (e) {
package/dist/index.css CHANGED
@@ -2917,14 +2917,6 @@
2917
2917
  color: var(--color-amber-400);
2918
2918
  }
2919
2919
  }
2920
- .dark\:text-amber-400\/90 {
2921
- @media (prefers-color-scheme: dark) {
2922
- color: color-mix(in srgb, oklch(82.8% 0.189 84.429) 90%, transparent);
2923
- @supports (color: color-mix(in lab, red, red)) {
2924
- color: color-mix(in oklab, var(--color-amber-400) 90%, transparent);
2925
- }
2926
- }
2927
- }
2928
2920
  .dark\:text-blue-100 {
2929
2921
  @media (prefers-color-scheme: dark) {
2930
2922
  color: var(--color-blue-100);