@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.
package/dist/server.js CHANGED
@@ -5348,7 +5348,7 @@ var ConfigValidator = class {
5348
5348
  // package.json
5349
5349
  var package_default = {
5350
5350
  name: "@retrivora-ai/rag-engine",
5351
- version: "2.1.4",
5351
+ version: "2.1.6",
5352
5352
  description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
5353
5353
  author: "Abhinav Alkuchi",
5354
5354
  license: "UNLICENSED",
@@ -11355,12 +11355,17 @@ function createStreamHandler(configOrPlugin, options) {
11355
11355
  const storage = new DatabaseStorage(plugin.getConfig());
11356
11356
  const onAuthorize = options == null ? void 0 : options.onAuthorize;
11357
11357
  return async function POST(req) {
11358
+ var _a2;
11358
11359
  const authResult = await checkAuth(req, onAuthorize);
11359
11360
  if (authResult) return authResult;
11360
11361
  const rateLimited = checkRateLimit(req);
11361
11362
  if (rateLimited) return rateLimited;
11362
11363
  let body;
11363
11364
  try {
11365
+ if ((_a2 = req.headers.get("content-type")) == null ? void 0 : _a2.includes("multipart/form-data")) {
11366
+ const uploader = createUploadHandler(plugin, { onAuthorize });
11367
+ return uploader(req);
11368
+ }
11364
11369
  body = await req.json();
11365
11370
  } catch (e) {
11366
11371
  return new Response(JSON.stringify({ error: { code: "INVALID_JSON", message: "Invalid JSON body" } }), {
@@ -11398,7 +11403,7 @@ function createStreamHandler(configOrPlugin, options) {
11398
11403
  let isActive = true;
11399
11404
  const stream = new ReadableStream({
11400
11405
  async start(controller) {
11401
- var _a2, _b, _c, _d, _e;
11406
+ var _a3, _b, _c, _d, _e;
11402
11407
  const enqueue = (text) => {
11403
11408
  if (!isActive) return;
11404
11409
  try {
@@ -11431,7 +11436,7 @@ function createStreamHandler(configOrPlugin, options) {
11431
11436
  let uiTransformation = responseChunk == null ? void 0 : responseChunk.ui_transformation;
11432
11437
  if (sources.length > 0) {
11433
11438
  try {
11434
- uiTransformation = (_a2 = responseChunk == null ? void 0 : responseChunk.ui_transformation) != null ? _a2 : UITransformer.transform(message, sources, plugin.getConfig());
11439
+ uiTransformation = (_a3 = responseChunk == null ? void 0 : responseChunk.ui_transformation) != null ? _a3 : UITransformer.transform(message, sources, plugin.getConfig());
11435
11440
  if (uiTransformation) {
11436
11441
  enqueue(sseUIFrame(uiTransformation));
11437
11442
  }
@@ -11828,16 +11833,32 @@ function createRagHandler(configOrPlugin, options) {
11828
11833
  return import_server.NextResponse.json({ error: `Method Not Allowed: GET segment "${segment}" not supported.` }, { status: 405 });
11829
11834
  }
11830
11835
  }
11831
- async function getSegment(context) {
11832
- var _a2;
11836
+ async function getSegment(req, context) {
11837
+ var _a2, _b;
11838
+ const contentType = req.headers.get("content-type") || "";
11839
+ if (contentType.includes("multipart/form-data")) {
11840
+ return "upload";
11841
+ }
11842
+ try {
11843
+ const url = new URL(req.url);
11844
+ const pathname = url.pathname;
11845
+ if (pathname.endsWith("/upload")) return "upload";
11846
+ if (pathname.endsWith("/chat") || pathname.endsWith("/chat-sync")) return "chat";
11847
+ if (pathname.endsWith("/health")) return "health";
11848
+ if (pathname.endsWith("/suggestions")) return "suggestions";
11849
+ if (pathname.endsWith("/feedback")) return "feedback";
11850
+ if (pathname.endsWith("/history")) return "history";
11851
+ } catch (e) {
11852
+ }
11833
11853
  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;
11834
- const segments = (resolvedParams == null ? void 0 : resolvedParams.retrivora) || [];
11835
- return segments.join("/") || "chat";
11854
+ const segments = (resolvedParams == null ? void 0 : resolvedParams.retrivora) || ((_b = resolvedParams == null ? void 0 : resolvedParams.params) == null ? void 0 : _b.retrivora) || [];
11855
+ const joined = segments.join("/");
11856
+ return joined || "chat";
11836
11857
  }
11837
11858
  return {
11838
11859
  GET: async (req, context) => {
11839
11860
  try {
11840
- const segment = await getSegment(context);
11861
+ const segment = await getSegment(req, context);
11841
11862
  return await routeGetRequest(req, segment);
11842
11863
  } catch (err) {
11843
11864
  const msg = err instanceof Error ? err.message : "GET Routing failed";
@@ -11846,7 +11867,7 @@ function createRagHandler(configOrPlugin, options) {
11846
11867
  },
11847
11868
  POST: async (req, context) => {
11848
11869
  try {
11849
- const segment = await getSegment(context);
11870
+ const segment = await getSegment(req, context);
11850
11871
  return await routePostRequest(req, segment);
11851
11872
  } catch (err) {
11852
11873
  const msg = err instanceof Error ? err.message : "POST Routing failed";
package/dist/server.mjs CHANGED
@@ -5251,7 +5251,7 @@ var ConfigValidator = class {
5251
5251
  // package.json
5252
5252
  var package_default = {
5253
5253
  name: "@retrivora-ai/rag-engine",
5254
- version: "2.1.4",
5254
+ version: "2.1.6",
5255
5255
  description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
5256
5256
  author: "Abhinav Alkuchi",
5257
5257
  license: "UNLICENSED",
@@ -11258,12 +11258,17 @@ function createStreamHandler(configOrPlugin, options) {
11258
11258
  const storage = new DatabaseStorage(plugin.getConfig());
11259
11259
  const onAuthorize = options == null ? void 0 : options.onAuthorize;
11260
11260
  return async function POST(req) {
11261
+ var _a2;
11261
11262
  const authResult = await checkAuth(req, onAuthorize);
11262
11263
  if (authResult) return authResult;
11263
11264
  const rateLimited = checkRateLimit(req);
11264
11265
  if (rateLimited) return rateLimited;
11265
11266
  let body;
11266
11267
  try {
11268
+ if ((_a2 = req.headers.get("content-type")) == null ? void 0 : _a2.includes("multipart/form-data")) {
11269
+ const uploader = createUploadHandler(plugin, { onAuthorize });
11270
+ return uploader(req);
11271
+ }
11267
11272
  body = await req.json();
11268
11273
  } catch (e) {
11269
11274
  return new Response(JSON.stringify({ error: { code: "INVALID_JSON", message: "Invalid JSON body" } }), {
@@ -11301,7 +11306,7 @@ function createStreamHandler(configOrPlugin, options) {
11301
11306
  let isActive = true;
11302
11307
  const stream = new ReadableStream({
11303
11308
  async start(controller) {
11304
- var _a2, _b, _c, _d, _e;
11309
+ var _a3, _b, _c, _d, _e;
11305
11310
  const enqueue = (text) => {
11306
11311
  if (!isActive) return;
11307
11312
  try {
@@ -11334,7 +11339,7 @@ function createStreamHandler(configOrPlugin, options) {
11334
11339
  let uiTransformation = responseChunk == null ? void 0 : responseChunk.ui_transformation;
11335
11340
  if (sources.length > 0) {
11336
11341
  try {
11337
- uiTransformation = (_a2 = responseChunk == null ? void 0 : responseChunk.ui_transformation) != null ? _a2 : UITransformer.transform(message, sources, plugin.getConfig());
11342
+ uiTransformation = (_a3 = responseChunk == null ? void 0 : responseChunk.ui_transformation) != null ? _a3 : UITransformer.transform(message, sources, plugin.getConfig());
11338
11343
  if (uiTransformation) {
11339
11344
  enqueue(sseUIFrame(uiTransformation));
11340
11345
  }
@@ -11731,16 +11736,32 @@ function createRagHandler(configOrPlugin, options) {
11731
11736
  return NextResponse.json({ error: `Method Not Allowed: GET segment "${segment}" not supported.` }, { status: 405 });
11732
11737
  }
11733
11738
  }
11734
- async function getSegment(context) {
11735
- var _a2;
11739
+ async function getSegment(req, context) {
11740
+ var _a2, _b;
11741
+ const contentType = req.headers.get("content-type") || "";
11742
+ if (contentType.includes("multipart/form-data")) {
11743
+ return "upload";
11744
+ }
11745
+ try {
11746
+ const url = new URL(req.url);
11747
+ const pathname = url.pathname;
11748
+ if (pathname.endsWith("/upload")) return "upload";
11749
+ if (pathname.endsWith("/chat") || pathname.endsWith("/chat-sync")) return "chat";
11750
+ if (pathname.endsWith("/health")) return "health";
11751
+ if (pathname.endsWith("/suggestions")) return "suggestions";
11752
+ if (pathname.endsWith("/feedback")) return "feedback";
11753
+ if (pathname.endsWith("/history")) return "history";
11754
+ } catch (e) {
11755
+ }
11736
11756
  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;
11737
- const segments = (resolvedParams == null ? void 0 : resolvedParams.retrivora) || [];
11738
- return segments.join("/") || "chat";
11757
+ const segments = (resolvedParams == null ? void 0 : resolvedParams.retrivora) || ((_b = resolvedParams == null ? void 0 : resolvedParams.params) == null ? void 0 : _b.retrivora) || [];
11758
+ const joined = segments.join("/");
11759
+ return joined || "chat";
11739
11760
  }
11740
11761
  return {
11741
11762
  GET: async (req, context) => {
11742
11763
  try {
11743
- const segment = await getSegment(context);
11764
+ const segment = await getSegment(req, context);
11744
11765
  return await routeGetRequest(req, segment);
11745
11766
  } catch (err) {
11746
11767
  const msg = err instanceof Error ? err.message : "GET Routing failed";
@@ -11749,7 +11770,7 @@ function createRagHandler(configOrPlugin, options) {
11749
11770
  },
11750
11771
  POST: async (req, context) => {
11751
11772
  try {
11752
- const segment = await getSegment(context);
11773
+ const segment = await getSegment(req, context);
11753
11774
  return await routePostRequest(req, segment);
11754
11775
  } catch (err) {
11755
11776
  const msg = err instanceof Error ? err.message : "POST Routing failed";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retrivora-ai/rag-engine",
3
- "version": "2.1.4",
3
+ "version": "2.1.6",
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",
@@ -173,33 +173,26 @@ export function DocumentUpload({ namespace, uploadUrl, retrivoraApiBase, onUploa
173
173
 
174
174
  <div className="mt-6 flex flex-col items-center gap-2 text-sm">
175
175
  <label className="text-slate-600 dark:text-white/60 font-medium">Embedding Dimension</label>
176
- <div className="flex flex-col items-center gap-1.5">
177
- <select
178
- value={dimension}
179
- onChange={(e) => setDimension(Number(e.target.value))}
180
- disabled={isUploading}
181
- className="px-3 py-1.5 rounded-lg bg-slate-50 dark:bg-white/5 border border-slate-200 dark:border-white/10 text-slate-800 dark:text-white/90 outline-none focus:border-emerald-500 transition-colors text-sm font-medium cursor-pointer"
182
- >
183
- {COMMON_DIMENSIONS.map(dim => {
184
- const isDisabled = isFreeTier && dim !== 768;
185
- return (
186
- <option
187
- key={dim}
188
- value={dim}
189
- disabled={isDisabled}
190
- className="bg-white dark:bg-slate-900 text-slate-800 dark:text-white disabled:text-slate-400 dark:disabled:text-white/30"
191
- >
192
- {dim} {dim === 768 ? '(Free Tier Fixed)' : isDisabled ? '(Pro/Enterprise Only)' : ''}
193
- </option>
194
- );
195
- })}
196
- </select>
197
- {isFreeTier && (
198
- <span className="text-[11px] text-amber-600 dark:text-amber-400/90 font-medium">
199
- ⚡ 768 Dimension active for Free Tier (Upgrade for 1536 / 3072)
200
- </span>
201
- )}
202
- </div>
176
+ <select
177
+ value={dimension}
178
+ onChange={(e) => setDimension(Number(e.target.value))}
179
+ disabled={isUploading}
180
+ className="px-3 py-1.5 rounded-lg bg-slate-50 dark:bg-white/5 border border-slate-200 dark:border-white/10 text-slate-800 dark:text-white/90 outline-none focus:border-emerald-500 transition-colors text-sm font-medium cursor-pointer"
181
+ >
182
+ {COMMON_DIMENSIONS.map(dim => {
183
+ const isDisabled = isFreeTier && dim !== 768;
184
+ return (
185
+ <option
186
+ key={dim}
187
+ value={dim}
188
+ disabled={isDisabled}
189
+ className="bg-white dark:bg-slate-900 text-slate-800 dark:text-white disabled:text-slate-400 dark:disabled:text-white/30"
190
+ >
191
+ {dim}
192
+ </option>
193
+ );
194
+ })}
195
+ </select>
203
196
  </div>
204
197
  </div>
205
198
 
@@ -378,6 +378,10 @@ export function createStreamHandler(
378
378
  userMessageId?: string;
379
379
  };
380
380
  try {
381
+ if (req.headers.get('content-type')?.includes('multipart/form-data')) {
382
+ const uploader = createUploadHandler(plugin, { onAuthorize });
383
+ return uploader(req);
384
+ }
381
385
  body = await req.json();
382
386
  } catch {
383
387
  return new Response(JSON.stringify({ error: { code: 'INVALID_JSON', message: 'Invalid JSON body' } }), {
@@ -961,19 +965,39 @@ export function createRagHandler(
961
965
  }
962
966
  }
963
967
 
964
- async function getSegment(context: any): Promise<string> {
968
+ async function getSegment(req: NextRequest, context: any): Promise<string> {
969
+ // 1. If content-type is multipart/form-data, it MUST be an upload request!
970
+ const contentType = req.headers.get('content-type') || '';
971
+ if (contentType.includes('multipart/form-data')) {
972
+ return 'upload';
973
+ }
974
+
975
+ // 2. Check path directly from request URL
976
+ try {
977
+ const url = new URL(req.url);
978
+ const pathname = url.pathname;
979
+ if (pathname.endsWith('/upload')) return 'upload';
980
+ if (pathname.endsWith('/chat') || pathname.endsWith('/chat-sync')) return 'chat';
981
+ if (pathname.endsWith('/health')) return 'health';
982
+ if (pathname.endsWith('/suggestions')) return 'suggestions';
983
+ if (pathname.endsWith('/feedback')) return 'feedback';
984
+ if (pathname.endsWith('/history')) return 'history';
985
+ } catch { /* silent */ }
986
+
987
+ // 3. Fall back to resolved context params
965
988
  const resolvedParams = typeof context?.params?.then === 'function'
966
989
  ? await context.params
967
990
  : context?.params;
968
991
 
969
- const segments: string[] = resolvedParams?.retrivora || [];
970
- return segments.join('/') || 'chat';
992
+ const segments: string[] = resolvedParams?.retrivora || resolvedParams?.params?.retrivora || [];
993
+ const joined = segments.join('/');
994
+ return joined || 'chat';
971
995
  }
972
996
 
973
997
  return {
974
998
  GET: async (req: NextRequest, context: any) => {
975
999
  try {
976
- const segment = await getSegment(context);
1000
+ const segment = await getSegment(req, context);
977
1001
  return await routeGetRequest(req, segment);
978
1002
  } catch (err) {
979
1003
  const msg = err instanceof Error ? err.message : 'GET Routing failed';
@@ -982,7 +1006,7 @@ export function createRagHandler(
982
1006
  },
983
1007
  POST: async (req: NextRequest, context: any) => {
984
1008
  try {
985
- const segment = await getSegment(context);
1009
+ const segment = await getSegment(req, context);
986
1010
  return await routePostRequest(req, segment);
987
1011
  } catch (err) {
988
1012
  const msg = err instanceof Error ? err.message : 'POST Routing failed';
package/src/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);