@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.
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties, MouseEvent, ReactNode, ElementType } from 'react';
2
- import { W as WidgetPosition, Z as Product, s as UIConfig, P as ProjectChatSettings, o as RagMessage, w as VectorMatch, L as LLMConfig, d as EmbeddingConfig, V as VectorDBConfig, J as UITransformationResponse, n as RagConfig, I as ILLMProvider, f as IngestDocument, C as ChatMessage, c as ChatResponse, _ as RetrievalResult, t as UniversalRagConfig } from './ILLMProvider-B8TAVx3j.js';
2
+ import { W as WidgetPosition, Z as Product, s as UIConfig, P as ProjectChatSettings, o as RagMessage, w as VectorMatch, L as LLMConfig, d as EmbeddingConfig, V as VectorDBConfig, J as UITransformationResponse, n as RagConfig, I as ILLMProvider, f as IngestDocument, C as ChatMessage, c as ChatResponse, _ as RetrievalResult, t as UniversalRagConfig } from './ILLMProvider-Y6aL5N8J.js';
3
3
 
4
4
  interface ArchitectureCardProps {
5
5
  icon: ReactNode;
@@ -61,6 +61,10 @@ interface ChatWindowProps {
61
61
  licenseKey?: string;
62
62
  /** Optional custom headers to send with the chat request */
63
63
  headers?: Record<string, string>;
64
+ /** Optional session ID to load conversation history from the server */
65
+ sessionId?: string;
66
+ /** Whether to show the ChatGPT-style sidebar history management and new chat controls */
67
+ showHistory?: boolean;
64
68
  }
65
69
  interface ChatWidgetProps {
66
70
  /** Position of the floating button. Defaults to bottom-right. */
@@ -143,6 +147,12 @@ interface ConfigProviderProps {
143
147
  retrivoraApiBase?: string;
144
148
  projectSettings?: Partial<ProjectChatSettings>;
145
149
  autoLoadProjectSettings?: boolean;
150
+ primaryColor?: string;
151
+ secondaryColor?: string;
152
+ accentColor?: string;
153
+ theme?: 'light' | 'dark' | 'system';
154
+ borderRadius?: 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
155
+ visualStyle?: 'solid' | 'glass';
146
156
  };
147
157
  children: ReactNode;
148
158
  }
@@ -253,6 +263,7 @@ interface LicenseTierConfig {
253
263
  requestsPerMinute: number;
254
264
  tokensPerDay: number;
255
265
  };
266
+ systemPrompt?: string;
256
267
  }
257
268
  interface ProviderCredentials {
258
269
  geminiApiKey?: string;
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties, MouseEvent, ReactNode, ElementType } from 'react';
2
- import { W as WidgetPosition, Z as Product, s as UIConfig, P as ProjectChatSettings, o as RagMessage, w as VectorMatch, L as LLMConfig, d as EmbeddingConfig, V as VectorDBConfig, J as UITransformationResponse, n as RagConfig, I as ILLMProvider, f as IngestDocument, C as ChatMessage, c as ChatResponse, _ as RetrievalResult, t as UniversalRagConfig } from './ILLMProvider-B8TAVx3j.mjs';
2
+ import { W as WidgetPosition, Z as Product, s as UIConfig, P as ProjectChatSettings, o as RagMessage, w as VectorMatch, L as LLMConfig, d as EmbeddingConfig, V as VectorDBConfig, J as UITransformationResponse, n as RagConfig, I as ILLMProvider, f as IngestDocument, C as ChatMessage, c as ChatResponse, _ as RetrievalResult, t as UniversalRagConfig } from './ILLMProvider-Y6aL5N8J.mjs';
3
3
 
4
4
  interface ArchitectureCardProps {
5
5
  icon: ReactNode;
@@ -61,6 +61,10 @@ interface ChatWindowProps {
61
61
  licenseKey?: string;
62
62
  /** Optional custom headers to send with the chat request */
63
63
  headers?: Record<string, string>;
64
+ /** Optional session ID to load conversation history from the server */
65
+ sessionId?: string;
66
+ /** Whether to show the ChatGPT-style sidebar history management and new chat controls */
67
+ showHistory?: boolean;
64
68
  }
65
69
  interface ChatWidgetProps {
66
70
  /** Position of the floating button. Defaults to bottom-right. */
@@ -143,6 +147,12 @@ interface ConfigProviderProps {
143
147
  retrivoraApiBase?: string;
144
148
  projectSettings?: Partial<ProjectChatSettings>;
145
149
  autoLoadProjectSettings?: boolean;
150
+ primaryColor?: string;
151
+ secondaryColor?: string;
152
+ accentColor?: string;
153
+ theme?: 'light' | 'dark' | 'system';
154
+ borderRadius?: 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
155
+ visualStyle?: 'solid' | 'glass';
146
156
  };
147
157
  children: ReactNode;
148
158
  }
@@ -253,6 +263,7 @@ interface LicenseTierConfig {
253
263
  requestsPerMinute: number;
254
264
  tokensPerDay: number;
255
265
  };
266
+ systemPrompt?: string;
256
267
  }
257
268
  interface ProviderCredentials {
258
269
  geminiApiKey?: string;
@@ -264,6 +264,7 @@ interface UIConfig {
264
264
  allowResize?: boolean;
265
265
  /** Whether to enable voice search input. Defaults to true. */
266
266
  enableVoiceInput?: boolean;
267
+ theme?: 'light' | 'dark' | 'system';
267
268
  }
268
269
  interface CAGConfig {
269
270
  /** Enable Cold RAG (Cache Augmented Generation) */
@@ -264,6 +264,7 @@ interface UIConfig {
264
264
  allowResize?: boolean;
265
265
  /** Whether to enable voice search input. Defaults to true. */
266
266
  enableVoiceInput?: boolean;
267
+ theme?: 'light' | 'dark' | 'system';
267
268
  }
268
269
  interface CAGConfig {
269
270
  /** Enable Cold RAG (Cache Augmented Generation) */
@@ -1,3 +1,3 @@
1
1
  import 'next/server';
2
- export { b as HandlerOptions, d as createChatHandler, e as createFeedbackHandler, f as createHealthHandler, g as createHistoryHandler, h as createIngestHandler, p as createLicenseHandler, i as createRagHandler, j as createSessionsHandler, k as createStreamHandler, q as createSuggestionsHandler, l as createUploadHandler, s as sseErrorFrame, m as sseFrame, n as sseMetaFrame, r as sseObservabilityFrame, o as sseTextFrame, t as sseUIFrame } from '../index-C7aHK7_g.mjs';
3
- import '../ILLMProvider-B8TAVx3j.mjs';
2
+ export { b as HandlerOptions, d as createChatHandler, e as createFeedbackHandler, f as createHealthHandler, g as createHistoryHandler, h as createIngestHandler, p as createLicenseHandler, i as createRagHandler, j as createSessionsHandler, k as createStreamHandler, q as createSuggestionsHandler, l as createUploadHandler, s as sseErrorFrame, m as sseFrame, n as sseMetaFrame, r as sseObservabilityFrame, o as sseTextFrame, t as sseUIFrame } from '../index-59CHg0V3.mjs';
3
+ import '../ILLMProvider-Y6aL5N8J.mjs';
@@ -1,3 +1,3 @@
1
1
  import 'next/server';
2
- export { b as HandlerOptions, d as createChatHandler, e as createFeedbackHandler, f as createHealthHandler, g as createHistoryHandler, h as createIngestHandler, p as createLicenseHandler, i as createRagHandler, j as createSessionsHandler, k as createStreamHandler, q as createSuggestionsHandler, l as createUploadHandler, s as sseErrorFrame, m as sseFrame, n as sseMetaFrame, r as sseObservabilityFrame, o as sseTextFrame, t as sseUIFrame } from '../index-BQd6Bax0.js';
3
- import '../ILLMProvider-B8TAVx3j.js';
2
+ export { b as HandlerOptions, d as createChatHandler, e as createFeedbackHandler, f as createHealthHandler, g as createHistoryHandler, h as createIngestHandler, p as createLicenseHandler, i as createRagHandler, j as createSessionsHandler, k as createStreamHandler, q as createSuggestionsHandler, l as createUploadHandler, s as sseErrorFrame, m as sseFrame, n as sseMetaFrame, r as sseObservabilityFrame, o as sseTextFrame, t as sseUIFrame } from '../index-BgKRInpa.js';
3
+ import '../ILLMProvider-Y6aL5N8J.js';
@@ -317,7 +317,7 @@ var init_package = __esm({
317
317
  "package.json"() {
318
318
  package_default = {
319
319
  name: "@retrivora-ai/rag-engine",
320
- version: "2.3.8",
320
+ version: "2.4.0",
321
321
  description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
322
322
  author: "Abhinav Alkuchi",
323
323
  license: "UNLICENSED",
@@ -512,6 +512,7 @@ var init_ConfigFetcher = __esm({
512
512
  for (const baseUrl of controlPlaneUrls) {
513
513
  try {
514
514
  const url = `${baseUrl}/api/v1/config?projectId=${encodeURIComponent(projectId)}`;
515
+ console.log(`[ConfigFetcher] Fetching config from: ${url}`);
515
516
  const res = await fetch(url, {
516
517
  method: "GET",
517
518
  headers: __spreadValues({
@@ -519,6 +520,10 @@ var init_ConfigFetcher = __esm({
519
520
  "x-sdk-version": SDK_VERSION
520
521
  }, licenseKey ? { "x-license-key": licenseKey } : {})
521
522
  });
523
+ console.log(`[ConfigFetcher] Response status: ${res.status}`);
524
+ if (!res.ok) {
525
+ console.warn(`[ConfigFetcher] Error text: ${await res.text()}`);
526
+ }
522
527
  if (res.ok) {
523
528
  const data = await res.json();
524
529
  if ((data == null ? void 0 : data.success) && (data == null ? void 0 : data.vectorDb)) {
@@ -3028,7 +3033,7 @@ function readEnum(env, name, fallback, allowed) {
3028
3033
  throw new Error(`[getRagConfig] ${name} must be one of: ${allowed.join(", ")}`);
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: {
@@ -4524,6 +4537,12 @@ var UniversalLLMAdapter = class {
4524
4537
  this.resolvedHeaders = __spreadValues(__spreadValues({
4525
4538
  "Content-Type": "application/json"
4526
4539
  }, config.apiKey ? { Authorization: `Bearer ${config.apiKey}` } : {}), this.opts.headers || {});
4540
+ console.log("[UniversalLLMAdapter] Initialized with:", {
4541
+ model: this.model,
4542
+ baseUrl: this.baseUrl,
4543
+ hasApiKey: !!this.apiKey,
4544
+ apiKeyPrefix: this.apiKey ? `${this.apiKey.slice(0, 12)}...` : void 0
4545
+ });
4527
4546
  this.http = import_axios2.default.create({
4528
4547
  baseURL: this.baseUrl,
4529
4548
  headers: this.resolvedHeaders,
@@ -4736,14 +4755,21 @@ ${context != null ? context : "None"}` },
4736
4755
  });
4737
4756
  }
4738
4757
  async embed(text) {
4739
- var _a3, _b, _c, _d, _e, _f, _g2;
4758
+ var _a3, _b, _c, _d, _e, _f, _g2, _h;
4740
4759
  const path2 = (_a3 = this.opts.embedPath) != null ? _a3 : "/embeddings";
4741
4760
  const payload = this.opts.embedPayloadTemplate ? buildPayload(this.opts.embedPayloadTemplate, { input: text, model: this.model }) : { input: text, model: this.model };
4742
4761
  try {
4762
+ console.log(`[UniversalLLMAdapter] Posting to embedding endpoint: ${this.baseUrl}${path2}`, {
4763
+ model: this.model,
4764
+ inputLength: typeof text === "string" ? text.length : "unknown"
4765
+ });
4743
4766
  const { data } = await this.http.post(path2, payload);
4744
4767
  const extractPath = (_b = this.opts.embedExtractPath) != null ? _b : "data[0].embedding";
4745
4768
  const vector = resolvePath(data, extractPath);
4746
- if (Array.isArray(vector)) return vector;
4769
+ if (Array.isArray(vector)) {
4770
+ console.log(`[UniversalLLMAdapter] Embedding HTTP request successful. Vector size: ${vector.length}`);
4771
+ return vector;
4772
+ }
4747
4773
  console.warn(
4748
4774
  `[UniversalLLMAdapter] Embedding API returned unexpected format for path '${extractPath}'. Response:`,
4749
4775
  data
@@ -4751,14 +4777,14 @@ ${context != null ? context : "None"}` },
4751
4777
  } catch (err) {
4752
4778
  console.warn(
4753
4779
  `[UniversalLLMAdapter] HTTP embedding request failed: ${(err == null ? void 0 : err.message) || err}`,
4754
- { path: path2, model: this.model }
4780
+ { path: path2, model: this.model, response: (_c = err == null ? void 0 : err.response) == null ? void 0 : _c.data }
4755
4781
  );
4756
4782
  const _g3 = globalThis;
4757
4783
  const dispatchEmbed = _g3.__retrivoraDispatchEmbedding;
4758
4784
  if (typeof dispatchEmbed === "function") {
4759
4785
  try {
4760
4786
  const res = await dispatchEmbed({ input: text, model: this.model }, this.apiKey);
4761
- if ((_d = (_c = res == null ? void 0 : res.data) == null ? void 0 : _c[0]) == null ? void 0 : _d.embedding) {
4787
+ if ((_e = (_d = res == null ? void 0 : res.data) == null ? void 0 : _d[0]) == null ? void 0 : _e.embedding) {
4762
4788
  return res.data[0].embedding;
4763
4789
  }
4764
4790
  } catch (dispatchErr) {
@@ -4767,10 +4793,12 @@ ${context != null ? context : "None"}` },
4767
4793
  }
4768
4794
  }
4769
4795
  try {
4796
+ console.log(`[UniversalLLMAdapter] Retrying embedding request to: ${this.baseUrl}${path2}`);
4770
4797
  const { data } = await this.http.post(path2, payload);
4771
- const extractPath = (_e = this.opts.embedExtractPath) != null ? _e : "data[0].embedding";
4798
+ const extractPath = (_f = this.opts.embedExtractPath) != null ? _f : "data[0].embedding";
4772
4799
  const vector = resolvePath(data, extractPath);
4773
4800
  if (Array.isArray(vector)) {
4801
+ console.log(`[UniversalLLMAdapter] Retry embedding HTTP request successful. Vector size: ${vector.length}`);
4774
4802
  return vector;
4775
4803
  }
4776
4804
  console.error(
@@ -4783,7 +4811,7 @@ ${context != null ? context : "None"}` },
4783
4811
  } catch (err) {
4784
4812
  console.error(
4785
4813
  `[UniversalLLMAdapter] Both embedding attempts failed. Path: ${path2}, Model: ${this.model}`,
4786
- { 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 }
4814
+ { 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 }
4787
4815
  );
4788
4816
  throw new Error(
4789
4817
  `[UniversalLLMAdapter] Failed to generate embedding after 2 attempts: ${(err == null ? void 0 : err.message) || err}`
@@ -11513,6 +11541,7 @@ function createLicenseHandler(configOrPlugin, options) {
11513
11541
  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 || "";
11514
11542
  const licenseKey = (rawKey || "").trim().replace(/^["']|["']$/g, "").trim();
11515
11543
  const projectId = (body == null ? void 0 : body.projectId) || config.projectId || "";
11544
+ console.log(`[DEBUG] createLicenseHandler: projectId="${projectId}", body.projectId="${body == null ? void 0 : body.projectId}", config.projectId="${config.projectId}"`);
11516
11545
  const payload = await LicenseVerifier.verifyAsync(licenseKey, projectId);
11517
11546
  return import_server.NextResponse.json({
11518
11547
  valid: true,
@@ -11890,7 +11919,7 @@ function createRagHandler(configOrPlugin, options) {
11890
11919
  }
11891
11920
  }
11892
11921
  async function getSegment(req, context) {
11893
- var _a3, _b;
11922
+ var _a3, _b, _c;
11894
11923
  const contentType = req.headers.get("content-type") || "";
11895
11924
  if (contentType.includes("multipart/form-data")) {
11896
11925
  return "upload";
@@ -11905,10 +11934,12 @@ function createRagHandler(configOrPlugin, options) {
11905
11934
  if (pathname.endsWith("/suggestions")) return "suggestions";
11906
11935
  if (pathname.endsWith("/feedback")) return "feedback";
11907
11936
  if (pathname.endsWith("/history")) return "history";
11937
+ if (pathname.endsWith("/history/clear")) return "history/clear";
11938
+ if (pathname.endsWith("/sessions")) return "sessions";
11908
11939
  } catch (e) {
11909
11940
  }
11910
11941
  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;
11911
- const segments = (resolvedParams == null ? void 0 : resolvedParams.retrivora) || ((_b = resolvedParams == null ? void 0 : resolvedParams.params) == null ? void 0 : _b.retrivora) || [];
11942
+ 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) || [];
11912
11943
  const joined = segments.join("/");
11913
11944
  return joined || "chat";
11914
11945
  }