@retrivora-ai/rag-engine 1.9.9 → 2.0.1

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
@@ -2127,46 +2127,48 @@ function getRagConfig(baseConfig, env = process.env) {
2127
2127
  return getEnvConfig(env, baseConfig);
2128
2128
  }
2129
2129
  function getEnvConfig(env = process.env, base) {
2130
- var _a2, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa;
2130
+ var _a2, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua;
2131
2131
  const projectId = (_c = (_b = (_a2 = readString(env, "RAG_PROJECT_ID")) != null ? _a2 : readString(env, "NEXT_PUBLIC_PROJECT_ID")) != null ? _b : base == null ? void 0 : base.projectId) != null ? _c : "__default__";
2132
+ const licenseKey = (_g2 = (_f = (_e = (_d = readString(env, "RAG_LICENSE_KEY")) != null ? _d : readString(env, "RETRIVORA_LICENSE_KEY")) != null ? _e : readString(env, "NEXT_PUBLIC_RETRIVORA_LICENSE_KEY")) != null ? _f : readString(env, "LICENSE_KEY")) != null ? _g2 : base == null ? void 0 : base.licenseKey;
2133
+ const telemetryEnabled = readString(env, "TELEMETRY_ENABLED") === "true" || readString(env, "NEXT_PUBLIC_TELEMETRY_ENABLED") === "true" || ((_h = base == null ? void 0 : base.telemetry) == null ? void 0 : _h.enabled) || Boolean(licenseKey);
2132
2134
  const vectorProvider = readEnum(env, "VECTOR_DB_PROVIDER", "pinecone", VECTOR_DB_PROVIDERS);
2133
2135
  const llmProvider = readEnum(env, "LLM_PROVIDER", "openai", LLM_PROVIDERS);
2134
2136
  const embeddingProvider = readEnum(env, "EMBEDDING_PROVIDER", "openai", EMBEDDING_PROVIDERS);
2135
2137
  const embeddingDimensions = readNumber(env, "EMBEDDING_DIMENSIONS", 1536);
2136
2138
  const vectorDbOptions = {};
2137
2139
  if (vectorProvider === "pinecone") {
2138
- vectorDbOptions.apiKey = (_g2 = (_f = readString(env, "PINECONE_API_KEY")) != null ? _f : (_e = (_d = base == null ? void 0 : base.vectorDb) == null ? void 0 : _d.options) == null ? void 0 : _e.apiKey) != null ? _g2 : "";
2139
- vectorDbOptions.indexName = (_l = (_i = readString(env, "PINECONE_INDEX")) != null ? _i : (_h = base == null ? void 0 : base.vectorDb) == null ? void 0 : _h.indexName) != null ? _l : (_k = (_j = base == null ? void 0 : base.vectorDb) == null ? void 0 : _j.options) == null ? void 0 : _k.indexName;
2140
+ vectorDbOptions.apiKey = (_l = (_k = readString(env, "PINECONE_API_KEY")) != null ? _k : (_j = (_i = base == null ? void 0 : base.vectorDb) == null ? void 0 : _i.options) == null ? void 0 : _j.apiKey) != null ? _l : "";
2141
+ vectorDbOptions.indexName = (_q = (_n = readString(env, "PINECONE_INDEX")) != null ? _n : (_m = base == null ? void 0 : base.vectorDb) == null ? void 0 : _m.indexName) != null ? _q : (_p = (_o = base == null ? void 0 : base.vectorDb) == null ? void 0 : _o.options) == null ? void 0 : _p.indexName;
2140
2142
  } else if (vectorProvider === "pgvector" || vectorProvider === "postgresql") {
2141
- vectorDbOptions.connectionString = (_q = (_p = (_m = readString(env, "PGVECTOR_CONNECTION_STRING")) != null ? _m : readString(env, "POSTGRES_URL")) != null ? _p : (_o = (_n = base == null ? void 0 : base.vectorDb) == null ? void 0 : _n.options) == null ? void 0 : _o.connectionString) != null ? _q : "";
2142
- vectorDbOptions.tables = (_v = (_s = (_r = readString(env, "VECTOR_DB_TABLES")) != null ? _r : readString(env, "POSTGRES_TABLES")) == null ? void 0 : _s.split(",").map((t) => t.trim())) != null ? _v : (_u = (_t = base == null ? void 0 : base.vectorDb) == null ? void 0 : _t.options) == null ? void 0 : _u.tables;
2143
- vectorDbOptions.searchFields = (_z = (_w = readString(env, "POSTGRES_SEARCH_FIELDS")) == null ? void 0 : _w.split(",").map((f) => f.trim())) != null ? _z : (_y = (_x = base == null ? void 0 : base.vectorDb) == null ? void 0 : _x.options) == null ? void 0 : _y.searchFields;
2143
+ vectorDbOptions.connectionString = (_v = (_u = (_r = readString(env, "PGVECTOR_CONNECTION_STRING")) != null ? _r : readString(env, "POSTGRES_URL")) != null ? _u : (_t = (_s = base == null ? void 0 : base.vectorDb) == null ? void 0 : _s.options) == null ? void 0 : _t.connectionString) != null ? _v : "";
2144
+ vectorDbOptions.tables = (_A = (_x = (_w = readString(env, "VECTOR_DB_TABLES")) != null ? _w : readString(env, "POSTGRES_TABLES")) == null ? void 0 : _x.split(",").map((t) => t.trim())) != null ? _A : (_z = (_y = base == null ? void 0 : base.vectorDb) == null ? void 0 : _y.options) == null ? void 0 : _z.tables;
2145
+ vectorDbOptions.searchFields = (_E = (_B = readString(env, "POSTGRES_SEARCH_FIELDS")) == null ? void 0 : _B.split(",").map((f) => f.trim())) != null ? _E : (_D = (_C = base == null ? void 0 : base.vectorDb) == null ? void 0 : _C.options) == null ? void 0 : _D.searchFields;
2144
2146
  vectorDbOptions.dimensions = embeddingDimensions;
2145
2147
  } else if (vectorProvider === "mongodb") {
2146
- vectorDbOptions.uri = (_D = (_C = readString(env, "MONGODB_URI")) != null ? _C : (_B = (_A = base == null ? void 0 : base.vectorDb) == null ? void 0 : _A.options) == null ? void 0 : _B.uri) != null ? _D : "";
2147
- vectorDbOptions.database = (_H = (_G = readString(env, "MONGODB_DB")) != null ? _G : (_F = (_E = base == null ? void 0 : base.vectorDb) == null ? void 0 : _E.options) == null ? void 0 : _F.database) != null ? _H : "";
2148
- vectorDbOptions.collection = (_L = (_K = readString(env, "MONGODB_COLLECTION")) != null ? _K : (_J = (_I = base == null ? void 0 : base.vectorDb) == null ? void 0 : _I.options) == null ? void 0 : _J.collection) != null ? _L : "";
2149
- vectorDbOptions.indexName = (_R = (_Q = (_N = readString(env, "MONGODB_INDEX_NAME")) != null ? _N : (_M = base == null ? void 0 : base.vectorDb) == null ? void 0 : _M.indexName) != null ? _Q : (_P = (_O = base == null ? void 0 : base.vectorDb) == null ? void 0 : _O.options) == null ? void 0 : _P.indexName) != null ? _R : "vector_index";
2148
+ vectorDbOptions.uri = (_I = (_H = readString(env, "MONGODB_URI")) != null ? _H : (_G = (_F = base == null ? void 0 : base.vectorDb) == null ? void 0 : _F.options) == null ? void 0 : _G.uri) != null ? _I : "";
2149
+ vectorDbOptions.database = (_M = (_L = readString(env, "MONGODB_DB")) != null ? _L : (_K = (_J = base == null ? void 0 : base.vectorDb) == null ? void 0 : _J.options) == null ? void 0 : _K.database) != null ? _M : "";
2150
+ vectorDbOptions.collection = (_Q = (_P = readString(env, "MONGODB_COLLECTION")) != null ? _P : (_O = (_N = base == null ? void 0 : base.vectorDb) == null ? void 0 : _N.options) == null ? void 0 : _O.collection) != null ? _Q : "";
2151
+ vectorDbOptions.indexName = (_W = (_V = (_S = readString(env, "MONGODB_INDEX_NAME")) != null ? _S : (_R = base == null ? void 0 : base.vectorDb) == null ? void 0 : _R.indexName) != null ? _V : (_U = (_T = base == null ? void 0 : base.vectorDb) == null ? void 0 : _T.options) == null ? void 0 : _U.indexName) != null ? _W : "vector_index";
2150
2152
  } else if (vectorProvider === "qdrant") {
2151
- vectorDbOptions.baseUrl = (_V = (_U = readString(env, "QDRANT_URL")) != null ? _U : (_T = (_S = base == null ? void 0 : base.vectorDb) == null ? void 0 : _S.options) == null ? void 0 : _T.baseUrl) != null ? _V : "http://localhost:6333";
2152
- vectorDbOptions.apiKey = (_Y = readString(env, "QDRANT_API_KEY")) != null ? _Y : (_X = (_W = base == null ? void 0 : base.vectorDb) == null ? void 0 : _W.options) == null ? void 0 : _X.apiKey;
2153
+ vectorDbOptions.baseUrl = (__ = (_Z = readString(env, "QDRANT_URL")) != null ? _Z : (_Y = (_X = base == null ? void 0 : base.vectorDb) == null ? void 0 : _X.options) == null ? void 0 : _Y.baseUrl) != null ? __ : "http://localhost:6333";
2154
+ vectorDbOptions.apiKey = (_ba = readString(env, "QDRANT_API_KEY")) != null ? _ba : (_aa = (_$ = base == null ? void 0 : base.vectorDb) == null ? void 0 : _$.options) == null ? void 0 : _aa.apiKey;
2153
2155
  vectorDbOptions.dimensions = embeddingDimensions;
2154
2156
  } else if (vectorProvider === "milvus") {
2155
- vectorDbOptions.baseUrl = (_Z = readString(env, "MILVUS_URL")) != null ? _Z : "http://localhost:19530";
2157
+ vectorDbOptions.baseUrl = (_ca = readString(env, "MILVUS_URL")) != null ? _ca : "http://localhost:19530";
2156
2158
  vectorDbOptions.apiKey = readString(env, "MILVUS_API_KEY");
2157
2159
  } else if (vectorProvider === "chromadb") {
2158
- vectorDbOptions.baseUrl = (__ = readString(env, "CHROMADB_URL")) != null ? __ : "http://localhost:8000";
2160
+ vectorDbOptions.baseUrl = (_da = readString(env, "CHROMADB_URL")) != null ? _da : "http://localhost:8000";
2159
2161
  } else if (vectorProvider === "weaviate") {
2160
- vectorDbOptions.baseUrl = (_$ = readString(env, "WEAVIATE_URL")) != null ? _$ : "http://localhost:8080";
2162
+ vectorDbOptions.baseUrl = (_ea = readString(env, "WEAVIATE_URL")) != null ? _ea : "http://localhost:8080";
2161
2163
  vectorDbOptions.apiKey = readString(env, "WEAVIATE_API_KEY");
2162
2164
  } else if (vectorProvider === "redis") {
2163
- vectorDbOptions.baseUrl = (_aa = readString(env, "REDIS_URL")) != null ? _aa : "";
2165
+ vectorDbOptions.baseUrl = (_fa = readString(env, "REDIS_URL")) != null ? _fa : "";
2164
2166
  vectorDbOptions.apiKey = readString(env, "REDIS_API_KEY");
2165
2167
  } else if (vectorProvider === "rest") {
2166
- vectorDbOptions.baseUrl = (_ba = readString(env, "VECTOR_DB_REST_URL")) != null ? _ba : "";
2168
+ vectorDbOptions.baseUrl = (_ga = readString(env, "VECTOR_DB_REST_URL")) != null ? _ga : "";
2167
2169
  vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { "api-key": readString(env, "VECTOR_DB_REST_API_KEY") } : {};
2168
2170
  } else if (vectorProvider === "universal_rest") {
2169
- vectorDbOptions.baseUrl = (_da = (_ca = readString(env, "VECTOR_BASE_URL")) != null ? _ca : readString(env, "VECTOR_DB_REST_URL")) != null ? _da : "";
2171
+ vectorDbOptions.baseUrl = (_ia = (_ha = readString(env, "VECTOR_BASE_URL")) != null ? _ha : readString(env, "VECTOR_DB_REST_URL")) != null ? _ia : "";
2170
2172
  vectorDbOptions.profile = readString(env, "VECTOR_UNIVERSAL_PROFILE");
2171
2173
  vectorDbOptions.headers = readString(env, "VECTOR_DB_REST_API_KEY") ? { Authorization: `Bearer ${readString(env, "VECTOR_DB_REST_API_KEY")}` } : {};
2172
2174
  }
@@ -2185,8 +2187,8 @@ function getEnvConfig(env = process.env, base) {
2185
2187
  // Anthropic needs a separate embedding provider; key kept for completeness
2186
2188
  gemini: readString(env, "GEMINI_API_KEY"),
2187
2189
  ollama: void 0,
2188
- universal_rest: (_ea = readString(env, "EMBEDDING_API_KEY")) != null ? _ea : readString(env, "OPENAI_API_KEY"),
2189
- custom: (_fa = readString(env, "EMBEDDING_API_KEY")) != null ? _fa : readString(env, "OPENAI_API_KEY")
2190
+ universal_rest: (_ja = readString(env, "EMBEDDING_API_KEY")) != null ? _ja : readString(env, "OPENAI_API_KEY"),
2191
+ custom: (_ka = readString(env, "EMBEDDING_API_KEY")) != null ? _ka : readString(env, "OPENAI_API_KEY")
2190
2192
  };
2191
2193
  const DEFAULT_MODEL_BY_PROVIDER = {
2192
2194
  openai: "gpt-4o",
@@ -2199,16 +2201,16 @@ function getEnvConfig(env = process.env, base) {
2199
2201
  };
2200
2202
  return __spreadProps(__spreadValues({
2201
2203
  projectId,
2202
- licenseKey: (_ha = (_ga = readString(env, "RETRIVORA_LICENSE_KEY")) != null ? _ga : readString(env, "LICENSE_KEY")) != null ? _ha : base == null ? void 0 : base.licenseKey,
2204
+ licenseKey: (_ma = (_la = readString(env, "RETRIVORA_LICENSE_KEY")) != null ? _la : readString(env, "LICENSE_KEY")) != null ? _ma : base == null ? void 0 : base.licenseKey,
2203
2205
  vectorDb: {
2204
2206
  provider: vectorProvider,
2205
- indexName: (_ja = (_ia = readString(env, "VECTOR_DB_INDEX")) != null ? _ia : vectorDbOptions.indexName) != null ? _ja : "rag-index",
2207
+ indexName: (_oa = (_na = readString(env, "VECTOR_DB_INDEX")) != null ? _na : vectorDbOptions.indexName) != null ? _oa : "rag-index",
2206
2208
  options: vectorDbOptions
2207
2209
  },
2208
2210
  llm: {
2209
2211
  provider: llmProvider,
2210
- model: (_la = (_ka = readString(env, "LLM_MODEL")) != null ? _ka : DEFAULT_MODEL_BY_PROVIDER[llmProvider]) != null ? _la : "gpt-4o",
2211
- apiKey: (_ma = llmApiKeyByProvider[llmProvider]) != null ? _ma : "",
2212
+ model: (_qa = (_pa = readString(env, "LLM_MODEL")) != null ? _pa : DEFAULT_MODEL_BY_PROVIDER[llmProvider]) != null ? _qa : "gpt-4o",
2213
+ apiKey: (_ra = llmApiKeyByProvider[llmProvider]) != null ? _ra : "",
2212
2214
  baseUrl: readString(env, "LLM_BASE_URL"),
2213
2215
  systemPrompt: readString(env, "LLM_SYSTEM_PROMPT"),
2214
2216
  maxTokens: readNumber(env, "LLM_MAX_TOKENS", 4096),
@@ -2221,7 +2223,7 @@ function getEnvConfig(env = process.env, base) {
2221
2223
  },
2222
2224
  embedding: {
2223
2225
  provider: embeddingProvider,
2224
- model: (_na = readString(env, "EMBEDDING_MODEL")) != null ? _na : "text-embedding-3-small",
2226
+ model: (_sa = readString(env, "EMBEDDING_MODEL")) != null ? _sa : "text-embedding-3-small",
2225
2227
  apiKey: embeddingApiKeyByProvider[embeddingProvider],
2226
2228
  baseUrl: readString(env, "EMBEDDING_BASE_URL"),
2227
2229
  dimensions: embeddingDimensions,
@@ -2232,30 +2234,30 @@ function getEnvConfig(env = process.env, base) {
2232
2234
  }
2233
2235
  },
2234
2236
  ui: {
2235
- title: (_pa = (_oa = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _oa : readString(env, "UI_TITLE")) != null ? _pa : "AI Assistant",
2236
- subtitle: (_ra = (_qa = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _qa : readString(env, "UI_SUBTITLE")) != null ? _ra : "Powered by RAG",
2237
- primaryColor: (_ta = (_sa = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _sa : readString(env, "UI_PRIMARY_COLOR")) != null ? _ta : "#10b981",
2238
- accentColor: (_va = (_ua = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _ua : readString(env, "UI_ACCENT_COLOR")) != null ? _va : "#3b82f6",
2239
- logoUrl: (_wa = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _wa : readString(env, "UI_LOGO_URL"),
2240
- placeholder: (_ya = (_xa = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _xa : readString(env, "UI_PLACEHOLDER")) != null ? _ya : "Ask me anything\u2026",
2241
- showSources: ((_Aa = (_za = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _za : readString(env, "UI_SHOW_SOURCES")) != null ? _Aa : "true") !== "false",
2242
- welcomeMessage: (_Ca = (_Ba = readString(env, "NEXT_PUBLIC_WELCOME_MESSAGE")) != null ? _Ba : readString(env, "UI_WELCOME_MESSAGE")) != null ? _Ca : "Hello! I'm your AI assistant. Ask me anything about your documents.",
2243
- visualStyle: (_Ea = (_Da = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _Da : readString(env, "UI_VISUAL_STYLE")) != null ? _Ea : "glass",
2244
- borderRadius: (_Ga = (_Fa = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _Fa : readString(env, "UI_BORDER_RADIUS")) != null ? _Ga : "xl",
2245
- allowUpload: ((_Ia = (_Ha = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _Ha : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Ia : "false") === "true"
2237
+ title: (_ua = (_ta = readString(env, "NEXT_PUBLIC_UI_TITLE")) != null ? _ta : readString(env, "UI_TITLE")) != null ? _ua : "AI Assistant",
2238
+ subtitle: (_wa = (_va = readString(env, "NEXT_PUBLIC_UI_SUBTITLE")) != null ? _va : readString(env, "UI_SUBTITLE")) != null ? _wa : "Powered by RAG",
2239
+ primaryColor: (_ya = (_xa = readString(env, "NEXT_PUBLIC_PRIMARY_COLOR")) != null ? _xa : readString(env, "UI_PRIMARY_COLOR")) != null ? _ya : "#10b981",
2240
+ accentColor: (_Aa = (_za = readString(env, "NEXT_PUBLIC_ACCENT_COLOR")) != null ? _za : readString(env, "UI_ACCENT_COLOR")) != null ? _Aa : "#3b82f6",
2241
+ logoUrl: (_Ba = readString(env, "NEXT_PUBLIC_LOGO_URL")) != null ? _Ba : readString(env, "UI_LOGO_URL"),
2242
+ placeholder: (_Da = (_Ca = readString(env, "NEXT_PUBLIC_PLACEHOLDER")) != null ? _Ca : readString(env, "UI_PLACEHOLDER")) != null ? _Da : "Ask me anything\u2026",
2243
+ showSources: ((_Fa = (_Ea = readString(env, "NEXT_PUBLIC_SHOW_SOURCES")) != null ? _Ea : readString(env, "UI_SHOW_SOURCES")) != null ? _Fa : "true") !== "false",
2244
+ welcomeMessage: (_Ha = (_Ga = readString(env, "NEXT_PUBLIC_WELCOME_MESSAGE")) != null ? _Ga : readString(env, "UI_WELCOME_MESSAGE")) != null ? _Ha : "Hello! I'm your AI assistant. Ask me anything about your documents.",
2245
+ visualStyle: (_Ja = (_Ia = readString(env, "NEXT_PUBLIC_UI_VISUAL_STYLE")) != null ? _Ia : readString(env, "UI_VISUAL_STYLE")) != null ? _Ja : "glass",
2246
+ borderRadius: (_La = (_Ka = readString(env, "NEXT_PUBLIC_UI_BORDER_RADIUS")) != null ? _Ka : readString(env, "UI_BORDER_RADIUS")) != null ? _La : "xl",
2247
+ allowUpload: ((_Na = (_Ma = readString(env, "NEXT_PUBLIC_ALLOW_UPLOAD")) != null ? _Ma : readString(env, "UI_ALLOW_UPLOAD")) != null ? _Na : "false") === "true"
2246
2248
  },
2247
2249
  rag: {
2248
2250
  topK: readNumber(env, "RAG_TOP_K", 5),
2249
2251
  scoreThreshold: readNumber(env, "RAG_SCORE_THRESHOLD", 0),
2250
2252
  chunkSize: readNumber(env, "RAG_CHUNK_SIZE", 1e3),
2251
2253
  chunkOverlap: readNumber(env, "RAG_CHUNK_OVERLAP", 200),
2252
- filterableFields: (_Ja = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Ja.split(",").map((f) => f.trim()),
2254
+ filterableFields: (_Oa = readString(env, "RAG_FILTERABLE_FIELDS")) == null ? void 0 : _Oa.split(",").map((f) => f.trim()),
2253
2255
  // Query pipeline toggles — read from .env.local
2254
2256
  useQueryTransformation: readString(env, "RAG_USE_QUERY_TRANSFORMATION") === "true",
2255
2257
  useReranking: readString(env, "RAG_USE_RERANKING") === "true",
2256
2258
  useGraphRetrieval: readString(env, "RAG_USE_GRAPH_RETRIEVAL") === "true",
2257
- architecture: (_Ka = readString(env, "RAG_ARCHITECTURE")) != null ? _Ka : "simple",
2258
- chunkingStrategy: (_La = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _La : "recursive",
2259
+ architecture: (_Pa = readString(env, "RAG_ARCHITECTURE")) != null ? _Pa : "simple",
2260
+ chunkingStrategy: (_Qa = readString(env, "RAG_CHUNKING_STRATEGY")) != null ? _Qa : "recursive",
2259
2261
  uiMapping: (() => {
2260
2262
  const raw = readString(env, "RAG_UI_MAPPING");
2261
2263
  if (!raw) return void 0;
@@ -2267,8 +2269,8 @@ function getEnvConfig(env = process.env, base) {
2267
2269
  })()
2268
2270
  },
2269
2271
  telemetry: {
2270
- enabled: readString(env, "TELEMETRY_ENABLED") === "true" || readString(env, "NEXT_PUBLIC_TELEMETRY_ENABLED") === "true" || ((_Ma = base == null ? void 0 : base.telemetry) == null ? void 0 : _Ma.enabled) || false,
2271
- url: (_Qa = (_Pa = (_Na = readString(env, "TELEMETRY_URL")) != null ? _Na : readString(env, "NEXT_PUBLIC_TELEMETRY_URL")) != null ? _Pa : (_Oa = base == null ? void 0 : base.telemetry) == null ? void 0 : _Oa.url) != null ? _Qa : "/api/telemetry"
2272
+ enabled: telemetryEnabled,
2273
+ url: (_Ua = (_Ta = (_Ra = readString(env, "TELEMETRY_URL")) != null ? _Ra : readString(env, "NEXT_PUBLIC_TELEMETRY_URL")) != null ? _Ta : (_Sa = base == null ? void 0 : base.telemetry) == null ? void 0 : _Sa.url) != null ? _Ua : process.env.NODE_ENV === "development" ? "http://localhost:3001/api/telemetry" : "https://retrivora.com/api/telemetry"
2272
2274
  }
2273
2275
  }, readString(env, "GRAPH_DB_PROVIDER") ? {
2274
2276
  graphDb: {
@@ -7697,7 +7699,7 @@ ${m.content}`).join("\n\n---\n\n");
7697
7699
  */
7698
7700
  askStreamInternal(_0) {
7699
7701
  return __asyncGenerator(this, arguments, function* (question, history = [], namespace) {
7700
- var _a2, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A;
7702
+ var _a2, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C;
7701
7703
  yield new __await(this.initialize());
7702
7704
  const ns = namespace != null ? namespace : this.config.projectId;
7703
7705
  const topK = (_b = (_a2 = this.config.rag) == null ? void 0 : _a2.topK) != null ? _b : 5;
@@ -8007,8 +8009,10 @@ ${context}`;
8007
8009
  hallucinationReason: hScore.reason
8008
8010
  } : {});
8009
8011
  const trace = buildTrace(hallucinationResult);
8010
- if ((_A = this.config.telemetry) == null ? void 0 : _A.enabled) {
8011
- const telemetryUrl = this.config.telemetry.url || "/api/telemetry";
8012
+ const isTelemetryActive = (_B = (_A = this.config.telemetry) == null ? void 0 : _A.enabled) != null ? _B : Boolean(this.config.licenseKey);
8013
+ if (isTelemetryActive) {
8014
+ const defaultUrl = process.env.NODE_ENV === "development" && !process.env.TELEMETRY_URL && !process.env.NEXT_PUBLIC_TELEMETRY_URL ? "http://localhost:3001/api/telemetry" : "https://retrivora.com/api/telemetry";
8015
+ const telemetryUrl = ((_C = this.config.telemetry) == null ? void 0 : _C.url) || process.env.TELEMETRY_URL || process.env.NEXT_PUBLIC_TELEMETRY_URL || defaultUrl;
8012
8016
  const absoluteUrl = telemetryUrl.startsWith("http") ? telemetryUrl : (process.env.NEXT_PUBLIC_APP_URL || `http://localhost:${process.env.PORT || 3e3}`) + telemetryUrl;
8013
8017
  (async () => {
8014
8018
  try {
@@ -9358,6 +9362,43 @@ function getOrCreatePlugin(configOrPlugin) {
9358
9362
  }
9359
9363
  return _g[cacheKey];
9360
9364
  }
9365
+ function reportTelemetry(req, plugin, action, status, details, trace) {
9366
+ var _a2;
9367
+ try {
9368
+ const config = plugin.getConfig();
9369
+ const licenseKey = config.licenseKey || process.env.RAG_LICENSE_KEY || process.env.RETRIVORA_LICENSE_KEY || process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY;
9370
+ const telemetryConfig = config.telemetry;
9371
+ const enabled = (_a2 = telemetryConfig == null ? void 0 : telemetryConfig.enabled) != null ? _a2 : Boolean(licenseKey);
9372
+ const defaultUrl = process.env.NODE_ENV === "development" && !process.env.TELEMETRY_URL && !process.env.NEXT_PUBLIC_TELEMETRY_URL ? "http://localhost:3001/api/telemetry" : "https://retrivora.com/api/telemetry";
9373
+ const telemetryUrl = (telemetryConfig == null ? void 0 : telemetryConfig.url) || process.env.TELEMETRY_URL || process.env.NEXT_PUBLIC_TELEMETRY_URL || defaultUrl;
9374
+ const host = req.headers.get("host") || "localhost";
9375
+ let absoluteUrl = telemetryUrl;
9376
+ if (!telemetryUrl.startsWith("http")) {
9377
+ const proto = req.headers.get("x-forwarded-proto") || "http";
9378
+ absoluteUrl = `${proto}://${host}${telemetryUrl}`;
9379
+ }
9380
+ const projectId = config.projectId || "default";
9381
+ fetch(absoluteUrl, {
9382
+ method: "POST",
9383
+ headers: {
9384
+ "Content-Type": "application/json",
9385
+ "x-forwarded-for": req.headers.get("x-forwarded-for") || "",
9386
+ "x-real-ip": req.headers.get("x-real-ip") || ""
9387
+ },
9388
+ body: JSON.stringify({
9389
+ trace,
9390
+ licenseKey,
9391
+ projectId,
9392
+ action,
9393
+ status,
9394
+ details
9395
+ })
9396
+ }).catch((err) => {
9397
+ console.warn("[Retrivora Telemetry] Async report warning:", err.message);
9398
+ });
9399
+ } catch (e) {
9400
+ }
9401
+ }
9361
9402
  function sseFrame(payload) {
9362
9403
  return `data: ${JSON.stringify(payload)}
9363
9404
 
@@ -9400,6 +9441,7 @@ function createChatHandler(configOrPlugin, options) {
9400
9441
  const storage = new DatabaseStorage(plugin.getConfig());
9401
9442
  const onAuthorize = options == null ? void 0 : options.onAuthorize;
9402
9443
  return async function POST(req) {
9444
+ var _a2, _b, _c, _d;
9403
9445
  const authResult = await checkAuth(req, onAuthorize);
9404
9446
  if (authResult) return authResult;
9405
9447
  const rateLimited = checkRateLimit(req);
@@ -9428,12 +9470,14 @@ function createChatHandler(configOrPlugin, options) {
9428
9470
  uiTransformation: result.ui_transformation,
9429
9471
  trace: result.trace
9430
9472
  }).catch((err) => console.warn("[createChatHandler] Failed to save assistant message:", err));
9473
+ reportTelemetry(req, plugin, "QUERY_GENERATION", "success", `Tokens: ${((_b = (_a2 = result.trace) == null ? void 0 : _a2.tokens) == null ? void 0 : _b.totalTokens) || 0}, Latency: ${((_d = (_c = result.trace) == null ? void 0 : _c.latency) == null ? void 0 : _d.totalMs) || 0}ms`, result.trace);
9431
9474
  return NextResponse.json(__spreadProps(__spreadValues({}, result), {
9432
9475
  messageId: assistantMsgId,
9433
9476
  userMessageId: userMsgId
9434
9477
  }));
9435
9478
  } catch (err) {
9436
9479
  const message = err instanceof Error ? err.message : "Internal server error";
9480
+ reportTelemetry(req, plugin, "QUERY_GENERATION", "error", message);
9437
9481
  return NextResponse.json({ error: message }, { status: 500 });
9438
9482
  }
9439
9483
  };
@@ -9476,7 +9520,7 @@ function createStreamHandler(configOrPlugin, options) {
9476
9520
  let isActive = true;
9477
9521
  const stream = new ReadableStream({
9478
9522
  async start(controller) {
9479
- var _a2;
9523
+ var _a2, _b, _c, _d, _e;
9480
9524
  const enqueue = (text) => {
9481
9525
  if (!isActive) return;
9482
9526
  try {
@@ -9533,6 +9577,7 @@ function createStreamHandler(configOrPlugin, options) {
9533
9577
  uiTransformation,
9534
9578
  trace: responseChunk == null ? void 0 : responseChunk.trace
9535
9579
  }).catch((err) => console.warn("[createStreamHandler] Failed to save assistant message:", err));
9580
+ reportTelemetry(req, plugin, "QUERY_GENERATION", "success", `Tokens: ${((_c = (_b = responseChunk == null ? void 0 : responseChunk.trace) == null ? void 0 : _b.tokens) == null ? void 0 : _c.totalTokens) || 0}, Latency: ${((_e = (_d = responseChunk == null ? void 0 : responseChunk.trace) == null ? void 0 : _d.latency) == null ? void 0 : _e.totalMs) || 0}ms`, responseChunk == null ? void 0 : responseChunk.trace);
9536
9581
  }
9537
9582
  }
9538
9583
  } catch (temp) {
@@ -9549,6 +9594,7 @@ function createStreamHandler(configOrPlugin, options) {
9549
9594
  if (isActive) {
9550
9595
  const errorMessage = streamError instanceof Error ? streamError.message : String(streamError);
9551
9596
  console.error("[createStreamHandler] Stream error:", streamError);
9597
+ reportTelemetry(req, plugin, "QUERY_GENERATION", "error", errorMessage);
9552
9598
  try {
9553
9599
  enqueue(sseErrorFrame(errorMessage));
9554
9600
  } catch (e) {
@@ -9585,9 +9631,11 @@ function createIngestHandler(configOrPlugin, options) {
9585
9631
  return NextResponse.json({ error: "documents array is required" }, { status: 400 });
9586
9632
  }
9587
9633
  const results = await plugin.ingest(documents, namespace);
9634
+ reportTelemetry(req, plugin, "DOCUMENT_INGESTION", "success", `Ingested ${documents.length} document(s)`);
9588
9635
  return NextResponse.json({ results });
9589
9636
  } catch (err) {
9590
9637
  const message = err instanceof Error ? err.message : "Internal server error";
9638
+ reportTelemetry(req, plugin, "DOCUMENT_INGESTION", "error", message);
9591
9639
  return NextResponse.json({ error: message }, { status: 500 });
9592
9640
  }
9593
9641
  };
@@ -9686,9 +9734,11 @@ function createUploadHandler(configOrPlugin, options) {
9686
9734
  }
9687
9735
  }
9688
9736
  const results = await plugin.ingest(documents, namespace);
9737
+ reportTelemetry(req, plugin, "DOCUMENT_INGESTION", "success", `Uploaded & ingested ${files.length} file(s)`);
9689
9738
  return NextResponse.json({ message: "Upload successful", results });
9690
9739
  } catch (err) {
9691
9740
  const message = err instanceof Error ? err.message : "Upload failed";
9741
+ reportTelemetry(req, plugin, "DOCUMENT_INGESTION", "error", message);
9692
9742
  return NextResponse.json({ error: message }, { status: 500 });
9693
9743
  }
9694
9744
  };
@@ -9696,19 +9746,30 @@ function createUploadHandler(configOrPlugin, options) {
9696
9746
  function createSuggestionsHandler(configOrPlugin, options) {
9697
9747
  const plugin = getOrCreatePlugin(configOrPlugin);
9698
9748
  const onAuthorize = options == null ? void 0 : options.onAuthorize;
9699
- return async function POST(req) {
9749
+ return async function handler(req) {
9700
9750
  const authResult = await checkAuth(req, onAuthorize);
9701
9751
  if (authResult) return authResult;
9702
9752
  try {
9703
- const body = await req.json();
9704
- const { query, namespace } = body;
9753
+ let query = "";
9754
+ let namespace = void 0;
9755
+ if (req.method === "POST") {
9756
+ const body = await req.json().catch(() => ({}));
9757
+ query = body.query || "";
9758
+ namespace = body.namespace;
9759
+ } else {
9760
+ const url = new URL(req.url);
9761
+ query = url.searchParams.get("query") || "";
9762
+ namespace = url.searchParams.get("namespace") || void 0;
9763
+ }
9705
9764
  if (typeof query !== "string") {
9706
9765
  return NextResponse.json({ error: "query is required" }, { status: 400 });
9707
9766
  }
9708
9767
  const suggestions = await plugin.getSuggestions(query, namespace);
9768
+ reportTelemetry(req, plugin, "AUTO_SUGGESTIONS", "success", `Fetched ${suggestions.length} suggestions for: ${query.slice(0, 30)}`);
9709
9769
  return NextResponse.json({ suggestions });
9710
9770
  } catch (err) {
9711
9771
  const message = err instanceof Error ? err.message : "Internal server error";
9772
+ reportTelemetry(req, plugin, "AUTO_SUGGESTIONS", "error", message);
9712
9773
  return NextResponse.json({ error: message }, { status: 500 });
9713
9774
  }
9714
9775
  };
@@ -9840,6 +9901,8 @@ function createRagHandler(configOrPlugin, options) {
9840
9901
  switch (segment) {
9841
9902
  case "health":
9842
9903
  return healthHandler(req);
9904
+ case "suggestions":
9905
+ return suggestionsHandler(req);
9843
9906
  case "history":
9844
9907
  return historyHandler(req);
9845
9908
  case "feedback":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retrivora-ai/rag-engine",
3
- "version": "1.9.9",
3
+ "version": "2.0.1",
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",
@@ -217,11 +217,22 @@ export function ChatWindow({
217
217
  const timer = setTimeout(async () => {
218
218
  setIsSuggesting(true);
219
219
  try {
220
- const response = await fetch('/api/suggestions', {
220
+ const base = retrivoraApiBase || '/api/retrivora';
221
+ const primaryUrl = `${base}/suggestions`;
222
+ let response = await fetch(primaryUrl, {
221
223
  method: 'POST',
222
- headers: { 'Content-Type': 'application/json' },
224
+ headers: { 'Content-Type': 'application/json', ...(headers || {}) },
223
225
  body: JSON.stringify({ query: input, namespace: projectId }),
224
226
  });
227
+
228
+ if (!response.ok && response.status === 404) {
229
+ response = await fetch('/api/suggestions', {
230
+ method: 'POST',
231
+ headers: { 'Content-Type': 'application/json', ...(headers || {}) },
232
+ body: JSON.stringify({ query: input, namespace: projectId }),
233
+ });
234
+ }
235
+
225
236
  const data = await response.json();
226
237
  if (data.suggestions) {
227
238
  setSuggestions(data.suggestions);
@@ -234,7 +245,7 @@ export function ChatWindow({
234
245
  }, 800); // 800ms debounce to save costs/latency
235
246
 
236
247
  return () => clearTimeout(timer);
237
- }, [input, projectId]);
248
+ }, [input, projectId, retrivoraApiBase, headers]);
238
249
 
239
250
  return (
240
251
  <div
@@ -64,6 +64,19 @@ export function getEnvConfig(env: Record<string, string | undefined> = process.e
64
64
  base?.projectId ??
65
65
  '__default__';
66
66
 
67
+ const licenseKey =
68
+ readString(env, 'RAG_LICENSE_KEY') ??
69
+ readString(env, 'RETRIVORA_LICENSE_KEY') ??
70
+ readString(env, 'NEXT_PUBLIC_RETRIVORA_LICENSE_KEY') ??
71
+ readString(env, 'LICENSE_KEY') ??
72
+ base?.licenseKey;
73
+
74
+ const telemetryEnabled =
75
+ readString(env, 'TELEMETRY_ENABLED') === 'true' ||
76
+ readString(env, 'NEXT_PUBLIC_TELEMETRY_ENABLED') === 'true' ||
77
+ base?.telemetry?.enabled ||
78
+ Boolean(licenseKey);
79
+
67
80
  const vectorProvider = readEnum(env, 'VECTOR_DB_PROVIDER', 'pinecone', VECTOR_DB_PROVIDERS);
68
81
  const llmProvider = readEnum(env, 'LLM_PROVIDER', 'openai', LLM_PROVIDERS);
69
82
  const embeddingProvider = readEnum(env, 'EMBEDDING_PROVIDER', 'openai', EMBEDDING_PROVIDERS);
@@ -219,8 +232,8 @@ export function getEnvConfig(env: Record<string, string | undefined> = process.e
219
232
  })(),
220
233
  },
221
234
  telemetry: {
222
- enabled: readString(env, 'TELEMETRY_ENABLED') === 'true' || readString(env, 'NEXT_PUBLIC_TELEMETRY_ENABLED') === 'true' || base?.telemetry?.enabled || false,
223
- url: readString(env, 'TELEMETRY_URL') ?? readString(env, 'NEXT_PUBLIC_TELEMETRY_URL') ?? base?.telemetry?.url ?? '/api/telemetry',
235
+ enabled: telemetryEnabled,
236
+ url: readString(env, 'TELEMETRY_URL') ?? readString(env, 'NEXT_PUBLIC_TELEMETRY_URL') ?? base?.telemetry?.url ?? (process.env.NODE_ENV === 'development' ? 'http://localhost:3001/api/telemetry' : 'https://retrivora.com/api/telemetry'),
224
237
  },
225
238
  // Optional graph DB — driven by GRAPH_DB_PROVIDER env var
226
239
  ...(readString(env, 'GRAPH_DB_PROVIDER') ? {
@@ -663,19 +663,19 @@ You are a helpful assistant. Use the provided context to answer questions accura
663
663
  const uiTransformationPromise = isProductQ
664
664
  // Product carousel: pure heuristic, zero LLM latency
665
665
  ? Promise.resolve(
666
- UITransformer.transform(question, sources, this.config, cachedSchema,
667
- { visualizationHint: 'product_browse', recommendedChart: 'text', filterInStockOnly: false, wantsExplicitTable: false, isTemporal: false, isComparison: false, language: 'en' }
668
- )
666
+ UITransformer.transform(question, sources, this.config, cachedSchema,
667
+ { visualizationHint: 'product_browse', recommendedChart: 'text', filterInStockOnly: false, wantsExplicitTable: false, isTemporal: false, isComparison: false, language: 'en' }
669
668
  )
669
+ )
670
670
  : this.generateUiTransformation(
671
- question,
672
- sources,
673
- cachedSchema,
674
- hasNumericPredicates,
675
- ).catch(uiError => {
676
- console.warn('[Pipeline] UI transformation failed concurrently:', uiError);
677
- return UITransformer.transform(question, sources, this.config, cachedSchema);
678
- });
671
+ question,
672
+ sources,
673
+ cachedSchema,
674
+ hasNumericPredicates,
675
+ ).catch(uiError => {
676
+ console.warn('[Pipeline] UI transformation failed concurrently:', uiError);
677
+ return UITransformer.transform(question, sources, this.config, cachedSchema);
678
+ });
679
679
 
680
680
  // 5. Generation (Streaming)
681
681
  // Start hallucination scoring as a background promise BEFORE streaming
@@ -687,14 +687,14 @@ You are a helpful assistant. Use the provided context to answer questions accura
687
687
  Promise.resolve(undefined);
688
688
 
689
689
  const restrictionSuffix = '\n\n(IMPORTANT: Format your response beautifully using rich Markdown! Use bolding for emphasis, headings (##) for structure, bullet points for lists, and proper line breaks between paragraphs to make it highly readable. However, NEVER generate Markdown tables, HTML figures, or text charts (the UI renders requested charts separately, so NEVER say you cannot create, display, draw, render, or provide a chart/visualization). If listing products, use simple markdown bullet points or comma-separated names. NEVER use plus signs (+) to separate product names, category names, or list items. For product description/detail questions, provide customer-facing prose only and do NOT list internal catalog fields such as Handle, Body (HTML), Vendor, Type, Tags, Published, Option, Variant, SKU, or raw metadata labels. You CAN use numbers for years/counts like 2006 or 5800, but NEVER put a dollar sign ($) before them.)';
690
-
690
+
691
691
  const isClaude37 = this.config.llm.model.includes('claude-3-7-sonnet');
692
692
  const isNativeThinking = isClaude37 && (this.config.llm.options?.thinking === true || this.config.llm.options?.thinking === 'enabled' || this.config.llm.options?.thinking !== false);
693
-
693
+
694
694
  const modelNameLower = this.config.llm.model.toLowerCase();
695
695
  const isReasoningModel = modelNameLower.includes('-r1') || modelNameLower.includes('deepseek-r1') || modelNameLower.includes('reasoning') || modelNameLower.includes('thinking');
696
696
  const isSimulatedThinking = !isNativeThinking && (
697
- this.config.llm.options?.thinking === true ||
697
+ this.config.llm.options?.thinking === true ||
698
698
  this.config.llm.options?.thinking === 'enabled' ||
699
699
  (isReasoningModel && this.config.llm.options?.thinking !== false)
700
700
  );
@@ -720,7 +720,7 @@ You are a helpful assistant. Use the provided context to answer questions accura
720
720
  if (this.llmProvider.chatStream) {
721
721
  const stream = this.llmProvider.chatStream(messages, context);
722
722
  if (!stream) throw new Error(`[Pipeline] ${this.config.llm.provider} chatStream returned undefined`);
723
-
723
+
724
724
  let inThinking = false;
725
725
  let textBuffer = '';
726
726
 
@@ -820,7 +820,7 @@ You are a helpful assistant. Use the provided context to answer questions accura
820
820
  // Kick off hallucination scoring now that we have the full reply.
821
821
  // It runs in parallel with the remaining post-processing below.
822
822
  const runHallucination = this.config.llm.options?.hallucinationScoring === true ||
823
- (this.config.llm.provider !== 'ollama' && this.config.llm.options?.hallucinationScoring !== false);
823
+ (this.config.llm.provider !== 'ollama' && this.config.llm.options?.hallucinationScoring !== false);
824
824
  if (runHallucination) {
825
825
  hallucinationScoringPromise = scoreHallucination(this.llmProvider, fullReply, context)
826
826
  .catch(() => undefined);
@@ -850,7 +850,7 @@ You are a helpful assistant. Use the provided context to answer questions accura
850
850
 
851
851
  // 7. Await UI transformation and optionally hallucination score before yielding the metadata frame.
852
852
  const awaitHallucination = this.config.llm.options?.awaitHallucination === true;
853
-
853
+
854
854
  const [uiTransformation, hallucinationResult] = await Promise.all([
855
855
  uiTransformationPromise,
856
856
  awaitHallucination ? hallucinationScoringPromise : Promise.resolve(undefined),
@@ -881,8 +881,13 @@ You are a helpful assistant. Use the provided context to answer questions accura
881
881
  const trace = buildTrace(hallucinationResult);
882
882
 
883
883
  // Asynchronously trigger telemetry logging without blocking response yield
884
- if (this.config.telemetry?.enabled) {
885
- const telemetryUrl = this.config.telemetry.url || '/api/telemetry';
884
+ const isTelemetryActive = this.config.telemetry?.enabled ?? Boolean(this.config.licenseKey);
885
+ if (isTelemetryActive) {
886
+ const defaultUrl = process.env.NODE_ENV === 'development' && !process.env.TELEMETRY_URL && !process.env.NEXT_PUBLIC_TELEMETRY_URL
887
+ ? 'http://localhost:3001/api/telemetry'
888
+ : 'https://retrivora.com/api/telemetry';
889
+
890
+ const telemetryUrl = this.config.telemetry?.url || process.env.TELEMETRY_URL || process.env.NEXT_PUBLIC_TELEMETRY_URL || defaultUrl;
886
891
  const absoluteUrl = telemetryUrl.startsWith('http')
887
892
  ? telemetryUrl
888
893
  : (process.env.NEXT_PUBLIC_APP_URL || `http://localhost:${process.env.PORT || 3000}`) + telemetryUrl;
@@ -897,7 +902,7 @@ You are a helpful assistant. Use the provided context to answer questions accura
897
902
  finalTrace = buildTrace(backgroundScoreResult);
898
903
  }
899
904
  }
900
-
905
+
901
906
  await fetch(absoluteUrl, {
902
907
  method: 'POST',
903
908
  headers: {