@retrivora-ai/rag-engine 2.3.6 → 2.3.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.
@@ -302,7 +302,7 @@ var init_package = __esm({
302
302
  "package.json"() {
303
303
  package_default = {
304
304
  name: "@retrivora-ai/rag-engine",
305
- version: "2.3.6",
305
+ version: "2.3.7",
306
306
  description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
307
307
  author: "Abhinav Alkuchi",
308
308
  license: "UNLICENSED",
@@ -2813,13 +2813,13 @@ LicenseVerifier.CACHE_TTL_MS = 60 * 1e3;
2813
2813
  // In production, this matches the private key held by Retrivora SaaS.
2814
2814
  // Rotate this key only when the signing private key is replaced.
2815
2815
  LicenseVerifier.PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
2816
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoOQlmDSKfCZaRy06rxwa
2817
- chuDimlF134xTCitKDTPTPizF23oSn34pGDJakm/0T09JVUX8L/cvhGPe/3lf/g9
2818
- 4Y1q+Gb2KVM17KNGeT1Aj9Ua3BKz/yao/oFhi/r3Zt3cWY13B/Rd6clqY9WshIAV
2819
- NqZNM8ilTl777cMbyym+6D+mzGXgmnJAO5brddIAI9FPLW0T3Znt8vEqDOIljEkC
2820
- HCGHeirKABLbjKSJ4hljCa3vVitWqndhiq8CBSJG6HatiSGYotgMWGRY+0EbdlEv
2821
- OJP4SqafQ3aD6YnL9q1n15QKwxu/uMK+JGM2VxxuyUi9GANtMIkCYy9xya73P4Qc
2822
- gQIDAQAB
2816
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyKvvOSYdCimG3b236ebV
2817
+ jpG88xQiU8dSiaMahtBJDf4w0AewRj7hMNgmeZ1wyTOj8kVgeGBOolp1Z0QmTr6O
2818
+ Tj4EDQ/zjsg12If7hSf3NiwLHCYmMLslyK0aaP6PQoTrYkBv3GNdkMecrIjKCijb
2819
+ 6VvDLLF3X696melTVM0z/d2e50BW2AlRw/rf1EqYi10d0BcPo5zje0XETr/WGmqu
2820
+ sDiXtsP5MlwkL9X7RQY2uovRa+l/vOAqAfdmJ+OzXuk5P7mDUPb+gCtKnoDbb1tr
2821
+ 6UAu733dkUnetAcMqyT3fNPBLO66DCc6m9rGCYYAaG7piMEDwG0/ZySZBFbgllJc
2822
+ 6QIDAQAB
2823
2823
  -----END PUBLIC KEY-----`;
2824
2824
 
2825
2825
  // src/config/constants.ts
@@ -2868,6 +2868,7 @@ var PROVIDERS_WITH_EMBEDDINGS = [
2868
2868
  var UI_BORDER_RADIUS_OPTIONS = ["none", "sm", "md", "lg", "xl", "full"];
2869
2869
 
2870
2870
  // src/config/serverConfig.ts
2871
+ var _runtimeConfig = null;
2871
2872
  function readString(env, name) {
2872
2873
  var _a3;
2873
2874
  const value = (_a3 = env[name]) == null ? void 0 : _a3.trim();
@@ -2891,7 +2892,7 @@ function readEnum(env, name, fallback, allowed) {
2891
2892
  throw new Error(`[getRagConfig] ${name} must be one of: ${allowed.join(", ")}`);
2892
2893
  }
2893
2894
  function getEnvConfig(env = process.env, base) {
2894
- var _a3, _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;
2895
+ var _a3, _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;
2895
2896
  const licenseKey = (_d = (_c = (_b = (_a3 = readString(env, "RAG_LICENSE_KEY")) != null ? _a3 : 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;
2896
2897
  const jwtProjectId = (() => {
2897
2898
  if (!licenseKey) return void 0;
@@ -2983,25 +2984,35 @@ function getEnvConfig(env = process.env, base) {
2983
2984
  return true;
2984
2985
  }
2985
2986
  })();
2986
- const defaultGatewayUrl = (_ra = (_qa = readString(env, "LITELLM_BASE_URL")) != null ? _qa : readString(env, "LLM_BASE_URL")) != null ? _ra : "https://www.retrivora.com/api/v1";
2987
- const defaultLlmProvider = isFreeTier2 ? "universal_rest" : "universal_rest";
2988
- 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;
2989
- 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;
2990
- const llmModel = (_Ca = (_Aa = readString(env, "LLM_MODEL")) != null ? _Aa : (_za = base == null ? void 0 : base.llm) == null ? void 0 : _za.model) != null ? _Ca : isFreeTier2 ? "llama-3.1-8b-instant" : (_Ba = DEFAULT_MODEL_BY_PROVIDER[llmProvider]) != null ? _Ba : "gpt-4o";
2991
- 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;
2992
- 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";
2993
- const defaultEmbeddingProvider = isFreeTier2 ? "universal_rest" : "universal_rest";
2994
- 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;
2995
- 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;
2996
- 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";
2997
- 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;
2998
- 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";
2987
+ const tierBasedLLMModel = isFreeTier2 ? "llama-3.1-8b-instant" : "llama-3.3-70b-versatile";
2988
+ const tierBasedEmbeddingModel = isFreeTier2 ? "text-embedding-004" : "text-embedding-004";
2989
+ const defaultGatewayUrl = "https://llm.retrivora.com/api/v1";
2990
+ const rt = _runtimeConfig;
2991
+ const defaultLlmProvider = "universal_rest";
2992
+ 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;
2993
+ const llmBaseUrl = (_xa = (_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 : rt == null ? void 0 : rt.llmBaseUrl) != null ? _xa : defaultGatewayUrl;
2994
+ const llmModel = (_Ba = (_Aa = (_za = readString(env, "LLM_MODEL")) != null ? _za : (_ya = base == null ? void 0 : base.llm) == null ? void 0 : _ya.model) != null ? _Aa : rt == null ? void 0 : rt.llmModel) != null ? _Ba : tierBasedLLMModel;
2995
+ const llmApiKey = (_Fa = (_Ea = (_Ca = readString(env, "LITELLM_MASTER_KEY")) != null ? _Ca : rt == null ? void 0 : rt.litellmApiKey) != null ? _Ea : (_Da = base == null ? void 0 : base.llm) == null ? void 0 : _Da.apiKey) != null ? _Fa : licenseKey;
2996
+ 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";
2997
+ console.log("[serverConfig] \u{1F527} LLM Configuration:", {
2998
+ baseUrl: llmBaseUrl,
2999
+ model: llmModel,
3000
+ provider: llmProvider,
3001
+ hasApiKey: !!llmApiKey,
3002
+ source: (rt == null ? void 0 : rt.llmModel) ? "runtime-injected" : "env/fallback"
3003
+ });
3004
+ const defaultEmbeddingProvider = "universal_rest";
3005
+ 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;
3006
+ const embeddingBaseUrl = (_Ta = (_Sa = (_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 : rt == null ? void 0 : rt.embeddingBaseUrl) != null ? _Sa : rt == null ? void 0 : rt.llmBaseUrl) != null ? _Ta : defaultGatewayUrl;
3007
+ const embeddingModel = (_Xa = (_Wa = (_Va = readString(env, "EMBEDDING_MODEL")) != null ? _Va : (_Ua = base == null ? void 0 : base.embedding) == null ? void 0 : _Ua.model) != null ? _Wa : rt == null ? void 0 : rt.embeddingModel) != null ? _Xa : tierBasedEmbeddingModel;
3008
+ const embeddingApiKey = (_$a = (__a = (_Ya = readString(env, "LITELLM_MASTER_KEY")) != null ? _Ya : rt == null ? void 0 : rt.litellmApiKey) != null ? __a : (_Za = base == null ? void 0 : base.embedding) == null ? void 0 : _Za.apiKey) != null ? _$a : licenseKey;
3009
+ 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";
2999
3010
  return __spreadProps(__spreadValues({
3000
3011
  projectId,
3001
3012
  licenseKey,
3002
3013
  vectorDb: {
3003
3014
  provider: vectorProvider,
3004
- indexName: (_ib = (_hb = readString(env, "VECTOR_DB_INDEX")) != null ? _hb : vectorDbOptions.indexName) != null ? _ib : "rag-index",
3015
+ indexName: (_fb = (_eb = readString(env, "VECTOR_DB_INDEX")) != null ? _eb : vectorDbOptions.indexName) != null ? _fb : "rag-index",
3005
3016
  options: vectorDbOptions
3006
3017
  },
3007
3018
  llm: {
@@ -3031,30 +3042,30 @@ function getEnvConfig(env = process.env, base) {
3031
3042
  }
3032
3043
  },
3033
3044
  ui: {
3034
- title: (_kb = (_jb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _jb : readString(env, "UI_TITLE")) != null ? _kb : "AI Assistant",
3035
- subtitle: (_mb = (_lb = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _lb : readString(env, "UI_SUBTITLE")) != null ? _mb : "Powered by RAG",
3036
- primaryColor: (_ob = (_nb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _nb : readString(env, "UI_PRIMARY_COLOR")) != null ? _ob : "#10b981",
3037
- accentColor: (_qb = (_pb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _pb : readString(env, "UI_ACCENT_COLOR")) != null ? _qb : "#3b82f6",
3038
- logoUrl: (_rb = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _rb : readString(env, "UI_LOGO_URL"),
3039
- placeholder: (_tb = (_sb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _sb : readString(env, "UI_PLACEHOLDER")) != null ? _tb : "Ask me anything\u2026",
3040
- showSources: ((_vb = (_ub = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _ub : readString(env, "UI_SHOW_SOURCES")) != null ? _vb : "true") !== "false",
3041
- 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.",
3042
- visualStyle: (_zb = (_yb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _yb : readString(env, "UI_VISUAL_STYLE")) != null ? _zb : "glass",
3043
- borderRadius: (_Bb = (_Ab = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _Ab : readString(env, "UI_BORDER_RADIUS")) != null ? _Bb : "xl",
3044
- allowUpload: ((_Db = (_Cb = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _Cb : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Db : "false") === "true"
3045
+ title: (_hb = (_gb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _gb : readString(env, "UI_TITLE")) != null ? _hb : "AI Assistant",
3046
+ subtitle: (_jb = (_ib = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _ib : readString(env, "UI_SUBTITLE")) != null ? _jb : "Powered by RAG",
3047
+ primaryColor: (_lb = (_kb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _kb : readString(env, "UI_PRIMARY_COLOR")) != null ? _lb : "#10b981",
3048
+ accentColor: (_nb = (_mb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _mb : readString(env, "UI_ACCENT_COLOR")) != null ? _nb : "#3b82f6",
3049
+ logoUrl: (_ob = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _ob : readString(env, "UI_LOGO_URL"),
3050
+ placeholder: (_qb = (_pb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _pb : readString(env, "UI_PLACEHOLDER")) != null ? _qb : "Ask me anything\u2026",
3051
+ showSources: ((_sb = (_rb = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _rb : readString(env, "UI_SHOW_SOURCES")) != null ? _sb : "true") !== "false",
3052
+ 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.",
3053
+ visualStyle: (_wb = (_vb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _vb : readString(env, "UI_VISUAL_STYLE")) != null ? _wb : "glass",
3054
+ borderRadius: (_yb = (_xb = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _xb : readString(env, "UI_BORDER_RADIUS")) != null ? _yb : "xl",
3055
+ allowUpload: ((_Ab = (_zb = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _zb : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Ab : "false") === "true"
3045
3056
  },
3046
3057
  rag: {
3047
3058
  topK: readNumber(env, "RAG_TOP_K", 5),
3048
3059
  scoreThreshold: readNumber(env, "RAG_SCORE_THRESHOLD", 0),
3049
3060
  chunkSize: readNumber(env, "RAG_CHUNK_SIZE", 1e3),
3050
3061
  chunkOverlap: readNumber(env, "RAG_CHUNK_OVERLAP", 200),
3051
- filterableFields: (_Eb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Eb.split(",").map((f) => f.trim()),
3062
+ filterableFields: (_Bb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Bb.split(",").map((f) => f.trim()),
3052
3063
  // Query pipeline toggles — read from .env.local
3053
3064
  useQueryTransformation: readString(env, "RAG_USE_QUERY_TRANSFORMATION") === "true",
3054
3065
  useReranking: readString(env, "RAG_USE_RERANKING") === "true",
3055
3066
  useGraphRetrieval: readString(env, "RAG_USE_GRAPH_RETRIEVAL") === "true",
3056
- architecture: (_Fb = readString(env, "RAG_ARCHITECTURE")) != null ? _Fb : "simple",
3057
- chunkingStrategy: (_Gb = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Gb : "recursive",
3067
+ architecture: (_Cb = readString(env, "RAG_ARCHITECTURE")) != null ? _Cb : "simple",
3068
+ chunkingStrategy: (_Db = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Db : "recursive",
3058
3069
  uiMapping: (() => {
3059
3070
  const raw = readString(env, "RAG_UI_MAPPING");
3060
3071
  if (!raw) return void 0;
@@ -3067,7 +3078,7 @@ function getEnvConfig(env = process.env, base) {
3067
3078
  },
3068
3079
  telemetry: {
3069
3080
  enabled: telemetryEnabled,
3070
- 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 : "https://www.retrivora.com/api/telemetry"
3081
+ 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 : "https://www.retrivora.com/api/telemetry"
3071
3082
  }
3072
3083
  }, readString(env, "GRAPH_DB_PROVIDER") ? {
3073
3084
  graphDb: {
@@ -4385,7 +4396,7 @@ var UniversalLLMAdapter = class {
4385
4396
  });
4386
4397
  }
4387
4398
  async chat(messages, context) {
4388
- var _a3, _b, _c, _d, _e;
4399
+ var _a3, _b, _c, _d, _e, _f, _g2, _h, _i, _j;
4389
4400
  const path2 = (_a3 = this.opts.chatPath) != null ? _a3 : "/chat/completions";
4390
4401
  const safeMessages = (Array.isArray(messages) ? messages : []).filter((m) => Boolean(m && typeof m === "object")).map((m) => ({
4391
4402
  role: m.role || "user",
@@ -4415,16 +4426,27 @@ ${context != null ? context : "None"}` },
4415
4426
  };
4416
4427
  }
4417
4428
  try {
4429
+ console.debug(`[UniversalLLMAdapter] POST ${this.baseUrl}${path2}`);
4430
+ console.debug(`[UniversalLLMAdapter] Model: ${this.model}`);
4431
+ console.debug(`[UniversalLLMAdapter] Auth: Bearer ${((_b = this.apiKey) == null ? void 0 : _b.substring(0, 20)) || "none"}...`);
4418
4432
  const { data: data2 } = await this.http.post(path2, payload);
4419
- const extractPath2 = (_b = this.opts.responseExtractPath) != null ? _b : "choices[0].message.content";
4420
- const result2 = (_c = resolvePath(data2, extractPath2)) != null ? _c : extractContent(data2);
4433
+ const extractPath2 = (_c = this.opts.responseExtractPath) != null ? _c : "choices[0].message.content";
4434
+ const result2 = (_d = resolvePath(data2, extractPath2)) != null ? _d : extractContent(data2);
4421
4435
  if (result2 !== void 0) {
4422
4436
  return String(result2);
4423
4437
  }
4424
4438
  } catch (httpErr) {
4425
- const _g2 = globalThis;
4426
- const dispatch = _g2.__retrivoraDispatchChat;
4439
+ console.error("[UniversalLLMAdapter] \u274C HTTP chat request failed:", {
4440
+ status: (_e = httpErr == null ? void 0 : httpErr.response) == null ? void 0 : _e.status,
4441
+ statusText: (_f = httpErr == null ? void 0 : httpErr.response) == null ? void 0 : _f.statusText,
4442
+ url: (_g2 = httpErr == null ? void 0 : httpErr.config) == null ? void 0 : _g2.url,
4443
+ errorData: (_h = httpErr == null ? void 0 : httpErr.response) == null ? void 0 : _h.data,
4444
+ message: httpErr == null ? void 0 : httpErr.message
4445
+ });
4446
+ const _g3 = globalThis;
4447
+ const dispatch = _g3.__retrivoraDispatchChat;
4427
4448
  if (typeof dispatch === "function") {
4449
+ console.debug("[UniversalLLMAdapter] \u{1F504} Attempting in-process fallback dispatch");
4428
4450
  const res = await dispatch({
4429
4451
  model: this.model,
4430
4452
  messages: formattedMessages,
@@ -4439,8 +4461,8 @@ ${context != null ? context : "None"}` },
4439
4461
  throw httpErr;
4440
4462
  }
4441
4463
  const { data } = await this.http.post(path2, payload);
4442
- const extractPath = (_d = this.opts.responseExtractPath) != null ? _d : "choices[0].message.content";
4443
- const result = (_e = resolvePath(data, extractPath)) != null ? _e : extractContent(data);
4464
+ const extractPath = (_i = this.opts.responseExtractPath) != null ? _i : "choices[0].message.content";
4465
+ const result = (_j = resolvePath(data, extractPath)) != null ? _j : extractContent(data);
4444
4466
  if (result === void 0) {
4445
4467
  throw new Error(`[UniversalLLMAdapter] Could not extract text from path '${extractPath}' in response.`);
4446
4468
  }
@@ -4579,36 +4601,70 @@ ${context != null ? context : "None"}` },
4579
4601
  });
4580
4602
  }
4581
4603
  async embed(text) {
4582
- var _a3, _b, _c, _d, _e;
4604
+ var _a3, _b, _c, _d, _e, _f, _g2;
4583
4605
  const path2 = (_a3 = this.opts.embedPath) != null ? _a3 : "/embeddings";
4584
4606
  const payload = this.opts.embedPayloadTemplate ? buildPayload(this.opts.embedPayloadTemplate, { input: text, model: this.model }) : { input: text, model: this.model };
4585
4607
  try {
4586
- const { data: data2 } = await this.http.post(path2, payload);
4587
- const extractPath2 = (_b = this.opts.embedExtractPath) != null ? _b : "data[0].embedding";
4588
- const vector2 = resolvePath(data2, extractPath2);
4589
- if (Array.isArray(vector2)) return vector2;
4590
- } catch (e) {
4591
- const _g2 = globalThis;
4592
- const dispatchEmbed = _g2.__retrivoraDispatchEmbedding;
4608
+ const { data } = await this.http.post(path2, payload);
4609
+ const extractPath = (_b = this.opts.embedExtractPath) != null ? _b : "data[0].embedding";
4610
+ const vector = resolvePath(data, extractPath);
4611
+ if (Array.isArray(vector)) return vector;
4612
+ console.warn(
4613
+ `[UniversalLLMAdapter] Embedding API returned unexpected format for path '${extractPath}'. Response:`,
4614
+ data
4615
+ );
4616
+ } catch (err) {
4617
+ console.warn(
4618
+ `[UniversalLLMAdapter] HTTP embedding request failed: ${(err == null ? void 0 : err.message) || err}`,
4619
+ { path: path2, model: this.model }
4620
+ );
4621
+ const _g3 = globalThis;
4622
+ const dispatchEmbed = _g3.__retrivoraDispatchEmbedding;
4593
4623
  if (typeof dispatchEmbed === "function") {
4594
- const res = await dispatchEmbed({ input: text, model: this.model }, this.apiKey);
4595
- if ((_d = (_c = res == null ? void 0 : res.data) == null ? void 0 : _c[0]) == null ? void 0 : _d.embedding) {
4596
- return res.data[0].embedding;
4624
+ try {
4625
+ const res = await dispatchEmbed({ input: text, model: this.model }, this.apiKey);
4626
+ if ((_d = (_c = res == null ? void 0 : res.data) == null ? void 0 : _c[0]) == null ? void 0 : _d.embedding) {
4627
+ return res.data[0].embedding;
4628
+ }
4629
+ } catch (dispatchErr) {
4630
+ console.warn("[UniversalLLMAdapter] In-process dispatch embedding failed:", dispatchErr);
4597
4631
  }
4598
4632
  }
4599
4633
  }
4600
- const { data } = await this.http.post(path2, payload);
4601
- const extractPath = (_e = this.opts.embedExtractPath) != null ? _e : "data[0].embedding";
4602
- const vector = resolvePath(data, extractPath);
4603
- if (!Array.isArray(vector)) {
4604
- throw new Error(`[UniversalLLMAdapter] Could not extract embedding vector from path '${extractPath}' in response.`);
4634
+ try {
4635
+ const { data } = await this.http.post(path2, payload);
4636
+ const extractPath = (_e = this.opts.embedExtractPath) != null ? _e : "data[0].embedding";
4637
+ const vector = resolvePath(data, extractPath);
4638
+ if (Array.isArray(vector)) {
4639
+ return vector;
4640
+ }
4641
+ console.error(
4642
+ `[UniversalLLMAdapter] Retry embedding failed: unexpected response format for path '${extractPath}'. Response:`,
4643
+ data
4644
+ );
4645
+ throw new Error(
4646
+ `[UniversalLLMAdapter] Could not extract embedding vector. Expected array at '${extractPath}', got: ${typeof vector}. Response keys: ${Object.keys(data || {})}.`
4647
+ );
4648
+ } catch (err) {
4649
+ console.error(
4650
+ `[UniversalLLMAdapter] Both embedding attempts failed. Path: ${path2}, Model: ${this.model}`,
4651
+ { error: err == null ? void 0 : err.message, statusCode: (_f = err == null ? void 0 : err.response) == null ? void 0 : _f.status, response: (_g2 = err == null ? void 0 : err.response) == null ? void 0 : _g2.data }
4652
+ );
4653
+ throw new Error(
4654
+ `[UniversalLLMAdapter] Failed to generate embedding after 2 attempts: ${(err == null ? void 0 : err.message) || err}`
4655
+ );
4605
4656
  }
4606
- return vector;
4607
4657
  }
4608
4658
  async batchEmbed(texts) {
4609
4659
  const results = [];
4610
4660
  for (const text of texts) {
4611
- results.push(await this.embed(text));
4661
+ try {
4662
+ const vector = await this.embed(text);
4663
+ results.push(vector);
4664
+ } catch (err) {
4665
+ console.warn(`[UniversalLLMAdapter] batchEmbed failed for text (first 50 chars): ${text.slice(0, 50)}...`, err);
4666
+ throw err;
4667
+ }
4612
4668
  }
4613
4669
  return results;
4614
4670
  }
@@ -11341,6 +11397,7 @@ function createUploadHandler(configOrPlugin, options) {
11341
11397
  const plugin = getOrCreatePlugin(configOrPlugin);
11342
11398
  const onAuthorize = options == null ? void 0 : options.onAuthorize;
11343
11399
  return async function POST(req, context) {
11400
+ console.log("Upload handler invoked");
11344
11401
  const authResult = await checkAuth(req, onAuthorize);
11345
11402
  if (authResult) return authResult;
11346
11403
  const config = plugin.getConfig();
@@ -11349,6 +11406,7 @@ function createUploadHandler(configOrPlugin, options) {
11349
11406
  try {
11350
11407
  const formData = await req.formData();
11351
11408
  const files = formData.getAll("files");
11409
+ console.log("Files received for upload:", files.map((f) => f.name));
11352
11410
  const namespace = formData.get("namespace") || void 0;
11353
11411
  const dimensionRaw = formData.get("dimension");
11354
11412
  const dimension = dimensionRaw ? parseInt(dimensionRaw, 10) : void 0;
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as ChatWidgetProps, a as ChatWindowProps, D as DocumentUploadProps, M as MessageBubbleProps, S as SourceCardProps, b as ConfigProviderProps, c as ClientConfig, P as ProductCardProps, d as ProductCarouselProps, R as RemoteConfig } from './BatchProcessor-Dfn23VAd.mjs';
3
- export { A as AuthenticationException, B as BatchOptions, e as BatchProcessor, f as BatchResult, g as ChartType, h as Chunk, i as ChunkOptions, j as ConfigFetcher, k as ConfigurationException, l as DecisionContext, E as EmbeddingFailedException, I as IRenderRule, m as IRendererStrategy, n as IntentCategory, L as LicenseValidationError, o as LicenseValidationRequest, p as LicenseValidationResponse, q as LicenseValidator, r as ProviderNotFoundException, s as RateLimitException, t as RemoteEmbeddingConfig, u as RemoteLLMConfig, v as RemoteVectorConfig, w as RenderDecision, x as RenderType, y as RetrievalException, z as Retrivora, F as RetrivoraError, G as RetrivoraErrorCode, H as SDKVersionUnsupportedError, J as SDK_VERSION, K as isTransientError } from './BatchProcessor-Dfn23VAd.mjs';
2
+ import { C as ChatWidgetProps, a as ChatWindowProps, D as DocumentUploadProps, M as MessageBubbleProps, S as SourceCardProps, b as ConfigProviderProps, c as ClientConfig, P as ProductCardProps, d as ProductCarouselProps, R as RemoteConfig } from './BatchProcessor-BhLczWj5.mjs';
3
+ export { A as AuthenticationException, B as BatchOptions, e as BatchProcessor, f as BatchResult, g as ChartType, h as Chunk, i as ChunkOptions, j as ConfigFetcher, k as ConfigurationException, l as DecisionContext, E as EmbeddingFailedException, I as IRenderRule, m as IRendererStrategy, n as IntentCategory, L as LicenseTierConfig, o as LicenseValidationError, p as LicenseValidationRequest, q as LicenseValidationResponse, r as LicenseValidator, s as ProviderCredentials, t as ProviderNotFoundException, u as RateLimitException, v as RemoteEmbeddingConfig, w as RemoteLLMConfig, x as RemoteVectorConfig, y as RenderDecision, z as RenderType, F as RetrievalException, G as Retrivora, H as RetrivoraError, J as RetrivoraErrorCode, K as SDKVersionUnsupportedError, N as SDK_VERSION, O as isTransientError } from './BatchProcessor-BhLczWj5.mjs';
4
4
  import { O as ObservabilityTrace, U as UseRagChatOptions, a as UseRagChatReturn, P as ProjectChatSettings } from './ILLMProvider-B8TAVx3j.mjs';
5
5
  export { A as AuthMode, C as ChatMessage, b as ChatOptions, c as ChatResponse, E as EmbedOptions, d as EmbeddingConfig, e as EmbeddingProvider, I as ILLMProvider, f as IngestDocument, L as LLMConfig, g as LLMProvider, h as LatencyBreakdown, i as ProjectAiSettings, j as ProjectAuthSettings, k as ProjectBrandingSettings, l as ProjectTelemetrySettings, m as ProjectWidgetSettings, R as RAGConfig, n as RagConfig, o as RagMessage, p as RetrievalConfig, q as RetrievedChunk, T as ThemeMode, r as TokenUsage, s as UIConfig, t as UniversalRagConfig, u as UpsertDocument, V as VectorDBConfig, v as VectorDBProvider, w as VectorMatch, W as WidgetPosition, x as WorkflowConfig, y as createDefaultProjectSettings, z as normalizeProjectSettings, B as projectSettingsToUiConfig } from './ILLMProvider-B8TAVx3j.mjs';
6
6
  import 'react';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as ChatWidgetProps, a as ChatWindowProps, D as DocumentUploadProps, M as MessageBubbleProps, S as SourceCardProps, b as ConfigProviderProps, c as ClientConfig, P as ProductCardProps, d as ProductCarouselProps, R as RemoteConfig } from './BatchProcessor-ByBl-1MA.js';
3
- export { A as AuthenticationException, B as BatchOptions, e as BatchProcessor, f as BatchResult, g as ChartType, h as Chunk, i as ChunkOptions, j as ConfigFetcher, k as ConfigurationException, l as DecisionContext, E as EmbeddingFailedException, I as IRenderRule, m as IRendererStrategy, n as IntentCategory, L as LicenseValidationError, o as LicenseValidationRequest, p as LicenseValidationResponse, q as LicenseValidator, r as ProviderNotFoundException, s as RateLimitException, t as RemoteEmbeddingConfig, u as RemoteLLMConfig, v as RemoteVectorConfig, w as RenderDecision, x as RenderType, y as RetrievalException, z as Retrivora, F as RetrivoraError, G as RetrivoraErrorCode, H as SDKVersionUnsupportedError, J as SDK_VERSION, K as isTransientError } from './BatchProcessor-ByBl-1MA.js';
2
+ import { C as ChatWidgetProps, a as ChatWindowProps, D as DocumentUploadProps, M as MessageBubbleProps, S as SourceCardProps, b as ConfigProviderProps, c as ClientConfig, P as ProductCardProps, d as ProductCarouselProps, R as RemoteConfig } from './BatchProcessor-C42_RVWO.js';
3
+ export { A as AuthenticationException, B as BatchOptions, e as BatchProcessor, f as BatchResult, g as ChartType, h as Chunk, i as ChunkOptions, j as ConfigFetcher, k as ConfigurationException, l as DecisionContext, E as EmbeddingFailedException, I as IRenderRule, m as IRendererStrategy, n as IntentCategory, L as LicenseTierConfig, o as LicenseValidationError, p as LicenseValidationRequest, q as LicenseValidationResponse, r as LicenseValidator, s as ProviderCredentials, t as ProviderNotFoundException, u as RateLimitException, v as RemoteEmbeddingConfig, w as RemoteLLMConfig, x as RemoteVectorConfig, y as RenderDecision, z as RenderType, F as RetrievalException, G as Retrivora, H as RetrivoraError, J as RetrivoraErrorCode, K as SDKVersionUnsupportedError, N as SDK_VERSION, O as isTransientError } from './BatchProcessor-C42_RVWO.js';
4
4
  import { O as ObservabilityTrace, U as UseRagChatOptions, a as UseRagChatReturn, P as ProjectChatSettings } from './ILLMProvider-B8TAVx3j.js';
5
5
  export { A as AuthMode, C as ChatMessage, b as ChatOptions, c as ChatResponse, E as EmbedOptions, d as EmbeddingConfig, e as EmbeddingProvider, I as ILLMProvider, f as IngestDocument, L as LLMConfig, g as LLMProvider, h as LatencyBreakdown, i as ProjectAiSettings, j as ProjectAuthSettings, k as ProjectBrandingSettings, l as ProjectTelemetrySettings, m as ProjectWidgetSettings, R as RAGConfig, n as RagConfig, o as RagMessage, p as RetrievalConfig, q as RetrievedChunk, T as ThemeMode, r as TokenUsage, s as UIConfig, t as UniversalRagConfig, u as UpsertDocument, V as VectorDBConfig, v as VectorDBProvider, w as VectorMatch, W as WidgetPosition, x as WorkflowConfig, y as createDefaultProjectSettings, z as normalizeProjectSettings, B as projectSettingsToUiConfig } from './ILLMProvider-B8TAVx3j.js';
6
6
  import 'react';
package/dist/index.js CHANGED
@@ -351,7 +351,7 @@ function projectSettingsToUiConfig(settings) {
351
351
  // package.json
352
352
  var package_default = {
353
353
  name: "@retrivora-ai/rag-engine",
354
- version: "2.3.6",
354
+ version: "2.3.7",
355
355
  description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
356
356
  author: "Abhinav Alkuchi",
357
357
  license: "UNLICENSED",
@@ -3770,13 +3770,13 @@ LicenseVerifier.CACHE_TTL_MS = 60 * 1e3;
3770
3770
  // In production, this matches the private key held by Retrivora SaaS.
3771
3771
  // Rotate this key only when the signing private key is replaced.
3772
3772
  LicenseVerifier.PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
3773
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoOQlmDSKfCZaRy06rxwa
3774
- chuDimlF134xTCitKDTPTPizF23oSn34pGDJakm/0T09JVUX8L/cvhGPe/3lf/g9
3775
- 4Y1q+Gb2KVM17KNGeT1Aj9Ua3BKz/yao/oFhi/r3Zt3cWY13B/Rd6clqY9WshIAV
3776
- NqZNM8ilTl777cMbyym+6D+mzGXgmnJAO5brddIAI9FPLW0T3Znt8vEqDOIljEkC
3777
- HCGHeirKABLbjKSJ4hljCa3vVitWqndhiq8CBSJG6HatiSGYotgMWGRY+0EbdlEv
3778
- OJP4SqafQ3aD6YnL9q1n15QKwxu/uMK+JGM2VxxuyUi9GANtMIkCYy9xya73P4Qc
3779
- gQIDAQAB
3773
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyKvvOSYdCimG3b236ebV
3774
+ jpG88xQiU8dSiaMahtBJDf4w0AewRj7hMNgmeZ1wyTOj8kVgeGBOolp1Z0QmTr6O
3775
+ Tj4EDQ/zjsg12If7hSf3NiwLHCYmMLslyK0aaP6PQoTrYkBv3GNdkMecrIjKCijb
3776
+ 6VvDLLF3X696melTVM0z/d2e50BW2AlRw/rf1EqYi10d0BcPo5zje0XETr/WGmqu
3777
+ sDiXtsP5MlwkL9X7RQY2uovRa+l/vOAqAfdmJ+OzXuk5P7mDUPb+gCtKnoDbb1tr
3778
+ 6UAu733dkUnetAcMqyT3fNPBLO66DCc6m9rGCYYAaG7piMEDwG0/ZySZBFbgllJc
3779
+ 6QIDAQAB
3780
3780
  -----END PUBLIC KEY-----`;
3781
3781
 
3782
3782
  // src/core/LicenseValidator.ts
package/dist/index.mjs CHANGED
@@ -307,7 +307,7 @@ function projectSettingsToUiConfig(settings) {
307
307
  // package.json
308
308
  var package_default = {
309
309
  name: "@retrivora-ai/rag-engine",
310
- version: "2.3.6",
310
+ version: "2.3.7",
311
311
  description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
312
312
  author: "Abhinav Alkuchi",
313
313
  license: "UNLICENSED",
@@ -3772,13 +3772,13 @@ LicenseVerifier.CACHE_TTL_MS = 60 * 1e3;
3772
3772
  // In production, this matches the private key held by Retrivora SaaS.
3773
3773
  // Rotate this key only when the signing private key is replaced.
3774
3774
  LicenseVerifier.PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
3775
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoOQlmDSKfCZaRy06rxwa
3776
- chuDimlF134xTCitKDTPTPizF23oSn34pGDJakm/0T09JVUX8L/cvhGPe/3lf/g9
3777
- 4Y1q+Gb2KVM17KNGeT1Aj9Ua3BKz/yao/oFhi/r3Zt3cWY13B/Rd6clqY9WshIAV
3778
- NqZNM8ilTl777cMbyym+6D+mzGXgmnJAO5brddIAI9FPLW0T3Znt8vEqDOIljEkC
3779
- HCGHeirKABLbjKSJ4hljCa3vVitWqndhiq8CBSJG6HatiSGYotgMWGRY+0EbdlEv
3780
- OJP4SqafQ3aD6YnL9q1n15QKwxu/uMK+JGM2VxxuyUi9GANtMIkCYy9xya73P4Qc
3781
- gQIDAQAB
3775
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyKvvOSYdCimG3b236ebV
3776
+ jpG88xQiU8dSiaMahtBJDf4w0AewRj7hMNgmeZ1wyTOj8kVgeGBOolp1Z0QmTr6O
3777
+ Tj4EDQ/zjsg12If7hSf3NiwLHCYmMLslyK0aaP6PQoTrYkBv3GNdkMecrIjKCijb
3778
+ 6VvDLLF3X696melTVM0z/d2e50BW2AlRw/rf1EqYi10d0BcPo5zje0XETr/WGmqu
3779
+ sDiXtsP5MlwkL9X7RQY2uovRa+l/vOAqAfdmJ+OzXuk5P7mDUPb+gCtKnoDbb1tr
3780
+ 6UAu733dkUnetAcMqyT3fNPBLO66DCc6m9rGCYYAaG7piMEDwG0/ZySZBFbgllJc
3781
+ 6QIDAQAB
3782
3782
  -----END PUBLIC KEY-----`;
3783
3783
 
3784
3784
  // src/core/LicenseValidator.ts