@retrivora-ai/rag-engine 2.1.4 → 2.1.6

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.
@@ -5247,7 +5247,7 @@ var ConfigValidator = class {
5247
5247
  // package.json
5248
5248
  var package_default = {
5249
5249
  name: "@retrivora-ai/rag-engine",
5250
- version: "2.1.4",
5250
+ version: "2.1.6",
5251
5251
  description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
5252
5252
  author: "Abhinav Alkuchi",
5253
5253
  license: "UNLICENSED",
@@ -10941,12 +10941,17 @@ function createStreamHandler(configOrPlugin, options) {
10941
10941
  const storage = new DatabaseStorage(plugin.getConfig());
10942
10942
  const onAuthorize = options == null ? void 0 : options.onAuthorize;
10943
10943
  return async function POST(req) {
10944
+ var _a2;
10944
10945
  const authResult = await checkAuth(req, onAuthorize);
10945
10946
  if (authResult) return authResult;
10946
10947
  const rateLimited = checkRateLimit(req);
10947
10948
  if (rateLimited) return rateLimited;
10948
10949
  let body;
10949
10950
  try {
10951
+ if ((_a2 = req.headers.get("content-type")) == null ? void 0 : _a2.includes("multipart/form-data")) {
10952
+ const uploader = createUploadHandler(plugin, { onAuthorize });
10953
+ return uploader(req);
10954
+ }
10950
10955
  body = await req.json();
10951
10956
  } catch (e) {
10952
10957
  return new Response(JSON.stringify({ error: { code: "INVALID_JSON", message: "Invalid JSON body" } }), {
@@ -10984,7 +10989,7 @@ function createStreamHandler(configOrPlugin, options) {
10984
10989
  let isActive = true;
10985
10990
  const stream = new ReadableStream({
10986
10991
  async start(controller) {
10987
- var _a2, _b, _c, _d, _e;
10992
+ var _a3, _b, _c, _d, _e;
10988
10993
  const enqueue = (text) => {
10989
10994
  if (!isActive) return;
10990
10995
  try {
@@ -11017,7 +11022,7 @@ function createStreamHandler(configOrPlugin, options) {
11017
11022
  let uiTransformation = responseChunk == null ? void 0 : responseChunk.ui_transformation;
11018
11023
  if (sources.length > 0) {
11019
11024
  try {
11020
- uiTransformation = (_a2 = responseChunk == null ? void 0 : responseChunk.ui_transformation) != null ? _a2 : UITransformer.transform(message, sources, plugin.getConfig());
11025
+ uiTransformation = (_a3 = responseChunk == null ? void 0 : responseChunk.ui_transformation) != null ? _a3 : UITransformer.transform(message, sources, plugin.getConfig());
11021
11026
  if (uiTransformation) {
11022
11027
  enqueue(sseUIFrame(uiTransformation));
11023
11028
  }
@@ -11414,16 +11419,32 @@ function createRagHandler(configOrPlugin, options) {
11414
11419
  return import_server.NextResponse.json({ error: `Method Not Allowed: GET segment "${segment}" not supported.` }, { status: 405 });
11415
11420
  }
11416
11421
  }
11417
- async function getSegment(context) {
11418
- var _a2;
11422
+ async function getSegment(req, context) {
11423
+ var _a2, _b;
11424
+ const contentType = req.headers.get("content-type") || "";
11425
+ if (contentType.includes("multipart/form-data")) {
11426
+ return "upload";
11427
+ }
11428
+ try {
11429
+ const url = new URL(req.url);
11430
+ const pathname = url.pathname;
11431
+ if (pathname.endsWith("/upload")) return "upload";
11432
+ if (pathname.endsWith("/chat") || pathname.endsWith("/chat-sync")) return "chat";
11433
+ if (pathname.endsWith("/health")) return "health";
11434
+ if (pathname.endsWith("/suggestions")) return "suggestions";
11435
+ if (pathname.endsWith("/feedback")) return "feedback";
11436
+ if (pathname.endsWith("/history")) return "history";
11437
+ } catch (e) {
11438
+ }
11419
11439
  const resolvedParams = typeof ((_a2 = context == null ? void 0 : context.params) == null ? void 0 : _a2.then) === "function" ? await context.params : context == null ? void 0 : context.params;
11420
- const segments = (resolvedParams == null ? void 0 : resolvedParams.retrivora) || [];
11421
- return segments.join("/") || "chat";
11440
+ const segments = (resolvedParams == null ? void 0 : resolvedParams.retrivora) || ((_b = resolvedParams == null ? void 0 : resolvedParams.params) == null ? void 0 : _b.retrivora) || [];
11441
+ const joined = segments.join("/");
11442
+ return joined || "chat";
11422
11443
  }
11423
11444
  return {
11424
11445
  GET: async (req, context) => {
11425
11446
  try {
11426
- const segment = await getSegment(context);
11447
+ const segment = await getSegment(req, context);
11427
11448
  return await routeGetRequest(req, segment);
11428
11449
  } catch (err) {
11429
11450
  const msg = err instanceof Error ? err.message : "GET Routing failed";
@@ -11432,7 +11453,7 @@ function createRagHandler(configOrPlugin, options) {
11432
11453
  },
11433
11454
  POST: async (req, context) => {
11434
11455
  try {
11435
- const segment = await getSegment(context);
11456
+ const segment = await getSegment(req, context);
11436
11457
  return await routePostRequest(req, segment);
11437
11458
  } catch (err) {
11438
11459
  const msg = err instanceof Error ? err.message : "POST Routing failed";
@@ -5212,7 +5212,7 @@ var ConfigValidator = class {
5212
5212
  // package.json
5213
5213
  var package_default = {
5214
5214
  name: "@retrivora-ai/rag-engine",
5215
- version: "2.1.4",
5215
+ version: "2.1.6",
5216
5216
  description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
5217
5217
  author: "Abhinav Alkuchi",
5218
5218
  license: "UNLICENSED",
@@ -10906,12 +10906,17 @@ function createStreamHandler(configOrPlugin, options) {
10906
10906
  const storage = new DatabaseStorage(plugin.getConfig());
10907
10907
  const onAuthorize = options == null ? void 0 : options.onAuthorize;
10908
10908
  return async function POST(req) {
10909
+ var _a2;
10909
10910
  const authResult = await checkAuth(req, onAuthorize);
10910
10911
  if (authResult) return authResult;
10911
10912
  const rateLimited = checkRateLimit(req);
10912
10913
  if (rateLimited) return rateLimited;
10913
10914
  let body;
10914
10915
  try {
10916
+ if ((_a2 = req.headers.get("content-type")) == null ? void 0 : _a2.includes("multipart/form-data")) {
10917
+ const uploader = createUploadHandler(plugin, { onAuthorize });
10918
+ return uploader(req);
10919
+ }
10915
10920
  body = await req.json();
10916
10921
  } catch (e) {
10917
10922
  return new Response(JSON.stringify({ error: { code: "INVALID_JSON", message: "Invalid JSON body" } }), {
@@ -10949,7 +10954,7 @@ function createStreamHandler(configOrPlugin, options) {
10949
10954
  let isActive = true;
10950
10955
  const stream = new ReadableStream({
10951
10956
  async start(controller) {
10952
- var _a2, _b, _c, _d, _e;
10957
+ var _a3, _b, _c, _d, _e;
10953
10958
  const enqueue = (text) => {
10954
10959
  if (!isActive) return;
10955
10960
  try {
@@ -10982,7 +10987,7 @@ function createStreamHandler(configOrPlugin, options) {
10982
10987
  let uiTransformation = responseChunk == null ? void 0 : responseChunk.ui_transformation;
10983
10988
  if (sources.length > 0) {
10984
10989
  try {
10985
- uiTransformation = (_a2 = responseChunk == null ? void 0 : responseChunk.ui_transformation) != null ? _a2 : UITransformer.transform(message, sources, plugin.getConfig());
10990
+ uiTransformation = (_a3 = responseChunk == null ? void 0 : responseChunk.ui_transformation) != null ? _a3 : UITransformer.transform(message, sources, plugin.getConfig());
10986
10991
  if (uiTransformation) {
10987
10992
  enqueue(sseUIFrame(uiTransformation));
10988
10993
  }
@@ -11379,16 +11384,32 @@ function createRagHandler(configOrPlugin, options) {
11379
11384
  return NextResponse.json({ error: `Method Not Allowed: GET segment "${segment}" not supported.` }, { status: 405 });
11380
11385
  }
11381
11386
  }
11382
- async function getSegment(context) {
11383
- var _a2;
11387
+ async function getSegment(req, context) {
11388
+ var _a2, _b;
11389
+ const contentType = req.headers.get("content-type") || "";
11390
+ if (contentType.includes("multipart/form-data")) {
11391
+ return "upload";
11392
+ }
11393
+ try {
11394
+ const url = new URL(req.url);
11395
+ const pathname = url.pathname;
11396
+ if (pathname.endsWith("/upload")) return "upload";
11397
+ if (pathname.endsWith("/chat") || pathname.endsWith("/chat-sync")) return "chat";
11398
+ if (pathname.endsWith("/health")) return "health";
11399
+ if (pathname.endsWith("/suggestions")) return "suggestions";
11400
+ if (pathname.endsWith("/feedback")) return "feedback";
11401
+ if (pathname.endsWith("/history")) return "history";
11402
+ } catch (e) {
11403
+ }
11384
11404
  const resolvedParams = typeof ((_a2 = context == null ? void 0 : context.params) == null ? void 0 : _a2.then) === "function" ? await context.params : context == null ? void 0 : context.params;
11385
- const segments = (resolvedParams == null ? void 0 : resolvedParams.retrivora) || [];
11386
- return segments.join("/") || "chat";
11405
+ const segments = (resolvedParams == null ? void 0 : resolvedParams.retrivora) || ((_b = resolvedParams == null ? void 0 : resolvedParams.params) == null ? void 0 : _b.retrivora) || [];
11406
+ const joined = segments.join("/");
11407
+ return joined || "chat";
11387
11408
  }
11388
11409
  return {
11389
11410
  GET: async (req, context) => {
11390
11411
  try {
11391
- const segment = await getSegment(context);
11412
+ const segment = await getSegment(req, context);
11392
11413
  return await routeGetRequest(req, segment);
11393
11414
  } catch (err) {
11394
11415
  const msg = err instanceof Error ? err.message : "GET Routing failed";
@@ -11397,7 +11418,7 @@ function createRagHandler(configOrPlugin, options) {
11397
11418
  },
11398
11419
  POST: async (req, context) => {
11399
11420
  try {
11400
- const segment = await getSegment(context);
11421
+ const segment = await getSegment(req, context);
11401
11422
  return await routePostRequest(req, segment);
11402
11423
  } catch (err) {
11403
11424
  const msg = err instanceof Error ? err.message : "POST Routing failed";
package/dist/index.css CHANGED
@@ -2917,14 +2917,6 @@
2917
2917
  color: var(--color-amber-400);
2918
2918
  }
2919
2919
  }
2920
- .dark\:text-amber-400\/90 {
2921
- @media (prefers-color-scheme: dark) {
2922
- color: color-mix(in srgb, oklch(82.8% 0.189 84.429) 90%, transparent);
2923
- @supports (color: color-mix(in lab, red, red)) {
2924
- color: color-mix(in oklab, var(--color-amber-400) 90%, transparent);
2925
- }
2926
- }
2927
- }
2928
2920
  .dark\:text-blue-100 {
2929
2921
  @media (prefers-color-scheme: dark) {
2930
2922
  color: var(--color-blue-100);