@retrivora-ai/rag-engine 2.3.8 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.mjs CHANGED
@@ -315,7 +315,7 @@ var init_package = __esm({
315
315
  "package.json"() {
316
316
  package_default = {
317
317
  name: "@retrivora-ai/rag-engine",
318
- version: "2.3.8",
318
+ version: "2.4.0",
319
319
  description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
320
320
  author: "Abhinav Alkuchi",
321
321
  license: "UNLICENSED",
@@ -510,6 +510,7 @@ var init_ConfigFetcher = __esm({
510
510
  for (const baseUrl of controlPlaneUrls) {
511
511
  try {
512
512
  const url = `${baseUrl}/api/v1/config?projectId=${encodeURIComponent(projectId)}`;
513
+ console.log(`[ConfigFetcher] Fetching config from: ${url}`);
513
514
  const res = await fetch(url, {
514
515
  method: "GET",
515
516
  headers: __spreadValues({
@@ -517,6 +518,10 @@ var init_ConfigFetcher = __esm({
517
518
  "x-sdk-version": SDK_VERSION
518
519
  }, licenseKey ? { "x-license-key": licenseKey } : {})
519
520
  });
521
+ console.log(`[ConfigFetcher] Response status: ${res.status}`);
522
+ if (!res.ok) {
523
+ console.warn(`[ConfigFetcher] Error text: ${await res.text()}`);
524
+ }
520
525
  if (res.ok) {
521
526
  const data = await res.json();
522
527
  if ((data == null ? void 0 : data.success) && (data == null ? void 0 : data.vectorDb)) {
@@ -3028,7 +3033,7 @@ function getRagConfig(baseConfig, env = process.env) {
3028
3033
  return getEnvConfig(env, baseConfig);
3029
3034
  }
3030
3035
  function getEnvConfig(env = process.env, base) {
3031
- 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;
3036
+ 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, _Lb, _Mb, _Nb;
3032
3037
  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;
3033
3038
  const jwtProjectId = (() => {
3034
3039
  if (!licenseKey) return void 0;
@@ -3121,14 +3126,15 @@ function getEnvConfig(env = process.env, base) {
3121
3126
  })();
3122
3127
  const tierBasedLLMModel = isFreeTier2 ? "llama-3.1-8b-instant" : "llama-3.3-70b-versatile";
3123
3128
  const tierBasedEmbeddingModel = isFreeTier2 ? "text-embedding-004" : "text-embedding-004";
3124
- const defaultGatewayUrl = "https://llm.retrivora.com/api/v1";
3129
+ const controlPlaneUrl = (_qa = readString(env, "RETRIVORA_CONTROL_PLANE_URL")) != null ? _qa : readString(env, "NEXT_PUBLIC_RETRIVORA_CONTROL_PLANE_URL");
3130
+ const defaultGatewayUrl = controlPlaneUrl ? `${controlPlaneUrl.replace(/\/$/, "")}/api/v1` : "https://llm.retrivora.com/api/v1";
3125
3131
  const rt = _runtimeConfig;
3126
3132
  const defaultLlmProvider = "universal_rest";
3127
- 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;
3128
- 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;
3129
- 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;
3130
- 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;
3131
- 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";
3133
+ const llmProvider = (_ta = (_sa = readEnum(env, "LLM_PROVIDER", defaultLlmProvider, LLM_PROVIDERS)) != null ? _sa : (_ra = base == null ? void 0 : base.llm) == null ? void 0 : _ra.provider) != null ? _ta : defaultLlmProvider;
3134
+ const llmBaseUrl = (_ya = (_xa = (_wa = (_ua = readString(env, "LITELLM_BASE_URL")) != null ? _ua : readString(env, "LLM_BASE_URL")) != null ? _wa : (_va = base == null ? void 0 : base.llm) == null ? void 0 : _va.baseUrl) != null ? _xa : rt == null ? void 0 : rt.llmBaseUrl) != null ? _ya : defaultGatewayUrl;
3135
+ const llmModel = (_Ca = (_Ba = (_Aa = readString(env, "LLM_MODEL")) != null ? _Aa : (_za = base == null ? void 0 : base.llm) == null ? void 0 : _za.model) != null ? _Ba : rt == null ? void 0 : rt.llmModel) != null ? _Ca : tierBasedLLMModel;
3136
+ const llmApiKey = (_Ga = (_Fa = (_Da = readString(env, "LITELLM_MASTER_KEY")) != null ? _Da : rt == null ? void 0 : rt.litellmApiKey) != null ? _Fa : (_Ea = base == null ? void 0 : base.llm) == null ? void 0 : _Ea.apiKey) != null ? _Ga : licenseKey;
3137
+ 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";
3132
3138
  console.log("[serverConfig] \u{1F527} LLM Configuration:", {
3133
3139
  baseUrl: llmBaseUrl,
3134
3140
  model: llmModel,
@@ -3137,17 +3143,24 @@ function getEnvConfig(env = process.env, base) {
3137
3143
  source: (rt == null ? void 0 : rt.llmModel) ? "runtime-injected" : "env/fallback"
3138
3144
  });
3139
3145
  const defaultEmbeddingProvider = "universal_rest";
3140
- 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;
3141
- 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;
3142
- 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;
3143
- 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;
3144
- 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";
3146
+ 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;
3147
+ const embeddingBaseUrl = (_Ua = (_Ta = (_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 : rt == null ? void 0 : rt.embeddingBaseUrl) != null ? _Ta : rt == null ? void 0 : rt.llmBaseUrl) != null ? _Ua : defaultGatewayUrl;
3148
+ const embeddingModel = (_Ya = (_Xa = (_Wa = readString(env, "EMBEDDING_MODEL")) != null ? _Wa : (_Va = base == null ? void 0 : base.embedding) == null ? void 0 : _Va.model) != null ? _Xa : rt == null ? void 0 : rt.embeddingModel) != null ? _Ya : tierBasedEmbeddingModel;
3149
+ const embeddingApiKey = (_ab = (_$a = (_Za = readString(env, "LITELLM_MASTER_KEY")) != null ? _Za : rt == null ? void 0 : rt.litellmApiKey) != null ? _$a : (__a = base == null ? void 0 : base.embedding) == null ? void 0 : __a.apiKey) != null ? _ab : licenseKey;
3150
+ 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";
3151
+ console.log("[serverConfig] \u{1F527} Embedding Configuration:", {
3152
+ baseUrl: embeddingBaseUrl,
3153
+ model: embeddingModel,
3154
+ provider: embeddingProvider,
3155
+ hasApiKey: !!embeddingApiKey,
3156
+ source: (rt == null ? void 0 : rt.embeddingModel) ? "runtime-injected" : "env/fallback"
3157
+ });
3145
3158
  return __spreadProps(__spreadValues({
3146
3159
  projectId,
3147
3160
  licenseKey,
3148
3161
  vectorDb: {
3149
3162
  provider: vectorProvider,
3150
- indexName: (_fb = (_eb = readString(env, "VECTOR_DB_INDEX")) != null ? _eb : vectorDbOptions.indexName) != null ? _fb : "rag-index",
3163
+ indexName: (_gb = (_fb = readString(env, "VECTOR_DB_INDEX")) != null ? _fb : vectorDbOptions.indexName) != null ? _gb : "rag-index",
3151
3164
  options: vectorDbOptions
3152
3165
  },
3153
3166
  llm: {
@@ -3155,8 +3168,8 @@ function getEnvConfig(env = process.env, base) {
3155
3168
  model: llmModel,
3156
3169
  apiKey: llmApiKey,
3157
3170
  baseUrl: llmBaseUrl,
3158
- systemPrompt: readString(env, "LLM_SYSTEM_PROMPT"),
3159
- maxTokens: readNumber(env, "LLM_MAX_TOKENS", 4096),
3171
+ systemPrompt: (_hb = readString(env, "LLM_SYSTEM_PROMPT")) != null ? _hb : rt == null ? void 0 : rt.systemPrompt,
3172
+ maxTokens: readNumber(env, "LLM_MAX_TOKENS", (_ib = rt == null ? void 0 : rt.maxTokens) != null ? _ib : 4096),
3160
3173
  temperature: readNumber(env, "LLM_TEMPERATURE", 0.7),
3161
3174
  options: {
3162
3175
  profile: llmProfile,
@@ -3177,30 +3190,30 @@ function getEnvConfig(env = process.env, base) {
3177
3190
  }
3178
3191
  },
3179
3192
  ui: {
3180
- title: (_hb = (_gb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _gb : readString(env, "UI_TITLE")) != null ? _hb : "AI Assistant",
3181
- subtitle: (_jb = (_ib = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _ib : readString(env, "UI_SUBTITLE")) != null ? _jb : "Powered by RAG",
3182
- primaryColor: (_lb = (_kb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _kb : readString(env, "UI_PRIMARY_COLOR")) != null ? _lb : "#10b981",
3183
- accentColor: (_nb = (_mb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _mb : readString(env, "UI_ACCENT_COLOR")) != null ? _nb : "#3b82f6",
3184
- logoUrl: (_ob = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _ob : readString(env, "UI_LOGO_URL"),
3185
- placeholder: (_qb = (_pb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _pb : readString(env, "UI_PLACEHOLDER")) != null ? _qb : "Ask me anything\u2026",
3186
- showSources: ((_sb = (_rb = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _rb : readString(env, "UI_SHOW_SOURCES")) != null ? _sb : "true") !== "false",
3187
- 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.",
3188
- visualStyle: (_wb = (_vb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _vb : readString(env, "UI_VISUAL_STYLE")) != null ? _wb : "glass",
3189
- borderRadius: (_yb = (_xb = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _xb : readString(env, "UI_BORDER_RADIUS")) != null ? _yb : "xl",
3190
- allowUpload: ((_Ab = (_zb = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _zb : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Ab : "false") === "true"
3193
+ title: (_kb = (_jb = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _jb : readString(env, "UI_TITLE")) != null ? _kb : "AI Assistant",
3194
+ subtitle: (_mb = (_lb = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _lb : readString(env, "UI_SUBTITLE")) != null ? _mb : "Powered by RAG",
3195
+ primaryColor: (_ob = (_nb = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _nb : readString(env, "UI_PRIMARY_COLOR")) != null ? _ob : "#10b981",
3196
+ accentColor: (_qb = (_pb = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _pb : readString(env, "UI_ACCENT_COLOR")) != null ? _qb : "#3b82f6",
3197
+ logoUrl: (_rb = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _rb : readString(env, "UI_LOGO_URL"),
3198
+ placeholder: (_tb = (_sb = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _sb : readString(env, "UI_PLACEHOLDER")) != null ? _tb : "Ask me anything\u2026",
3199
+ showSources: ((_vb = (_ub = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _ub : readString(env, "UI_SHOW_SOURCES")) != null ? _vb : "true") !== "false",
3200
+ 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.",
3201
+ visualStyle: (_zb = (_yb = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _yb : readString(env, "UI_VISUAL_STYLE")) != null ? _zb : "glass",
3202
+ borderRadius: (_Bb = (_Ab = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _Ab : readString(env, "UI_BORDER_RADIUS")) != null ? _Bb : "xl",
3203
+ allowUpload: ((_Db = (_Cb = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _Cb : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Db : "false") === "true"
3191
3204
  },
3192
3205
  rag: {
3193
- topK: readNumber(env, "RAG_TOP_K", 5),
3206
+ topK: readNumber(env, "RAG_TOP_K", (_Eb = rt == null ? void 0 : rt.topK) != null ? _Eb : 5),
3194
3207
  scoreThreshold: readNumber(env, "RAG_SCORE_THRESHOLD", 0),
3195
- chunkSize: readNumber(env, "RAG_CHUNK_SIZE", 1e3),
3196
- chunkOverlap: readNumber(env, "RAG_CHUNK_OVERLAP", 200),
3197
- filterableFields: (_Bb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Bb.split(",").map((f) => f.trim()),
3208
+ chunkSize: readNumber(env, "RAG_CHUNK_SIZE", (_Fb = rt == null ? void 0 : rt.chunkSize) != null ? _Fb : 1e3),
3209
+ chunkOverlap: readNumber(env, "RAG_CHUNK_OVERLAP", (_Gb = rt == null ? void 0 : rt.chunkOverlap) != null ? _Gb : 200),
3210
+ filterableFields: (_Hb = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Hb.split(",").map((f) => f.trim()),
3198
3211
  // Query pipeline toggles — read from .env.local
3199
3212
  useQueryTransformation: readString(env, "RAG_USE_QUERY_TRANSFORMATION") === "true",
3200
3213
  useReranking: readString(env, "RAG_USE_RERANKING") === "true",
3201
3214
  useGraphRetrieval: readString(env, "RAG_USE_GRAPH_RETRIEVAL") === "true",
3202
- architecture: (_Cb = readString(env, "RAG_ARCHITECTURE")) != null ? _Cb : "simple",
3203
- chunkingStrategy: (_Db = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Db : "recursive",
3215
+ architecture: (_Ib = readString(env, "RAG_ARCHITECTURE")) != null ? _Ib : "simple",
3216
+ chunkingStrategy: (_Jb = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Jb : "recursive",
3204
3217
  uiMapping: (() => {
3205
3218
  const raw = readString(env, "RAG_UI_MAPPING");
3206
3219
  if (!raw) return void 0;
@@ -3213,7 +3226,7 @@ function getEnvConfig(env = process.env, base) {
3213
3226
  },
3214
3227
  telemetry: {
3215
3228
  enabled: telemetryEnabled,
3216
- 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"
3229
+ url: (_Nb = (_Mb = (_Kb = readString(env, "TELEMETRY_URL")) != null ? _Kb : readString(env, "NEXT_PUBLIC_TELEMETRY_URL")) != null ? _Mb : (_Lb = base == null ? void 0 : base.telemetry) == null ? void 0 : _Lb.url) != null ? _Nb : "https://www.retrivora.com/api/telemetry"
3217
3230
  }
3218
3231
  }, readString(env, "GRAPH_DB_PROVIDER") ? {
3219
3232
  graphDb: {
@@ -4563,6 +4576,12 @@ var UniversalLLMAdapter = class {
4563
4576
  this.resolvedHeaders = __spreadValues(__spreadValues({
4564
4577
  "Content-Type": "application/json"
4565
4578
  }, config.apiKey ? { Authorization: `Bearer ${config.apiKey}` } : {}), this.opts.headers || {});
4579
+ console.log("[UniversalLLMAdapter] Initialized with:", {
4580
+ model: this.model,
4581
+ baseUrl: this.baseUrl,
4582
+ hasApiKey: !!this.apiKey,
4583
+ apiKeyPrefix: this.apiKey ? `${this.apiKey.slice(0, 12)}...` : void 0
4584
+ });
4566
4585
  this.http = axios2.create({
4567
4586
  baseURL: this.baseUrl,
4568
4587
  headers: this.resolvedHeaders,
@@ -4775,14 +4794,21 @@ ${context != null ? context : "None"}` },
4775
4794
  });
4776
4795
  }
4777
4796
  async embed(text) {
4778
- var _a3, _b, _c, _d, _e, _f, _g2;
4797
+ var _a3, _b, _c, _d, _e, _f, _g2, _h;
4779
4798
  const path2 = (_a3 = this.opts.embedPath) != null ? _a3 : "/embeddings";
4780
4799
  const payload = this.opts.embedPayloadTemplate ? buildPayload(this.opts.embedPayloadTemplate, { input: text, model: this.model }) : { input: text, model: this.model };
4781
4800
  try {
4801
+ console.log(`[UniversalLLMAdapter] Posting to embedding endpoint: ${this.baseUrl}${path2}`, {
4802
+ model: this.model,
4803
+ inputLength: typeof text === "string" ? text.length : "unknown"
4804
+ });
4782
4805
  const { data } = await this.http.post(path2, payload);
4783
4806
  const extractPath = (_b = this.opts.embedExtractPath) != null ? _b : "data[0].embedding";
4784
4807
  const vector = resolvePath(data, extractPath);
4785
- if (Array.isArray(vector)) return vector;
4808
+ if (Array.isArray(vector)) {
4809
+ console.log(`[UniversalLLMAdapter] Embedding HTTP request successful. Vector size: ${vector.length}`);
4810
+ return vector;
4811
+ }
4786
4812
  console.warn(
4787
4813
  `[UniversalLLMAdapter] Embedding API returned unexpected format for path '${extractPath}'. Response:`,
4788
4814
  data
@@ -4790,14 +4816,14 @@ ${context != null ? context : "None"}` },
4790
4816
  } catch (err) {
4791
4817
  console.warn(
4792
4818
  `[UniversalLLMAdapter] HTTP embedding request failed: ${(err == null ? void 0 : err.message) || err}`,
4793
- { path: path2, model: this.model }
4819
+ { path: path2, model: this.model, response: (_c = err == null ? void 0 : err.response) == null ? void 0 : _c.data }
4794
4820
  );
4795
4821
  const _g3 = globalThis;
4796
4822
  const dispatchEmbed = _g3.__retrivoraDispatchEmbedding;
4797
4823
  if (typeof dispatchEmbed === "function") {
4798
4824
  try {
4799
4825
  const res = await dispatchEmbed({ input: text, model: this.model }, this.apiKey);
4800
- if ((_d = (_c = res == null ? void 0 : res.data) == null ? void 0 : _c[0]) == null ? void 0 : _d.embedding) {
4826
+ if ((_e = (_d = res == null ? void 0 : res.data) == null ? void 0 : _d[0]) == null ? void 0 : _e.embedding) {
4801
4827
  return res.data[0].embedding;
4802
4828
  }
4803
4829
  } catch (dispatchErr) {
@@ -4806,10 +4832,12 @@ ${context != null ? context : "None"}` },
4806
4832
  }
4807
4833
  }
4808
4834
  try {
4835
+ console.log(`[UniversalLLMAdapter] Retrying embedding request to: ${this.baseUrl}${path2}`);
4809
4836
  const { data } = await this.http.post(path2, payload);
4810
- const extractPath = (_e = this.opts.embedExtractPath) != null ? _e : "data[0].embedding";
4837
+ const extractPath = (_f = this.opts.embedExtractPath) != null ? _f : "data[0].embedding";
4811
4838
  const vector = resolvePath(data, extractPath);
4812
4839
  if (Array.isArray(vector)) {
4840
+ console.log(`[UniversalLLMAdapter] Retry embedding HTTP request successful. Vector size: ${vector.length}`);
4813
4841
  return vector;
4814
4842
  }
4815
4843
  console.error(
@@ -4822,7 +4850,7 @@ ${context != null ? context : "None"}` },
4822
4850
  } catch (err) {
4823
4851
  console.error(
4824
4852
  `[UniversalLLMAdapter] Both embedding attempts failed. Path: ${path2}, Model: ${this.model}`,
4825
- { 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 }
4853
+ { error: err == null ? void 0 : err.message, statusCode: (_g2 = err == null ? void 0 : err.response) == null ? void 0 : _g2.status, response: (_h = err == null ? void 0 : err.response) == null ? void 0 : _h.data }
4826
4854
  );
4827
4855
  throw new Error(
4828
4856
  `[UniversalLLMAdapter] Failed to generate embedding after 2 attempts: ${(err == null ? void 0 : err.message) || err}`
@@ -11870,6 +11898,7 @@ function createLicenseHandler(configOrPlugin, options) {
11870
11898
  const rawKey = req.headers.get("x-license-key") || (body == null ? void 0 : body.licenseKey) || ((_a3 = req.headers.get("authorization")) == null ? void 0 : _a3.replace(/^Bearer\s+/i, "")) || config.licenseKey || process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY || process.env.RETRIVORA_LICENSE_KEY || "";
11871
11899
  const licenseKey = (rawKey || "").trim().replace(/^["']|["']$/g, "").trim();
11872
11900
  const projectId = (body == null ? void 0 : body.projectId) || config.projectId || "";
11901
+ console.log(`[DEBUG] createLicenseHandler: projectId="${projectId}", body.projectId="${body == null ? void 0 : body.projectId}", config.projectId="${config.projectId}"`);
11873
11902
  const payload = await LicenseVerifier.verifyAsync(licenseKey, projectId);
11874
11903
  return NextResponse.json({
11875
11904
  valid: true,
@@ -12247,7 +12276,7 @@ function createRagHandler(configOrPlugin, options) {
12247
12276
  }
12248
12277
  }
12249
12278
  async function getSegment(req, context) {
12250
- var _a3, _b;
12279
+ var _a3, _b, _c;
12251
12280
  const contentType = req.headers.get("content-type") || "";
12252
12281
  if (contentType.includes("multipart/form-data")) {
12253
12282
  return "upload";
@@ -12262,10 +12291,12 @@ function createRagHandler(configOrPlugin, options) {
12262
12291
  if (pathname.endsWith("/suggestions")) return "suggestions";
12263
12292
  if (pathname.endsWith("/feedback")) return "feedback";
12264
12293
  if (pathname.endsWith("/history")) return "history";
12294
+ if (pathname.endsWith("/history/clear")) return "history/clear";
12295
+ if (pathname.endsWith("/sessions")) return "sessions";
12265
12296
  } catch (e) {
12266
12297
  }
12267
12298
  const resolvedParams = typeof ((_a3 = context == null ? void 0 : context.params) == null ? void 0 : _a3.then) === "function" ? await context.params : context == null ? void 0 : context.params;
12268
- const segments = (resolvedParams == null ? void 0 : resolvedParams.retrivora) || ((_b = resolvedParams == null ? void 0 : resolvedParams.params) == null ? void 0 : _b.retrivora) || [];
12299
+ const segments = (resolvedParams == null ? void 0 : resolvedParams.retrivora) || ((_b = resolvedParams == null ? void 0 : resolvedParams.params) == null ? void 0 : _b.retrivora) || (resolvedParams == null ? void 0 : resolvedParams.rag) || ((_c = resolvedParams == null ? void 0 : resolvedParams.params) == null ? void 0 : _c.rag) || [];
12269
12300
  const joined = segments.join("/");
12270
12301
  return joined || "chat";
12271
12302
  }
@@ -12573,8 +12604,9 @@ var LicenseConfigResolver = class {
12573
12604
  provider: llmProvider,
12574
12605
  model: tierConfig.llmModel,
12575
12606
  apiKey: llmApiKey,
12576
- maxTokens: tierConfig.maxTokens,
12607
+ maxTokens: tierConfig == null ? void 0 : tierConfig.maxTokens,
12577
12608
  temperature: 0.7,
12609
+ systemPrompt: tierConfig == null ? void 0 : tierConfig.systemPrompt,
12578
12610
  options: {}
12579
12611
  };
12580
12612
  const embeddingConfig = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retrivora-ai/rag-engine",
3
- "version": "2.3.8",
3
+ "version": "2.4.0",
4
4
  "description": "Retrivora AI is a plug-and-play AI engine for RAG chat experiences — generic vector DB + LLM provider, embeddable or standalone.",
5
5
  "author": "Abhinav Alkuchi",
6
6
  "license": "UNLICENSED",